Skip to contentSkip to conversation

arm64: synquacer: Add SynQuacer/DeveloperBox support

PATCH Superseded Masami Hiramatsu 10 participants 35 messages Apr 16, 2021 – May 6, 2021

Subsystems (8)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm64: synquacer: Add SynQuacer/DeveloperBox support

Hello,

Here is the 2nd version of the series (including some fixes for build errors) to add SynQuacer/DeveloperBox 96board EE suport on U-Boot.

Because of my poor typo, the previous version was not sent to the ML. Anyway I have fixed it.

This series includes not only DeveloperBox support but also some fixes for the issues which I faced while porting U-Boot on the DeveloperBox. First 3 patches are fixes, next 1 patch is a code cleanup for generic gpio for arm. The next 7 patches adding DeveloperBox devices and board support. The last 2 patches are related to the UEFI capsule update.

Changes in v2
-------------

Previous [1/13] was re-sent to the ML by Tim Harvey, so I dropped it. So this series needs the following patch.

https://lists.denx.de/pipermail/u-boot/2021-April/447519.html

And I had some comments on the v1 patch, so I updated:

[10/13]
- Add reference commit id of original EDK2 to the comment
- Just copy the EDK2 dts files as-is (change #include path)
- Split out the u-boot specific changes in -u-boot.dtsi.
- Removed unneeded spi-nor flash partition information.
[11/13]
- Do not include arch/gpio.h and remove arch-sc2a11/gpio.h.
- Remove non-UEFI boot commands.
- Use Distro boot.
- Remove NOR-connected SPI node by path instead of alias.
- Rename configs/SynQuacer_defconfig to configs/synquacer_developerbox_defconfig.
- Rename include/configs/SynQuacer.h to include/configs/synquacer.h.
- Move README under doc/board/socionext/ and make it .rst text.

DeveloperBox
============

DeveloperBox is a certified 96boards Enterprise Edition board. The board/SoC has: -
* Socionext SC2A11 24-cores ARM Cortex-A53 on tbe Mini-ATX form factor motherboard
* 4 DIMM slots (4GB DDR4-2400 UDIMM shipped by default)
* 1 4xPCIe Gen2 slot and 2 1xPCIe Gen2 slots
(1x slots are connected via PCIe bridge chip)
* 4 USB-3.0 ports
* 2 SATA ports
* 1 GbE network port
* 1 USB-UART serial port (micro USB)
* 64MB SPI NOR Flash
* 8GB eMMC Flash Storage
* 96boards LS connector

The DeveloperBox schematic can be found here: -
https://www.96boards.org/documentation/enterprise/developerbox/hardware-docs/mzsc2am_v03_20180115_a.pdf

And the other documents can be found here: -
https://www.96boards.org/documentation/enterprise/developerbox/

Currently, the U-Boot port supports: -
* USB
* eMMC
* SPI-NOR
* SATA
* GbE

The DeveloperBox boots the TF-A and EDK2 as a main bootloader by default. The DeveloperBox U-Boot port will replace the EDK2 and boot from TF-A as BL33, but no need to combine with it.

Thank you,

---

Jassi Brar (4):
mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash
mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver
spi: synquacer: Add HSSPI SPI controller driver for SynQuacer
net: synquacer: Add netsec driver

Masami Hiramatsu (9):
ata: ahci-pci: Use scsi_ops to initialize ops
dm: pci: Skip setting VGA bridge bits if parent device is the host bus
efi: Fix to use null handle to create new handle for efi_fmp_raw
gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs
pci: synquacer: Add SynQuacer ECAM based PCIe driver
ARM: dts: synquacer: Add device trees for DeveloperBox
board: synquacer: Add DeveloperBox 96boards EE support
doc: qemu: arm64: Fix the documentation of capsule update
configs: synquacer: Enable EFI capsule update support

 arch/arm/Kconfig                                   |   32 +
 arch/arm/dts/Makefile                              |    2 
 arch/arm/dts/synquacer-sc2a11-caches.dtsi          |   73 +
 .../dts/synquacer-sc2a11-developerbox-u-boot.dtsi  |   57 +
 arch/arm/dts/synquacer-sc2a11-developerbox.dts     |   56 +
 arch/arm/dts/synquacer-sc2a11.dtsi                 |  595 ++++++++++
 arch/arm/include/asm/gpio.h                        |    8 
 board/cortina/common/Kconfig                       |    1 
 board/socionext/developerbox/Kconfig               |   36 +
 board/socionext/developerbox/MAINTAINERS           |   13 
 board/socionext/developerbox/Makefile              |    9 
 board/socionext/developerbox/developerbox.c        |  145 +++
 configs/synquacer_developerbox_defconfig           |  108 ++
 doc/board/emulation/qemu_capsule_update.rst        |   11 
 doc/board/index.rst                                |    1 
 doc/board/socionext/developerbox.rst               |   87 ++
 doc/board/socionext/index.rst                      |    9 
 drivers/ata/ahci-pci.c                             |    2 
 drivers/mmc/Kconfig                                |   10 
 drivers/mmc/Makefile                               |    1 
 drivers/mmc/f_sdh30.c                              |   81 +
 drivers/mmc/sdhci.c                                |    9 
 drivers/mtd/spi/spi-nor-ids.c                      |    2 
 drivers/net/Kconfig                                |    8 
 drivers/net/Makefile                               |    1 
 drivers/net/sni_netsec.c                           | 1134 ++++++++++++++++++++
 drivers/pci/Kconfig                                |   12 
 drivers/pci/Makefile                               |    1 
 drivers/pci/pci-uclass.c                           |    3 
 drivers/pci/pcie_ecam_synquacer.c                  |  600 +++++++++++
 drivers/spi/Kconfig                                |    8 
 drivers/spi/Makefile                               |    1 
 drivers/spi/spi-synquacer.c                        |  491 +++++++++
 include/configs/synquacer.h                        |  112 ++
 lib/efi_loader/efi_capsule.c                       |    2 
 35 files changed, 3704 insertions(+), 17 deletions(-)
 create mode 100644 arch/arm/dts/synquacer-sc2a11-caches.dtsi
 create mode 100644 arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi
 create mode 100644 arch/arm/dts/synquacer-sc2a11-developerbox.dts
 create mode 100644 arch/arm/dts/synquacer-sc2a11.dtsi
 create mode 100644 board/socionext/developerbox/Kconfig
 create mode 100644 board/socionext/developerbox/MAINTAINERS
 create mode 100644 board/socionext/developerbox/Makefile
 create mode 100644 board/socionext/developerbox/developerbox.c
 create mode 100644 configs/synquacer_developerbox_defconfig
 create mode 100644 doc/board/socionext/developerbox.rst
 create mode 100644 doc/board/socionext/index.rst
 create mode 100644 drivers/mmc/f_sdh30.c
 create mode 100644 drivers/net/sni_netsec.c
 create mode 100644 drivers/pci/pcie_ecam_synquacer.c
 create mode 100644 drivers/spi/spi-synquacer.c
 create mode 100644 include/configs/synquacer.h

--
Masami Hiramatsu <[email protected]>

#1 lore raw

PATCH v2 1/13 ata: ahci-pci: Use scsi_ops to initialize ops

Without this fix, scsi-scan will cause a synchronous abort when accessing ops->scan.

---
 drivers/ata/ahci-pci.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/ata/ahci-pci.c +2 -0
index 11ec98b56f..b1d231e0f9 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <ahci.h>
+#include <scsi.h>
 #include <dm.h>
 #include <pci.h>
 
@@ -28,6 +29,7 @@ static const struct udevice_id ahci_pci_ids[] = {
 U_BOOT_DRIVER(ahci_pci) = {
 	.name	= "ahci_pci",
 	.id	= UCLASS_AHCI,
+	.ops	= &scsi_ops,
 	.of_match = ahci_pci_ids,
 	.bind	= ahci_pci_bind,
 	.probe = ahci_pci_probe,
#2 lore raw

PATCH v2 2/13 dm: pci: Skip setting VGA bridge bits if parent device is the host bus

In reply to Masami Hiramatsu

Commit bbbcb5262839 ("dm: pci: Enable VGA address forwarding on bridges") sets the VGA bridge bits by checking pplat->class, but if the parent device is the pci host bus device, it can be skipped. Moreover, it shouldn't access the pplat because the parent has different plat data.

Without this fix, "pci enum" command cause a synchronous abort.

pci_auto_config_devices: start
PCI Autoconfig: Bus Memory region: [78000000-7fffffff],

		Physical Memory [78000000-7fffffffx]
PCI Autoconfig: Bus I/O region: [0-ffff],
		Physical Memory [77f00000-77f0ffffx]

pci_auto_config_devices: device pci_6:0.0
PCI Autoconfig: BAR 0, Mem, size=0x1000000, address=0x78000000 bus_lower=0x79000000

PCI Autoconfig: BAR 1, Mem, size=0x8000000, No room in resource, avail start=79000000 / size=8000000, need=8000000
PCI: Failed autoconfig bar 14

PCI Autoconfig: BAR 2, I/O, size=0x4, address=0x1000 bus_lower=0x1004

PCI Autoconfig: BAR 3, Mem, size=0x2000000, address=0x7a000000 bus_lower=0x7c000000

PCI Autoconfig: BAR 4, I/O, size=0x80, address=0x1080 bus_lower=0x1100

PCI Autoconfig: ROM, size=0x80000, address=0x7c000000 bus_lower=0x7c080000

"Synchronous Abort" handler, esr 0x96000006
elr: 00000000e002bd28 lr : 00000000e002bce8 (reloc)
elr: 00000000fff6fd28 lr : 00000000fff6fce8 x0 : 0000000000001041 x1 : 000000000000003e x2 : 00000000ffb0f8c8 x3 : 0000000000000001 x4 : 0000000000000080 x5 : 0000000000000000 x6 : 00000000fff718fc x7 : 000000000000000f x8 : 00000000ffb0f238 x9 : 0000000000000008
x10: 0000000000000000 x11: 0000000000000010
x12: 0000000000000006 x13: 000000000001869f
x14: 00000000ffb0fcd0 x15: 0000000000000020
x16: 00000000fff71cc4 x17: 0000000000000000
x18: 00000000ffb13d90 x19: 00000000ffb14320
x20: 0000000000000000 x21: 00000000ffb14090
x22: 00000000ffb0f8c8 x23: 0000000000000001
x24: 00000000ffb14c10 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 00000000ffb14c70 x29: 00000000ffb0f830

Code: 52800843 52800061 52800e00 97ffcf65 (b9400280)

Resetting CPU ...

---
 drivers/pci/pci-uclass.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/pci/pci-uclass.c +3 -0
index f463ef3550..e9baa34e74 100644
@@ -550,6 +550,9 @@ int pci_auto_config_devices(struct udevice *bus)
 		max_bus = ret;
 		sub_bus = max(sub_bus, max_bus);
 
+		if (dev_get_parent(dev) == bus)
+			continue;
+
 		pplat = dev_get_parent_plat(dev);
 		if (pplat->class == (PCI_CLASS_DISPLAY_VGA << 8))
 			set_vga_bridge_bits(dev);
#3 lore raw

PATCH v2 3/13 efi: Fix to use null handle to create new handle for efi_fmp_raw

In reply to Masami Hiramatsu

When running the efidebug capsule disk-update command, the efi_fmp_raw protocol installation is failed with 2 (EFI_INVALID_PARAMETER) as below. This is because the code passes efi_root instaed of handle.

=> efidebug capsule disk-update
EFI: Call: efi_install_multiple_protocol_interfaces( &handle, &efi_guid_firmware_management_protocol, &efi_fmp_fit, NULL)
EFI: Entry efi_install_multiple_protocol_interfaces(00000000fbaf5988)
EFI: Call: efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)
EFI: Entry efi_install_protocol_interface(00000000fbaf5988, 86c77a67-0b97-4633-a187-49104d0685c7, 0, 00000000fbfa6ee8)
EFI: new handle 00000000fbb37520
EFI: Exit: efi_install_protocol_interface: 0
EFI: 0 returned by efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)
EFI: Exit: efi_install_multiple_protocol_interfaces: 0
EFI: 0 returned by efi_install_multiple_protocol_interfaces( &handle, &efi_guid_firmware_management_protocol, &efi_fmp_fit, NULL)
EFI: Call: efi_install_multiple_protocol_interfaces( &efi_root, &efi_guid_firmware_management_protocol, &efi_fmp_raw, NULL)
EFI: Entry efi_install_multiple_protocol_interfaces(00000000fbfec648)
EFI: Call: efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)
EFI: Entry efi_install_protocol_interface(00000000fbfec648, 86c77a67-0b97-4633-a187-49104d0685c7, 0, 00000000fbfa6f18)
EFI: handle 00000000fbaf8520
EFI: Exit: efi_install_protocol_interface: 2
EFI: 2 returned by efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)
EFI: Exit: efi_install_multiple_protocol_interfaces: 2
EFI: 2 returned by efi_install_multiple_protocol_interfaces( &efi_root, &efi_guid_firmware_management_protocol, &efi_fmp_raw, NULL) Command failed, result=1

To fix this issue, pass the handle variable as same as the efi_fmp_fit installation.

---
 lib/efi_loader/efi_capsule.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/efi_capsule.c +1 -1
index 7ba1ced0a0..ebb0725484 100644
@@ -938,7 +938,7 @@ efi_status_t __weak arch_efi_load_capsule_drivers(void)
 	if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_RAW)) {
 		handle = NULL;
 		ret = EFI_CALL(efi_install_multiple_protocol_interfaces(
-				&efi_root,
+				&handle,
 				&efi_guid_firmware_management_protocol,
 				&efi_fmp_raw, NULL));
 	}
#4 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

In reply to Masami Hiramatsu

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO and select it.

---
 arch/arm/Kconfig             |   17 +++++++++++++++++
 arch/arm/include/asm/gpio.h  |    8 +-------
 board/cortina/common/Kconfig |    1 +
 3 files changed, 19 insertions(+), 7 deletions(-)
arch/arm/Kconfig +17 -0
index 3307f2b3fc..fba28323cd 100644
@@ -89,6 +89,11 @@ config HAS_VBAR
 config HAS_THUMB2
 	bool
 
+config ONLY_GENERIC_GPIO
+	bool
+	help
+	  The target has no arch-xxxx/gpio.h and use only asm-generic/gpio.h.
+
 # Used for compatibility with asm files copied from the kernel
 config ARM_ASM_UNIFIED
 	bool
@@ -634,18 +639,21 @@ config ARCH_BCM283X
 
 config ARCH_BCM63158
 	bool "Broadcom BCM63158 family"
+	select ONLY_GENERIC_GPIO
 	select DM
 	select OF_CONTROL
 	imply CMD_DM
 
 config ARCH_BCM68360
 	bool "Broadcom BCM68360 family"
+	select ONLY_GENERIC_GPIO
 	select DM
 	select OF_CONTROL
 	imply CMD_DM
 
 config ARCH_BCM6858
 	bool "Broadcom BCM6858 family"
+	select ONLY_GENERIC_GPIO
 	select DM
 	select OF_CONTROL
 	imply CMD_DM
@@ -716,6 +724,7 @@ config TARGET_BCMNS2
 config TARGET_BCMNS3
 	bool "Support Broadcom NS3"
 	select ARM64
+	select ONLY_GENERIC_GPIO
 	select BOARD_LATE_INIT
 	help
 	  Support for Broadcom Northstar 3 SoCs. NS3 is a octo-core 64-bit
@@ -784,6 +793,7 @@ config ARCH_KEYSTONE
 
 config ARCH_K3
 	bool "Texas Instruments' K3 Architecture"
+	select ONLY_GENERIC_GPIO
 	select SPL
 	select SUPPORT_SPL
 	select FIT
@@ -929,6 +939,7 @@ config ARCH_OWL
 
 config ARCH_QEMU
 	bool "QEMU Virtual Platform"
+	select ONLY_GENERIC_GPIO
 	select DM
 	select DM_SERIAL
 	select OF_CONTROL
@@ -1061,6 +1072,7 @@ config ARCH_SUNXI
 config ARCH_U8500
 	bool "ST-Ericsson U8500 Series"
 	select CPU_V7A
+	select ONLY_GENERIC_GPIO
 	select DM
 	select DM_GPIO
 	select DM_MMC if MMC
@@ -1203,6 +1215,7 @@ config TARGET_VEXPRESS64_JUNO
 config TARGET_TOTAL_COMPUTE
 	bool "Support Total Compute Platform"
 	select ARM64
+	select ONLY_GENERIC_GPIO
 	select PL01X_SERIAL
 	select DM
 	select DM_SERIAL
@@ -1633,6 +1646,7 @@ config TARGET_COLIBRI_PXA270
 
 config ARCH_UNIPHIER
 	bool "Socionext UniPhier SoCs"
+	select ONLY_GENERIC_GPIO
 	select BOARD_LATE_INIT
 	select DM
 	select DM_ETH
@@ -1670,6 +1684,7 @@ config ARCH_STM32
 
 config ARCH_STI
 	bool "Support STMicrolectronics SoCs"
+	select ONLY_GENERIC_GPIO
 	select BLK
 	select CPU_V7A
 	select DM
@@ -1717,6 +1732,7 @@ config ARCH_STM32MP
 
 config ARCH_ROCKCHIP
 	bool "Support Rockchip SoCs"
+	select ONLY_GENERIC_GPIO
 	select BLK
 	select BINMAN if SPL_OPTEE
 	select DM
@@ -1778,6 +1794,7 @@ config TARGET_THUNDERX_88XX
 
 config ARCH_ASPEED
 	bool "Support Aspeed SoCs"
+	select ONLY_GENERIC_GPIO
 	select DM
 	select OF_CONTROL
 	imply CMD_DM
arch/arm/include/asm/gpio.h +1 -7
index 7609367884..bf1f239f81 100644
@@ -1,10 +1,4 @@
-#if !defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARCH_STI) && \
-	!defined(CONFIG_ARCH_K3) && !defined(CONFIG_ARCH_BCM68360) && \
-	!defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \
-	!defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \
-	!defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) && \
-	!defined(CONFIG_TARGET_BCMNS3) && !defined(CONFIG_TARGET_TOTAL_COMPUTE) && \
-	!defined(CONFIG_ARCH_QEMU)
+#if !defined(CONFIG_ONLY_GENERIC_GPIO)
 #include <asm/arch/gpio.h>
 #endif
 #include <asm-generic/gpio.h>
board/cortina/common/Kconfig +1 -0
index 00c709e70f..3f1be84d21 100644
@@ -1,6 +1,7 @@
 config CORTINA_PLATFORM
        bool "Cortina-Access Platform"
        default y
+       select ONLY_GENERIC_GPIO
        help
          Select this option for Cortina-Access platforms
 	 to enables selection of CAxxxx drivers
#5 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

Hi Masami,

Quoted 3 lines · Masami Hiramatsu

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO

This seems OK, but I think GPIO_GENERIC_ONLY is a better name, since it uses the GPIO prefix.

I would also prefer to have a 'positive' option, but I suspect that might be a pain to do?

Quoted 9 lines

and select it.

---
 arch/arm/Kconfig             |   17 +++++++++++++++++
 arch/arm/include/asm/gpio.h  |    8 +-------
 board/cortina/common/Kconfig |    1 +
 3 files changed, 19 insertions(+), 7 deletions(-)

[..]

Regards,
Simon

#6 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

Hi Simon,

2021?4?30?(?) 1:10 Simon Glass <[email protected]>:

Quoted 6 lines

Hi Masami,

Quoted 1 line · Masami Hiramatsu
Quoted 8 lines
Quoted 2 lines

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO

This seems OK, but I think GPIO_GENERIC_ONLY is a better name, since it uses the GPIO prefix.

I would also prefer to have a 'positive' option, but I suspect that might be a pain to do?

Would you mean making it something like CONFIG_GPIO_EXTRA_HEADER ?

I think it is also possible. My concern is if I missed any arch which should say y that :P.

Thank you,

Quoted 11 lines
Quoted 10 lines

and select it.

---
 arch/arm/Kconfig             |   17 +++++++++++++++++
 arch/arm/include/asm/gpio.h  |    8 +-------
 board/cortina/common/Kconfig |    1 +
 3 files changed, 19 insertions(+), 7 deletions(-)
Quoted 4 lines

[..]

Regards,
Simon

--
Masami Hiramatsu

#7 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

Hi Masami,

Quoted 16 lines · Masami Hiramatsu

Hi Simon,

2021?4?30?(?) 1:10 Simon Glass <[email protected]>:

Quoted 12 lines

Hi Masami,

Quoted 3 lines · Masami Hiramatsu

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO

This seems OK, but I think GPIO_GENERIC_ONLY is a better name, since it uses the GPIO prefix.

Quoted 7 lines
Quoted 2 lines

I would also prefer to have a 'positive' option, but I suspect that might be a pain to do?

Would you mean making it something like CONFIG_GPIO_EXTRA_HEADER ?

I think it is also possible. My concern is if I missed any arch which should say y that :P.

Yes...it's just that negative configs generally cause us pain at some point.

Regards,
Simon

#8 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

Quoted 23 lines · Simon Glass

Hi Masami,

Quoted 19 lines · Masami Hiramatsu

Hi Simon,

2021?4?30?(?) 1:10 Simon Glass <[email protected]>:

Quoted 14 lines

Hi Masami,

Quoted 3 lines · Masami Hiramatsu

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO

This seems OK, but I think GPIO_GENERIC_ONLY is a better name, since it uses the GPIO prefix.

I would also prefer to have a 'positive' option, but I suspect that might be a pain to do?

Quoted 6 lines
Quoted 4 lines

Would you mean making it something like CONFIG_GPIO_EXTRA_HEADER ?

I think it is also possible. My concern is if I missed any arch which should say y that :P.

Yes...it's just that negative configs generally cause us pain at some point.

And in terms of catching all of the platforms, you can submit a pull request in GitHub which will trigger a CI world build and tell you what's broken :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210503/7220088a/attachment.sig>
#9 lore raw

PATCH v2 4/13 gpio: Introduce CONFIG_ONLY_GENERIC_GPIO to cleanup #ifdefs

Hi Tom,

2021?5?3?(?) 20:51 Tom Rini <[email protected]>:

Quoted 27 lines · Simon Glass
Quoted 25 lines

Hi Masami,

Quoted 21 lines · Masami Hiramatsu

Hi Simon,

2021?4?30?(?) 1:10 Simon Glass <[email protected]>:

Quoted 6 lines

Hi Masami,

Quoted 1 line · Masami Hiramatsu
Quoted 8 lines
Quoted 2 lines

Many architecture do not have specific asm/arch/gpio.h, so instead of adding !defined(CONFIG_ARCH_xxx), introduce CONFIG_ONLY_GENERIC_GPIO

This seems OK, but I think GPIO_GENERIC_ONLY is a better name, since it uses the GPIO prefix.

I would also prefer to have a 'positive' option, but I suspect that might be a pain to do?

Would you mean making it something like CONFIG_GPIO_EXTRA_HEADER ?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I think it is also possible. My concern is if I missed any arch which should say y that :P.

Yes...it's just that negative configs generally cause us pain at some point.

And in terms of catching all of the platforms, you can submit a pull request in GitHub which will trigger a CI world build and tell you what's broken :)

OK, let me try it.

Thank you!

Quoted 3 lines

--
Tom

Signature · 1 line
Masami Hiramatsu
#10 lore raw

PATCH v2 5/13 mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash

In reply to Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mtd/spi/spi-nor-ids.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi/spi-nor-ids.c +2 -0
index 2b57797954..30a18b4140 100644
@@ -160,9 +160,11 @@ const struct flash_info spi_nor_ids[] = {
 	{ INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) },
 	{ INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
+	{ INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0) },
 	{ INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66u51235f", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+	{ INFO("mx66u1g45g",  0xc2253b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66u2g45g",  0xc2253c, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66l1g45g",  0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ INFO("mx25l1633e", 0xc22415, 0, 64 * 1024,   32, SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES | SECT_4K) },
#11 lore raw

PATCH v2 5/13 mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash

Quoted 12 lines · Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mtd/spi/spi-nor-ids.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/spi/spi-nor-ids.c +0 -0
index 2b57797954..30a18b4140 100644

drivers/mtd/spi/spi-nor-ids.c const struct flash_info spi_nor_ids[] = { · line 163

Quoted 4 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
@@ -160,9 +160,11 @@ const struct flash_info spi_nor_ids[] = {
 	{ INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) },
 	{ INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
+	{ INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },

The flash ID is the same as that of mx66u51235f. Because the ID matching function searches through this array in linear fashion, mx66u51235f can never be detected. This is a regression.

I am seeing a lot of ID collisions on Macronix flashes recently [0]. Not sure how to handle them though. At least in this case both flashes use the same set of flags so it should just change the name of the flash detected.

[0] https://lore.kernel.org/linux-mtd/CAEyMn7ZEp9f1SuE6umRDWkr8bVT5hdRi-4F3+G-GP9anuGG1Bw at mail.gmail.com/T/#u

Quoted 8 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
 	{ INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0) },
 	{ INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66u51235f", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+	{ INFO("mx66u1g45g",  0xc2253b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66u2g45g",  0xc2253c, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("mx66l1g45g",  0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 	{ INFO("mx25l1633e", 0xc22415, 0, 64 * 1024,   32, SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES | SECT_4K) },
Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#12 lore raw

PATCH v2 5/13 mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash

Hello Pratyush,

2021?4?19?(?) 17:41 Pratyush Yadav <[email protected]>:

Quoted 9 lines · Masami Hiramatsu
Quoted 7 lines

From: Jassi Brar <[email protected]>

---
 drivers/mtd/spi/spi-nor-ids.c |    2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/mtd/spi/spi-nor-ids.c const struct flash_info spi_nor_ids[] = { · line 163

Quoted 9 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
index 2b57797954..30a18b4140 100644
@@ -160,9 +160,11 @@ const struct flash_info spi_nor_ids[] = {
      { INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) },
      { INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
      { INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
+     { INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },

The flash ID is the same as that of mx66u51235f. Because the ID matching function searches through this array in linear fashion, mx66u51235f can never be detected. This is a regression.

OK

Quoted 5 lines

I am seeing a lot of ID collisions on Macronix flashes recently [0]. Not sure how to handle them though. At least in this case both flashes use the same set of flags so it should just change the name of the flash detected.

Would you mean rename the entry as below?

{ INFO("mx66u51235f/mx25u51245g",...

Thank you,

Quoted 16 lines

[0] https://lore.kernel.org/linux-mtd/CAEyMn7ZEp9f1SuE6umRDWkr8bVT5hdRi-4F3+G-GP9anuGG1Bw at mail.gmail.com/T/#u

drivers/mtd/spi/spi-nor-ids.c const struct flash_info spi_nor_ids[] = { · line 170

Quoted 8 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
      { INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0) },
      { INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66u51235f", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+     { INFO("mx66u1g45g",  0xc2253b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66u2g45g",  0xc2253c, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66l1g45g",  0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
      { INFO("mx25l1633e", 0xc22415, 0, 64 * 1024,   32, SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES | SECT_4K) },

--
Regards,
Pratyush Yadav
Texas Instruments Inc.

Signature · 1 line
Masami Hiramatsu
#13 lore raw

PATCH v2 5/13 mtd: spi-nor-ids: add support for Macronix mx25u51245g and mx66u1g45g flash

Quoted 29 lines · Masami Hiramatsu

Hello Pratyush,

2021?4?19?(?) 17:41 Pratyush Yadav <[email protected]>:

Quoted 9 lines · Masami Hiramatsu
Quoted 7 lines

From: Jassi Brar <[email protected]>

---
 drivers/mtd/spi/spi-nor-ids.c |    2 ++
 1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/mtd/spi/spi-nor-ids.c const struct flash_info spi_nor_ids[] = { · line 163

Quoted 9 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
index 2b57797954..30a18b4140 100644
@@ -160,9 +160,11 @@ const struct flash_info spi_nor_ids[] = {
      { INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) },
      { INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
      { INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_4B_OPCODES) },
+     { INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },

The flash ID is the same as that of mx66u51235f. Because the ID matching function searches through this array in linear fashion, mx66u51235f can never be detected. This is a regression.

OK

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

I am seeing a lot of ID collisions on Macronix flashes recently [0]. Not sure how to handle them though. At least in this case both flashes use the same set of flags so it should just change the name of the flash detected.

Would you mean rename the entry as below?

{ INFO("mx66u51235f/mx25u51245g",...

No, I am saying that your change will make mx66u51235f get detected as mx25u51245g, but it won't make any difference in practice because both entries have the same flags set.

There have been some ideas on the Linux side about how to handle these collisions. One of them being that the SFDP contents can be used to differentiate between flashes having the same ID. I would appreciate it if you help drive the solution forward on the Linux side, and then it can be ported back to U-Boot.

Quoted 15 lines

Thank you,

Quoted 12 lines

[0] https://lore.kernel.org/linux-mtd/CAEyMn7ZEp9f1SuE6umRDWkr8bVT5hdRi-4F3+G-GP9anuGG1Bw at mail.gmail.com/T/#u

Quoted 8 lines
drivers/mtd/spi/spi-nor-ids.c +1 -0
      { INFO("mx25l25655e", 0xc22619, 0, 64 * 1024, 512, 0) },
      { INFO("mx66l51235l", 0xc2201a, 0, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66u51235f", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+     { INFO("mx66u1g45g",  0xc2253b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66u2g45g",  0xc2253c, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
      { INFO("mx66l1g45g",  0xc2201b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
      { INFO("mx25l1633e", 0xc22415, 0, 64 * 1024,   32, SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES | SECT_4K) },
Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#14 lore raw

PATCH v2 6/13 pci: synquacer: Add SynQuacer ECAM based PCIe driver

In reply to Masami Hiramatsu

Add ECAM based SynQuacer PCIe RC driver. This driver configures the PCIe RC and filter out a ghost pcie config.

Since the Linux kernel expects "socionext,synquacer-pcie-ecam" device is configured by firmware (EDK2), it doesn't re-configure in the kernel. So as same as EDK2, U-Boot needs to configure it before boot the kernel.

---
 drivers/pci/Kconfig               |   12 +
 drivers/pci/Makefile              |    1 
 drivers/pci/pcie_ecam_synquacer.c |  600 +++++++++++++++++++++++++++++++++++++
 3 files changed, 613 insertions(+)
 create mode 100644 drivers/pci/pcie_ecam_synquacer.c
drivers/pci/Kconfig +12 -0
index ba41787f64..e36551a771 100644
@@ -81,6 +81,18 @@ config PCIE_ECAM_GENERIC
 	  Say Y here if you want to enable support for generic ECAM-based
 	  PCIe host controllers, such as the one emulated by QEMU.
 
+config PCIE_ECAM_SYNQUACER
+	bool "SynQuacer ECAM-based PCI host controller support"
+	default n
+	depends on DM_PCI
+	select PCI_INIT_R
+	select PCI_REGION_MULTI_ENTRY
+	help
+	  Say Y here if you want to enable support for Socionext
+	  SynQuacer SoC's ECAM-based PCIe host controllers.
+	  Note that this must be configured when boot because Linux driver
+	  expects the PCIe RC has been configured in the bootloader.
+
 config PCI_PHYTIUM
 	bool "Phytium PCIe support"
 	depends on DM_PCI
drivers/pci/Makefile +1 -0
index 5ed94bc95c..6338c595af 100644
@@ -16,6 +16,7 @@ endif
 obj-$(CONFIG_PCI) += pci_auto_common.o pci_common.o
 
 obj-$(CONFIG_PCIE_ECAM_GENERIC) += pcie_ecam_generic.o
+obj-$(CONFIG_PCIE_ECAM_SYNQUACER) += pcie_ecam_synquacer.o
 obj-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
 obj-$(CONFIG_PCI_INDIRECT_BRIDGE) += pci_indirect.o
 obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o
drivers/pci/pcie_ecam_synquacer.c new file +600 -0

600 lines not on this page · raw message

#15 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

In reply to Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mmc/Kconfig   |   10 ++++++
 drivers/mmc/Makefile  |    1 +
 drivers/mmc/f_sdh30.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c   |    9 +++++
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/mmc/f_sdh30.c
drivers/mmc/Kconfig +10 -0
index f8ca52efb6..a9ae419e41 100644
@@ -549,6 +549,16 @@ config MMC_SDHCI_IPROC
 
 	  If unsure, say N.
 
+config F_SDH30_SDHCI
+	bool "SDHCI support for Fujitsu Semiconductor F_SDH30"
+	depends on BLK && DM_MMC
+	depends on MMC_SDHCI
+	help
+	  This selects the Secure Digital Host Controller Interface (SDHCI)
+	  Needed by some Fujitsu SoC for MMC / SD / SDIO support.
+	  If you have a controller with this interface, say Y or M here.
+	  If unsure, say N.
+
 config MMC_SDHCI_KONA
 	bool "SDHCI support on Broadcom KONA platform"
 	depends on MMC_SDHCI
drivers/mmc/Makefile +1 -0
index 89d6af3db3..b48a76ba94 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_MMC_UNIPHIER)		+= tmio-common.o uniphier-sd.o
 obj-$(CONFIG_RENESAS_SDHI)		+= tmio-common.o renesas-sdhi.o
 obj-$(CONFIG_MMC_BCM2835)		+= bcm2835_sdhost.o
 obj-$(CONFIG_MMC_MTK)			+= mtk-sd.o
+obj-$(CONFIG_F_SDH30_SDHCI)		+= f_sdh30.o
drivers/mmc/f_sdh30.c new file +81 -0

81 lines not on this page · raw message

drivers/mmc/sdhci.c +9 -0
index d9ab6a0a83..f038debc6c 100644
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
 	sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+	if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {
+		/*
+		 * Reference to Part1 Physical Layer Simplified Specification
+		 * Ver 3.01, 6.4.1 Power Up
+		 * This delay must be at least 74 clock sizes, or 1 ms.
+		 */
+		udelay(1000);
+	}
+
 	if (host->ops && host->ops->get_cd)
 		host->ops->get_cd(host);
 
#16 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

Hi Masami,

Quoted 17 lines · Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mmc/Kconfig   |   10 ++++++
 drivers/mmc/Makefile  |    1 +
 drivers/mmc/f_sdh30.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c   |    9 +++++
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/mmc/f_sdh30.c
drivers/mmc/Kconfig +0 -0
index f8ca52efb6..a9ae419e41 100644

drivers/mmc/Kconfig config MMC_SDHCI_IPROC · line 552

Quoted 4 lines
drivers/mmc/Kconfig +1 -0
@@ -549,6 +549,16 @@ config MMC_SDHCI_IPROC
 
 	  If unsure, say N.
 
+config F_SDH30_SDHCI

MMS_SDHCI_F_SDH30 or MMC_SDHCI_xxx.

Quoted 38 lines
drivers/mmc/Kconfig +9 -0
+	bool "SDHCI support for Fujitsu Semiconductor F_SDH30"
+	depends on BLK && DM_MMC
+	depends on MMC_SDHCI
+	help
+	  This selects the Secure Digital Host Controller Interface (SDHCI)
+	  Needed by some Fujitsu SoC for MMC / SD / SDIO support.
+	  If you have a controller with this interface, say Y or M here.
+	  If unsure, say N.
+
 config MMC_SDHCI_KONA
 	bool "SDHCI support on Broadcom KONA platform"
 	depends on MMC_SDHCI
drivers/mmc/Makefile +1 -0
index 89d6af3db3..b48a76ba94 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_MMC_UNIPHIER)		+= tmio-common.o uniphier-sd.o
 obj-$(CONFIG_RENESAS_SDHI)		+= tmio-common.o renesas-sdhi.o
 obj-$(CONFIG_MMC_BCM2835)		+= bcm2835_sdhost.o
 obj-$(CONFIG_MMC_MTK)			+= mtk-sd.o
+obj-$(CONFIG_F_SDH30_SDHCI)		+= f_sdh30.o
drivers/mmc/f_sdh30.c new file +11 -0
new file mode 100644
index 0000000000..44c6521bfe
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Socionext F_SDH30 eMMC driver
+ * Copyright 2021 Linaro Ltd.
+ * Copyright 2021 Socionext, Inc.
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <malloc.h>

drivers/mmc/f_sdh30.c line 21

Quoted 10 lines
drivers/mmc/f_sdh30.c new file +10 -0
+#include <sdhci.h>
+
+struct f_sdh30_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int f_sdh30_probe(struct udevice *dev)

xxx_sdhci_probe().

Quoted 65 lines
drivers/mmc/f_sdh30.c new file +60 -0
+{
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct f_sdh30_plat *plat = dev_get_plat(dev);
+	struct sdhci_host *host = dev_get_priv(dev);
+	int ret;
+
+	ret = mmc_of_parse(dev, &plat->cfg);
+	if (ret)
+		return ret;
+
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
+	host->mmc->priv = host;
+
+	ret = sdhci_setup_cfg(&plat->cfg, host, 200000000, 400000);
+	if (ret)
+		return ret;
+
+	upriv->mmc = host->mmc;
+
+	mmc_set_clock(host->mmc, host->mmc->cfg->f_min, MMC_CLK_ENABLE);
+
+	return sdhci_probe(dev);
+}
+
+static int f_sdh30_of_to_plat(struct udevice *dev)
+{
+	struct sdhci_host *host = dev_get_priv(dev);
+
+	host->name = strdup(dev->name);
+	host->ioaddr = dev_read_addr_ptr(dev);
+	host->bus_width = dev_read_u32_default(dev, "bus-width", 4);
+	host->index = dev_read_u32_default(dev, "index", 0);
+
+	return 0;
+}
+
+static int f_sdh30_bind(struct udevice *dev)
+{
+	struct f_sdh30_plat *plat = dev_get_plat(dev);
+
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id f_sdh30_mmc_ids[] = {
+	{ .compatible = "fujitsu,mb86s70-sdhci-3.0" },
+	{ }
+};
+
+U_BOOT_DRIVER(f_sdh30_drv) = {
+	.name		= "f_sdh30_sdhci",
+	.id		= UCLASS_MMC,
+	.of_match	= f_sdh30_mmc_ids,
+	.of_to_plat	= f_sdh30_of_to_plat,
+	.ops		= &sdhci_ops,
+	.bind		= f_sdh30_bind,
+	.probe		= f_sdh30_probe,
+	.priv_auto	= sizeof(struct sdhci_host),
+	.plat_auto	= sizeof(struct f_sdh30_plat),
+};
drivers/mmc/sdhci.c +0 -0
index d9ab6a0a83..f038debc6c 100644

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 711

Quoted 4 lines
drivers/mmc/sdhci.c +1 -0
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
 	sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+	if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {

I don't want to add specific sdhci driver configuration in sdhci.c.

According to below comment and Specification,
it has to delay 1ms. Can it be removed the above condition checking?

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 717

Quoted 6 lines
drivers/mmc/sdhci.c +6 -0
+		/*
+		 * Reference to Part1 Physical Layer Simplified Specification
+		 * Ver 3.01, 6.4.1 Power Up
+		 * This delay must be at least 74 clock sizes, or 1 ms.
+		 */
+		udelay(1000);

I don't have any objection about this, If possible, it needs to calculate clock-cycle with real clock value in future.

Best Regards,
Jaehoon Chung

Quoted 7 lines
drivers/mmc/sdhci.c +2 -0
+	}
+
 	if (host->ops && host->ops->get_cd)
 		host->ops->get_cd(host);
 
#17 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

Hi Jaehoon,

Thanks for your comments.

2021?4?20?(?) 7:05 Jaehoon Chung <[email protected]>:

Quoted 22 lines

Hi Masami,

Quoted 18 lines · Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mmc/Kconfig   |   10 ++++++
 drivers/mmc/Makefile  |    1 +
 drivers/mmc/f_sdh30.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c   |    9 +++++
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/mmc/f_sdh30.c
drivers/mmc/Kconfig +0 -0
index f8ca52efb6..a9ae419e41 100644
@@ -549,6 +549,16 @@ config MMC_SDHCI_IPROC
 
Quoted 5 lines

drivers/mmc/Kconfig config MMC_SDHCI_IPROC · line 552

Quoted 3 lines
drivers/mmc/Kconfig +1 -0
        If unsure, say N.
 
+config F_SDH30_SDHCI

MMS_SDHCI_F_SDH30 or MMC_SDHCI_xxx.

OK. I'll change it.

Quoted 43 lines
Quoted 43 lines
drivers/mmc/Kconfig +9 -0
+     bool "SDHCI support for Fujitsu Semiconductor F_SDH30"
+     depends on BLK && DM_MMC
+     depends on MMC_SDHCI
+     help
+       This selects the Secure Digital Host Controller Interface (SDHCI)
+       Needed by some Fujitsu SoC for MMC / SD / SDIO support.
+       If you have a controller with this interface, say Y or M here.
+       If unsure, say N.
+
 config MMC_SDHCI_KONA
      bool "SDHCI support on Broadcom KONA platform"
      depends on MMC_SDHCI
drivers/mmc/Makefile +1 -0
index 89d6af3db3..b48a76ba94 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_MMC_UNIPHIER)          += tmio-common.o uniphier-sd.o
 obj-$(CONFIG_RENESAS_SDHI)           += tmio-common.o renesas-sdhi.o
 obj-$(CONFIG_MMC_BCM2835)            += bcm2835_sdhost.o
 obj-$(CONFIG_MMC_MTK)                        += mtk-sd.o
+obj-$(CONFIG_F_SDH30_SDHCI)          += f_sdh30.o
drivers/mmc/f_sdh30.c new file +15 -0
new file mode 100644
index 0000000000..44c6521bfe
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Socionext F_SDH30 eMMC driver
+ * Copyright 2021 Linaro Ltd.
+ * Copyright 2021 Socionext, Inc.
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <malloc.h>
+#include <sdhci.h>
+
+struct f_sdh30_plat {
+     struct mmc_config cfg;
Quoted 8 lines

drivers/mmc/f_sdh30.c line 21

Quoted 6 lines
drivers/mmc/f_sdh30.c new file +6 -0
+     struct mmc mmc;
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int f_sdh30_probe(struct udevice *dev)

xxx_sdhci_probe().

Let me confirm. The controller name is F_SDH30, so it is better to be f_sdh30_sdhci_probe(), correct?

Quoted 66 lines
Quoted 66 lines
drivers/mmc/f_sdh30.c new file +60 -0
+{
+     struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+     struct f_sdh30_plat *plat = dev_get_plat(dev);
+     struct sdhci_host *host = dev_get_priv(dev);
+     int ret;
+
+     ret = mmc_of_parse(dev, &plat->cfg);
+     if (ret)
+             return ret;
+
+     host->mmc = &plat->mmc;
+     host->mmc->dev = dev;
+     host->mmc->priv = host;
+
+     ret = sdhci_setup_cfg(&plat->cfg, host, 200000000, 400000);
+     if (ret)
+             return ret;
+
+     upriv->mmc = host->mmc;
+
+     mmc_set_clock(host->mmc, host->mmc->cfg->f_min, MMC_CLK_ENABLE);
+
+     return sdhci_probe(dev);
+}
+
+static int f_sdh30_of_to_plat(struct udevice *dev)
+{
+     struct sdhci_host *host = dev_get_priv(dev);
+
+     host->name = strdup(dev->name);
+     host->ioaddr = dev_read_addr_ptr(dev);
+     host->bus_width = dev_read_u32_default(dev, "bus-width", 4);
+     host->index = dev_read_u32_default(dev, "index", 0);
+
+     return 0;
+}
+
+static int f_sdh30_bind(struct udevice *dev)
+{
+     struct f_sdh30_plat *plat = dev_get_plat(dev);
+
+     return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id f_sdh30_mmc_ids[] = {
+     { .compatible = "fujitsu,mb86s70-sdhci-3.0" },
+     { }
+};
+
+U_BOOT_DRIVER(f_sdh30_drv) = {
+     .name           = "f_sdh30_sdhci",
+     .id             = UCLASS_MMC,
+     .of_match       = f_sdh30_mmc_ids,
+     .of_to_plat     = f_sdh30_of_to_plat,
+     .ops            = &sdhci_ops,
+     .bind           = f_sdh30_bind,
+     .probe          = f_sdh30_probe,
+     .priv_auto      = sizeof(struct sdhci_host),
+     .plat_auto      = sizeof(struct f_sdh30_plat),
+};
drivers/mmc/sdhci.c +0 -0
index d9ab6a0a83..f038debc6c 100644
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 711

Quoted 3 lines
drivers/mmc/sdhci.c +1 -0
      sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+     if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {

I don't want to add specific sdhci driver configuration in sdhci.c.

According to below comment and Specification,
it has to delay 1ms. Can it be removed the above condition checking?

Yes, of course!

Quoted 10 lines

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 717

Quoted 7 lines
drivers/mmc/sdhci.c +6 -0
+             /*
+              * Reference to Part1 Physical Layer Simplified Specification
+              * Ver 3.01, 6.4.1 Power Up
+              * This delay must be at least 74 clock sizes, or 1 ms.
+              */
+             udelay(1000);

I don't have any objection about this, If possible, it needs to calculate clock-cycle with real clock value in future.

Should I split this part as an independent patch?

Thank you,

Signature · 1 line
Masami Hiramatsu
#18 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

Quoted 87 lines · Masami Hiramatsu

Hi Jaehoon,

Thanks for your comments.

2021?4?20?(?) 7:05 Jaehoon Chung <[email protected]>:

Quoted 22 lines

Hi Masami,

Quoted 18 lines · Masami Hiramatsu

From: Jassi Brar <[email protected]>

---
 drivers/mmc/Kconfig   |   10 ++++++
 drivers/mmc/Makefile  |    1 +
 drivers/mmc/f_sdh30.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c   |    9 +++++
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/mmc/f_sdh30.c
drivers/mmc/Kconfig +0 -0
index f8ca52efb6..a9ae419e41 100644
@@ -549,6 +549,16 @@ config MMC_SDHCI_IPROC
 
Quoted 5 lines

drivers/mmc/Kconfig config MMC_SDHCI_IPROC · line 552

Quoted 3 lines
drivers/mmc/Kconfig +1 -0
        If unsure, say N.
 
+config F_SDH30_SDHCI

MMS_SDHCI_F_SDH30 or MMC_SDHCI_xxx.

OK. I'll change it.

Quoted 43 lines
Quoted 43 lines
drivers/mmc/Kconfig +9 -0
+     bool "SDHCI support for Fujitsu Semiconductor F_SDH30"
+     depends on BLK && DM_MMC
+     depends on MMC_SDHCI
+     help
+       This selects the Secure Digital Host Controller Interface (SDHCI)
+       Needed by some Fujitsu SoC for MMC / SD / SDIO support.
+       If you have a controller with this interface, say Y or M here.
+       If unsure, say N.
+
 config MMC_SDHCI_KONA
      bool "SDHCI support on Broadcom KONA platform"
      depends on MMC_SDHCI
drivers/mmc/Makefile +1 -0
index 89d6af3db3..b48a76ba94 100644
@@ -76,3 +76,4 @@ obj-$(CONFIG_MMC_UNIPHIER)          += tmio-common.o uniphier-sd.o
 obj-$(CONFIG_RENESAS_SDHI)           += tmio-common.o renesas-sdhi.o
 obj-$(CONFIG_MMC_BCM2835)            += bcm2835_sdhost.o
 obj-$(CONFIG_MMC_MTK)                        += mtk-sd.o
+obj-$(CONFIG_F_SDH30_SDHCI)          += f_sdh30.o
drivers/mmc/f_sdh30.c new file +15 -0
new file mode 100644
index 0000000000..44c6521bfe
@@ -0,0 +1,81 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Socionext F_SDH30 eMMC driver
+ * Copyright 2021 Linaro Ltd.
+ * Copyright 2021 Socionext, Inc.
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <malloc.h>
+#include <sdhci.h>
+
+struct f_sdh30_plat {
+     struct mmc_config cfg;
Quoted 8 lines

drivers/mmc/f_sdh30.c line 21

Quoted 6 lines
drivers/mmc/f_sdh30.c new file +6 -0
+     struct mmc mmc;
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int f_sdh30_probe(struct udevice *dev)

xxx_sdhci_probe().

Quoted 2 lines

Let me confirm. The controller name is F_SDH30, so it is better to be f_sdh30_sdhci_probe(), correct?

I think that it's better. :)
It's my preference. But other driver are using the similar naming.

Quoted 86 lines
Quoted 67 lines
Quoted 67 lines
drivers/mmc/f_sdh30.c new file +60 -0
+{
+     struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+     struct f_sdh30_plat *plat = dev_get_plat(dev);
+     struct sdhci_host *host = dev_get_priv(dev);
+     int ret;
+
+     ret = mmc_of_parse(dev, &plat->cfg);
+     if (ret)
+             return ret;
+
+     host->mmc = &plat->mmc;
+     host->mmc->dev = dev;
+     host->mmc->priv = host;
+
+     ret = sdhci_setup_cfg(&plat->cfg, host, 200000000, 400000);
+     if (ret)
+             return ret;
+
+     upriv->mmc = host->mmc;
+
+     mmc_set_clock(host->mmc, host->mmc->cfg->f_min, MMC_CLK_ENABLE);
+
+     return sdhci_probe(dev);
+}
+
+static int f_sdh30_of_to_plat(struct udevice *dev)
+{
+     struct sdhci_host *host = dev_get_priv(dev);
+
+     host->name = strdup(dev->name);
+     host->ioaddr = dev_read_addr_ptr(dev);
+     host->bus_width = dev_read_u32_default(dev, "bus-width", 4);
+     host->index = dev_read_u32_default(dev, "index", 0);
+
+     return 0;
+}
+
+static int f_sdh30_bind(struct udevice *dev)
+{
+     struct f_sdh30_plat *plat = dev_get_plat(dev);
+
+     return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id f_sdh30_mmc_ids[] = {
+     { .compatible = "fujitsu,mb86s70-sdhci-3.0" },
+     { }
+};
+
+U_BOOT_DRIVER(f_sdh30_drv) = {
+     .name           = "f_sdh30_sdhci",
+     .id             = UCLASS_MMC,
+     .of_match       = f_sdh30_mmc_ids,
+     .of_to_plat     = f_sdh30_of_to_plat,
+     .ops            = &sdhci_ops,
+     .bind           = f_sdh30_bind,
+     .probe          = f_sdh30_probe,
+     .priv_auto      = sizeof(struct sdhci_host),
+     .plat_auto      = sizeof(struct f_sdh30_plat),
+};
drivers/mmc/sdhci.c +0 -0
index d9ab6a0a83..f038debc6c 100644
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 711

Quoted 3 lines
drivers/mmc/sdhci.c +1 -0
      sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+     if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {

I don't want to add specific sdhci driver configuration in sdhci.c.

According to below comment and Specification,
it has to delay 1ms. Can it be removed the above condition checking?

Yes, of course!

Quoted 8 lines
Quoted 7 lines
drivers/mmc/sdhci.c +6 -0
+             /*
+              * Reference to Part1 Physical Layer Simplified Specification
+              * Ver 3.01, 6.4.1 Power Up
+              * This delay must be at least 74 clock sizes, or 1 ms.
+              */
+             udelay(1000);
Quoted 4 lines
Quoted 2 lines

I don't have any objection about this, If possible, it needs to calculate clock-cycle with real clock value in future.

Should I split this part as an independent patch?

I hope so. :)

Thanks

Best Regards,
Jaehoon Chung

Quoted 5 lines

Thank you,

#19 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

In reply to Jaehoon Chung
Quoted 15 lines · Jaehoon Chung

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 711

Quoted 9 lines
drivers/mmc/sdhci.c +1 -0
index d9ab6a0a83..f038debc6c 100644
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
      sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+     if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {

I don't want to add specific sdhci driver configuration in sdhci.c.

According to below comment and Specification,
it has to delay 1ms. Can it be removed the above condition checking?

Quoted 9 lines

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 717

Quoted 6 lines
drivers/mmc/sdhci.c +6 -0
+             /*
+              * Reference to Part1 Physical Layer Simplified Specification
+              * Ver 3.01, 6.4.1 Power Up
+              * This delay must be at least 74 clock sizes, or 1 ms.
+              */
+             udelay(1000);

I don't have any objection about this, If possible, it needs to calculate clock-cycle with real clock value in future.

This change is carried over from some ancient patchset. While it might be helpful to some platform, I tried removing the delay, and it still works. So for f_sdh30 we don't seem to need it.

thanks.

#20 lore raw

PATCH v2 7/13 mmc: synquacer: Add SynQuacer F_SDH30 SDHCI driver

Quoted 24 lines · Jassi Brar
Quoted 22 lines · Jaehoon Chung

drivers/mmc/sdhci.c static int sdhci_init(struct mmc *mmc) · line 711

Quoted 9 lines
drivers/mmc/sdhci.c +1 -0
index d9ab6a0a83..f038debc6c 100644
@@ -708,6 +708,15 @@ static int sdhci_init(struct mmc *mmc)
 
      sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
+     if (IS_ENABLED(CONFIG_F_SDH30_SDHCI)) {

I don't want to add specific sdhci driver configuration in sdhci.c.

According to below comment and Specification,
it has to delay 1ms. Can it be removed the above condition checking?

Quoted 6 lines
drivers/mmc/sdhci.c +6 -0
+             /*
+              * Reference to Part1 Physical Layer Simplified Specification
+              * Ver 3.01, 6.4.1 Power Up
+              * This delay must be at least 74 clock sizes, or 1 ms.
+              */
+             udelay(1000);
Quoted 5 lines
Quoted 2 lines

I don't have any objection about this, If possible, it needs to calculate clock-cycle with real clock value in future.

This change is carried over from some ancient patchset. While it might be helpful to some platform, I tried removing the delay, and it still works. So for f_sdh30 we don't seem to need it.

Thanks for checking it.

Best Regards,
Jaehoon Chung

Quoted 3 lines

thanks.

#21 lore raw

PATCH v2 8/13 spi: synquacer: Add HSSPI SPI controller driver for SynQuacer

In reply to Masami Hiramatsu

From: Jassi Brar <[email protected]>

This is a driver for the HSSPI SPI controller on SynQuacer SoC. The HSSPI has command sequence mode (memory mapped) and direct mode (FIFO access). The driver will operate it under the direct mode. And before booting OS, it switch back to the command sequence mode since that is compatible with default EDK2 behavior.

---
 drivers/spi/Kconfig         |    8 +
 drivers/spi/Makefile        |    1 
 drivers/spi/spi-synquacer.c |  491 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 500 insertions(+)
 create mode 100644 drivers/spi/spi-synquacer.c
drivers/spi/Kconfig +8 -0
index 1494c91763..62d9676550 100644
@@ -481,4 +481,12 @@ config MXC_SPI
 	  Enable the MXC SPI controller driver. This driver can be used
 	  on various i.MX SoCs such as i.MX31/35/51/6/7.
 
+config SYNQUACER_SPI
+	bool "Socionext SynQuacer HS-SPI driver"
+	depends on ARCH_SYNQUACER
+	help
+	  Enable the Socionext HS-SPI driver for SynQuacer. This driver can
+	  be used to access the SPI interface and SPI NOR flash on platforms
+	  embedding this HS-SPI IP core.
+
 endif # menu "SPI Support"
drivers/spi/Makefile +1 -0
index cfe4fae1d4..98c95323d1 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 obj-$(CONFIG_FSL_DSPI) += fsl_dspi.o
 obj-$(CONFIG_FSL_ESPI) += fsl_espi.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
+obj-$(CONFIG_SYNQUACER_SPI) += spi-synquacer.o
 obj-$(CONFIG_ICH_SPI) +=  ich.o
 obj-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
 obj-$(CONFIG_MESON_SPIFC) += meson_spifc.o
drivers/spi/spi-synquacer.c new file +491 -0

491 lines not on this page · raw message

#22 lore raw

PATCH v2 9/13 net: synquacer: Add netsec driver

In reply to Masami Hiramatsu

From: Jassi Brar <[email protected]>

Add SynQuacer's NETSEC GbE controller driver. Since this driver will load the firmware from SPI NOR flash, this depends on CONFIG_SYNQUACER_SPI=y.

---
 drivers/net/Kconfig      |    8 
 drivers/net/Makefile     |    1 
 drivers/net/sni_netsec.c | 1134 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1143 insertions(+)
 create mode 100644 drivers/net/sni_netsec.c
drivers/net/Kconfig +8 -0
index 0e84c22b50..e7c6814c31 100644
@@ -649,6 +649,14 @@ config SNI_AVE
 	  This driver implements support for the Socionext AVE Ethernet
 	  controller, as found on the Socionext UniPhier family.
 
+config SNI_NETSEC
+	bool "Socionext NETSEC Ethernet support"
+	depends on DM_ETH && SYNQUACER_SPI
+	select PHYLIB
+	help
+	  This driver implements support for the Socionext SynQuacer NETSEC
+	  ethernet controller, as found on the Socionext SynQuacer family.
+
 source "drivers/net/mscc_eswitch/Kconfig"
 
 config ETHER_ON_FEC1
drivers/net/Makefile +1 -0
index a19511aaa7..30e1c9baab 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
 obj-$(CONFIG_FSL_PFE) += pfe_eth/
 obj-y += qe/
 obj-$(CONFIG_SNI_AVE) += sni_ave.o
+obj-$(CONFIG_SNI_NETSEC) += sni_netsec.o
 obj-y += ti/
 obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
 obj-y += mscc_eswitch/
drivers/net/sni_netsec.c new file +1134 -0

1,134 lines not on this page · raw message

#23 lore raw

PATCH v2 9/13 net: synquacer: Add netsec driver

Quoted 1,177 lines · Masami Hiramatsu

From: Jassi Brar <[email protected]>

Add SynQuacer's NETSEC GbE controller driver. Since this driver will load the firmware from SPI NOR flash, this depends on CONFIG_SYNQUACER_SPI=y.

---
 drivers/net/Kconfig      |    8
 drivers/net/Makefile     |    1
 drivers/net/sni_netsec.c | 1134 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1143 insertions(+)
 create mode 100644 drivers/net/sni_netsec.c
drivers/net/Kconfig +8 -0
index 0e84c22b50..e7c6814c31 100644
@@ -649,6 +649,14 @@ config SNI_AVE
          This driver implements support for the Socionext AVE Ethernet
          controller, as found on the Socionext UniPhier family.
 
+config SNI_NETSEC
+       bool "Socionext NETSEC Ethernet support"
+       depends on DM_ETH && SYNQUACER_SPI
+       select PHYLIB
+       help
+         This driver implements support for the Socionext SynQuacer NETSEC
+         ethernet controller, as found on the Socionext SynQuacer family.
+
 source "drivers/net/mscc_eswitch/Kconfig"
 
 config ETHER_ON_FEC1
drivers/net/Makefile +1 -0
index a19511aaa7..30e1c9baab 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
 obj-$(CONFIG_FSL_PFE) += pfe_eth/
 obj-y += qe/
 obj-$(CONFIG_SNI_AVE) += sni_ave.o
+obj-$(CONFIG_SNI_NETSEC) += sni_netsec.o
 obj-y += ti/
 obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
 obj-y += mscc_eswitch/
drivers/net/sni_netsec.c new file +1124 -0
new file mode 100644
index 0000000000..a9ebf6af9c
@@ -0,0 +1,1134 @@
+// SPDX-License-Identifier: GPL-2.0+
+/**
+ * netsec.c - Socionext Synquacer Netsec driver
+ * Copyright 2021 Linaro Ltd.
+ */
+
+#include <clk.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <fdt_support.h>
+#include <log.h>
+#include <malloc.h>
+#include <miiphy.h>
+#include <net.h>
+#include <regmap.h>
+#include <reset.h>
+#include <syscon.h>
+#include <asm/cache.h>
+#include <asm/global_data.h>
+#include <dm/device_compat.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/iopoll.h>
+#include <spi.h>
+#include <spi_flash.h>
+
+#define NETSEC_REG_SOFT_RST                    0x104
+#define NETSEC_REG_COM_INIT                    0x120
+
+#define NETSEC_REG_TOP_STATUS                  0x200
+#define NETSEC_IRQ_RX                          BIT(1)
+#define NETSEC_IRQ_TX                          BIT(0)
+
+#define NETSEC_REG_TOP_INTEN                   0x204
+#define NETSEC_REG_INTEN_SET                   0x234
+#define NETSEC_REG_INTEN_CLR                   0x238
+
+#define NETSEC_REG_NRM_TX_STATUS               0x400
+#define NETSEC_REG_NRM_TX_INTEN                        0x404
+#define NETSEC_REG_NRM_TX_INTEN_SET            0x428
+#define NETSEC_REG_NRM_TX_INTEN_CLR            0x42c
+#define NRM_TX_ST_NTOWNR       BIT(17)
+#define NRM_TX_ST_TR_ERR       BIT(16)
+#define NRM_TX_ST_TXDONE       BIT(15)
+#define NRM_TX_ST_TMREXP       BIT(14)
+
+#define NETSEC_REG_NRM_RX_STATUS               0x440
+#define NETSEC_REG_NRM_RX_INTEN                        0x444
+#define NETSEC_REG_NRM_RX_INTEN_SET            0x468
+#define NETSEC_REG_NRM_RX_INTEN_CLR            0x46c
+#define NRM_RX_ST_RC_ERR       BIT(16)
+#define NRM_RX_ST_PKTCNT       BIT(15)
+#define NRM_RX_ST_TMREXP       BIT(14)
+
+#define NETSEC_REG_PKT_CMD_BUF                 0xd0
+
+#define NETSEC_REG_CLK_EN                      0x100
+
+#define NETSEC_REG_PKT_CTRL                    0x140
+
+#define NETSEC_REG_DMA_TMR_CTRL                        0x20c
+#define NETSEC_REG_F_TAIKI_MC_VER              0x22c
+#define NETSEC_REG_F_TAIKI_VER                 0x230
+#define NETSEC_REG_DMA_HM_CTRL                 0x214
+#define NETSEC_REG_DMA_MH_CTRL                 0x220
+#define NETSEC_REG_ADDR_DIS_CORE               0x218
+#define NETSEC_REG_DMAC_HM_CMD_BUF             0x210
+#define NETSEC_REG_DMAC_MH_CMD_BUF             0x21c
+
+#define NETSEC_REG_NRM_TX_PKTCNT               0x410
+
+#define NETSEC_REG_NRM_TX_DONE_PKTCNT          0x414
+#define NETSEC_REG_NRM_TX_DONE_TXINT_PKTCNT    0x418
+
+#define NETSEC_REG_NRM_TX_TMR                  0x41c
+
+#define NETSEC_REG_NRM_RX_PKTCNT               0x454
+#define NETSEC_REG_NRM_RX_RXINT_PKTCNT         0x458
+#define NETSEC_REG_NRM_TX_TXINT_TMR            0x420
+#define NETSEC_REG_NRM_RX_RXINT_TMR            0x460
+
+#define NETSEC_REG_NRM_RX_TMR                  0x45c
+
+#define NETSEC_REG_NRM_TX_DESC_START_UP                0x434
+#define NETSEC_REG_NRM_TX_DESC_START_LW                0x408
+#define NETSEC_REG_NRM_RX_DESC_START_UP                0x474
+#define NETSEC_REG_NRM_RX_DESC_START_LW                0x448
+
+#define NETSEC_REG_NRM_TX_CONFIG               0x430
+#define NETSEC_REG_NRM_RX_CONFIG               0x470
+
+#define MAC_REG_STATUS                         0x1024
+#define MAC_REG_DATA                           0x11c0
+#define MAC_REG_CMD                            0x11c4
+#define MAC_REG_FLOW_TH                                0x11cc
+#define MAC_REG_INTF_SEL                       0x11d4
+#define MAC_REG_DESC_INIT                      0x11fc
+#define MAC_REG_DESC_SOFT_RST                  0x1204
+#define NETSEC_REG_MODE_TRANS_COMP_STATUS      0x500
+
+#define GMAC_REG_MCR                           0x0000
+#define GMAC_REG_MFFR                          0x0004
+#define GMAC_REG_GAR                           0x0010
+#define GMAC_REG_GDR                           0x0014
+#define GMAC_REG_FCR                           0x0018
+#define GMAC_REG_BMR                           0x1000
+#define GMAC_REG_RDLAR                         0x100c
+#define GMAC_REG_TDLAR                         0x1010
+#define GMAC_REG_OMR                           0x1018
+
+#define MHZ(n)         ((n) * 1000 * 1000)
+
+#define NETSEC_TX_SHIFT_OWN_FIELD              31
+#define NETSEC_TX_SHIFT_LD_FIELD               30
+#define NETSEC_TX_SHIFT_DRID_FIELD             24
+#define NETSEC_TX_SHIFT_PT_FIELD               21
+#define NETSEC_TX_SHIFT_TDRID_FIELD            16
+#define NETSEC_TX_SHIFT_CC_FIELD               15
+#define NETSEC_TX_SHIFT_FS_FIELD               9
+#define NETSEC_TX_LAST                         8
+#define NETSEC_TX_SHIFT_CO                     7
+#define NETSEC_TX_SHIFT_SO                     6
+#define NETSEC_TX_SHIFT_TRS_FIELD              4
+
+#define NETSEC_RX_PKT_OWN_FIELD                        31
+#define NETSEC_RX_PKT_LD_FIELD                 30
+#define NETSEC_RX_PKT_SDRID_FIELD              24
+#define NETSEC_RX_PKT_FR_FIELD                 23
+#define NETSEC_RX_PKT_ER_FIELD                 21
+#define NETSEC_RX_PKT_ERR_FIELD                        16
+#define NETSEC_RX_PKT_TDRID_FIELD              12
+#define NETSEC_RX_PKT_FS_FIELD                 9
+#define NETSEC_RX_PKT_LS_FIELD                 8
+#define NETSEC_RX_PKT_CO_FIELD                 6
+
+#define NETSEC_RX_PKT_ERR_MASK                 3
+
+#define NETSEC_MAX_TX_PKT_LEN                  1518
+#define NETSEC_MAX_TX_JUMBO_PKT_LEN            9018
+
+#define NETSEC_RING_GMAC                       15
+#define NETSEC_RING_MAX                                2
+
+#define NETSEC_TCP_SEG_LEN_MAX                 1460
+#define NETSEC_TCP_JUMBO_SEG_LEN_MAX           8960
+
+#define NETSEC_RX_CKSUM_NOTAVAIL               0
+#define NETSEC_RX_CKSUM_OK                     1
+#define NETSEC_RX_CKSUM_NG                     2
+
+#define NETSEC_TOP_IRQ_REG_ME_START                    BIT(20)
+#define NETSEC_IRQ_TRANSITION_COMPLETE         BIT(4)
+
+#define NETSEC_MODE_TRANS_COMP_IRQ_N2T         BIT(20)
+#define NETSEC_MODE_TRANS_COMP_IRQ_T2N         BIT(19)
+
+#define NETSEC_INT_PKTCNT_MAX                  2047
+
+#define NETSEC_FLOW_START_TH_MAX               95
+#define NETSEC_FLOW_STOP_TH_MAX                        95
+#define NETSEC_FLOW_PAUSE_TIME_MIN             5
+
+#define NETSEC_CLK_EN_REG_DOM_ALL              0x3f
+
+#define NETSEC_PKT_CTRL_REG_MODE_NRM           BIT(28)
+#define NETSEC_PKT_CTRL_REG_EN_JUMBO           BIT(27)
+#define NETSEC_PKT_CTRL_REG_LOG_CHKSUM_ER      BIT(3)
+#define NETSEC_PKT_CTRL_REG_LOG_HD_INCOMPLETE  BIT(2)
+#define NETSEC_PKT_CTRL_REG_LOG_HD_ER          BIT(1)
+#define NETSEC_PKT_CTRL_REG_DRP_NO_MATCH       BIT(0)
+
+#define NETSEC_CLK_EN_REG_DOM_G                        BIT(5)
+#define NETSEC_CLK_EN_REG_DOM_C                        BIT(1)
+#define NETSEC_CLK_EN_REG_DOM_D                        BIT(0)
+
+#define NETSEC_COM_INIT_REG_DB                 BIT(2)
+#define NETSEC_COM_INIT_REG_CLS                        BIT(1)
+#define NETSEC_COM_INIT_REG_ALL                        (NETSEC_COM_INIT_REG_CLS | \
+                                                NETSEC_COM_INIT_REG_DB)
+
+#define NETSEC_SOFT_RST_REG_RESET              0
+#define NETSEC_SOFT_RST_REG_RUN                        BIT(31)
+
+#define NETSEC_DMA_CTRL_REG_STOP               1
+#define MH_CTRL__MODE_TRANS                    BIT(20)
+
+#define NETSEC_GMAC_CMD_ST_READ                        0
+#define NETSEC_GMAC_CMD_ST_WRITE               BIT(28)
+#define NETSEC_GMAC_CMD_ST_BUSY                        BIT(31)
+
+#define NETSEC_GMAC_BMR_REG_COMMON             0x00412080
+#define NETSEC_GMAC_BMR_REG_RESET              0x00020181
+#define NETSEC_GMAC_BMR_REG_SWR                        0x00000001
+
+#define NETSEC_GMAC_OMR_REG_ST                 BIT(13)
+#define NETSEC_GMAC_OMR_REG_SR                 BIT(1)
+
+#define NETSEC_GMAC_MCR_REG_IBN                        BIT(30)
+#define NETSEC_GMAC_MCR_REG_CST                        BIT(25)
+#define NETSEC_GMAC_MCR_REG_JE                 BIT(20)
+#define NETSEC_MCR_PS                          BIT(15)
+#define NETSEC_GMAC_MCR_REG_FES                        BIT(14)
+#define NETSEC_GMAC_MCR_REG_FULL_DUPLEX_COMMON 0x0000280c
+#define NETSEC_GMAC_MCR_REG_HALF_DUPLEX_COMMON 0x0001a00c
+
+#define NETSEC_FCR_RFE                         BIT(2)
+#define NETSEC_FCR_TFE                         BIT(1)
+
+#define NETSEC_GMAC_GAR_REG_GW                 BIT(1)
+#define NETSEC_GMAC_GAR_REG_GB                 BIT(0)
+
+#define NETSEC_GMAC_GAR_REG_SHIFT_PA           11
+#define NETSEC_GMAC_GAR_REG_SHIFT_GR           6
+#define GMAC_REG_SHIFT_CR_GAR                  2
+
+#define NETSEC_GMAC_GAR_REG_CR_25_35_MHZ       2
+#define NETSEC_GMAC_GAR_REG_CR_35_60_MHZ       3
+#define NETSEC_GMAC_GAR_REG_CR_60_100_MHZ      0
+#define NETSEC_GMAC_GAR_REG_CR_100_150_MHZ     1
+#define NETSEC_GMAC_GAR_REG_CR_150_250_MHZ     4
+#define NETSEC_GMAC_GAR_REG_CR_250_300_MHZ     5
+
+#define NETSEC_GMAC_RDLAR_REG_COMMON           0x18000
+#define NETSEC_GMAC_TDLAR_REG_COMMON           0x1c000
+
+#define NETSEC_REG_NETSEC_VER_F_TAIKI          0x50000
+
+#define NETSEC_REG_DESC_RING_CONFIG_CFG_UP     BIT(31)
+#define NETSEC_REG_DESC_RING_CONFIG_CH_RST     BIT(30)
+#define NETSEC_REG_DESC_TMR_MODE               4
+#define NETSEC_REG_DESC_ENDIAN                 0
+
+#define NETSEC_MAC_DESC_SOFT_RST_SOFT_RST      1
+#define NETSEC_MAC_DESC_INIT_REG_INIT          1
+
+#define NETSEC_EEPROM_MAC_ADDRESS              0x00
+#define NETSEC_EEPROM_HM_ME_ADDRESS_H          0x08
+#define NETSEC_EEPROM_HM_ME_ADDRESS_L          0x0C
+#define NETSEC_EEPROM_HM_ME_SIZE               0x10
+#define NETSEC_EEPROM_MH_ME_ADDRESS_H          0x14
+#define NETSEC_EEPROM_MH_ME_ADDRESS_L          0x18
+#define NETSEC_EEPROM_MH_ME_SIZE               0x1C
+#define NETSEC_EEPROM_PKT_ME_ADDRESS           0x20
+#define NETSEC_EEPROM_PKT_ME_SIZE              0x24
+
+#define DESC_SZ        sizeof(struct netsec_de)
+
+#define NETSEC_F_NETSEC_VER_MAJOR_NUM(x)       ((x) & 0xffff0000)
+
+#define EERPROM_MAP_OFFSET     0x8000000
+#define NOR_BLOCK      1024
+
+struct netsec_de { /* Netsec Descriptor layout */
+       u32 attr;
+       u32 data_buf_addr_up;
+       u32 data_buf_addr_lw;
+       u32 buf_len_info;
+};
+
+struct netsec_priv {
+       struct netsec_de rxde[PKTBUFSRX];
+       struct netsec_de txde[1];
+       u16 rxat;
+
+       phys_addr_t eeprom_base;
+       phys_addr_t ioaddr;
+
+       struct mii_dev *bus;
+       struct phy_device *phydev;
+       u32 phy_addr, freq;
+       int phy_mode;
+       int max_speed;
+};
+
+struct netsec_tx_pkt_ctrl {
+       u16 tcp_seg_len;
+       bool tcp_seg_offload_flag;
+       bool cksum_offload_flag;
+};
+
+struct netsec_rx_pkt_info {
+       int rx_cksum_result;
+       int err_code;
+       bool err_flag;
+};
+
+static void netsec_write_reg(struct netsec_priv *priv, u32 reg_addr, u32 val)
+{
+       writel(val, priv->ioaddr + reg_addr);
+}
+
+static u32 netsec_read_reg(struct netsec_priv *priv, u32 reg_addr)
+{
+       return readl(priv->ioaddr + reg_addr);
+}
+
+/************* MDIO BUS OPS FOLLOW *************/
+
+#define TIMEOUT_SPINS_MAC              1000
+#define TIMEOUT_SECONDARY_MS_MAC       100
+
+static u32 netsec_clk_type(u32 freq)
+{
+       if (freq < MHZ(35))
+               return NETSEC_GMAC_GAR_REG_CR_25_35_MHZ;
+       if (freq < MHZ(60))
+               return NETSEC_GMAC_GAR_REG_CR_35_60_MHZ;
+       if (freq < MHZ(100))
+               return NETSEC_GMAC_GAR_REG_CR_60_100_MHZ;
+       if (freq < MHZ(150))
+               return NETSEC_GMAC_GAR_REG_CR_100_150_MHZ;
+       if (freq < MHZ(250))
+               return NETSEC_GMAC_GAR_REG_CR_150_250_MHZ;
+
+       return NETSEC_GMAC_GAR_REG_CR_250_300_MHZ;
+}
+
+static int netsec_wait_while_busy(struct netsec_priv *priv, u32 addr, u32 mask)
+{
+       u32 timeout = TIMEOUT_SPINS_MAC;
+
+       while (--timeout && netsec_read_reg(priv, addr) & mask)
+               cpu_relax();
+       if (timeout)
+               return 0;
+
+       timeout = TIMEOUT_SECONDARY_MS_MAC;
+       while (--timeout && netsec_read_reg(priv, addr) & mask)
+               udelay(2000);
+
+       if (timeout)
+               return 0;
+
+       pr_err("%s: timeout\n", __func__);
+
+       return -ETIMEDOUT;
+}
+
+static int netsec_set_mac_reg(struct netsec_priv *priv, u32 addr, u32 value)
+{
+       netsec_write_reg(priv, MAC_REG_DATA, value);
+       netsec_write_reg(priv, MAC_REG_CMD, addr | NETSEC_GMAC_CMD_ST_WRITE);
+       return netsec_wait_while_busy(priv,
+                                     MAC_REG_CMD, NETSEC_GMAC_CMD_ST_BUSY);
+}
+
+static int netsec_get_mac_reg(struct netsec_priv *priv, u32 addr, u32 *read)
+{
+       int ret;
+
+       netsec_write_reg(priv, MAC_REG_CMD, addr | NETSEC_GMAC_CMD_ST_READ);
+       ret = netsec_wait_while_busy(priv,
+                                    MAC_REG_CMD, NETSEC_GMAC_CMD_ST_BUSY);
+       if (ret)
+               return ret;
+
+       *read = netsec_read_reg(priv, MAC_REG_DATA);
+
+       return 0;
+}
+
+static int netsec_mac_wait_while_busy(struct netsec_priv *priv,
+                                     u32 addr, u32 mask)
+{
+       u32 timeout = TIMEOUT_SPINS_MAC;
+       u32 data;
+       int ret;
+
+       do {
+               ret = netsec_get_mac_reg(priv, addr, &data);
+               if (ret)
+                       break;
+               udelay(1);
+       } while (--timeout && (data & mask));
+
+       if (timeout)
+               return 0;
+
+       timeout = TIMEOUT_SECONDARY_MS_MAC;
+       do {
+               udelay(2000);
+
+               ret = netsec_get_mac_reg(priv, addr, &data);
+               if (ret)
+                       break;
+               cpu_relax();
+       } while (--timeout && (data & mask));
+
+       if (timeout && !ret)
+               return 0;
+
+       return -ETIMEDOUT;
+}
+
+static void netsec_cache_invalidate(uintptr_t vaddr, int len)
+{
+       invalidate_dcache_range(rounddown(vaddr, ARCH_DMA_MINALIGN),
+                               roundup(vaddr + len, ARCH_DMA_MINALIGN));
+}
+
+static void netsec_cache_flush(uintptr_t vaddr, int len)
+{
+       flush_dcache_range(rounddown(vaddr, ARCH_DMA_MINALIGN),
+                          roundup(vaddr + len, ARCH_DMA_MINALIGN));
+}
+
+static void netsec_set_rx_de(struct netsec_priv *priv, u16 idx, void *addr)
+{
+       struct netsec_de *de = &priv->rxde[idx];
+       u32 attr = (1 << NETSEC_RX_PKT_OWN_FIELD) |
+                  (1 << NETSEC_RX_PKT_FS_FIELD) |
+                  (1 << NETSEC_RX_PKT_LS_FIELD);
+
+       if (idx == PKTBUFSRX - 1)
+               attr |= (1 << NETSEC_RX_PKT_LD_FIELD);
+
+       de->data_buf_addr_up = upper_32_bits((dma_addr_t)addr);
+       de->data_buf_addr_lw = lower_32_bits((dma_addr_t)addr);
+       de->buf_len_info = PKTSIZE;
+       de->attr = attr;
+       dmb();
+       netsec_cache_flush((uintptr_t)de, sizeof(*de));
+}
+
+static void netsec_set_tx_de(struct netsec_priv *priv, void *addr, int len)
+{
+       struct netsec_de *de = &priv->txde[0];
+       u32 attr;
+
+       attr = (1 << NETSEC_TX_SHIFT_OWN_FIELD) |
+              (1 << NETSEC_TX_SHIFT_PT_FIELD) |
+              (NETSEC_RING_GMAC << NETSEC_TX_SHIFT_TDRID_FIELD) |
+              (1 << NETSEC_TX_SHIFT_FS_FIELD) |
+              (1 << NETSEC_TX_LAST) |
+              (1 << NETSEC_TX_SHIFT_TRS_FIELD) |
+                       (1 << NETSEC_TX_SHIFT_LD_FIELD);
+
+       de->data_buf_addr_up = upper_32_bits((dma_addr_t)addr);
+       de->data_buf_addr_lw = lower_32_bits((dma_addr_t)addr);
+       de->buf_len_info = len;
+       de->attr = attr;
+       dmb();
+       netsec_cache_flush((uintptr_t)de, sizeof(*de));
+}
+
+static int netsec_get_phy_reg(struct netsec_priv *priv,
+                             int phy_addr, int reg_addr)
+{
+       u32 data;
+       int ret;
+
+       if (phy_addr != 7)
+               return -EINVAL;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_GAR, NETSEC_GMAC_GAR_REG_GB |
+                              phy_addr << NETSEC_GMAC_GAR_REG_SHIFT_PA |
+                              reg_addr << NETSEC_GMAC_GAR_REG_SHIFT_GR |
+                              (netsec_clk_type(priv->freq) <<
+                               GMAC_REG_SHIFT_CR_GAR)))
+               return -ETIMEDOUT;
+
+       ret = netsec_mac_wait_while_busy(priv, GMAC_REG_GAR,
+                                        NETSEC_GMAC_GAR_REG_GB);
+       if (ret)
+               return ret;
+
+       ret = netsec_get_mac_reg(priv, GMAC_REG_GDR, &data);
+       if (ret)
+               return ret;
+
+       return data;
+}
+
+static int netsec_set_phy_reg(struct netsec_priv *priv,
+                             int phy_addr, int reg_addr, u16 val)
+{
+       int ret;
+
+       if (phy_addr != 7)
+               return -EINVAL;
+       if (netsec_set_mac_reg(priv, GMAC_REG_GDR, val))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_GAR,
+                              phy_addr << NETSEC_GMAC_GAR_REG_SHIFT_PA |
+                              reg_addr << NETSEC_GMAC_GAR_REG_SHIFT_GR |
+                              NETSEC_GMAC_GAR_REG_GW | NETSEC_GMAC_GAR_REG_GB |
+                              (netsec_clk_type(priv->freq) <<
+                               GMAC_REG_SHIFT_CR_GAR)))
+               return -ETIMEDOUT;
+
+       ret = netsec_mac_wait_while_busy(priv, GMAC_REG_GAR,
+                                        NETSEC_GMAC_GAR_REG_GB);
+
+       /* Developerbox implements RTL8211E PHY and there is
+        * a compatibility problem with F_GMAC4.
+        * RTL8211E expects MDC clock must be kept toggling for several
+        * clock cycle with MDIO high before entering the IDLE state.
+        * To meet this requirement, netsec driver needs to issue dummy
+        * read(e.g. read PHYID1(offset 0x2) register) right after write.
+        */
+       netsec_get_phy_reg(priv, phy_addr, MII_PHYSID1);
+
+       return ret;
+}
+
+static int netsec_mac_update_to_phy_state(struct netsec_priv *priv)
+{
+       struct phy_device *phydev = priv->phydev;
+       u32 value = 0;
+
+       value = phydev->duplex ? NETSEC_GMAC_MCR_REG_FULL_DUPLEX_COMMON :
+                                NETSEC_GMAC_MCR_REG_HALF_DUPLEX_COMMON;
+
+       if (phydev->speed != SPEED_1000)
+               value |= NETSEC_MCR_PS;
+
+       if (phydev->interface != PHY_INTERFACE_MODE_GMII &&
+           phydev->speed == SPEED_100)
+               value |= NETSEC_GMAC_MCR_REG_FES;
+
+       value |= NETSEC_GMAC_MCR_REG_CST | NETSEC_GMAC_MCR_REG_JE;
+
+       if (phy_interface_is_rgmii(phydev))
+               value |= NETSEC_GMAC_MCR_REG_IBN;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_MCR, value))
+               return -ETIMEDOUT;
+
+       return 0;
+}
+
+static int netsec_start_gmac(struct netsec_priv *priv)
+{
+       u32 value = 0;
+       int ret;
+
+       if (priv->max_speed != SPEED_1000)
+               value = (NETSEC_GMAC_MCR_REG_CST |
+                        NETSEC_GMAC_MCR_REG_HALF_DUPLEX_COMMON);
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_MCR, value))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_BMR,
+                              NETSEC_GMAC_BMR_REG_RESET))
+               return -ETIMEDOUT;
+
+       /* Wait soft reset */
+       mdelay(5);
+
+       ret = netsec_get_mac_reg(priv, GMAC_REG_BMR, &value);
+       if (ret)
+               return ret;
+
+       if (value & NETSEC_GMAC_BMR_REG_SWR)
+               return -EAGAIN;
+
+       netsec_write_reg(priv, MAC_REG_DESC_SOFT_RST, 1);
+       if (netsec_wait_while_busy(priv, MAC_REG_DESC_SOFT_RST, 1))
+               return -ETIMEDOUT;
+
+       netsec_write_reg(priv, MAC_REG_DESC_INIT, 1);
+       if (netsec_wait_while_busy(priv, MAC_REG_DESC_INIT, 1))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_BMR,
+                              NETSEC_GMAC_BMR_REG_COMMON))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_RDLAR,
+                              NETSEC_GMAC_RDLAR_REG_COMMON))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_TDLAR,
+                              NETSEC_GMAC_TDLAR_REG_COMMON))
+               return -ETIMEDOUT;
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_MFFR, 0x80000001))
+               return -ETIMEDOUT;
+
+       ret = netsec_mac_update_to_phy_state(priv);
+       if (ret)
+               return ret;
+
+       ret = netsec_get_mac_reg(priv, GMAC_REG_OMR, &value);
+       if (ret)
+               return ret;
+
+       value |= NETSEC_GMAC_OMR_REG_SR;
+       value |= NETSEC_GMAC_OMR_REG_ST;
+
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_INTEN_CLR, ~0);
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_INTEN_CLR, ~0);
+
+       if (netsec_set_mac_reg(priv, GMAC_REG_OMR, value))
+               return -ETIMEDOUT;
+
+       return 0;
+}
+
+static int netsec_stop_gmac(struct netsec_priv *priv)
+{
+       u32 value;
+       int ret;
+
+       ret = netsec_get_mac_reg(priv, GMAC_REG_OMR, &value);
+       if (ret)
+               return ret;
+       value &= ~NETSEC_GMAC_OMR_REG_SR;
+       value &= ~NETSEC_GMAC_OMR_REG_ST;
+
+       /* disable all interrupts */
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_INTEN_CLR, ~0);
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_INTEN_CLR, ~0);
+
+       return netsec_set_mac_reg(priv, GMAC_REG_OMR, value);
+}
+
+static void netsec_spi_read(char *buf, loff_t len, loff_t offset)
+{
+       struct udevice *new;
+       struct spi_flash *flash;
+
+       spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
+                              CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE, &new);
+       flash = dev_get_uclass_priv(new);
+
+       spi_flash_read(flash, offset, len, buf);
+}
+
+static int netsec_read_rom_hwaddr(struct udevice *dev)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+       struct eth_pdata *pdata = dev_get_plat(dev);
+       char macp[NOR_BLOCK];
+
+       netsec_spi_read(macp, sizeof(macp), priv->eeprom_base);
+
+       pdata->enetaddr[0] = readb(macp + 3);
+       pdata->enetaddr[1] = readb(macp + 2);
+       pdata->enetaddr[2] = readb(macp + 1);
+       pdata->enetaddr[3] = readb(macp + 0);
+       pdata->enetaddr[4] = readb(macp + 7);
+       pdata->enetaddr[5] = readb(macp + 6);
+       return 0;
+}
+
+static int netsec_send(struct udevice *dev, void *packet, int length)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+       u32 val, tout;
+
+       val = netsec_read_reg(priv, NETSEC_REG_NRM_TX_STATUS);
+       netsec_cache_flush((uintptr_t)packet, length);
+       netsec_set_tx_de(priv, packet, length);
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_PKTCNT, 1); /* submit another tx */
+
+       val = netsec_read_reg(priv, NETSEC_REG_NRM_TX_PKTCNT);
+
+       tout = 10000;
+       do {
+               val = netsec_read_reg(priv, NETSEC_REG_NRM_TX_DONE_PKTCNT);
+               udelay(2);
+       } while (--tout && !val);
+
+       if (!tout) {
+               val = netsec_read_reg(priv, NETSEC_REG_NRM_TX_PKTCNT);
+               pr_err("%s: ETIMEDOUT:  %dpackets\n", __func__, val);
+               return -ETIMEDOUT;
+       }
+
+       return 0;
+}
+
+static int netsec_free_packet(struct udevice *dev, uchar *packet, int length)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+
+       netsec_set_rx_de(priv, priv->rxat, net_rx_packets[priv->rxat]);
+
+       priv->rxat++;
+       if (priv->rxat == PKTBUFSRX)
+               priv->rxat = 0;
+
+       return 0;
+}
+
+static int netsec_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+       int idx = priv->rxat;
+       uchar *ptr = net_rx_packets[idx];
+       struct netsec_de *de = &priv->rxde[idx];
+       int length = 0;
+
+       netsec_cache_invalidate((uintptr_t)de, sizeof(*de));
+
+       if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD))
+               return -EAGAIN;
+
+       length = de->buf_len_info >> 16;
+
+       /* invalidate after DMA is done */
+       netsec_cache_invalidate((uintptr_t)ptr, length);
+       *packetp = ptr;
+
+       return length;
+}
+
+static int _netsec_get_phy_reg(struct mii_dev *bus,
+                              int phy_addr, int devad, int reg_addr)
+{
+       return netsec_get_phy_reg(bus->priv, phy_addr, reg_addr);
+}
+
+static int _netsec_set_phy_reg(struct mii_dev *bus,
+                              int phy_addr, int devad, int reg_addr, u16 val)
+{
+       return netsec_set_phy_reg(bus->priv, phy_addr, reg_addr, val);
+}
+
+static int netsec_mdiobus_init(struct netsec_priv *priv, const char *name)
+{
+       struct mii_dev *bus = mdio_alloc();
+
+       if (!bus)
+               return -ENOMEM;
+
+       bus->read = _netsec_get_phy_reg;
+       bus->write = _netsec_set_phy_reg;
+       snprintf(bus->name, sizeof(bus->name), "%s", name);
+       bus->priv = priv;
+
+       return mdio_register(bus);
+}
+
+static int netsec_phy_init(struct netsec_priv *priv, void *dev)
+{
+       struct phy_device *phydev;
+       int ret;
+
+       phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode);
+
+       phydev->supported &= PHY_GBIT_FEATURES;
+       if (priv->max_speed) {
+               ret = phy_set_supported(phydev, priv->max_speed);
+               if (ret)
+                       return ret;
+       }
+       phydev->advertising = phydev->supported;
+
+       priv->phydev = phydev;
+       phy_config(phydev);
+
+       return 0;
+}
+
+static int netsec_netdev_load_ucode_region(struct netsec_priv *priv, u32 reg,
+                                          u32 addr_h, u32 addr_l, u32 size)
+{
+       u64 base = ((u64)addr_h << 32 | addr_l) - EERPROM_MAP_OFFSET;
+
+       while (size > 0) {
+               char buf[NOR_BLOCK];
+               u32 *ucode = (u32 *)buf;
+               u64 off;
+               int i;
+
+               off = base % NOR_BLOCK;
+               base -= off;
+               netsec_spi_read(buf, sizeof(buf), base);
+
+               for (i = off / 4; i < sizeof(buf) / 4 && size > 0; i++, size--)
+                       netsec_write_reg(priv, reg, ucode[i]);
+               base += NOR_BLOCK;
+       }
+
+       return 0;
+}
+
+static int netsec_netdev_load_microcode(struct netsec_priv *priv)
+{
+       u32 addr_h, addr_l, size;
+       char buf[NOR_BLOCK];
+       u32 *ucinfo = (u32 *)buf;
+       int err;
+
+       netsec_spi_read(buf, sizeof(buf), priv->eeprom_base);
+
+       addr_h = ucinfo[NETSEC_EEPROM_HM_ME_ADDRESS_H >> 2];
+       addr_l = ucinfo[NETSEC_EEPROM_HM_ME_ADDRESS_L >> 2];
+       size = ucinfo[NETSEC_EEPROM_HM_ME_SIZE >> 2];
+
+       err = netsec_netdev_load_ucode_region(priv, NETSEC_REG_DMAC_HM_CMD_BUF,
+                                             addr_h, addr_l, size);
+       if (err)
+               return err;
+
+       addr_h = ucinfo[NETSEC_EEPROM_MH_ME_ADDRESS_H >> 2];
+       addr_l = ucinfo[NETSEC_EEPROM_MH_ME_ADDRESS_L >> 2];
+       size = ucinfo[NETSEC_EEPROM_MH_ME_SIZE >> 2];
+
+       err = netsec_netdev_load_ucode_region(priv, NETSEC_REG_DMAC_MH_CMD_BUF,
+                                             addr_h, addr_l, size);
+       if (err)
+               return err;
+
+       addr_h = 0;
+       addr_l = ucinfo[NETSEC_EEPROM_PKT_ME_ADDRESS >> 2];
+       size = ucinfo[NETSEC_EEPROM_PKT_ME_SIZE >> 2];
+
+       err = netsec_netdev_load_ucode_region(priv, NETSEC_REG_PKT_CMD_BUF,
+                                             addr_h, addr_l, size);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+void netsec_pre_init_microengine(struct netsec_priv *priv)
+{
+       u32 data;
+
+       /* Remove dormant settings */
+       data = netsec_get_phy_reg(priv, priv->phy_addr, MII_BMCR);
+       data &= ~BMCR_PDOWN;
+       data |= BMCR_ISOLATE;
+       netsec_set_phy_reg(priv, priv->phy_addr, MII_BMCR, data);
+       mdelay(100);
+
+       /* Put phy in loopback mode to guarantee RXCLK input */
+       data |= BMCR_LOOPBACK;
+       netsec_set_phy_reg(priv, priv->phy_addr, MII_BMCR, data);
+       mdelay(100);
+}
+
+void netsec_post_init_microengine(struct netsec_priv *priv)
+{
+       u32 data;
+
+       /* Get phy back to normal operation */
+       data = netsec_get_phy_reg(priv, priv->phy_addr, MII_BMCR);
+       data &= ~BMCR_LOOPBACK;
+       netsec_set_phy_reg(priv, priv->phy_addr, MII_BMCR, data);
+       mdelay(100);
+
+       /* Apply software reset */
+       data |= BMCR_RESET;
+       netsec_set_phy_reg(priv, priv->phy_addr, MII_BMCR, data);
+       mdelay(100);
+}
+
+static int netsec_reset_hardware(struct netsec_priv *priv, bool load_ucode)
+{
+       u32 value;
+       int err;
+
+       netsec_write_reg(priv, NETSEC_REG_CLK_EN, 0x24);
+
+       /* stop DMA engines */
+       if (!netsec_read_reg(priv, NETSEC_REG_ADDR_DIS_CORE)) {
+               netsec_write_reg(priv, NETSEC_REG_DMA_HM_CTRL,
+                                NETSEC_DMA_CTRL_REG_STOP);
+               netsec_write_reg(priv, NETSEC_REG_DMA_MH_CTRL,
+                                NETSEC_DMA_CTRL_REG_STOP);
+
+               value = 100;
+               while (netsec_read_reg(priv, NETSEC_REG_DMA_HM_CTRL) &
+                      NETSEC_DMA_CTRL_REG_STOP) {
+                       udelay(1000);
+                       if (--value == 0) {
+                               pr_err("%s:%d timeout!\n", __func__, __LINE__);
+                               break;
+                       }
+               }
+
+               value = 100;
+               while (netsec_read_reg(priv, NETSEC_REG_DMA_MH_CTRL) &
+                      NETSEC_DMA_CTRL_REG_STOP) {
+                       udelay(1000);
+                       if (--value == 0) {
+                               pr_err("%s:%d timeout!\n", __func__, __LINE__);
+                               break;
+                       }
+               }
+       }
+
+       netsec_set_mac_reg(priv, GMAC_REG_BMR, NETSEC_GMAC_BMR_REG_RESET);
+
+       netsec_write_reg(priv, NETSEC_REG_SOFT_RST, NETSEC_SOFT_RST_REG_RESET);
+       netsec_write_reg(priv, NETSEC_REG_SOFT_RST, NETSEC_SOFT_RST_REG_RUN);
+       netsec_write_reg(priv, NETSEC_REG_COM_INIT, NETSEC_COM_INIT_REG_ALL);
+
+       value = 100;
+       while (netsec_read_reg(priv, NETSEC_REG_COM_INIT) != 0) {
+               udelay(1000);
+               if (--value == 0) {
+                       pr_err("%s:%d COM_INIT timeout!\n", __func__, __LINE__);
+                       break;
+               }
+       }
+
+       /* MAC desc init */
+       netsec_write_reg(priv, MAC_REG_DESC_INIT, 1);
+       netsec_wait_while_busy(priv, MAC_REG_DESC_INIT, 1);
+       /* set MAC_INTF_SEL */
+       netsec_write_reg(priv, MAC_REG_INTF_SEL, 1);
+
+       netsec_write_reg(priv, NETSEC_REG_CLK_EN, 1 << 5);
+
+       /* set desc_start addr */
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_DESC_START_UP,
+                        upper_32_bits((dma_addr_t)priv->rxde));
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_DESC_START_LW,
+                        lower_32_bits((dma_addr_t)priv->rxde));
+
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_DESC_START_UP,
+                        upper_32_bits((dma_addr_t)priv->txde));
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_DESC_START_LW,
+                        lower_32_bits((dma_addr_t)priv->txde));
+
+       /* set normal tx dring ring config */
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_CONFIG,
+                        1 << NETSEC_REG_DESC_ENDIAN);
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_CONFIG,
+                        1 << NETSEC_REG_DESC_ENDIAN);
+
+       if (load_ucode) {
+               err = netsec_netdev_load_microcode(priv);
+               if (err) {
+                       pr_err("%s: failed to load microcode (%d)\n",
+                              __func__, err);
+                       return err;
+               }
+       }
+
+       /* set desc_start addr */
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_DESC_START_UP,
+                        upper_32_bits((dma_addr_t)priv->rxde));
+       netsec_write_reg(priv, NETSEC_REG_NRM_RX_DESC_START_LW,
+                        lower_32_bits((dma_addr_t)priv->rxde));
+
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_DESC_START_UP,
+                        upper_32_bits((dma_addr_t)priv->txde));
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_DESC_START_LW,
+                        lower_32_bits((dma_addr_t)priv->txde));
+
+       netsec_write_reg(priv, NETSEC_REG_CLK_EN, 1 << 5);
+
+       /* start DMA engines */
+       netsec_write_reg(priv, NETSEC_REG_DMA_TMR_CTRL, priv->freq / 1000000 - 1);
+
+       netsec_pre_init_microengine(priv);
+
+       netsec_write_reg(priv, NETSEC_REG_ADDR_DIS_CORE, 0);
+
+       mdelay(100);
+
+       if (!(netsec_read_reg(priv, NETSEC_REG_TOP_STATUS) &
+             NETSEC_TOP_IRQ_REG_ME_START)) {
+               pr_err("microengine start failed\n");
+               return -ENXIO;
+       }
+
+       netsec_post_init_microengine(priv);
+
+       /* clear microcode load end status */
+       netsec_write_reg(priv, NETSEC_REG_TOP_STATUS,
+                        NETSEC_TOP_IRQ_REG_ME_START);
+
+       netsec_write_reg(priv, NETSEC_REG_CLK_EN, 1 << 5);
+
+       value = netsec_read_reg(priv, NETSEC_REG_PKT_CTRL);
+       value |= NETSEC_PKT_CTRL_REG_MODE_NRM;
+       /* change to normal mode */
+       netsec_write_reg(priv, NETSEC_REG_DMA_MH_CTRL, MH_CTRL__MODE_TRANS);
+       netsec_write_reg(priv, NETSEC_REG_PKT_CTRL, value);
+
+       value = 100;
+       while ((netsec_read_reg(priv, NETSEC_REG_MODE_TRANS_COMP_STATUS) &
+               NETSEC_MODE_TRANS_COMP_IRQ_T2N) == 0) {
+               udelay(1000);
+               if (--value == 0) {
+                       value = netsec_read_reg(priv, NETSEC_REG_MODE_TRANS_COMP_STATUS);
+                       pr_err("%s:%d timeout! val=%x\n", __func__, __LINE__, value);
+                       break;
+               }
+       }
+
+       /* clear any pending EMPTY/ERR irq status */
+       netsec_write_reg(priv, NETSEC_REG_NRM_TX_STATUS, ~0);
+
+       /* Disable TX & RX intr */
+       netsec_write_reg(priv, NETSEC_REG_INTEN_CLR, ~0);
+
+       return 0;
+}
+
+static void netsec_stop(struct udevice *dev)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+
+       netsec_write_reg(priv, NETSEC_REG_ADDR_DIS_CORE, 7);
+       netsec_stop_gmac(priv);
+       phy_shutdown(priv->phydev);
+       netsec_reset_hardware(priv, false);
+}
+
+static int netsec_start(struct udevice *dev)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+       int i;
+
+       phy_startup(priv->phydev);
+       netsec_start_gmac(priv);
+
+       priv->rxat = 0;
+       for (i = 0; i < PKTBUFSRX; i++)
+               netsec_set_rx_de(priv, i, net_rx_packets[i]);
+
+       return 0;
+}
+
+static int netsec_of_to_plat(struct udevice *dev)
+{
+       struct eth_pdata *pdata = dev_get_plat(dev);
+       struct netsec_priv *priv = dev_get_priv(dev);
+       struct ofnode_phandle_args phandle_args;
+       const char *phy_mode;
+
+       pdata->iobase = dev_read_addr_index(dev, 0);
+       priv->eeprom_base = dev_read_addr_index(dev, 1) - EERPROM_MAP_OFFSET;
+
+       pdata->phy_interface = -1;
+       phy_mode = dev_read_prop(dev, "phy-mode", NULL);
+       if (phy_mode)
+               pdata->phy_interface = phy_get_interface_by_name(phy_mode);
+       if (pdata->phy_interface == -1) {
+               pr_err("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+               return -EINVAL;
+       }
+
+       if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+                                       &phandle_args))
+               priv->phy_addr = ofnode_read_u32_default(phandle_args.node, "reg", 7);
+       else
+               priv->phy_addr = 7;
+
+       pdata->max_speed = dev_read_u32_default(dev, "max-speed", SPEED_1000);
+
+       priv->ioaddr = pdata->iobase;
+       priv->phy_mode = pdata->phy_interface;
+       priv->max_speed = pdata->max_speed;
+       priv->freq = 250000000UL;
+
+       return 0;
+}
+
+#define SMMU_SCR0_SHCFG_INNER             (0x2 << 22)
+#define SMMU_SCR0_MTCFG                   (0x1 << 20)
+#define SMMU_SCR0_MEMATTR_INNER_OUTER_WB  (0xf << 16)
+
+static int netsec_probe(struct udevice *dev)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+       int ret;
+
+       writel(SMMU_SCR0_SHCFG_INNER | SMMU_SCR0_MTCFG | SMMU_SCR0_MEMATTR_INNER_OUTER_WB,
+              (phys_addr_t)0x52E00000);
+
+       netsec_reset_hardware(priv, true);
+
+       ret = netsec_mdiobus_init(priv, dev->name);
+       if (ret) {
+               pr_err("Failed to initialize mdiobus: %d\n", ret);
+               return ret;
+       }
+
+       priv->bus = miiphy_get_dev_by_name(dev->name);
+
+       ret = netsec_phy_init(priv, dev);
+       if (ret) {
+               pr_err("Failed to initialize phy: %d\n", ret);
+               goto out_mdiobus_release;
+       }
+
+       return 0;
+out_mdiobus_release:
+       mdio_unregister(priv->bus);
+       mdio_free(priv->bus);
+       return ret;
+}
+
+static int netsec_remove(struct udevice *dev)
+{
+       struct netsec_priv *priv = dev_get_priv(dev);
+
+       free(priv->phydev);
+       mdio_unregister(priv->bus);
+       mdio_free(priv->bus);
+
+       return 0;
+}
+
+static const struct eth_ops netsec_ops = {
+       .start        = netsec_start,
+       .stop         = netsec_stop,
+       .send         = netsec_send,
+       .recv         = netsec_recv,
+       .free_pkt     = netsec_free_packet,
+       .read_rom_hwaddr = netsec_read_rom_hwaddr,
+};
+
+static const struct udevice_id netsec_ids[] = {
+       {
+               .compatible = "socionext,synquacer-netsec",
+       },
+       {}
+};
+
+U_BOOT_DRIVER(ave) = {

drivers/net/sni_netsec.c line 1134

Quoted 10 lines
drivers/net/sni_netsec.c new file +10 -0
+       .name     = "synquacer_netsec",
+       .id       = UCLASS_ETH,
+       .of_match = netsec_ids,
+       .probe    = netsec_probe,
+       .remove   = netsec_remove,
+       .of_to_plat = netsec_of_to_plat,
+       .ops      = &netsec_ops,
+       .priv_auto      = sizeof(struct netsec_priv),
+       .plat_auto      = sizeof(struct eth_pdata),
+};
#24 lore raw

PATCH v2 10/13 ARM: dts: synquacer: Add device trees for DeveloperBox

In reply to Masami Hiramatsu

Add device trees for 96boards EE DeveloperBox and basement SynQuacer SoC dtsi. These files are imported from EDK2

commit 83d38b0b4c0f240d4488c600bbe87cea391f3922

as-is (except for the changes #include path and some macros).

And add U-Boot specific changes in synquacer-sc2a11-developerbox-u-boot.dtsi

---
Changes in v2:
- Add reference commit id of original EDK2 to the comment
- Just copy the EDK2 dts files as-is (change #include path)
- Split out the u-boot specific changes in -u-boot.dtsi.
- Removed unneeded spi-nor flash partition information.

---
 arch/arm/dts/Makefile                              |    2 
 arch/arm/dts/synquacer-sc2a11-caches.dtsi          |   73 ++
 .../dts/synquacer-sc2a11-developerbox-u-boot.dtsi  |   57 ++
 arch/arm/dts/synquacer-sc2a11-developerbox.dts     |   56 ++
 arch/arm/dts/synquacer-sc2a11.dtsi                 |  595 ++++++++++++++++++++
 5 files changed, 783 insertions(+)
 create mode 100644 arch/arm/dts/synquacer-sc2a11-caches.dtsi
 create mode 100644 arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi
 create mode 100644 arch/arm/dts/synquacer-sc2a11-developerbox.dts
 create mode 100644 arch/arm/dts/synquacer-sc2a11.dtsi
arch/arm/dts/Makefile +2 -0
index c6710826a0..127fdb75a2 100644
@@ -1032,6 +1032,8 @@ dtb-$(CONFIG_TARGET_DURIAN) += phytium-durian.dtb
 
 dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
 
+dtb-$(CONFIG_ARCH_SYNQUACER) += synquacer-sc2a11-developerbox.dtb
+
 targets += $(dtb-y)
 
 # Add any required device tree compiler flags here
arch/arm/dts/synquacer-sc2a11-caches.dtsi new file +73 -0

73 lines not on this page · raw message

arch/arm/dts/synquacer-sc2a11-developerbox-u-boot.dtsi new file +57 -0

57 lines not on this page · raw message

arch/arm/dts/synquacer-sc2a11-developerbox.dts new file +56 -0

56 lines not on this page · raw message

arch/arm/dts/synquacer-sc2a11.dtsi new file +595 -0

595 lines not on this page · raw message

#25 lore raw

PATCH v2 11/13 board: synquacer: Add DeveloperBox 96boards EE support

In reply to Masami Hiramatsu

Add the DeveloperBox 96boards EE support. This board is also known as Socionext SynQuacer E-Series. It contians one "SC2A11" SoC, which has 24-cores of arm Cortex-A53, and 4 DDR3 slots, 3 PCIe slots (1 4x port and 2 1x ports which are expanded via PCIe bridge chip), 2 USB 3.0 ports and 2 USB 2.0 ports, 2 SATA ports and 1 GbE, 64MB NOR flash and 8GB eMMC on standard MicroATX Form Factor.

For more information, see this page;
https://www.96boards.org/product/developerbox/

---
Changes in v2:
- Do not include arch/gpio.h and remove arch-sc2a11/gpio.h.
- Remove non-UEFI boot commands.
- Use Distro boot.
- Remove NOR-connected SPI node by path instead of alias.
- Rename configs/SynQuacer_defconfig to configs/synquacer_developerbox_defconfig.
- Rename include/configs/SynQuacer.h to include/configs/synquacer.h.
- Move README under doc/board/socionext/ and make it .rst text.

---
 arch/arm/Kconfig                            |   15 +++
 board/socionext/developerbox/Kconfig        |   36 +++++++
 board/socionext/developerbox/MAINTAINERS    |   13 ++
 board/socionext/developerbox/Makefile       |    9 ++
 board/socionext/developerbox/developerbox.c |  145 +++++++++++++++++++++++++++
 configs/synquacer_developerbox_defconfig    |   93 +++++++++++++++++
 doc/board/index.rst                         |    1 
 doc/board/socionext/developerbox.rst        |   87 ++++++++++++++++
 doc/board/socionext/index.rst               |    9 ++
 include/configs/synquacer.h                 |  106 ++++++++++++++++++++
 10 files changed, 514 insertions(+)
 create mode 100644 board/socionext/developerbox/Kconfig
 create mode 100644 board/socionext/developerbox/MAINTAINERS
 create mode 100644 board/socionext/developerbox/Makefile
 create mode 100644 board/socionext/developerbox/developerbox.c
 create mode 100644 configs/synquacer_developerbox_defconfig
 create mode 100644 doc/board/socionext/developerbox.rst
 create mode 100644 doc/board/socionext/index.rst
 create mode 100644 include/configs/synquacer.h
arch/arm/Kconfig +15 -0
index fba28323cd..1caea3ac58 100644
@@ -1675,6 +1675,20 @@ config ARCH_UNIPHIER
 	  Support for UniPhier SoC family developed by Socionext Inc.
 	  (formerly, System LSI Business Division of Panasonic Corporation)
 
+config ARCH_SYNQUACER
+	bool "Socionext SynQuacer SoCs"
+	select ARM64
+	select ONLY_GENERIC_GPIO
+	select DM
+	select GIC_V3
+	select PSCI_RESET
+	select SYSRESET
+	select SYSRESET_PSCI
+	select OF_CONTROL
+	help
+	  Support for SynQuacer SoC family developed by Socionext Inc.
+	  This SoC is used on 96boards EE DeveloperBox.
+
 config ARCH_STM32
 	bool "Support STMicroelectronics STM32 MCU with cortex M"
 	select CPU_V7M
@@ -2022,6 +2036,7 @@ source "board/hisilicon/poplar/Kconfig"
 source "board/isee/igep003x/Kconfig"
 source "board/kontron/sl28/Kconfig"
 source "board/myir/mys_6ulx/Kconfig"
+source "board/socionext/developerbox/Kconfig"
 source "board/spear/spear300/Kconfig"
 source "board/spear/spear310/Kconfig"
 source "board/spear/spear320/Kconfig"
board/socionext/developerbox/Kconfig new file +36 -0
new file mode 100644
index 0000000000..706b8dc0f1
@@ -0,0 +1,36 @@
+if ARCH_SYNQUACER
+
+choice
+	prompt "SC2A11 Cortex-A53 MPCore 24cores"
+	optional
+
+config TARGET_DEVELOPERBOX
+	bool "Socionext DeveloperBox"
+	select PCI
+	select DM_PCI
+	select PCIE_ECAM_SYNQUACER
+	select SYS_DISABLE_DCACHE_OPS
+	select OF_BOARD_SETUP
+	help
+	 Choose this option if you build the U-Boot for the DeveloperBox
+	 96boards Enterprise Edition.
+	 This board will booted from SCP firmware and it enables SMMU, thus
+	 the dcache is updated automatically when DMA operation is executed.
+endchoice
+
+config SYS_SOC
+	default "sc2a11"
+
+if TARGET_DEVELOPERBOX
+
+config SYS_BOARD
+	default "developerbox"
+
+config SYS_VENDOR
+	default "socionext"
+
+config SYS_CONFIG_NAME
+	default "synquacer"
+
+endif
+endif
board/socionext/developerbox/MAINTAINERS new file +13 -0
new file mode 100644
index 0000000000..d10ad3b8f7
@@ -0,0 +1,13 @@
+DEVELOPER BOX
+M:	Masami Hiramatsu <[email protected]>
+M:	Jassi Brar <[email protected]>
+S:	Maintained
+F:	arch/arm/dts/synquacer-*
+F:	board/socionext/developerbox/*
+F:	configs/synquacer_developerbox_defconfig
+F:	drivers/mmc/f_sdh30.c
+F:	drivers/net/sni_netsec.c
+F:	drivers/pci/pcie_ecam_synquacer.c
+F:	drivers/spi/spi-synquacer.c
+F:	include/configs/synquacer.h
+F:	doc/board/socionext/developerbox.rst
board/socionext/developerbox/Makefile new file +9 -0
new file mode 100644
index 0000000000..4a46de995a
@@ -0,0 +1,9 @@
+#
+# Author: Masami Hiramatsu <[email protected]>
+#
+# Copyright (C) 2021 Linaro Ltd.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= developerbox.o
board/socionext/developerbox/developerbox.c new file +145 -0

145 lines not on this page · raw message

configs/synquacer_developerbox_defconfig new file +93 -0

93 lines not on this page · raw message

doc/board/index.rst +1 -0
index a70d2de19d..242372b321 100644
@@ -21,6 +21,7 @@ Board-specific doc
    rockchip/index
    sifive/index
    sipeed/index
+   socionext/index
    st/index
    tbs/index
    toradex/index
doc/board/socionext/developerbox.rst new file +87 -0

87 lines not on this page · raw message

doc/board/socionext/index.rst new file +9 -0
new file mode 100644
index 0000000000..4673dcc45b
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Socionext
+=========
+
+.. toctree::
+   :maxdepth: 2
+
+   developerbox
include/configs/synquacer.h new file +106 -0

106 lines not on this page · raw message

#26 lore raw

PATCH v2 11/13 board: synquacer: Add DeveloperBox 96boards EE support

Hi,

I found that I need to enable CONFIG_CMD_FS_GENERIC for enabling distroboot support.
I'll fix it in the next version.

Thank you,

2021?4?17?(?) 8:39 Masami Hiramatsu <[email protected]>:

Quoted 636 lines

Add the DeveloperBox 96boards EE support. This board is also known as Socionext SynQuacer E-Series. It contians one "SC2A11" SoC, which has 24-cores of arm Cortex-A53, and 4 DDR3 slots, 3 PCIe slots (1 4x port and 2 1x ports which are expanded via PCIe bridge chip), 2 USB 3.0 ports and 2 USB 2.0 ports, 2 SATA ports and 1 GbE, 64MB NOR flash and 8GB eMMC on standard MicroATX Form Factor.

For more information, see this page;
https://www.96boards.org/product/developerbox/

---
Changes in v2:
- Do not include arch/gpio.h and remove arch-sc2a11/gpio.h.
- Remove non-UEFI boot commands.
- Use Distro boot.
- Remove NOR-connected SPI node by path instead of alias.
- Rename configs/SynQuacer_defconfig to configs/synquacer_developerbox_defconfig.
- Rename include/configs/SynQuacer.h to include/configs/synquacer.h.
- Move README under doc/board/socionext/ and make it .rst text.

---
 arch/arm/Kconfig                            |   15 +++
 board/socionext/developerbox/Kconfig        |   36 +++++++
 board/socionext/developerbox/MAINTAINERS    |   13 ++
 board/socionext/developerbox/Makefile       |    9 ++
 board/socionext/developerbox/developerbox.c |  145 +++++++++++++++++++++++++++
 configs/synquacer_developerbox_defconfig    |   93 +++++++++++++++++
 doc/board/index.rst                         |    1
 doc/board/socionext/developerbox.rst        |   87 ++++++++++++++++
 doc/board/socionext/index.rst               |    9 ++
 include/configs/synquacer.h                 |  106 ++++++++++++++++++++
 10 files changed, 514 insertions(+)
 create mode 100644 board/socionext/developerbox/Kconfig
 create mode 100644 board/socionext/developerbox/MAINTAINERS
 create mode 100644 board/socionext/developerbox/Makefile
 create mode 100644 board/socionext/developerbox/developerbox.c
 create mode 100644 configs/synquacer_developerbox_defconfig
 create mode 100644 doc/board/socionext/developerbox.rst
 create mode 100644 doc/board/socionext/index.rst
 create mode 100644 include/configs/synquacer.h
arch/arm/Kconfig +15 -0
index fba28323cd..1caea3ac58 100644
@@ -1675,6 +1675,20 @@ config ARCH_UNIPHIER
          Support for UniPhier SoC family developed by Socionext Inc.
          (formerly, System LSI Business Division of Panasonic Corporation)
 
+config ARCH_SYNQUACER
+       bool "Socionext SynQuacer SoCs"
+       select ARM64
+       select ONLY_GENERIC_GPIO
+       select DM
+       select GIC_V3
+       select PSCI_RESET
+       select SYSRESET
+       select SYSRESET_PSCI
+       select OF_CONTROL
+       help
+         Support for SynQuacer SoC family developed by Socionext Inc.
+         This SoC is used on 96boards EE DeveloperBox.
+
 config ARCH_STM32
        bool "Support STMicroelectronics STM32 MCU with cortex M"
        select CPU_V7M
@@ -2022,6 +2036,7 @@ source "board/hisilicon/poplar/Kconfig"
 source "board/isee/igep003x/Kconfig"
 source "board/kontron/sl28/Kconfig"
 source "board/myir/mys_6ulx/Kconfig"
+source "board/socionext/developerbox/Kconfig"
 source "board/spear/spear300/Kconfig"
 source "board/spear/spear310/Kconfig"
 source "board/spear/spear320/Kconfig"
board/socionext/developerbox/Kconfig new file +36 -0
new file mode 100644
index 0000000000..706b8dc0f1
@@ -0,0 +1,36 @@
+if ARCH_SYNQUACER
+
+choice
+       prompt "SC2A11 Cortex-A53 MPCore 24cores"
+       optional
+
+config TARGET_DEVELOPERBOX
+       bool "Socionext DeveloperBox"
+       select PCI
+       select DM_PCI
+       select PCIE_ECAM_SYNQUACER
+       select SYS_DISABLE_DCACHE_OPS
+       select OF_BOARD_SETUP
+       help
+        Choose this option if you build the U-Boot for the DeveloperBox
+        96boards Enterprise Edition.
+        This board will booted from SCP firmware and it enables SMMU, thus
+        the dcache is updated automatically when DMA operation is executed.
+endchoice
+
+config SYS_SOC
+       default "sc2a11"
+
+if TARGET_DEVELOPERBOX
+
+config SYS_BOARD
+       default "developerbox"
+
+config SYS_VENDOR
+       default "socionext"
+
+config SYS_CONFIG_NAME
+       default "synquacer"
+
+endif
+endif
board/socionext/developerbox/MAINTAINERS new file +13 -0
new file mode 100644
index 0000000000..d10ad3b8f7
@@ -0,0 +1,13 @@
+DEVELOPER BOX
+M:     Masami Hiramatsu <[email protected]>
+M:     Jassi Brar <[email protected]>
+S:     Maintained
+F:     arch/arm/dts/synquacer-*
+F:     board/socionext/developerbox/*
+F:     configs/synquacer_developerbox_defconfig
+F:     drivers/mmc/f_sdh30.c
+F:     drivers/net/sni_netsec.c
+F:     drivers/pci/pcie_ecam_synquacer.c
+F:     drivers/spi/spi-synquacer.c
+F:     include/configs/synquacer.h
+F:     doc/board/socionext/developerbox.rst
board/socionext/developerbox/Makefile new file +9 -0
new file mode 100644
index 0000000000..4a46de995a
@@ -0,0 +1,9 @@
+#
+# Author: Masami Hiramatsu <[email protected]>
+#
+# Copyright (C) 2021 Linaro Ltd.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := developerbox.o
board/socionext/developerbox/developerbox.c new file +145 -0
new file mode 100644
index 0000000000..3e943a279c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * u-boot/board/socionext/developerbox/developerbox.c
+ *
+ * Copyright (C) 2016-2017 Socionext Inc.
+ * Copyright (C) 2021 Linaro Ltd.
+ */
+#include <asm/types.h>
+#include <asm/armv8/mmu.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <common.h>
+#include <env_internal.h>
+#include <fdt_support.h>
+#include <log.h>
+
+static struct mm_region sc2a11_mem_map[] = {
+       {
+               .virt = 0x0UL,
+               .phys = 0x0UL,
+               .size = 0x80000000UL,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+                        PTE_BLOCK_OUTER_SHARE
+       }, {
+               /* 1st DDR block */
+               .virt = 0x80000000UL,
+               .phys = 0x80000000UL,
+               .size = PHYS_SDRAM_SIZE,
+               .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+                        PTE_BLOCK_OUTER_SHARE
+       }, {
+               /* 2nd DDR place holder */
+               0,
+       }, {
+               /* 3rd DDR place holder */
+               0,
+       }, {
+               /* List terminator */
+               0,
+       }
+};
+
+struct mm_region *mem_map = sc2a11_mem_map;
+
+#define DDR_REGION_INDEX(i)    (1 + (i))
+#define MAX_DDR_REGIONS                3
+
+struct draminfo_entry {
+       u64     base;
+       u64     size;
+};
+
+struct draminfo {
+       u32     nr_regions;
+       u32     reserved;
+       struct draminfo_entry   entry[3];
+};
+
+struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define LOAD_OFFSET 0x100
+
+/*
+ * Miscellaneous platform dependent initialisations
+ */
+int board_init(void)
+{
+       gd->bd->bi_boot_params = CONFIG_SYS_LOAD_ADDR + LOAD_OFFSET;
+
+       gd->env_addr = (ulong)&default_environment[0];
+
+       return 0;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+       /* Remove SPI NOR for making System DT compatible with EDK2 */
+       fdt_del_node_and_alias(blob, "spi_nor");
+
+       return 0;
+}
+
+/*
+ * DRAM configuration
+ */
+
+int dram_init(void)
+{
+       struct draminfo_entry *ent = synquacer_draminfo->entry;
+       struct mm_region *mr;
+       int i, ri;
+
+       if (synquacer_draminfo->nr_regions < 1) {
+               log_err("Failed to get correct DRAM information\n");
+               return -1;
+       }
+
+       /*
+        * U-Boot RAM size must be under the first DRAM region so that it doesn't
+        * access secure memory which is at the end of the first DRAM region.
+        */
+       gd->ram_size = ent[0].size;
+
+       /* Update memory region maps */
+       for (i = 0; i < synquacer_draminfo->nr_regions; i++) {
+               if (i >= MAX_DDR_REGIONS)
+                       break;
+
+               ri = DDR_REGION_INDEX(i);
+               mem_map[ri].phys = ent[i].base;
+               mem_map[ri].size = ent[i].size;
+               if (i == 0)
+                       continue;
+
+               mr = &mem_map[DDR_REGION_INDEX(0)];
+               mem_map[ri].virt = mr->virt + mr->size;
+               mem_map[ri].attrs = mr->attrs;
+       }
+
+       return 0;
+}
+
+int dram_init_banksize(void)
+{
+       struct draminfo_entry *ent = synquacer_draminfo->entry;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) {
+               if (i < synquacer_draminfo->nr_regions) {
+                       debug("%s: dram[%d] = %llx@%llx\n", __func__, i, ent[i].size, ent[i].base);
+                       gd->bd->bi_dram[i].start = ent[i].base;
+                       gd->bd->bi_dram[i].size = ent[i].size;
+               }
+       }
+
+       return 0;
+}
+
+int print_cpuinfo(void)
+{
+       printf("CPU:   SC2A11:Cortex-A53 MPCore 24cores\n");
+       return 0;
+}
configs/synquacer_developerbox_defconfig new file +93 -0
new file mode 100644
index 0000000000..c0d6fa49c0
@@ -0,0 +1,93 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SYNQUACER=y
+CONFIG_SYS_TEXT_BASE=0x08200000
+CONFIG_ENV_SIZE=0x30000
+CONFIG_ENV_OFFSET=0x300000
+CONFIG_DEBUG_UART_BASE=0x2a400000
+CONFIG_DEBUG_UART_CLOCK=62500000
+CONFIG_ENV_SECT_SIZE=0x10000
+CONFIG_DM_GPIO=y
+CONFIG_TARGET_DEVELOPERBOX=y
+CONFIG_DEFAULT_DEVICE_TREE="synquacer-sc2a11-developerbox"
+CONFIG_AHCI=y
+CONFIG_BOOTSTAGE_STASH_SIZE=4096
+CONFIG_LOGLEVEL=9
+CONFIG_LOG_MAX_LEVEL=7
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_IMLS=y
+CONFIG_CMD_NVEDIT_INFO=y
+CONFIG_CMD_DM=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_NET=y
+CONFIG_CMD_BOOTP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_POWEROFF=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_SATA=y
+CONFIG_CMD_NVME=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDPARTS_DEFAULT="nor1:448k(BootStrap-BL1),576k(Flash-Writer),512k(SCP-BL2),480k(FIP-TFA),32k(Stg2-Tables),1m at 2m(U-Boot),1m at 3m(UBoot-Env),2m at 5m(Ex-OPTEE)"
+CONFIG_MTDIDS_DEFAULT="nor1=nor1"
+CONFIG_CMD_LOG=y
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_OF_SEPARATE=y
+CONFIG_ENV_IS_IN_SPI_FLASH=y
+CONFIG_USE_ENV_SPI_BUS=y
+CONFIG_ENV_SPI_BUS=0
+CONFIG_USE_ENV_SPI_CS=y
+CONFIG_ENV_SPI_CS=0
+CONFIG_PROT_UDP=y
+CONFIG_BAUDRATE=115200
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_CONS_INDEX=0
+CONFIG_DM_SERIAL=y
+CONFIG_PL01X_SERIAL=y
+CONFIG_SATA=y
+CONFIG_NVME=y
+CONFIG_SCSI_AHCI=y
+CONFIG_AHCI_PCI=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_F_SDH30_SDHCI=y
+CONFIG_MTD=y
+CONFIG_DM_MTD=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_FLASH_CFI_MTD=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_DM_SPI_FLASH=y
+CONFIG_SF_DEFAULT_SPEED=31250000
+CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
+CONFIG_PHYLIB=y
+CONFIG_PHYLIB_10G=y
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_SNI_NETSEC=y
+CONFIG_DM_ETH=y
+CONFIG_DM_MDIO=y
+CONFIG_PHY_GIGE=y
+CONFIG_RGMII=y
+CONFIG_MII=y
+CONFIG_SCSI=y
+CONFIG_DM_SCSI=y
+CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_SYNQUACER_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_PCI=y
+CONFIG_USB_STORAGE=y
doc/board/index.rst +1 -0
index a70d2de19d..242372b321 100644
@@ -21,6 +21,7 @@ Board-specific doc
    rockchip/index
    sifive/index
    sipeed/index
+   socionext/index
    st/index
    tbs/index
    toradex/index
doc/board/socionext/developerbox.rst new file +87 -0
new file mode 100644
index 0000000000..2d943c23be
@@ -0,0 +1,87 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Introduction
+============
+
+DeveloperBox is a certified 96boards Enterprise Edition board. The board/SoC has: -
+
+* Socionext SC2A11 24-cores ARM Cortex-A53 on tbe Mini-ATX form factor motherboard
+* 4 DIMM slots (4GB DDR4-2400 UDIMM shipped by default)
+* 1 4xPCIe Gen2 slot and 2 1xPCIe Gen2 slots
+  (1x slots are connected via PCIe bridge chip)
+* 4 USB-3.0 ports
+* 2 SATA ports
+* 1 GbE network port
+* 1 USB-UART serial port (micro USB)
+* 64MB SPI NOR Flash
+* 8GB eMMC Flash Storage
+* 96boards LS connector
+
+The DeveloperBox schematic can be found here: -
+https://www.96boards.org/documentation/enterprise/developerbox/hardware-docs/mzsc2am_v03_20180115_a.pdf
+
+And the other documents can be found here: -
+https://www.96boards.org/documentation/enterprise/developerbox/
+
+
+Currently, the U-Boot port supports: -
+
+* USB
+* eMMC
+* SPI-NOR
+* SATA
+* GbE
+
+The DeveloperBox boots the TF-A and EDK2 as a main bootloader by default.
+The DeveloperBox U-Boot port will replace the EDK2 and boot from TF-A as
+BL33, but no need to combine with it.
+
+Compile from source
+===================
+
+You can build U-Boot without any additinal source code.::
+
+  cd u-boot
+  export ARCH=arm64
+  export CROSS_COMPILE=aarch64-linux-gnu-
+  make SynQuacer_defconfig
+  make -j `noproc`
+
+Then, expand the binary to 1MB for preparing flash.::
+
+  cp u-boot.bin SPI_NOR_UBOOT.fd
+  truncate -s 1M SPI_NOR_UBOOT.fd
+
+Installation
+============
+
+You can install the SNI_NOR_UBOOT.fd via NOR flash writer.
+
+Flashing the U-Boot image on DeveloperBox requires a 96boards UART mezzanine or other mezzanine which can connect to LS-UART0 port.
+Connect USB cable from host to the LS-UART0 and set DSW2-7 to ON, and turn the board on again. The flash writer program will be started automatically; don?t forget to turn the DSW2-7 off again after flashing.
+
+*!!CAUTION!! If you failed to write the U-Boot image on wrong address, the board can be bricked. See below page if you need to recover the bricked board. See the following page for more detail*
+
+https://www.96boards.org/documentation/enterprise/developerbox/installation/board-recovery.md.html
+
+When the serial flasher is running correctly is will show the following boot messages shown via LS-UART0::
+
+
+  /*------------------------------------------*/
+  /*  SC2A11 "SynQuacer" series Flash writer  */
+  /*                                          */
+  /*  Version: cd254ac                        */
+  /*  Build: 12/15/17 11:25:45                */
+  /*------------------------------------------*/
+
+  Command Input >
+
+Once the flasher tool is running we are ready flash the UEFI image::
+
+  flash rawwrite 200000 100000
+  >> Send SPI_NOR_UBOOT.fd via XMODEM (Control-A S in minicom) <<
+
+*!!NOTE!! The flasher command parameter is different from the command for board recovery. U-Boot uses the offset 200000 (2-five-0, 2M in hex) and the size 100000 (1-five-0, 1M in hex).*
+
+After transferring the SPI_NOR_UBOOT.fd, turn off the DSW2-7 and reset the board.
+
doc/board/socionext/index.rst new file +9 -0
new file mode 100644
index 0000000000..4673dcc45b
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Socionext
+=========
+
+.. toctree::
+   :maxdepth: 2
+
+   developerbox
include/configs/synquacer.h new file +106 -0
new file mode 100644
index 0000000000..b2dd6d0f0f
@@ -0,0 +1,106 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2016-2017 Socionext Inc.
+ */
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/* Timers for fasp(TIMCLK) */
+#define CONFIG_SYS_HZ                  1000            /* 1 msec */
+#define CONFIG_SYS_TIMERBASE           0x31080000      /* AP Timer 1 (ARM-SP804) */
+
+/*
+ * SDRAM (for initialize)
+ */
+#define CONFIG_SYS_SDRAM_BASE          (0x80000000)    /* Start address of DDR3 */
+#define PHYS_SDRAM_SIZE                        (0x7c000000)    /* Default size (2GB - Secure memory) */
+
+#define CONFIG_VERY_BIG_RAM                            /* SynQuacer supports up to 64GB */
+#define CONFIG_MAX_MEM_MAPPED          PHYS_SDRAM_SIZE
+
+#define SQ_DRAMINFO_BASE               (0x2e00ffc0)    /* DRAM info from TF-A */
+
+/*
+ * Boot info
+ */
+#define CONFIG_SYS_INIT_SP_ADDR                (0xe0000000)    /* stack of init proccess */
+#define CONFIG_SYS_MALLOC_LEN          (0x01000000)    /* 16Mbyte size of malloc() */
+#define CONFIG_SYS_LOAD_ADDR           CONFIG_SYS_SDRAM_BASE /* default kernel load address */
+
+/*
+ * Hardware drivers support
+ */
+
+/* Serial (pl011)       */
+#define UART_CLK                       (62500000)
+#define CONFIG_SERIAL_MULTI
+#define CONFIG_PL011_SERIAL
+#define CONFIG_PL011_CLOCK             UART_CLK
+#define CONFIG_PL01x_PORTS             {(void *)(0x2a400000)}
+
+#define CONFIG_ENV_OVERWRITE           /* ethaddr can be reprogrammed */
+
+/* Support MTD */
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+#define CONFIG_SYS_FLASH_BASE          (0x08000000)
+#define CONFIG_SYS_FLASH_BANKS_LIST    {CONFIG_SYS_FLASH_BASE}
+
+#define CONFIG_SYS_MEMTEST_START       (CONFIG_SYS_SDRAM_BASE + (512 * 1024))
+#define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_SDRAM_BASE + PHYS_SDRAM_SIZE)
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_BAUDRATE_TABLE      {115200, 19200, 38400, 57600, 9600 }
+
+#define CONFIG_SYS_CBSIZE              1024
+#define CONFIG_SYS_MAXARGS             128
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+
+/* Since U-Boot 64bit PCIe support is limited, disable 64bit MMIO support */
+/* #define CONFIG_SYS_PCI_64BIT                1 */
+
+/* Distro boot settings */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_CMD_USB
+#define BOOT_TARGET_DEVICE_USB(func)   func(USB, usb, 0)
+#else
+#define BOOT_TARGET_DEVICE_USB(func)
+#endif
+
+#ifdef CONFIG_CMD_MMC
+#define BOOT_TARGET_DEVICE_MMC(func)   func(MMC, mmc, 0)
+#else
+#define BOOT_TARGET_DEVICE_MMC(func)
+#endif
+
+#ifdef CONFIG_CMD_NVME
+#define BOOT_TARGET_DEVICE_NVME(func)  func(NVME, nvme, 0)
+#else
+#define BOOT_TARGET_DEVICE_NVME(func)
+#endif
+
+#ifdef CONFIG_CMD_SCSI
+#define BOOT_TARGET_DEVICE_SCSI(func)  func(SCSI, scsi, 0) func(SCSI, scsi, 1)
+#else
+#define BOOT_TARGET_DEVICE_SCSI(func)
+#endif
+
+#define BOOT_TARGET_DEVICES(func)      \
+       BOOT_TARGET_DEVICE_USB(func)    \
+       BOOT_TARGET_DEVICE_MMC(func)    \
+       BOOT_TARGET_DEVICE_SCSI(func)   \
+       BOOT_TARGET_DEVICE_NVME(func)   \
+
+#include <config_distro_bootcmd.h>
+#else /* CONFIG_SPL_BUILD */
+#define BOOTENV
+#endif
+
+#define        CONFIG_EXTRA_ENV_SETTINGS               \
+       "fdt_addr_r=0x9fe00000\0"               \
+       "kernel_addr_r=0x90000000\0"            \
+       "ramdisk_addr_r=0xa0000000\0"           \
+       "scriptaddr=0x88000000\0"               \
+       "pxefile_addr_r=0x88100000\0"           \
+       BOOTENV
+
+#endif /* __CONFIG_H */
Signature · 1 line
Masami Hiramatsu
#27 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

In reply to Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the document should refer the mkeficapsule in tools.

---
 doc/board/emulation/qemu_capsule_update.rst |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
doc/board/emulation/qemu_capsule_update.rst +2 -9
index 9fec75f8f1..e2a9f0db71 100644
@@ -39,16 +39,9 @@ In addition, the following config needs to be disabled(QEMU ARM specific)::
 
     CONFIG_TFABOOT
 
-The capsule file can be generated by using the GenerateCapsule.py
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid \
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index \
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the tools/mkeficapsule::
 
-The above is a wrapper script(GenerateCapsule) which eventually calls
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name>
 
 As per the UEFI specification, the capsule file needs to be placed on
 the EFI System Partition, under the \EFI\UpdateCapsule directory. The
#28 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Quoted 19 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the document should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -2
index 9fec75f8f1..e2a9f0db71 100644
@@ -39,16 +39,9 @@ In addition, the following config needs to be disabled(QEMU ARM specific)::
 
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the GenerateCapsule.py
-script in EDKII::

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific):: · line 44

Quoted 10 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +2 -7
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid \
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index \
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the tools/mkeficapsule::
 
-The above is a wrapper script(GenerateCapsule) which eventually calls
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name>

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

Best regards

Heinrich

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be placed on
  the EFI System Partition, under the \EFI\UpdateCapsule directory. The
 
#29 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Quoted 30 lines · Heinrich Schuchardt

Review

Quoted 10 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the document should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/doc/board/emulation/qemu_capsule_update.rst

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be

Quoted 4 lines

index 9fec75f8f1..e2a9f0db71 100644

doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
@@ -39,16 +39,9 @@ In addition, the following config needs to be

disabled(QEMU ARM specific)::

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific)::

Quoted 9 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -6
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the GenerateCapsule.py
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid \
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index

\

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the tools/mkeficapsule::
 
Quoted 9 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific):: · line 44

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -2
-The above is a wrapper script(GenerateCapsule) which eventually calls
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name>

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

Currently, we do not have support for adding authentication header to the capsule. This is because I have been using the GenerateCapsule script in edk2 for generation of a capsule with authentication header. I think adding the signature to the capsule is easier when done through a python script rather than C code. I am working on adding support for the latest version of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER in the GenerateCapsule script in edk2. Meanwhile, would it be possible to have support for the version 2 of this header in the capsule driver -- it is a minor change and I already have a patch for it. If you are fine, I can submit a patch for the same.

-sughosh

Quoted 11 lines

Best regards

Heinrich

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be placed on
  the EFI System Partition, under the \EFI\UpdateCapsule directory. The
 
#30 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Sughosh,

Quoted 43 lines · Sughosh Ganu
Quoted 30 lines · Heinrich Schuchardt

Review

Quoted 10 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the document should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/doc/board/emulation/qemu_capsule_update.rst

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be

Quoted 4 lines

index 9fec75f8f1..e2a9f0db71 100644

doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
@@ -39,16 +39,9 @@ In addition, the following config needs to be

disabled(QEMU ARM specific)::

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific)::

Quoted 9 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -6
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the GenerateCapsule.py
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid \
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index

\

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the tools/mkeficapsule::
 
Quoted 9 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific):: · line 44

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -2
-The above is a wrapper script(GenerateCapsule) which eventually calls
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name>

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

Quoted 5 lines

Currently, we do not have support for adding authentication header to the capsule. This is because I have been using the GenerateCapsule script in edk2 for generation of a capsule with authentication header. I think adding the signature to the capsule is easier when done through a python script rather than C code.

Why do you think so?
At a quick glance at the script, it internally uses openssl command like:

    openssl smime -sign -binary -outform DER -md sha256 \
        -signer <...> -certfile <...>

(See PayloadDescriptor.Encode in the script.)

The output from the standard output is exactly what you want to use to build a capsule file, that is "AuthInfo".
Then you can naturally extend mkeficapsule to insert this signature between the header and the image itself in a capsule file.

Furthermore, I believe, it is fairly straightforward to add a native 'signing' feature to mkeficapsule if you use openssl library.

-Takahiro Akashi

Quoted 21 lines

I am working on adding support for the latest version
of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER in the GenerateCapsule script in edk2. Meanwhile, would it be possible to have support for the version 2 of this header in the capsule driver -- it is a minor change and I already have a patch for it. If you are fine, I can submit a patch for the same.

-sughosh

Quoted 11 lines

Best regards

Heinrich

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be placed on
  the EFI System Partition, under the \EFI\UpdateCapsule directory. The
 
#31 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Hi,

2021?4?19?(?) 9:37 Takahiro Akashi <[email protected]>:

Quoted 45 lines

Sughosh,

Quoted 41 lines · Sughosh Ganu
Quoted 38 lines · Heinrich Schuchardt

Review

Quoted 10 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the document should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11 ++---------
  1 file changed, 2 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/doc/board/emulation/qemu_capsule_update.rst

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be

Quoted 4 lines

index 9fec75f8f1..e2a9f0db71 100644

doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
@@ -39,16 +39,9 @@ In addition, the following config needs to be

disabled(QEMU ARM specific)::

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific)::

Quoted 9 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -6
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the GenerateCapsule.py
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o \
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid \
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose --update-image-index

\

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific):: · line 44

Quoted 6 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +2 -3
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the tools/mkeficapsule::
 
-The above is a wrapper script(GenerateCapsule) which eventually calls
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1 <capsule_file_name>

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

So as Sughosh said, since currently mkeficapsule doesn't support authentication, I only changed it for the normal capsule update. Without this change, the capsule
update just failed.

Quoted 8 lines
Quoted 5 lines

Currently, we do not have support for adding authentication header to the capsule. This is because I have been using the GenerateCapsule script in edk2 for generation of a capsule with authentication header. I think adding the signature to the capsule is easier when done through a python script rather than C code.

Why do you think so?
At a quick glance at the script, it internally uses openssl command like:

Quoted 8 lines
    openssl smime -sign -binary -outform DER -md sha256 \
        -signer <...> -certfile <...>

(See PayloadDescriptor.Encode in the script.)

The output from the standard output is exactly what you want to use to build a capsule file, that is "AuthInfo".
Then you can naturally extend mkeficapsule to insert this signature between the header and the image itself in a capsule file.

Hmm, if it can be done by just calling openssl, I think it is easier for me to run the tools/mkeficapsule, because I don't need to build EDK2 for U-Boot.

If GenerateCapsule becomes a standard implementation and independent from the EDK2 project, from the interoperability point of view, it is better to use that. But it is a part of EDK2 and the GenerateCapsule seems out-of-date and not maintained well (why doesn't it support the latest version yet??)

Thank you,

Quoted 27 lines

Furthermore, I believe, it is fairly straightforward to add a native 'signing' feature to mkeficapsule if you use openssl library.

-Takahiro Akashi

Quoted 21 lines

I am working on adding support for the latest version
of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER in the GenerateCapsule script in edk2. Meanwhile, would it be possible to have support for the version 2 of this header in the capsule driver -- it is a minor change and I already have a patch for it. If you are fine, I can submit a patch for the same.

-sughosh

Quoted 11 lines

Best regards

Heinrich

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be placed on
  the EFI System Partition, under the \EFI\UpdateCapsule directory. The
 

--
Masami Hiramatsu

#32 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Am 19. April 2021 04:24:37 MESZ schrieb Masami Hiramatsu <[email protected]>:

Quoted 94 lines

Hi,

2021?4?19?(?) 9:37 Takahiro Akashi <[email protected]>:

Quoted 5 lines

Sughosh,

Quoted 1 line · Sughosh Ganu

On Sat, 17 Apr 2021 at 23:51, Heinrich Schuchardt

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines · wrote:
Quoted 2 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the

document

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11

++---------

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
  1 file changed, 2 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/doc/board/emulation/qemu_capsule_update.rst

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to

Quoted 4 lines

index 9fec75f8f1..e2a9f0db71 100644

doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
@@ -39,16 +39,9 @@ In addition, the following config needs to

be

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

disabled(QEMU ARM specific)::

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the

GenerateCapsule.py

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific)::

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -3
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o

\

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 45

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid

\

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 46

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose

--update-image-index

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

\

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the

tools/mkeficapsule::

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 48

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-The above is a wrapper script(GenerateCapsule) which

eventually calls

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 42

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1

<capsule_file_name>

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

So as Sughosh said, since currently mkeficapsule doesn't support authentication,
I only changed it for the normal capsule update. Without this change, the capsule
update just failed.

Quoted 1 line
Quoted 1 line

Currently, we do not have support for adding authentication header

to the

Quoted 1 line
Quoted 1 line

capsule. This is because I have been using the GenerateCapsule

script in

Quoted 1 line
Quoted 1 line

edk2 for generation of a capsule with authentication header. I

think adding

Quoted 1 line
Quoted 1 line

the signature to the capsule is easier when done through a python

script

Quoted 4 lines
Quoted 1 line

rather than C code.

Why do you think so?
At a quick glance at the script, it internally uses openssl command

like:

Quoted 8 lines
    openssl smime -sign -binary -outform DER -md sha256 \
        -signer <...> -certfile <...>

(See PayloadDescriptor.Encode in the script.)

The output from the standard output is exactly what you want to use to build a capsule file, that is "AuthInfo".
Then you can naturally extend mkeficapsule to insert this signature between the header and the image itself in a capsule file.

Hmm, if it can be done by just calling openssl, I think it is easier for me
to run the tools/mkeficapsule, because I don't need to build EDK2 for U-Boot.

Quoted 5 lines

If GenerateCapsule becomes a standard implementation and independent from the EDK2 project, from the interoperability point of view, it is better to use that. But it is a part of EDK2 and the GenerateCapsule seems out-of-date and not maintained well (why doesn't it support the latest version yet??)

Sughosh told me that EDK II cannot create a signed capsule that is usable with U-Boot due to an outdated header version used by EDK II.

It should be sufficient to describe the steps used by U-Boot's test script here.

Best regards

Heinrich

Quoted 41 lines

Thank you,

Quoted 8 lines

Furthermore, I believe, it is fairly straightforward to add a native 'signing' feature to mkeficapsule if you use openssl library.

-Takahiro Akashi

Quoted 2 lines

I am working on adding support for the latest version of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER in the

GenerateCapsule

Quoted 1 line
Quoted 1 line

script in edk2. Meanwhile, would it be possible to have support for

the

Quoted 1 line
Quoted 1 line

version 2 of this header in the capsule driver -- it is a minor

change and

Quoted 1 line
Quoted 1 line

I already have a patch for it. If you are fine, I can submit a

patch for

Quoted 6 lines
Quoted 6 lines

the same.

-sughosh

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Best regards

Heinrich

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be

placed on

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 44

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  the EFI System Partition, under the \EFI\UpdateCapsule

directory. The

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

--
Masami Hiramatsu

#33 lore raw

PATCH v2 12/13 doc: qemu: arm64: Fix the documentation of capsule update

Heinrich, Sughosh,

Quoted 95 lines · Heinrich Schuchardt

Am 19. April 2021 04:24:37 MESZ schrieb Masami Hiramatsu <[email protected]>:

Quoted 94 lines

Hi,

2021?4?19?(?) 9:37 Takahiro Akashi <[email protected]>:

Quoted 5 lines

Sughosh,

Quoted 1 line · Sughosh Ganu

On Sat, 17 Apr 2021 at 23:51, Heinrich Schuchardt

<[email protected]>

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines · wrote:
Quoted 2 lines · Masami Hiramatsu

Since the EDK2 GenerateCapsule script is out of date and it doesn't generate the supported version capsule file, the

document

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

should refer the mkeficapsule in tools.

---
  doc/board/emulation/qemu_capsule_update.rst |   11

++---------

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 3 lines
  1 file changed, 2 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/doc/board/emulation/qemu_capsule_update.rst

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to

Quoted 4 lines

index 9fec75f8f1..e2a9f0db71 100644

doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
@@ -39,16 +39,9 @@ In addition, the following config needs to

be

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

disabled(QEMU ARM specific)::

Quoted 4 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
      CONFIG_TFABOOT
 
-The capsule file can be generated by using the

GenerateCapsule.py

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to be disabled(QEMU ARM specific)::

Quoted 3 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -3
-script in EDKII::
-
-    $ ./BaseTools/BinWrappers/PosixLike/GenerateCapsule -e -o

\

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 45

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-    <capsule_file_name> --fw-version <val> --lsv <val> --guid

\

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 46

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-    e2bb9c06-70e9-4b14-97a3-5a7913176e3f --verbose

--update-image-index

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

\

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-    <val> --verbose <u-boot.bin>
+The capsule file can be generated by using the

tools/mkeficapsule::

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 48

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -1
-The above is a wrapper script(GenerateCapsule) which

eventually calls

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 42

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +1 -1
-the actual GenerateCapsule.py script.
+    $ mkeficapsule --raw <u-boot.bin> --index 1

<capsule_file_name>

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Thanks for the change.

Could you, please, adjust the same in chapter "Enabling Capsule Authentication" below.

So as Sughosh said, since currently mkeficapsule doesn't support authentication,
I only changed it for the normal capsule update. Without this change, the capsule
update just failed.

Quoted 1 line
Quoted 1 line

Currently, we do not have support for adding authentication header

to the

Quoted 1 line
Quoted 1 line

capsule. This is because I have been using the GenerateCapsule

script in

Quoted 1 line
Quoted 1 line

edk2 for generation of a capsule with authentication header. I

think adding

Quoted 1 line
Quoted 1 line

the signature to the capsule is easier when done through a python

script

Quoted 4 lines
Quoted 1 line

rather than C code.

Why do you think so?
At a quick glance at the script, it internally uses openssl command

like:

Quoted 8 lines
    openssl smime -sign -binary -outform DER -md sha256 \
        -signer <...> -certfile <...>

(See PayloadDescriptor.Encode in the script.)

The output from the standard output is exactly what you want to use to build a capsule file, that is "AuthInfo".
Then you can naturally extend mkeficapsule to insert this signature between the header and the image itself in a capsule file.

Hmm, if it can be done by just calling openssl, I think it is easier for me
to run the tools/mkeficapsule, because I don't need to build EDK2 for U-Boot.

Quoted 7 lines
Quoted 5 lines

If GenerateCapsule becomes a standard implementation and independent from the EDK2 project, from the interoperability point of view, it is better to use that. But it is a part of EDK2 and the GenerateCapsule seems out-of-date and not maintained well (why doesn't it support the latest version yet??)

Sughosh told me that EDK II cannot create a signed capsule that is usable with U-Boot due to an outdated header version used by EDK II.

I decided to add a signing feature to mkeficapsule, and actually have finished the coding (half-a-day work). Yet I have to find some time to debug the command as I have never tried capsule authentication. (Hopefully Masami will help here.)

The syntax will look like:
mkeficapsule -m <mono count> -P <private key> -C <certificate file>
-r <firmware image> <capsule file>

-Takahiro Akashi

Quoted 48 lines

It should be sufficient to describe the steps used by U-Boot's test script here.

Best regards

Heinrich

Quoted 41 lines

Thank you,

Quoted 8 lines

Furthermore, I believe, it is fairly straightforward to add a native 'signing' feature to mkeficapsule if you use openssl library.

-Takahiro Akashi

Quoted 2 lines

I am working on adding support for the latest version of the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER in the

GenerateCapsule

Quoted 1 line
Quoted 1 line

script in edk2. Meanwhile, would it be possible to have support for

the

Quoted 1 line
Quoted 1 line

version 2 of this header in the capsule driver -- it is a minor

change and

Quoted 1 line
Quoted 1 line

I already have a patch for it. If you are fine, I can submit a

patch for

Quoted 6 lines
Quoted 6 lines

the same.

-sughosh

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Best regards

Heinrich

Quoted 2 lines
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  As per the UEFI specification, the capsule file needs to be

placed on

Quoted 1 line
Quoted 1 line
Quoted 1 line

doc/board/emulation/qemu_capsule_update.rst In addition, the following config needs to · line 44

Quoted 1 line
doc/board/emulation/qemu_capsule_update.rst renamed from c +0 -0
  the EFI System Partition, under the \EFI\UpdateCapsule

directory. The

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

--
Masami Hiramatsu

#34 lore raw

PATCH v2 13/13 configs: synquacer: Enable EFI capsule update support

In reply to Masami Hiramatsu

Enable EFI capsule update support. With the EFI capsule update, you can update U-Boot, TF-A and OP-TEE. TF-A and OP-TEE are usually combined as a FIP binary, but if the binary is bigger than 480KB, you have to modify FIP header, split the OP-TEE and stores the OP-TEE binary in the different place. This configuration supports both cases.

---
 configs/synquacer_developerbox_defconfig |   15 +++++++++++++++
 include/configs/synquacer.h              |    6 ++++++
 2 files changed, 21 insertions(+)
configs/synquacer_developerbox_defconfig +15 -0
index c0d6fa49c0..a0bbbfdd0f 100644
@@ -91,3 +91,18 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_PCI=y
 CONFIG_USB_STORAGE=y
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
+CONFIG_CMD_EFIDEBUG=y
+CONFIG_CMD_DFU=y
+CONFIG_DFU_TFTP=y
+CONFIG_DFU_MTD=y
+CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_DFU_SF_PART=y
+CONFIG_FIT=y
+CONFIG_OF_LIBFDT=y
+CONFIG_CMD_NVEDIT_EFI=y
+CONFIG_CMD_ERASEENV=y
include/configs/synquacer.h +6 -0
index b2dd6d0f0f..5eeb16ce1c 100644
@@ -58,6 +58,11 @@
 /* Since U-Boot 64bit PCIe support is limited, disable 64bit MMIO support */
 /* #define CONFIG_SYS_PCI_64BIT		1 */
 
+#define DEFAULT_DFU_ALT_INFO "dfu_alt_info='"				\
+			"mtd nor1=u-boot.bin raw 200000 100000;"	\
+			"fip.bin raw 180000 78000;"			\
+			"optee.bin raw 500000 100000'\0"
+
 /* Distro boot settings */
 #ifndef CONFIG_SPL_BUILD
 #ifdef CONFIG_CMD_USB
@@ -101,6 +106,7 @@
 	"ramdisk_addr_r=0xa0000000\0"		\
 	"scriptaddr=0x88000000\0"		\
 	"pxefile_addr_r=0x88100000\0"		\
+	DEFAULT_DFU_ALT_INFO			\
 	BOOTENV
 
 #endif /* __CONFIG_H */