subtree updates:raspberrypi:arm:security: Jan 27 2023

meta-raspberrypi: 896566aa92..6c57b92708:
  Martin Jansa (2):
        pi-bluetooth: fix typo in Upstream-Status
        gstreamer1.0-omx: fix Upstream-Status format

meta-arm: 5c42f084f7..3d51e1117d:
  Abdellatif El Khlifi (1):
        arm-bsp/u-boot: Corstone1000: bump to v2022.10

  Anton Antonov (1):
        arm/kernel: Update ARM-FFA kernel drivers

  Daniel Díaz (1):
        arm-bsp/firmware-image-juno: Fix deployment of compressed Image

  Jon Mason (8):
        arm-bsp/juno: move to compressed initramfs image
        arm-bsp/juno: Update kernel patches to the latest
        arm-bsp/trusted-firmware-m: corstone1000: TFM file clean-ups
        arm/trusted-firmware-m: disable fatal warnings
        arm-toolchain: update Arm GCC to 12.2
        external-arm-toolchain: Enable 12.2.rel1 support
        arm-bsp: add u-boot v2022.10 support
        arm-bsp: add u-boot v2022.10 support

  Peter Hoyes (8):
        arm/scp-firmware: Ensure CMAKE_BUILD_TYPE is capitalized
        arm/scp-firmware: Disable cppcheck
        arm: Add addpylib declaration
        arm/lib: Add XAUTHORITY to runfvp environment
        classes: Define FVP_ENV_PASSTHROUGH variable dependencies
        classes: Prevent passing None to the runfvp environment
        classes: Set ARMLMD_LICENSE_FILE in the runfvp environment
        arm: Use SRC* variables consistently

  Qi Feng (1):
        arm-bsp/fvp-baser-aemv8r64: Rebase u-boot patches onto v2022.10

  Ross Burton (9):
        meta-*: mark layers as compatible with mickledore only
        arm-toolchain: remove obsolete oe_import
        CI: switch back to master
        CI: remove obsolete linux-yocto workarounds
        Revert "CI: revert a meta-clang change which breaks pixman (thus, xserver)"
        arm-bsp/fvp-base*: no need to remove rng-tools from openssh
        CI: pass --update and --force-checkout to kas in pending-updates job
        CI: use 'kas dump' instead of manually catting files
        CI: remove obsolete install

  Rui Miguel Silva (1):
        arm-bsp/u-boot: corstone500: bump to 2022.10

  Theodore A. Roth (1):
        arm/optee-os: Fix FILESEXTRAPATHS

meta-security: f991b20f56..3d9dab6d14:
  Chen Qi (1):
        openscap: add libpcre DEPEDNS to fix do_configure failure

  Markus Volk (1):
        bubblewrap: remove recipe

  Martin Jansa (1):
        layer.conf: update LAYERSERIES_COMPAT for mickledore

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I5abd2487fbf395b33b1934ff90bd6d97c7953e6c
diff --git a/meta-arm/.gitlab-ci.yml b/meta-arm/.gitlab-ci.yml
index 09ca8c4..d61443d 100644
--- a/meta-arm/.gitlab-ci.yml
+++ b/meta-arm/.gitlab-ci.yml
@@ -35,8 +35,6 @@
     - mkdir --verbose --parents $KAS_WORK_DIR $KAS_REPO_REF_DIR $SSTATE_DIR $DL_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
     # Must do this here, as it's the only way to make sure the toolchain is installed on the same builder
     - ./ci/get-binary-toolchains $DL_DIR $TOOLCHAIN_DIR $TOOLCHAIN_LINK_DIR
-    # This can be removed with Kas 3.2
-    - sudo apt-get update && sudo apt-get install --yes python3-subunit
 
 # Generalised fragment to do a Kas build
 .build:
@@ -45,7 +43,7 @@
     KUBERNETES_CPU_REQUEST: $CPU_REQUEST
   script:
     - KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME")
-    - kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf'
+    - kas dump --update --force-checkout --resolve-refs --resolve-env $KASFILES 
     - kas build $KASFILES
     - ./ci/check-warnings $KAS_WORK_DIR/build/warnings.log
   artifacts:
@@ -221,7 +219,7 @@
   script:
     - rm -fr update-report
     # This configuration has all of the layers we need enabled
-    - kas shell ci/qemuarm64.yml:ci/meta-openembedded.yml --command \
+    - kas shell --update --force-checkout ci/qemuarm64.yml:ci/meta-openembedded.yml --command \
       "$CI_PROJECT_DIR/scripts/machine-summary.py -t report -o $CI_PROJECT_DIR/update-report $($CI_PROJECT_DIR/ci/listmachines.py meta-arm meta-arm-bsp)"
   # Do this on x86 whilst the compilers are x86-only
   tags:
diff --git a/meta-arm/ci/0001-Revert-pixman-Do-not-use-clang-assembler-for-now.patch b/meta-arm/ci/0001-Revert-pixman-Do-not-use-clang-assembler-for-now.patch
deleted file mode 100644
index 4ad6607..0000000
--- a/meta-arm/ci/0001-Revert-pixman-Do-not-use-clang-assembler-for-now.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-This causes illegal instruction faults in pixman, so xserver crashes.
-https://github.com/kraj/meta-clang/issues/696
-
-From 8659c5c5bec39dd43a1988b19d4cf30507a44679 Mon Sep 17 00:00:00 2001
-From: Ross Burton <ross.burton@arm.com>
-Date: Mon, 28 Nov 2022 16:52:50 +0000
-Subject: [PATCH] Revert "pixman: Do not use clang assembler for now"
-
-This reverts commit 84dbafa42d8141b00da75d6664aef07c252a52ee.
----
- conf/nonclangable.conf | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/conf/nonclangable.conf b/conf/nonclangable.conf
-index 04112f4..b5db848 100644
---- a/conf/nonclangable.conf
-+++ b/conf/nonclangable.conf
-@@ -347,5 +347,4 @@ DEPENDS:append:pn-pixman:mips:toolchain-clang = " openmp"
- #| .endfunc
- #| ^
- CFLAGS:append:pn-pixman:arm:toolchain-clang = " -no-integrated-as"
--CFLAGS:append:pn-pixman:aarch64:toolchain-clang = " -no-integrated-as"
- 
--- 
-2.34.1
-
diff --git a/meta-arm/ci/armgcc.yml b/meta-arm/ci/armgcc.yml
index a797172..9fb38cf 100644
--- a/meta-arm/ci/armgcc.yml
+++ b/meta-arm/ci/armgcc.yml
@@ -3,4 +3,4 @@
 
 local_conf_header:
   cc: |
-    GCCVERSION = "arm-11.3"
+    GCCVERSION = "arm-12.2"
diff --git a/meta-arm/ci/base.yml b/meta-arm/ci/base.yml
index 7f209de..23fb7cc 100644
--- a/meta-arm/ci/base.yml
+++ b/meta-arm/ci/base.yml
@@ -5,7 +5,7 @@
 
 defaults:
   repos:
-    refspec: langdale
+    refspec: master
 
 repos:
   meta-arm:
diff --git a/meta-arm/ci/clang.yml b/meta-arm/ci/clang.yml
index 6c90902..a2063f1 100644
--- a/meta-arm/ci/clang.yml
+++ b/meta-arm/ci/clang.yml
@@ -4,16 +4,7 @@
 repos:
   meta-clang:
     url: https://github.com/kraj/meta-clang
-    patches:
-      pixman:
-        repo: meta-arm
-        path: ci/0001-Revert-pixman-Do-not-use-clang-assembler-for-now.patch
 
 local_conf_header:
   clang: |
     TOOLCHAIN = "clang"
-    # Backport d89e06ad94a46f6810d0a8787004b71b8ecaf87d to langdale
-    OBJCOPY:pn-linux-yocto:toolchain-clang = "${HOST_PREFIX}objcopy"
-    # Perf needs fixes backported, use GCC for now
-    # https://lore.kernel.org/linux-perf-users/Y5d4k7fDxfRP7hcN@kernel.org/T/#t
-    TOOLCHAIN:pn-perf = "gcc"
diff --git a/meta-arm/ci/get-binary-toolchains b/meta-arm/ci/get-binary-toolchains
index bf8bf3e..23c3bbb 100755
--- a/meta-arm/ci/get-binary-toolchains
+++ b/meta-arm/ci/get-binary-toolchains
@@ -2,7 +2,7 @@
 set -u -e
 
 BASENAME=arm-gnu-toolchain
-VER=${VER:-11.3.rel1}
+VER=${VER:-12.2.rel1}
 HOST_ARCH=${HOST_ARCH:-$(uname -m)}
 
 DOWNLOAD_DIR=$1
diff --git a/meta-arm/meta-arm-bsp/conf/layer.conf b/meta-arm/meta-arm-bsp/conf/layer.conf
index 75efe54..e192a83 100644
--- a/meta-arm/meta-arm-bsp/conf/layer.conf
+++ b/meta-arm/meta-arm-bsp/conf/layer.conf
@@ -9,7 +9,7 @@
 BBFILE_PATTERN_meta-arm-bsp = "^${LAYERDIR}/"
 BBFILE_PRIORITY_meta-arm-bsp = "5"
 
-LAYERSERIES_COMPAT_meta-arm-bsp = "langdale mickledore"
+LAYERSERIES_COMPAT_meta-arm-bsp = "mickledore"
 
 LAYERDEPENDS_meta-arm-bsp = "core meta-arm"
 # This won't be used by layerindex-fetch, but works everywhere else
diff --git a/meta-arm/meta-arm-bsp/conf/machine/corstone500.conf b/meta-arm/meta-arm-bsp/conf/machine/corstone500.conf
index 9db2ceb..dfc850d 100644
--- a/meta-arm/meta-arm-bsp/conf/machine/corstone500.conf
+++ b/meta-arm/meta-arm-bsp/conf/machine/corstone500.conf
@@ -26,7 +26,7 @@
 UBOOT_MACHINE = "corstone500_defconfig"
 UBOOT_IMAGE_ENTRYPOINT = "0x84000000"
 UBOOT_IMAGE_LOADADDRESS = "0x84000000"
-PREFERRED_VERSION_u-boot ?= "2022.07"
+PREFERRED_VERSION_u-boot ?= "2022.10"
 
 # making sure EXTRA_IMAGEDEPENDS will be used while creating the image
 WKS_FILE_DEPENDS:append = " ${EXTRA_IMAGEDEPENDS}"
diff --git a/meta-arm/meta-arm-bsp/conf/machine/fvp-baser-aemv8r64.conf b/meta-arm/meta-arm-bsp/conf/machine/fvp-baser-aemv8r64.conf
index 06bef29..0c2ea12 100644
--- a/meta-arm/meta-arm-bsp/conf/machine/fvp-baser-aemv8r64.conf
+++ b/meta-arm/meta-arm-bsp/conf/machine/fvp-baser-aemv8r64.conf
@@ -9,7 +9,7 @@
 EXTRA_IMAGEDEPENDS += "boot-wrapper-aarch64"
 
 PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto"
-PREFERRED_VERSION_u-boot ?= "2022.07"
+PREFERRED_VERSION_u-boot ?= "2022.10"
 
 KERNEL_IMAGETYPE = "Image"
 KERNEL_DEVICETREE = "arm/fvp-baser-aemv8r64.dtb"
@@ -25,9 +25,7 @@
 MACHINE_FEATURES:append = " efi"
 
 # As this is a virtual target that will not be used in the real world there is
-# no need for real SSH keys.  Disable rng-tools (which takes too long to
-# initialise) and install the pre-generated keys.
-PACKAGECONFIG:remove:pn-openssh = "rng-tools"
+# no need for real SSH keys.
 MACHINE_EXTRA_RRECOMMENDS += "ssh-pregen-hostkeys"
 
 # testimage configuration
diff --git a/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc b/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc
index ff00e3f..d5d6418 100644
--- a/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc
+++ b/meta-arm/meta-arm-bsp/conf/machine/include/corstone1000.inc
@@ -22,7 +22,7 @@
 RE_IMAGE_OFFSET = "0x1000"
 
 # u-boot
-PREFERRED_VERSION_u-boot ?= "2022.07"
+PREFERRED_VERSION_u-boot ?= "2022.10"
 EXTRA_IMAGEDEPENDS += "u-boot"
 
 UBOOT_CONFIG ??= "EFI"
diff --git a/meta-arm/meta-arm-bsp/conf/machine/include/fvp-common.inc b/meta-arm/meta-arm-bsp/conf/machine/include/fvp-common.inc
index b10977c..b6fc74d 100644
--- a/meta-arm/meta-arm-bsp/conf/machine/include/fvp-common.inc
+++ b/meta-arm/meta-arm-bsp/conf/machine/include/fvp-common.inc
@@ -19,9 +19,7 @@
 EXTRA_IMAGEDEPENDS += "trusted-firmware-a u-boot"
 
 # As this is a virtual target that will not be used in the real world there is
-# no need for real SSH keys.  Disable rng-tools (which takes too long to
-# initialise) and install the pre-generated keys.
-PACKAGECONFIG:remove:pn-openssh = "rng-tools"
+# no need for real SSH keys.
 MACHINE_EXTRA_RRECOMMENDS += "ssh-pregen-hostkeys"
 
 TEST_TARGET = "OEFVPTarget"
diff --git a/meta-arm/meta-arm-bsp/conf/machine/juno.conf b/meta-arm/meta-arm-bsp/conf/machine/juno.conf
index c002ed6..4a86d4e 100644
--- a/meta-arm/meta-arm-bsp/conf/machine/juno.conf
+++ b/meta-arm/meta-arm-bsp/conf/machine/juno.conf
@@ -10,10 +10,10 @@
 
 MACHINE_FEATURES = "usbhost usbgadget alsa screen wifi bluetooth optee pci"
 
-KERNEL_IMAGETYPE = "Image"
+KERNEL_IMAGETYPE = "Image.gz"
 KERNEL_DEVICETREE = "arm/juno.dtb arm/juno-r1.dtb arm/juno-r2.dtb"
 
-IMAGE_FSTYPES += "tar.bz2 ext4"
+IMAGE_FSTYPES += "tar.bz2 ext4 cpio.gz"
 
 SERIAL_CONSOLES = "115200;ttyAMA0"
 
@@ -25,3 +25,6 @@
 
 # Juno u-boot configuration
 UBOOT_MACHINE = "vexpress_aemv8a_juno_defconfig"
+
+INITRAMFS_IMAGE_BUNDLE ?= "1"
+INITRAMFS_IMAGE = "core-image-minimal"
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bb b/meta-arm/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bb
index 80565af..45f2ec7 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bb
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/images/firmware-image-juno.bb
@@ -63,10 +63,10 @@
     done
 
     if [ "${INITRAMFS_IMAGE_BUNDLE}" -eq 1 ]; then
-        cp -L -f ${DEPLOY_DIR_IMAGE}/Image-initramfs-juno.bin \
+        cp -L -f ${DEPLOY_DIR_IMAGE}/Image.gz-initramfs-juno.bin \
             ${D}/${UNPACK_DIR}/SOFTWARE/Image
     else
-        cp -L -f ${DEPLOY_DIR_IMAGE}/Image ${D}/${UNPACK_DIR}/SOFTWARE/
+        cp -L -f ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ${D}/${UNPACK_DIR}/SOFTWARE/
     fi
 
     # Compress the files
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc
index 861dcff..279109e 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-corstone1000.inc
@@ -6,8 +6,6 @@
 
 TFM_DEBUG = "1"
 
-
-
 ## Default is the MPS3 board
 TFM_PLATFORM_IS_FVP ?= "FALSE"
 EXTRA_OECMAKE += "-DPLATFORM_IS_FVP=${TFM_PLATFORM_IS_FVP}"
@@ -28,11 +26,6 @@
 EXTRA_OECMAKE += "-DLIBOPENAMP_SRC_PATH=${S}/../openamp -DLIBOPENAMP_BIN_PATH=${B}/libopenamp-build"
 
 
-# Uncomment to apply patches
-# FILESEXTRAPATHS:prepend := "${THISDIR}/corstone1000:"
-# SRC_URI:append:corstone1000 = " \
-#           "
-
 do_install() {
   install -D -p -m 0644 ${B}/install/outputs/tfm_s_signed.bin ${D}/firmware/tfm_s_signed.bin
   install -D -p -m 0644 ${B}/install/outputs/bl2_signed.bin ${D}/firmware/bl2_signed.bin
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch
similarity index 78%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch
index 01cd561..837f8a9 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch
@@ -1,7 +1,7 @@
-From 7afe2370bc24b9003be8184fbd3169ebca03165a Mon Sep 17 00:00:00 2001
+From 584e4952dca726c3dc9df319dffb37a518b65c14 Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 Date: Fri, 29 Jul 2022 13:06:19 +0100
-Subject: [PATCH 06/26] arm64: smccc: add support for SMCCCv1.2 x0-x17
+Subject: [PATCH 01/25] arm64: smccc: add support for SMCCCv1.2 x0-x17
  registers
 
 add support for x0-x17 registers used by the SMC calls
@@ -16,13 +16,19 @@
 [1]: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token=
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
-
----
+Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v7:
+
+* improve indentation of ARM_SMCCC_1_2_REGS_Xn_OFFS
+
 v4:
 
 * rename the commit title and improve description
@@ -33,11 +39,11 @@
 * port x0-x17 registers support from linux kernel as defined by SMCCCv1.2
   commit title:
       arm64: smccc: add Xn registers support used by SMC calls
-
+---
  arch/arm/cpu/armv8/smccc-call.S | 53 +++++++++++++++++++++++++++++++++
- arch/arm/lib/asm-offsets.c      | 13 ++++++++
+ arch/arm/lib/asm-offsets.c      | 14 +++++++++
  include/linux/arm-smccc.h       | 43 ++++++++++++++++++++++++++
- 3 files changed, 109 insertions(+)
+ 3 files changed, 110 insertions(+)
 
 diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S
 index dc92b28777..ec6f299bc9 100644
@@ -108,38 +114,39 @@
 +
 +#endif
 diff --git a/arch/arm/lib/asm-offsets.c b/arch/arm/lib/asm-offsets.c
-index 22fd541f9a..b6bd1b32b0 100644
+index 22fd541f9a..db6d7ed234 100644
 --- a/arch/arm/lib/asm-offsets.c
 +++ b/arch/arm/lib/asm-offsets.c
-@@ -9,6 +9,8 @@
+@@ -9,6 +9,9 @@
   * generate asm statements containing #defines,
   * compile this file to assembler, and then extract the
   * #defines from the assembly-language output.
 + *
 + * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
   */
  
  #include <common.h>
-@@ -117,6 +119,17 @@ int main(void)
+@@ -117,6 +120,17 @@ int main(void)
  	DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
  	DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id));
  	DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state));
-+	#ifdef CONFIG_ARM64
-+		DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS,	offsetof(struct arm_smccc_1_2_regs, a0));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS,	offsetof(struct arm_smccc_1_2_regs, a2));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS,	offsetof(struct arm_smccc_1_2_regs, a4));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS,	offsetof(struct arm_smccc_1_2_regs, a6));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS,	offsetof(struct arm_smccc_1_2_regs, a8));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS,	offsetof(struct arm_smccc_1_2_regs, a10));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS,	offsetof(struct arm_smccc_1_2_regs, a12));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS,	offsetof(struct arm_smccc_1_2_regs, a14));
-+		DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS,	offsetof(struct arm_smccc_1_2_regs, a16));
-+	#endif
++#ifdef CONFIG_ARM64
++	DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS,	offsetof(struct arm_smccc_1_2_regs, a0));
++	DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS,	offsetof(struct arm_smccc_1_2_regs, a2));
++	DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS,	offsetof(struct arm_smccc_1_2_regs, a4));
++	DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS,	offsetof(struct arm_smccc_1_2_regs, a6));
++	DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS,	offsetof(struct arm_smccc_1_2_regs, a8));
++	DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS,	offsetof(struct arm_smccc_1_2_regs, a10));
++	DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS,	offsetof(struct arm_smccc_1_2_regs, a12));
++	DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS,	offsetof(struct arm_smccc_1_2_regs, a14));
++	DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS,	offsetof(struct arm_smccc_1_2_regs, a16));
++#endif
  #endif
  
  	return 0;
 diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
-index 7f2be23394..dae58d3476 100644
+index e1d09884a1..9105031d55 100644
 --- a/include/linux/arm-smccc.h
 +++ b/include/linux/arm-smccc.h
 @@ -1,6 +1,8 @@
@@ -151,7 +158,7 @@
   */
  #ifndef __LINUX_ARM_SMCCC_H
  #define __LINUX_ARM_SMCCC_H
-@@ -66,6 +68,47 @@ struct arm_smccc_res {
+@@ -70,6 +72,47 @@ struct arm_smccc_res {
  	unsigned long a3;
  };
  
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-cmd-load-add-load-command-for-memory-mapped.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-cmd-load-add-load-command-for-memory-mapped.patch
deleted file mode 100644
index 4d7c51f..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0001-cmd-load-add-load-command-for-memory-mapped.patch
+++ /dev/null
@@ -1,186 +0,0 @@
-From 910760408430de32ad08b1e5ddf894cc9f2f3d0c Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Thu, 24 Jun 2021 09:25:00 +0100
-Subject: [PATCH 01/26] cmd: load: add load command for memory mapped
-
-cp.b is used a lot as a way to load binaries to memory and execute
-them, however we may need to integrate this with the efi subsystem to
-set it up as a bootdev.
-
-So, introduce a loadm command that will be consistent with the other
-loadX commands and will call the efi API's.
-
-ex: loadm $kernel_addr $kernel_addr_r $kernel_size
-
-with this a kernel with CONFIG_EFI_STUB enabled will be loaded and
-then subsequently booted with bootefi command.
-
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Accepted [2022.10-rc1]
----
- README                           |  1 +
- cmd/Kconfig                      |  6 ++++
- cmd/bootefi.c                    | 12 ++++++++
- cmd/load.c                       | 48 ++++++++++++++++++++++++++++++++
- include/efi_loader.h             |  2 ++
- lib/efi_loader/efi_device_path.c |  9 ++++++
- 6 files changed, 78 insertions(+)
-
-diff --git a/README b/README
-index b7ab6e5070..cd76f95e74 100644
---- a/README
-+++ b/README
-@@ -2578,6 +2578,7 @@ rarpboot- boot image via network using RARP/TFTP protocol
- diskboot- boot from IDE devicebootd   - boot default, i.e., run 'bootcmd'
- loads	- load S-Record file over serial line
- loadb	- load binary file over serial line (kermit mode)
-+loadm   - load binary blob from source address to destination address
- md	- memory display
- mm	- memory modify (auto-incrementing)
- nm	- memory modify (constant address)
-diff --git a/cmd/Kconfig b/cmd/Kconfig
-index 09193b61b9..ba2f321ae9 100644
---- a/cmd/Kconfig
-+++ b/cmd/Kconfig
-@@ -1143,6 +1143,12 @@ config CMD_LOADB
- 	help
- 	  Load a binary file over serial line.
- 
-+config CMD_LOADM
-+	bool "loadm"
-+	default y
-+	help
-+	  Load a binary over memory mapped.
-+
- config CMD_LOADS
- 	bool "loads"
- 	default y
-diff --git a/cmd/bootefi.c b/cmd/bootefi.c
-index 827fcd97df..37ce659fa1 100644
---- a/cmd/bootefi.c
-+++ b/cmd/bootefi.c
-@@ -34,6 +34,18 @@ static struct efi_device_path *bootefi_device_path;
- static void *image_addr;
- static size_t image_size;
- 
-+/**
-+ * efi_get_image_parameters() - return image parameters
-+ *
-+ * @img_addr:		address of loaded image in memory
-+ * @img_size:		size of loaded image
-+ */
-+void efi_get_image_parameters(void **img_addr, size_t *img_size)
-+{
-+	*img_addr = image_addr;
-+	*img_size = image_size;
-+}
-+
- /**
-  * efi_clear_bootdev() - clear boot device
-  */
-diff --git a/cmd/load.c b/cmd/load.c
-index 7e4a552d90..1224a7f85b 100644
---- a/cmd/load.c
-+++ b/cmd/load.c
-@@ -1063,6 +1063,44 @@ static ulong load_serial_ymodem(ulong offset, int mode)
- 
- #endif
- 
-+#if defined(CONFIG_CMD_LOADM)
-+static int do_load_memory_bin(struct cmd_tbl *cmdtp, int flag, int argc,
-+			      char *const argv[])
-+{
-+	ulong	addr, dest, size;
-+	void	*src, *dst;
-+
-+	if (argc != 4)
-+		return CMD_RET_USAGE;
-+
-+	addr = simple_strtoul(argv[1], NULL, 16);
-+
-+	dest = simple_strtoul(argv[2], NULL, 16);
-+
-+	size = simple_strtoul(argv[3], NULL, 16);
-+
-+	if (!size) {
-+		printf("loadm: can not load zero bytes\n");
-+		return 1;
-+	}
-+
-+	src = map_sysmem(addr, size);
-+	dst = map_sysmem(dest, size);
-+
-+	memcpy(dst, src, size);
-+
-+	unmap_sysmem(src);
-+	unmap_sysmem(dst);
-+
-+	if (IS_ENABLED(CONFIG_CMD_BOOTEFI))
-+		efi_set_bootdev("Mem", "", "", map_sysmem(dest, 0), size);
-+
-+	printf("loaded bin to memory: size: %lu\n", size);
-+
-+	return 0;
-+}
-+#endif
-+
- /* -------------------------------------------------------------------- */
- 
- #if defined(CONFIG_CMD_LOADS)
-@@ -1137,3 +1175,13 @@ U_BOOT_CMD(
- );
- 
- #endif	/* CONFIG_CMD_LOADB */
-+
-+#if defined(CONFIG_CMD_LOADM)
-+U_BOOT_CMD(
-+	loadm, 4, 0,	do_load_memory_bin,
-+	"load binary blob from source address to destination address",
-+	"[src_addr] [dst_addr] [size]\n"
-+	"     - load a binary blob from one memory location to other"
-+	" from src_addr to dst_addr by size bytes"
-+);
-+#endif /* CONFIG_CMD_LOADM */
-diff --git a/include/efi_loader.h b/include/efi_loader.h
-index 11930fbea8..5b41985244 100644
---- a/include/efi_loader.h
-+++ b/include/efi_loader.h
-@@ -591,6 +591,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
- void efi_save_gd(void);
- /* Call this to relocate the runtime section to an address space */
- void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
-+/* Call this to get image parameters */
-+void efi_get_image_parameters(void **img_addr, size_t *img_size);
- /* Add a new object to the object list. */
- void efi_add_handle(efi_handle_t obj);
- /* Create handle */
-diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
-index 171661b897..2493d74326 100644
---- a/lib/efi_loader/efi_device_path.c
-+++ b/lib/efi_loader/efi_device_path.c
-@@ -1158,6 +1158,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
- {
- 	struct blk_desc *desc = NULL;
- 	struct disk_partition fs_partition;
-+	size_t image_size;
-+	void *image_addr;
- 	int part = 0;
- 	char *filename;
- 	char *s;
-@@ -1173,6 +1175,13 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
- 	} else if (!strcmp(dev, "Uart")) {
- 		if (device)
- 			*device = efi_dp_from_uart();
-+	} else if (!strcmp(dev, "Mem")) {
-+		efi_get_image_parameters(&image_addr, &image_size);
-+
-+		if (device)
-+			*device = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
-+						  (uintptr_t)image_addr,
-+						  image_size);
- 	} else {
- 		part = blk_get_device_part_str(dev, devnr, &desc, &fs_partition,
- 					       1);
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-arm-add-support-to-corstone1000-platform.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-arm-add-support-to-corstone1000-platform.patch
deleted file mode 100644
index 4c7c9b1..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-arm-add-support-to-corstone1000-platform.patch
+++ /dev/null
@@ -1,682 +0,0 @@
-From 3523b1bac430f10f02a31f7d013ea369e29656be Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Tue, 15 Feb 2022 09:44:10 +0000
-Subject: [PATCH 02/26] arm: add support to corstone1000 platform
-
-Corstone1000 is a platform from arm, which includes pre
-verified Corstone SSE710 sub-system that combines Cortex-A and
-Cortex-M processors [0].
-
-This code adds the support for the Cortex-A35 implementation
-at host side, it contains also the necessary bits to support
-the Corstone 1000 FVP (Fixed Virtual Platform) [1] and also the
-FPGA MPS3 board implementation of this platform. [2]
-
-0: https://documentation-service.arm.com/static/619e02b1f45f0b1fbf3a8f16
-1: https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps
-2: https://documentation-service.arm.com/static/61f3f4d7fa8173727a1b71bf
-
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Accepted [2022.10-rc1]
----
- arch/arm/Kconfig                         |   8 ++
- arch/arm/dts/Makefile                    |   3 +
- arch/arm/dts/corstone1000-fvp.dts        |  23 +++
- arch/arm/dts/corstone1000-mps3.dts       |  32 +++++
- arch/arm/dts/corstone1000.dtsi           | 169 +++++++++++++++++++++++
- board/armltd/corstone1000/Kconfig        |  12 ++
- board/armltd/corstone1000/MAINTAINERS    |   7 +
- board/armltd/corstone1000/Makefile       |   7 +
- board/armltd/corstone1000/corstone1000.c | 125 +++++++++++++++++
- configs/corstone1000_defconfig           |  80 +++++++++++
- include/configs/corstone1000.h           |  86 ++++++++++++
- 11 files changed, 552 insertions(+)
- create mode 100644 arch/arm/dts/corstone1000-fvp.dts
- create mode 100644 arch/arm/dts/corstone1000-mps3.dts
- create mode 100644 arch/arm/dts/corstone1000.dtsi
- create mode 100644 board/armltd/corstone1000/Kconfig
- create mode 100644 board/armltd/corstone1000/MAINTAINERS
- create mode 100644 board/armltd/corstone1000/Makefile
- create mode 100644 board/armltd/corstone1000/corstone1000.c
- create mode 100644 configs/corstone1000_defconfig
- create mode 100644 include/configs/corstone1000.h
-
-diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
-index 9898c7d68e..2fc2b7d20f 100644
---- a/arch/arm/Kconfig
-+++ b/arch/arm/Kconfig
-@@ -1347,6 +1347,12 @@ config ARCH_VEXPRESS64
- 	select ENV_IS_IN_FLASH if MTD
- 	imply DISTRO_DEFAULTS
- 
-+config TARGET_CORSTONE1000
-+	bool "Support Corstone1000 Platform"
-+	select ARM64
-+	select PL01X_SERIAL
-+	select DM
-+
- config TARGET_TOTAL_COMPUTE
- 	bool "Support Total Compute Platform"
- 	select ARM64
-@@ -2295,6 +2301,8 @@ source "arch/arm/mach-npcm/Kconfig"
- 
- source "board/armltd/total_compute/Kconfig"
- 
-+source "board/armltd/corstone1000/Kconfig"
-+
- source "board/bosch/shc/Kconfig"
- source "board/bosch/guardian/Kconfig"
- source "board/Marvell/octeontx/Kconfig"
-diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
-index a7e0d9f6c0..8c8f15b6a8 100644
---- a/arch/arm/dts/Makefile
-+++ b/arch/arm/dts/Makefile
-@@ -1265,6 +1265,9 @@ dtb-$(CONFIG_TARGET_EA_LPC3250DEVKITV2) += lpc3250-ea3250.dtb
- 
- dtb-$(CONFIG_ARCH_QEMU) += qemu-arm.dtb qemu-arm64.dtb
- 
-+dtb-$(CONFIG_TARGET_CORSTONE1000) += corstone1000-mps3.dtb \
-+				     corstone1000-fvp.dtb
-+
- include $(srctree)/scripts/Makefile.dts
- 
- targets += $(dtb-y)
-diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
-new file mode 100644
-index 0000000000..1fcc137a49
---- /dev/null
-+++ b/arch/arm/dts/corstone1000-fvp.dts
-@@ -0,0 +1,23 @@
-+// SPDX-License-Identifier: GPL-2.0 or MIT
-+/*
-+ * Copyright (c) 2022, Arm Limited. All rights reserved.
-+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
-+ *
-+ */
-+
-+/dts-v1/;
-+
-+#include "corstone1000.dtsi"
-+
-+/ {
-+	model = "ARM Corstone1000 FVP (Fixed Virtual Platform)";
-+	compatible = "arm,corstone1000-fvp";
-+
-+	smsc: ethernet@4010000 {
-+		compatible = "smsc,lan91c111";
-+		reg = <0x40100000 0x10000>;
-+		phy-mode = "mii";
-+		interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
-+		reg-io-width = <2>;
-+	};
-+};
-diff --git a/arch/arm/dts/corstone1000-mps3.dts b/arch/arm/dts/corstone1000-mps3.dts
-new file mode 100644
-index 0000000000..e3146747c2
---- /dev/null
-+++ b/arch/arm/dts/corstone1000-mps3.dts
-@@ -0,0 +1,32 @@
-+// SPDX-License-Identifier: GPL-2.0 or MIT
-+/*
-+ * Copyright (c) 2022, Arm Limited. All rights reserved.
-+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
-+ *
-+ */
-+
-+/dts-v1/;
-+
-+#include "corstone1000.dtsi"
-+
-+/ {
-+	model = "ARM Corstone1000 FPGA MPS3 board";
-+	compatible = "arm,corstone1000-mps3";
-+
-+	smsc: ethernet@4010000 {
-+		compatible = "smsc,lan9220", "smsc,lan9115";
-+		reg = <0x40100000 0x10000>;
-+		phy-mode = "mii";
-+		interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
-+		reg-io-width = <2>;
-+		smsc,irq-push-pull;
-+	};
-+
-+	usb_host: usb@40200000 {
-+		compatible = "nxp,usb-isp1763";
-+		reg = <0x40200000 0x100000>;
-+		interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
-+		bus-width = <16>;
-+		dr_mode = "host";
-+	};
-+};
-diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
-new file mode 100644
-index 0000000000..d0194aa893
---- /dev/null
-+++ b/arch/arm/dts/corstone1000.dtsi
-@@ -0,0 +1,169 @@
-+// SPDX-License-Identifier: GPL-2.0 or MIT
-+/*
-+ * Copyright (c) 2022, Arm Limited. All rights reserved.
-+ * Copyright (c) 2022, Linaro Limited. All rights reserved.
-+ *
-+ */
-+
-+#include <dt-bindings/interrupt-controller/arm-gic.h>
-+
-+/ {
-+	interrupt-parent = <&gic>;
-+	#address-cells = <1>;
-+	#size-cells = <1>;
-+
-+	aliases {
-+		serial0 = &uart0;
-+		serial1 = &uart1;
-+	};
-+
-+	chosen {
-+		stdout-path = "serial0:115200n8";
-+	};
-+
-+	cpus {
-+		#address-cells = <1>;
-+		#size-cells = <0>;
-+
-+		cpu: cpu@0 {
-+			device_type = "cpu";
-+			compatible = "arm,cortex-a35";
-+			reg = <0>;
-+			next-level-cache = <&L2_0>;
-+		};
-+	};
-+
-+	memory@88200000 {
-+		device_type = "memory";
-+		reg = <0x88200000 0x77e00000>;
-+	};
-+
-+	gic: interrupt-controller@1c000000 {
-+		compatible = "arm,gic-400";
-+		#interrupt-cells = <3>;
-+		#address-cells = <0>;
-+		interrupt-controller;
-+		reg =	<0x1c010000 0x1000>,
-+			<0x1c02f000 0x2000>,
-+			<0x1c04f000 0x1000>,
-+			<0x1c06f000 0x2000>;
-+		interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(1) |
-+			      IRQ_TYPE_LEVEL_LOW)>;
-+	};
-+
-+	L2_0: l2-cache0 {
-+		compatible = "cache";
-+		cache-level = <2>;
-+		cache-size = <0x80000>;
-+		cache-line-size = <64>;
-+		cache-sets = <1024>;
-+	};
-+
-+	refclk100mhz: refclk100mhz {
-+		compatible = "fixed-clock";
-+		#clock-cells = <0>;
-+		clock-frequency = <100000000>;
-+		clock-output-names = "apb_pclk";
-+	};
-+
-+	smbclk: refclk24mhzx2 {
-+		/* Reference 24MHz clock x 2 */
-+		compatible = "fixed-clock";
-+		#clock-cells = <0>;
-+		clock-frequency = <48000000>;
-+		clock-output-names = "smclk";
-+	};
-+
-+	timer {
-+		compatible = "arm,armv8-timer";
-+		interrupts =	<GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) |
-+				 IRQ_TYPE_LEVEL_LOW)>,
-+				<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) |
-+				 IRQ_TYPE_LEVEL_LOW)>,
-+				<GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) |
-+				 IRQ_TYPE_LEVEL_LOW)>,
-+				<GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) |
-+				 IRQ_TYPE_LEVEL_LOW)>;
-+	};
-+
-+	uartclk: uartclk {
-+		/* UART clock - 50MHz */
-+		compatible = "fixed-clock";
-+		#clock-cells = <0>;
-+		clock-frequency = <50000000>;
-+		clock-output-names = "uartclk";
-+	};
-+
-+	psci {
-+		compatible = "arm,psci-1.0", "arm,psci-0.2";
-+		method = "smc";
-+	};
-+
-+	soc {
-+		compatible = "simple-bus";
-+		#address-cells = <1>;
-+		#size-cells = <1>;
-+		interrupt-parent = <&gic>;
-+		ranges;
-+
-+		timer@1a220000 {
-+			compatible = "arm,armv7-timer-mem";
-+			reg = <0x1a220000 0x1000>;
-+			#address-cells = <1>;
-+			#size-cells = <1>;
-+			clock-frequency = <50000000>;
-+			ranges;
-+
-+			frame@1a230000 {
-+				frame-number = <0>;
-+				interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
-+				reg = <0x1a230000 0x1000>;
-+			};
-+		};
-+
-+		uart0: serial@1a510000 {
-+			compatible = "arm,pl011", "arm,primecell";
-+			reg = <0x1a510000 0x1000>;
-+			interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
-+			clocks = <&uartclk>, <&refclk100mhz>;
-+			clock-names = "uartclk", "apb_pclk";
-+		};
-+
-+		uart1: serial@1a520000 {
-+			compatible = "arm,pl011", "arm,primecell";
-+			reg = <0x1a520000 0x1000>;
-+			interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
-+			clocks = <&uartclk>, <&refclk100mhz>;
-+			clock-names = "uartclk", "apb_pclk";
-+		};
-+
-+		mhu_hse1: mailbox@1b820000 {
-+			compatible = "arm,mhuv2-tx", "arm,primecell";
-+			reg = <0x1b820000 0x1000>;
-+			clocks = <&refclk100mhz>;
-+			clock-names = "apb_pclk";
-+			interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
-+			#mbox-cells = <2>;
-+			arm,mhuv2-protocols = <0 0>;
-+			secure-status = "okay";     /* secure-world-only */
-+			status = "disabled";
-+		};
-+
-+		mhu_seh1: mailbox@1b830000 {
-+			compatible = "arm,mhuv2-rx", "arm,primecell";
-+			reg = <0x1b830000 0x1000>;
-+			clocks = <&refclk100mhz>;
-+			clock-names = "apb_pclk";
-+			interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
-+			#mbox-cells = <2>;
-+			arm,mhuv2-protocols = <0 0>;
-+			secure-status = "okay";     /* secure-world-only */
-+			status = "disabled";
-+		};
-+	};
-+
-+	arm_ffa: arm_ffa {
-+		compatible = "arm,ffa";
-+		method = "smc";
-+	};
-+};
-diff --git a/board/armltd/corstone1000/Kconfig b/board/armltd/corstone1000/Kconfig
-new file mode 100644
-index 0000000000..709674d4cf
---- /dev/null
-+++ b/board/armltd/corstone1000/Kconfig
-@@ -0,0 +1,12 @@
-+if TARGET_CORSTONE1000
-+
-+config SYS_BOARD
-+	default "corstone1000"
-+
-+config SYS_VENDOR
-+	default "armltd"
-+
-+config SYS_CONFIG_NAME
-+	default "corstone1000"
-+
-+endif
-diff --git a/board/armltd/corstone1000/MAINTAINERS b/board/armltd/corstone1000/MAINTAINERS
-new file mode 100644
-index 0000000000..8c905686de
---- /dev/null
-+++ b/board/armltd/corstone1000/MAINTAINERS
-@@ -0,0 +1,7 @@
-+CORSTONE1000 BOARD
-+M:	Rui Miguel Silva <rui.silva@linaro.org>
-+M:	Vishnu Banavath <vishnu.banavath@arm.com>
-+S:	Maintained
-+F:	board/armltd/corstone1000/
-+F:	include/configs/corstone1000.h
-+F:	configs/corstone1000_defconfig
-diff --git a/board/armltd/corstone1000/Makefile b/board/armltd/corstone1000/Makefile
-new file mode 100644
-index 0000000000..77a82c2892
---- /dev/null
-+++ b/board/armltd/corstone1000/Makefile
-@@ -0,0 +1,7 @@
-+# SPDX-License-Identifier: GPL-2.0+
-+#
-+# (C) Copyright 2022 Arm Limited
-+# (C) Copyright 2022 Linaro
-+# Rui Miguel Silva <rui.silva@linaro.org>
-+
-+obj-y	:= corstone1000.o
-diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
-new file mode 100644
-index 0000000000..2fa485ff37
---- /dev/null
-+++ b/board/armltd/corstone1000/corstone1000.c
-@@ -0,0 +1,125 @@
-+// SPDX-License-Identifier: GPL-2.0+
-+/*
-+ * (C) Copyright 2022 ARM Limited
-+ * (C) Copyright 2022 Linaro
-+ * Rui Miguel Silva <rui.silva@linaro.org>
-+ */
-+
-+#include <common.h>
-+#include <dm.h>
-+#include <dm/platform_data/serial_pl01x.h>
-+#include <asm/armv8/mmu.h>
-+#include <asm/global_data.h>
-+
-+
-+static const struct pl01x_serial_plat serial_plat = {
-+	.base = V2M_UART0,
-+	.type = TYPE_PL011,
-+	.clock = CONFIG_PL011_CLOCK,
-+};
-+
-+U_BOOT_DRVINFO(corstone1000_serials) = {
-+	.name = "serial_pl01x",
-+	.plat = &serial_plat,
-+};
-+
-+static struct mm_region corstone1000_mem_map[] = {
-+	{
-+		/* CVM */
-+		.virt = 0x02000000UL,
-+		.phys = 0x02000000UL,
-+		.size = 0x02000000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-+			 PTE_BLOCK_INNER_SHARE
-+	}, {
-+		/* QSPI */
-+		.virt = 0x08000000UL,
-+		.phys = 0x08000000UL,
-+		.size = 0x08000000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-+			 PTE_BLOCK_INNER_SHARE
-+	}, {
-+		/* Host Peripherals */
-+		.virt = 0x1A000000UL,
-+		.phys = 0x1A000000UL,
-+		.size = 0x26000000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+			 PTE_BLOCK_NON_SHARE |
-+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+        }, {
-+                /* USB */
-+                .virt = 0x40200000UL,
-+                .phys = 0x40200000UL,
-+                .size = 0x00100000UL,
-+                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+                         PTE_BLOCK_NON_SHARE |
-+                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+	}, {
-+                 /* ethernet */
-+                .virt = 0x40100000UL,
-+                .phys = 0x40100000UL,
-+                .size = 0x00100000UL,
-+                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+                         PTE_BLOCK_NON_SHARE |
-+                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+	}, {
-+		/* OCVM */
-+		.virt = 0x80000000UL,
-+		.phys = 0x80000000UL,
-+		.size = 0x80000000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-+			 PTE_BLOCK_INNER_SHARE
-+	}, {
-+		/* List terminator */
-+		0,
-+	}
-+};
-+
-+struct mm_region *mem_map = corstone1000_mem_map;
-+
-+void set_dfu_alt_info(char *interface, char *devstr)
-+{
-+}
-+
-+int board_init(void)
-+{
-+	return 0;
-+}
-+
-+int dram_init(void)
-+{
-+	gd->ram_size = PHYS_SDRAM_1_SIZE;
-+
-+	return 0;
-+}
-+
-+int dram_init_banksize(void)
-+{
-+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-+	gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
-+
-+	return 0;
-+}
-+
-+/*
-+ * Board specific ethernet initialization routine.
-+ * */
-+int board_eth_init(struct bd_info *bis)
-+{
-+	int rc = 0;
-+
-+#ifndef CONFIG_DM_ETH
-+#ifdef CONFIG_SMC91111
-+	rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
-+#endif
-+#ifdef CONFIG_SMC911X
-+	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
-+#endif
-+#endif
-+
-+	return rc;
-+}
-+
-+void reset_cpu(ulong addr)
-+{
-+}
-diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
-new file mode 100644
-index 0000000000..02f931b0d4
---- /dev/null
-+++ b/configs/corstone1000_defconfig
-@@ -0,0 +1,80 @@
-+CONFIG_ARM=y
-+CONFIG_TARGET_CORSTONE1000=y
-+CONFIG_SYS_TEXT_BASE=0x80000000
-+CONFIG_SYS_MALLOC_F_LEN=0x2000
-+CONFIG_SYS_MALLOC_LEN=0x2000000
-+CONFIG_SYS_LOAD_ADDR=0x82100000
-+CONFIG_NR_DRAM_BANKS=1
-+CONFIG_IDENT_STRING=" corstone1000 aarch64 "
-+CONFIG_FIT=y
-+CONFIG_BOOTDELAY=3
-+CONFIG_USE_BOOTARGS=y
-+CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
-+CONFIG_LOGLEVEL=7
-+# CONFIG_DISPLAY_CPUINFO is not set
-+# CONFIG_DISPLAY_BOARDINFO is not set
-+CONFIG_HUSH_PARSER=y
-+CONFIG_SYS_PROMPT="corstone1000# "
-+# CONFIG_CMD_CONSOLE is not set
-+CONFIG_CMD_BOOTZ=y
-+CONFIG_CMD_BOOTM=y
-+CONFIG_CMD_LOADM=y
-+CONFIG_CMD_BOOTEFI=y
-+CONFIG_EFI_LOADER=y
-+CONFIG_EFI_PARTITION=y
-+CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
-+CONFIG_CMD_BOOTEFI_HELLO=y
-+# CONFIG_CMD_XIMG is not set
-+# CONFIG_CMD_ENV_EXISTS is not set
-+CONFIG_CMD_NVEDIT_EFI=y
-+# CONFIG_CMD_LOADS is not set
-+CONFIG_CMD_USB=y
-+CONFIG_CMD_ITEST=y
-+# CONFIG_CMD_SETEXPR is not set
-+# CONFIG_CMD_NFS is not set
-+CONFIG_CMD_MII=y
-+CONFIG_CMD_CACHE=y
-+CONFIG_CMD_EFIDEBUG=y
-+CONFIG_CMD_FAT=y
-+CONFIG_OF_CONTROL=y
-+CONFIG_REGMAP=y
-+# CONFIG_MMC is not set
-+CONFIG_DM_SERIAL=y
-+CONFIG_USB=y
-+CONFIG_DM_USB=y
-+CONFIG_USB_STORAGE=y
-+CONFIG_EFI_MM_COMM_TEE=y
-+# CONFIG_OPTEE is not set
-+# CONFIG_GENERATE_SMBIOS_TABLE is not set
-+# CONFIG_HEXDUMP is not set
-+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
-+CONFIG_EFI_CAPSULE_ON_DISK=y
-+# CONFIG_EFI_CAPSULE_ON_DISK_EARLY is not set
-+# CONFIG_EFI_CAPSULE_AUTHENTICATE is not set
-+CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y
-+CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
-+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
-+CONFIG_EFI_SECURE_BOOT=y
-+CONFIG_DM_RTC=y
-+CONFIG_CMD_RTC=y
-+CONFIG_EFI_GET_TIME=y
-+CONFIG_EFI_SET_TIME=y
-+CONFIG_RTC_EMULATION=y
-+CONFIG_PSCI_RESET=y
-+CONFIG_DISTRO_DEFAULTS=y
-+CONFIG_CMD_DHCP=y
-+CONFIG_SMC911X=y
-+CONFIG_SMC911X_BASE=0x40100000
-+CONFIG_DM_ETH=y
-+CONFIG_PHY_SMSC=y
-+CONFIG_CMD_BOOTEFI_SELFTEST=y
-+CONFIG_CMD_TIME=y
-+CONFIG_CMD_GETTIME=y
-+CONFIG_NET_RANDOM_ETHADDR=y
-+CONFIG_VERSION_VARIABLE=y
-+CONFIG_PHYLIB=y
-+CONFIG_PHY=y
-+CONFIG_RAM=y
-+CONFIG_ERRNO_STR=y
-+CONFIG_CMD_EDITENV=y
-+CONFIG_MISC=y
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-new file mode 100644
-index 0000000000..cf166f107e
---- /dev/null
-+++ b/include/configs/corstone1000.h
-@@ -0,0 +1,86 @@
-+/* SPDX-License-Identifier: GPL-2.0+ */
-+/*
-+ * (C) Copyright 2022 ARM Limited
-+ * (C) Copyright 2022 Linaro
-+ * Rui Miguel Silva <rui.silva@linaro.org>
-+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-+ *
-+ * Configuration for Corstone1000. Parts were derived from other ARM
-+ * configurations.
-+ */
-+
-+#ifndef __CORSTONE1000_H
-+#define __CORSTONE1000_H
-+
-+#include <linux/sizes.h>
-+
-+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x03f00000)
-+#define CONFIG_SKIP_LOWLEVEL_INIT
-+
-+#define CONFIG_SYS_HZ		1000
-+
-+#define V2M_SRAM0		0x02000000
-+#define V2M_QSPI		0x08000000
-+
-+#define V2M_DEBUG		0x10000000
-+#define V2M_BASE_PERIPH		0x1A000000
-+
-+#define V2M_BASE		0x80000000
-+
-+#define V2M_PERIPH_OFFSET(x)	(x << 16)
-+
-+#define V2M_SYSID		(V2M_BASE_PERIPH)
-+#define V2M_SYSCTL		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(1))
-+
-+#define V2M_COUNTER_CTL		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(32))
-+#define V2M_COUNTER_READ	(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(33))
-+
-+#define V2M_TIMER_CTL		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(34))
-+#define V2M_TIMER_BASE0		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(35))
-+
-+#define V2M_UART0		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(81))
-+#define V2M_UART1		(V2M_BASE_PERIPH + V2M_PERIPH_OFFSET(82))
-+
-+#define CONFIG_PL011_CLOCK	50000000
-+
-+/* Physical Memory Map */
-+#define PHYS_SDRAM_1		(V2M_BASE)
-+#define PHYS_SDRAM_1_SIZE	0x80000000
-+
-+#define CONFIG_ENV_SECT_SIZE	SZ_64K
-+
-+#define CONFIG_SYS_SDRAM_BASE	PHYS_SDRAM_1
-+
-+/* Monitor Command Prompt */
-+#define CONFIG_SYS_CBSIZE	512	/* Console I/O Buffer Size */
-+#define CONFIG_SYS_MAXARGS	64	/* max command args */
-+
-+#define CONFIG_EXTRA_ENV_SETTINGS							\
-+				"usb_pgood_delay=250\0"					\
-+				"boot_bank_flag=0x08002000\0"				\
-+				"kernel_addr_bank_0=0x083EE000\0"			\
-+				"kernel_addr_bank_1=0x0936E000\0"			\
-+				"retrieve_kernel_load_addr="				\
-+					"if itest.l *${boot_bank_flag} == 0; then "	\
-+					    "setenv kernel_addr $kernel_addr_bank_0;"	\
-+					"else "						\
-+					    "setenv kernel_addr $kernel_addr_bank_1;"	\
-+					"fi;"						\
-+					"\0"						\
-+				"kernel_addr_r=0x88200000\0"				\
-+				"fdt_high=0xffffffff\0"
-+
-+/*
-+ * config_distro_bootcmd define the boot command to distro_bootcmd, but we here
-+ * want to first try to load a kernel if exists, override that config then
-+ */
-+#undef CONFIG_BOOTCOMMAND
-+
-+#define CONFIG_BOOTCOMMAND								\
-+				"run retrieve_kernel_load_addr;"			\
-+				"echo Loading kernel from $kernel_addr to memory ... ;"	\
-+				"loadm $kernel_addr $kernel_addr_r 0xc00000;"		\
-+				"usb start; usb reset;"					\
-+				"run distro_bootcmd;"					\
-+				"bootefi $kernel_addr_r $fdtcontroladdr;"
-+#endif
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch
new file mode 100644
index 0000000..1b043dd
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch
@@ -0,0 +1,132 @@
+From b226e6000de0b1f55d56c1193d1fde028d64abd3 Mon Sep 17 00:00:00 2001
+From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Date: Thu, 4 Aug 2022 16:46:47 +0100
+Subject: [PATCH 02/25] lib: uuid: introduce uuid_str_to_le_bin function
+
+convert UUID string to little endian binary data
+
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
+
+Changelog:
+===============
+
+v8:
+
+* use simple_strtoull() in uuid_str_to_le_bin() to support 32-bit platforms
+
+v7:
+
+* rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin()
+* make uuid_str_to_le_bin() implementation similar to uuid_str_to_bin()
+  by using same APIs
+
+v4:
+
+* rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
+  a standalone commit (the current)
+
+v3:
+
+* introduce ffa_uuid_str_to_bin (provided by
+  arm_ffa: introduce Arm FF-A low-level driver)
+---
+ include/uuid.h |  8 ++++++++
+ lib/uuid.c     | 46 ++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 54 insertions(+)
+
+diff --git a/include/uuid.h b/include/uuid.h
+index 4a4883d3b5..293a8eb0a5 100644
+--- a/include/uuid.h
++++ b/include/uuid.h
+@@ -2,6 +2,8 @@
+ /*
+  * Copyright (C) 2014 Samsung Electronics
+  * Przemyslaw Marczak <p.marczak@samsung.com>
++ * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ #ifndef __UUID_H__
+ #define __UUID_H__
+@@ -44,4 +46,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
+ const char *uuid_guid_get_str(const unsigned char *guid_bin);
+ void gen_rand_uuid(unsigned char *uuid_bin);
+ void gen_rand_uuid_str(char *uuid_str, int str_format);
++
++/**
++ * uuid_str_to_le_bin - Converts a UUID string to little endian binary data
++ */
++int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
++
+ #endif
+diff --git a/lib/uuid.c b/lib/uuid.c
+index 465e1ac38f..d29f561a70 100644
+--- a/lib/uuid.c
++++ b/lib/uuid.c
+@@ -1,6 +1,8 @@
+ // SPDX-License-Identifier: GPL-2.0+
+ /*
+  * Copyright 2011 Calxeda, Inc.
++ * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ 
+ #include <common.h>
+@@ -346,6 +348,50 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
+ 	return 0;
+ }
+ 
++/**
++ * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
++ * @uuid_str:	pointer to UUID string
++ * @uuid_bin:	pointer to allocated array for little endian output [16B]
++ *
++ * UUID string is 36 characters (36 bytes):
++ *
++ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
++ *
++ * where x is a hexadecimal character. Fields are separated by '-'s.
++ * When converting to a little endian binary UUID, the string fields are reversed.
++ *
++ * Return:
++ *
++ *    uuid_bin filled with little endian UUID data
++ *    On success 0 is returned. Otherwise, failure code.
++ */
++int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
++{
++	u16 tmp16;
++	u32 tmp32;
++	u64 tmp64;
++
++	if (!uuid_str_valid(uuid_str) || !uuid_bin)
++		return -EINVAL;
++
++	tmp32 = cpu_to_le32(hextoul(uuid_str, NULL));
++	memcpy(uuid_bin, &tmp32, 4);
++
++	tmp16 = cpu_to_le16(hextoul(uuid_str + 9, NULL));
++	memcpy(uuid_bin + 4, &tmp16, 2);
++
++	tmp16 = cpu_to_le16(hextoul(uuid_str + 14, NULL));
++	memcpy(uuid_bin + 6, &tmp16, 2);
++
++	tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
++	memcpy(uuid_bin + 8, &tmp16, 2);
++
++	tmp64 = cpu_to_le64(simple_strtoull(uuid_str + 24, NULL, 16));
++	memcpy(uuid_bin + 10, &tmp64, 6);
++
++	return 0;
++}
++
+ /*
+  * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
+  *
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch
similarity index 69%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch
index 64653b3..774af44 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch
@@ -1,11 +1,11 @@
-From 4729efd57e260b8c02d8cd1c30a443d29885dbd1 Mon Sep 17 00:00:00 2001
+From 93e3267b19c5c5d27664ef133121db4b678ad72d Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Mon, 15 Aug 2022 15:00:44 +0100
-Subject: [PATCH 09/26] arm_ffa: introduce Arm FF-A low-level driver
+Date: Tue, 29 Nov 2022 14:40:05 +0000
+Subject: [PATCH 03/25] arm_ffa: introduce Arm FF-A low-level driver
 
-Add the driver implementing Arm Firmware Framework for Armv8-A v1.0
+Add the core driver implementing Arm Firmware Framework for Armv8-A v1.0
 
-The Firmware Framework for Arm A-profile processors (FF-A)
+The Firmware Framework for Arm A-profile processors (FF-A v1.0) [1]
 describes interfaces (ABIs) that standardize communication
 between the Secure World and Normal World leveraging TrustZone
 technology.
@@ -14,10 +14,16 @@
 on top of the SMCCC layer. The driver provides the FF-A ABIs needed for
 querying the FF-A framework from the secure world.
 
-32-bit version of the ABIs is supported and 64-bit version of FFA_RXTX_MAP
-and FFA_MSG_SEND_DIRECT_{REQ, RESP}.
+The driver uses SMC32 calling convention which means using the first
+32-bit data of the Xn registers.
 
-In u-boot FF-A design, FF-A is considered as a discoverable bus.
+All supported ABIs come with their 32-bit version except FFA_RXTX_MAP
+which has 64-bit version supported.
+
+Both 32-bit and 64-bit direct messaging are supported which allows both
+32-bit and 64-bit clients to use the FF-A bus.
+
+In U-Boot FF-A design, FF-A is considered as a discoverable bus.
 The Secure World is considered as one entity to communicate with
 using the FF-A bus. FF-A communication is handled by one device and
 one instance (the bus). This FF-A driver takes care of all the
@@ -31,16 +37,45 @@
 - sync_send_receive
 - rxtx_unmap
 
-This implementation provides an optional feature to copy the driver data
-to EFI runtime area.
+For more details please refer to the driver documentation [2].
+
+[1]: https://developer.arm.com/documentation/den0077/latest/
+[2]: doc/arch/arm64.ffa.rst
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v8:
+
+* make ffa_get_partitions_info() second argument to be an SP count in both
+  modes
+* update ffa_bus_prvdata_get() to return a pointer rather than a pointer
+  address
+* remove packing from ffa_partition_info and ffa_send_direct_data structures
+* pass the FF-A bus device to the bus operations
+
+v7:
+
+* add support for 32-bit direct messaging
+* rename be_uuid_str_to_le_bin() to uuid_str_to_le_bin()
+* improve the declaration of error handling mapping
+* stating in doc/arch/arm64.ffa.rst that EFI runtime is not supported
+
+v6:
+
+* drop use of EFI runtime support (We decided with Linaro to add this later)
+* drop discovery from initcalls (discovery will be on demand by FF-A users)
+* set the alignment of the RX/TX buffers to the larger translation granule size
+* move FF-A RX/TX buffers unmapping at ExitBootServices() to a separate commit
+* update the documentation and move it to doc/arch/arm64.ffa.rst
+
 v4:
 
 * add doc/README.ffa.drv
@@ -52,16 +87,16 @@
 * replacing panics with an error log and returning an error code
 * improving features discovery in FFA_FEATURES by introducing
   rxtx_min_pages private data field
-* add ffa_remove and ffa_bind functions
+* add ffa_remove and ffa_unbind functions
 * improve how the driver behaves when bus discovery is done more than
   once
 
 v3:
 
-* align the interfaces of the u-boot FF-A driver with those in the linux
+* align the interfaces of the U-Boot FF-A driver with those in the linux
   FF-A driver
 * remove the FF-A helper layer
-* make the u-boot FF-A driver independent from EFI
+* make the U-Boot FF-A driver independent from EFI
 * provide an optional config that enables copying the driver data to EFI
   runtime section at ExitBootServices service
 * use 64-bit version of FFA_RXTX_MAP, FFA_MSG_SEND_DIRECT_{REQ, RESP}
@@ -74,113 +109,105 @@
 v1:
 
 * introduce FF-A bus driver with device tree support
-
- MAINTAINERS                                   |    7 +
- common/board_r.c                              |    7 +
- doc/README.ffa.drv                            |  160 ++
- drivers/Kconfig                               |    2 +
- drivers/Makefile                              |    1 +
- drivers/firmware/arm-ffa/Kconfig              |   39 +
- drivers/firmware/arm-ffa/Makefile             |    7 +
- drivers/firmware/arm-ffa/arm-ffa-uclass.c     |   16 +
- drivers/firmware/arm-ffa/arm_ffa_prv.h        |  196 +++
- drivers/firmware/arm-ffa/core.c               | 1344 +++++++++++++++++
- .../arm-ffa/efi_ffa_runtime_data_mgr.c        |   94 ++
- include/arm_ffa.h                             |  127 ++
- include/dm/uclass-id.h                        |    1 +
- lib/efi_loader/efi_boottime.c                 |   12 +
- 14 files changed, 2013 insertions(+)
- create mode 100644 doc/README.ffa.drv
+---
+ MAINTAINERS                               |    7 +
+ doc/arch/arm64.ffa.rst                    |  218 ++++
+ doc/arch/index.rst                        |    1 +
+ drivers/Kconfig                           |    2 +
+ drivers/Makefile                          |    1 +
+ drivers/firmware/arm-ffa/Kconfig          |   30 +
+ drivers/firmware/arm-ffa/Makefile         |    6 +
+ drivers/firmware/arm-ffa/arm-ffa-uclass.c |   16 +
+ drivers/firmware/arm-ffa/arm_ffa_prv.h    |  200 ++++
+ drivers/firmware/arm-ffa/core.c           | 1315 +++++++++++++++++++++
+ include/arm_ffa.h                         |   97 ++
+ include/dm/uclass-id.h                    |    4 +
+ 12 files changed, 1897 insertions(+)
+ create mode 100644 doc/arch/arm64.ffa.rst
  create mode 100644 drivers/firmware/arm-ffa/Kconfig
  create mode 100644 drivers/firmware/arm-ffa/Makefile
  create mode 100644 drivers/firmware/arm-ffa/arm-ffa-uclass.c
  create mode 100644 drivers/firmware/arm-ffa/arm_ffa_prv.h
  create mode 100644 drivers/firmware/arm-ffa/core.c
- create mode 100644 drivers/firmware/arm-ffa/efi_ffa_runtime_data_mgr.c
  create mode 100644 include/arm_ffa.h
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index 7f27ff4c20..e760b4ca3a 100644
+index 83346183ee..734fcb10c4 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -244,6 +244,13 @@ F:	board/CZ.NIC/
- F:	configs/turris_*_defconfig
- F:	include/configs/turris_*.h
+@@ -248,6 +248,13 @@ F:	drivers/net/cortina_ni.h
+ F:	drivers/net/phy/ca_phy.c
+ F:	configs/cortina_presidio-asic-pnand_defconfig
  
 +ARM FF-A
 +M:	Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 +S:	Maintained
-+F:	doc/README.ffa.drv
++F:	doc/arch/arm64.ffa.rst
 +F:	drivers/firmware/arm-ffa/
 +F:	include/arm_ffa.h
 +
  ARM FREESCALE IMX
  M:	Stefano Babic <sbabic@denx.de>
  M:	Fabio Estevam <festevam@gmail.com>
-diff --git a/common/board_r.c b/common/board_r.c
-index 6f4aca2077..c75634286b 100644
---- a/common/board_r.c
-+++ b/common/board_r.c
-@@ -63,6 +63,10 @@
- #include <efi_loader.h>
- #include <relocate.h>
- 
-+#ifdef CONFIG_ARM_FFA_TRANSPORT
-+#include <arm_ffa.h>
-+#endif
-+
- DECLARE_GLOBAL_DATA_PTR;
- 
- ulong monitor_flash_len;
-@@ -779,6 +783,9 @@ static init_fnc_t init_sequence_r[] = {
- 	INIT_FUNC_WATCHDOG_RESET
- 	initr_net,
- #endif
-+#ifdef CONFIG_ARM_FFA_TRANSPORT
-+	ffa_bus_discover,
-+#endif
- #ifdef CONFIG_POST
- 	initr_post,
- #endif
-diff --git a/doc/README.ffa.drv b/doc/README.ffa.drv
+diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst
 new file mode 100644
-index 0000000000..1c0a33deb8
+index 0000000000..dfcec82e45
 --- /dev/null
-+++ b/doc/README.ffa.drv
-@@ -0,0 +1,160 @@
-+Arm FF-A Driver
-+====================
++++ b/doc/arch/arm64.ffa.rst
+@@ -0,0 +1,218 @@
++.. SPDX-License-Identifier: GPL-2.0+
 +
-+Introduction
-+--------------------
++Arm FF-A Driver
++===============
++
++Summary
++-------
 +
 +FF-A stands for Firmware Framework for Arm A-profile processors.
 +
-+FF-A specifies interfaces that enable a pair of software sandboxes to communicate with each other. A sandbox aka partition could
-+be a VM in the Normal or Secure world, an application in S-EL0, or a Trusted OS in S-EL1.
++FF-A specifies interfaces that enable a pair of software sandboxes to
++communicate with each other. A sandbox aka partition could
++be a VM in the Normal or Secure world, an application in S-EL0, or a
++Trusted OS in S-EL1.
 +
-+This FF-A driver implements the interfaces to communicate with partitions in the Secure world aka Secure partitions (SPs).
++This FF-A driver implements the interfaces to communicate with partitions in
++the Secure world aka Secure partitions (SPs).
 +
-+The driver specifically focuses on communicating with SPs that isolate portions of EFI runtime services that must run in a
-+protected environment which is inaccessible by the Host OS or Hypervisor. Examples of such services are set/get variables.
++The driver specifically focuses on communicating with SPs that isolate portions
++of EFI runtime services that must run in a protected environment which is
++inaccessible by the Host OS or Hypervisor. Examples of such services are
++set/get variables.
 +
 +FF-A driver uses the SMC ABIs defined by the FF-A specification to:
 +
-+- Discover the presence of SPs of interest.
-+- Access an SP's service through communication protocols e.g. EFI MM communication protocol.
++- Discover the presence of SPs of interest
++- Access an SP's service through communication protocols
++  e.g. EFI MM communication protocol
++
++At this stage of development the FF-A driver supports EFI boot time only.
++
++Runtime support will be added in future developments.
 +
 +FF-A and SMC specifications
 +-------------------------------------------
 +
-+The current implementation of the driver relies on FF-A specification v1.0 and uses SMC32 calling convention.
++The current implementation of the driver relies on FF-A specification v1.0
++and uses SMC32 calling convention which means using the first 32-bit data of the
++Xn registers.
 +
-+The driver has been tested with Optee OS which supports SMC32 for most of the SMC ABIs.
++At this stage we only need the FF-A v1.0 features.
 +
-+For more details please refer to: https://developer.arm.com/documentation/den0077/a/?lang=en
++The driver has been tested with OP-TEE which supports SMC32 calling convention.
++
++For more details please refer to the FF-A v1.0 spec:
++https://documentation-service.arm.com/static/5fb7e8a6ca04df4095c1d65e?token=
++
++Hypervisors are supported if they are configured to trap SMC calls.
 +
 +The FF-A driver uses 64-bit registers as per SMCCCv1.2 specification.
 +
-+For more details please refer to: https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token=
++For more details please refer to the SMC Calling Convention v1.2 spec:
++https://documentation-service.arm.com/static/5f8edaeff86e16515cdbe4c6?token=
 +
 +Supported hardware
 +--------------------------------
@@ -191,60 +218,90 @@
 +----------------------
 +
 +CONFIG_ARM_FFA_TRANSPORT
-+    Enables the FF-A bus driver. Turn this on if you want to use FF-A communication.
-+
-+CONFIG_ARM_FFA_EFI_RUNTIME_MODE
-+    Optional config that enables EFI runtime support for FF-A data and code.
-+    ffa_copy_runtime_data allows to copy the FF-A driver data structures to EFI runtime data section.
-+    Turning the config on makes ffa_copy_runtime_data available for use and the driver code placed at EFI runtime code section.
-+    Call ffa_copy_runtime_data at the event on which you want the FF-A data to be copied (example: at ExitBootServices).
++    Enables the FF-A bus driver. Turn this on if you want to use FF-A
++    communication.
 +
 +CONFIG_SANDBOX_FFA
-+    Enables FF-A Sandbox driver. This emulates the FF-A ABIs handling under Sandbox and provides
-+    functional tests for FF-A.
++    Enables FF-A Sandbox driver. This emulates the FF-A ABIs handling under
++    Sandbox and provides functional tests for FF-A.
 +
 +FF-A ABIs under the hood
 +---------------------------------------
 +
-+Invoking an FF-A ABI involves providing to the secure world/hypervisor the expected arguments from the ABI.
++Invoking an FF-A ABI involves providing to the secure world/hypervisor the
++expected arguments from the ABI.
 +
-+The ABI arguments are stored in x0 to x7 registers. Then, an SMC instruction is executed.
++The ABI arguments are stored in x0 to x7 registers. Then, an SMC instruction
++is executed.
 +
-+At the secure side level or hypervisor the ABI is handled at a higher exception level and the arguments are read and processed.
++At the secure side level or hypervisor the ABI is handled at a higher exception
++level and the arguments are read and processed.
 +
-+The response is put back through x0 to x7 registers and control is giving back to the u-boot FF-A driver (non secure world).
++The response is put back through x0 to x7 registers and control is given back
++to the U-Boot FF-A driver (non-secure world).
 +
 +The driver reads the response and processes it accordingly.
 +
 +This methodology applies to all the FF-A ABIs in the driver.
 +
-+FF-A bus discovery in u-boot
++FF-A bus discovery in U-Boot
 +-------------------------------------------
 +
-+When CONFIG_ARM_FFA_TRANSPORT is enabled, the FF-A bus is automatically discovered at initcall level (after u-boot relocation).
++When CONFIG_ARM_FFA_TRANSPORT is enabled, the FF-A bus is discovered on
++demand by the clients (users).
 +
-+The function that triggers the discovery process is ffa_bus_discover.
++Clients can discover the FF-A bus using ffa_bus_discover() API which triggers the
++discovery process.
 +
-+ffa_bus_discover creates, binds and probes the arm_ffa device using device_{bind, probe} APIs.
++ffa_bus_discover() creates, binds and probes the arm_ffa device using
++device_{bind, probe} APIs.
 +
-+When the device is probed, ffa_probe is called which tries to communicate with the secure world or hypervisor.
++The discovery process consists in communicating with secure world (or hypervisor)
++and querying specific data.
 +
-+The FF-A bus is usable when these checks succeed:
++The discovery process takes place during the arm_ffa device probing which is
++handled by ffa_probe().
++
++The FF-A bus discovery is successful and the bus is ready for use when these
++operations succeed:
 +
 +- querying the FF-A framework version
-+- querying from secure world the u-boot endpoint ID
-+- querying from secure world the supported features of the specified FF-A calls
++- querying from secure world the U-Boot endpoint ID
++- querying from secure world the RX/TX mapping  features
 +- mapping the RX/TX buffers
 +- querying from secure world all the partitions information
 +
-+Probing fails when any of these operations fail. The FF-A bus discovery succeeds when probing is successful.
++Discovery failure results in a probing failure and the arm_ffa device is
++destroyed.
 +
-+When discovery fails the arm_ffa device is destroyed.
++Requirements for clients
++-------------------------------------
++
++When using the FF-A bus with EFI, clients must:
++
++- Query SPs in EFI boot time mode using the service UUID.
++- Unmap RX/TX buffers before EFI runtime mode starts.
++
++The RX/TX buffers are only available at EFI boot time. Querying partitions is
++done at boot time and data is cached for future use.
++
++RX/TX buffers should be unmapped by the user before EFI runtime mode
++starts. The driver provides a bus operation for that: rxtx_unmap()
++
++If  RX/TX buffers created by U-Boot are not unmapped and by
++consequence becoming available at EFI runtime, secure world will get confused
++about RX/TX buffers ownership (U-Boot vs kernel).
++
++When invoking FF-A direct messaging, clients should specify which ABI protocol
++they want to use (32-bit vs 64-bit). Selecting the protocol means using
++the 32-bit or 64-bit version of FFA_MSG_SEND_DIRECT_{REQ, RESP}.
++The calling convention stays the same: SMC32.
 +
 +The bus driver layer
 +------------------------------
 +
-+The driver comes on top of the SMCCC layer and is implemented in drivers/firmware/arm-ffa/core.c
++The driver comes on top of the SMCCC layer and is implemented in
++drivers/firmware/arm-ffa/core.c
 +
 +The driver provides the following features:
 +
@@ -260,6 +317,8 @@
 +FFA_ERROR
 +FFA_SUCCESS
 +FFA_INTERRUPT
++FFA_MSG_SEND_DIRECT_REQ
++FFA_MSG_SEND_DIRECT_RESP
 +
 +- Support for the 64-bit version of the following ABIs:
 +
@@ -269,8 +328,9 @@
 +
 +- Processing the received data from the secure world/hypervisor and caching it
 +
-+- Hiding from upper layers the FF-A protocol and registers details. Upper layers focus on exchanged data,
-+the driver takes care of how to transport that to the secure world/hypervisor using FF-A.
++- Hiding from upper layers the FF-A protocol and registers details. Upper
++  layers focus on exchanged data, the driver takes care of how to transport
++  that to the secure world/hypervisor using FF-A
 +
 +- The driver provides callbacks to be used by clients to access the FF-A bus:
 +
@@ -278,18 +338,19 @@
 +sync_send_receive
 +rxtx_unmap
 +
-+- FF-A bus discovery at initcalls level (after u-boot relocation). The bus is up and running if the FF-A framework is responsive and compatible with the driver.
++- FF-A bus discovery makes sure FF-A framework is responsive and compatible
++  with the driver
 +
-+- When EFI is enabled, unmap the RX/TX buffers at ExitBootServices() level.
-+
-+- When CONFIG_ARM_FFA_EFI_RUNTIME_MODE enabled, ffa_copy_runtime_data function is available for use.
++- FF-A bus can be compiled and used without EFI
 +
 +Using armffa command
 +-----------------------------------
 +
-+armffa is a command showcasing how to use the FF-A driver and how to invoke its operations.
++armffa is an implementation defined command showcasing how to use the FF-A driver and how to invoke
++its operations.
 +
-+This provides a guidance to the client developers on how to call the FF-A bus interfaces.
++This provides a guidance to the client developers on how to call the FF-A bus
++interfaces.
 +
 +Usage:
 +
@@ -308,8 +369,24 @@
 +        devlist
 +
 +            displays the arm_ffa device info
++
++Contributors
++------------
++   * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+diff --git a/doc/arch/index.rst b/doc/arch/index.rst
+index 792d9182c3..8d1ab0ad4e 100644
+--- a/doc/arch/index.rst
++++ b/doc/arch/index.rst
+@@ -8,6 +8,7 @@ Architecture-specific doc
+ 
+    arc
+    arm64
++   arm64.ffa
+    m68k
+    mips
+    nios2
 diff --git a/drivers/Kconfig b/drivers/Kconfig
-index b26ca8cf70..4a602517bf 100644
+index 8b6fead351..b06b1ae481 100644
 --- a/drivers/Kconfig
 +++ b/drivers/Kconfig
 @@ -6,6 +6,8 @@ source "drivers/core/Kconfig"
@@ -322,10 +399,10 @@
  
  source "drivers/axi/Kconfig"
 diff --git a/drivers/Makefile b/drivers/Makefile
-index 67c8af7442..77db8736e6 100644
+index eba9940231..c3bfad94ac 100644
 --- a/drivers/Makefile
 +++ b/drivers/Makefile
-@@ -109,6 +109,7 @@ obj-y += iommu/
+@@ -110,6 +110,7 @@ obj-y += iommu/
  obj-y += smem/
  obj-y += thermal/
  obj-$(CONFIG_TEE) += tee/
@@ -335,10 +412,10 @@
  obj-$(CONFIG_W1) += w1/
 diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig
 new file mode 100644
-index 0000000000..aceb61cf49
+index 0000000000..e4914b9bc7
 --- /dev/null
 +++ b/drivers/firmware/arm-ffa/Kconfig
-@@ -0,0 +1,39 @@
+@@ -0,0 +1,30 @@
 +# SPDX-License-Identifier: GPL-2.0
 +
 +config ARM_FFA_TRANSPORT
@@ -360,37 +437,27 @@
 +
 +	  https://developer.arm.com/documentation/den0077/a/?lang=en
 +
-+	  In u-boot FF-A design, FF-A is considered as a discoverable bus.
++	  In U-Boot FF-A design, FF-A is considered as a discoverable bus.
 +	  The Secure World is considered as one entity to communicate with
 +	  using the FF-A bus.
 +	  FF-A communication is handled by one device and one instance (the bus).
 +	  This FF-A driver takes care of all the interactions between Normal world
 +	  and Secure World.
 +
-+	  For more details about the FF-A driver, please refer to doc/README.ffa.drv
++	  For more details about the FF-A driver, please refer to doc/arch/arm64.ffa.rst
 +
-+config ARM_FFA_EFI_RUNTIME_MODE
-+	bool "Enable EFI runtime support for FF-A data and code"
-+	depends on ARM_FFA_TRANSPORT && EFI_LOADER
-+	help
-+	  Allows FF-A driver data structures and code to be accessible at EFI runtime.
-+	  FF-A data is copied by ffa_copy_runtime_data function.
-+	  The driver Code needed at runtime is placed at EFI runtime code section.
-+	  Turning this on makes ffa_copy_runtime_data available for use and the driver
-+	  code placed at EFI runtime code section.
 diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile
 new file mode 100644
-index 0000000000..0b9b0a61b4
+index 0000000000..043a8915be
 --- /dev/null
 +++ b/drivers/firmware/arm-ffa/Makefile
-@@ -0,0 +1,7 @@
+@@ -0,0 +1,6 @@
 +# SPDX-License-Identifier: GPL-2.0+
 +#
-+# (C) Copyright 2022 Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-+#
++# (C) Copyright 2022
++# Abdellatif El Khlifi, Arm Limited, abdellatif.elkhlifi@arm.com.
 +
 +obj-y += arm-ffa-uclass.o core.o
-+obj-$(CONFIG_ARM_FFA_EFI_RUNTIME_MODE) += efi_ffa_runtime_data_mgr.o
 diff --git a/drivers/firmware/arm-ffa/arm-ffa-uclass.c b/drivers/firmware/arm-ffa/arm-ffa-uclass.c
 new file mode 100644
 index 0000000000..7d9695d289
@@ -415,10 +482,10 @@
 +};
 diff --git a/drivers/firmware/arm-ffa/arm_ffa_prv.h b/drivers/firmware/arm-ffa/arm_ffa_prv.h
 new file mode 100644
-index 0000000000..7bc90f7f66
+index 0000000000..4eea7dc036
 --- /dev/null
 +++ b/drivers/firmware/arm-ffa/arm_ffa_prv.h
-@@ -0,0 +1,196 @@
+@@ -0,0 +1,200 @@
 +/* SPDX-License-Identifier: GPL-2.0+ */
 +/*
 + * (C) Copyright 2022 ARM Limited
@@ -485,27 +552,36 @@
 +#define FFA_SMC_64(func_num)				FFA_SMC(ARM_SMCCC_SMC_64, (func_num))
 +
 +enum ffa_abis {
-+	FFA_ERROR					= 0x60,
-+	FFA_SUCCESS					= 0x61,
-+	FFA_INTERRUPT				= 0x62,
-+	FFA_VERSION					= 0x63,
-+	FFA_FEATURES				= 0x64,
-+	FFA_RX_RELEASE				= 0x65,
-+	FFA_RXTX_MAP				= 0x66,
-+	FFA_RXTX_UNMAP			= 0x67,
-+	FFA_PARTITION_INFO_GET		= 0x68,
-+	FFA_ID_GET					= 0x69,
-+	FFA_RUN						= 0x6D,
-+	FFA_MSG_SEND_DIRECT_REQ	= 0x6F,
-+	FFA_MSG_SEND_DIRECT_RESP	= 0x70,
++	FFA_ERROR                 = 0x60,
++	FFA_SUCCESS               = 0x61,
++	FFA_INTERRUPT             = 0x62,
++	FFA_VERSION               = 0x63,
++	FFA_FEATURES              = 0x64,
++	FFA_RX_RELEASE            = 0x65,
++	FFA_RXTX_MAP              = 0x66,
++	FFA_RXTX_UNMAP            = 0x67,
++	FFA_PARTITION_INFO_GET    = 0x68,
++	FFA_ID_GET                = 0x69,
++	FFA_RUN                   = 0x6D,
++	FFA_MSG_SEND_DIRECT_REQ   = 0x6F,
++	FFA_MSG_SEND_DIRECT_RESP  = 0x70,
 +
 +	/* to be updated when adding new FFA IDs */
-+	FFA_FIRST_ID = FFA_ERROR, /* lowest number ID*/
-+	FFA_LAST_ID = FFA_MSG_SEND_DIRECT_RESP, /* highest number ID*/
++	FFA_FIRST_ID              = FFA_ERROR, /* lowest number ID*/
++	FFA_LAST_ID               = FFA_MSG_SEND_DIRECT_RESP, /* highest number ID*/
 +};
 +
-+/* number of the errors supported by the FF-A specification */
-+#define MAX_NUMBER_FFA_ERR 9
++enum ffa_abi_errcode {
++	NOT_SUPPORTED = 1,
++	INVALID_PARAMETERS,
++	NO_MEMORY,
++	BUSY,
++	INTERRUPTED,
++	DENIED,
++	RETRY,
++	ABORTED,
++	MAX_NUMBER_FFA_ERR
++};
 +
 +/* container structure and helper macros to map between an FF-A error and relevant error log */
 +struct ffa_abi_errmap {
@@ -605,22 +681,17 @@
 +};
 +
 +/**
-+ * ffa_device_get - create, bind and probe the arm_ffa device
-+ */
-+int ffa_device_get(void);
-+
-+/**
 + * ffa_bus_prvdata_get - bus driver private data getter
 + */
-+struct ffa_prvdata **ffa_bus_prvdata_get(void);
++struct ffa_prvdata *ffa_bus_prvdata_get(void);
 +
 +#endif
 diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c
 new file mode 100644
-index 0000000000..41c7b96e68
+index 0000000000..0b1f8e6a07
 --- /dev/null
 +++ b/drivers/firmware/arm-ffa/core.c
-@@ -0,0 +1,1344 @@
+@@ -0,0 +1,1315 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * (C) Copyright 2022 ARM Limited
@@ -644,115 +715,83 @@
 +DECLARE_GLOBAL_DATA_PTR;
 +
 +/**
-+ * The device private data structure containing all the resident
++ * The device private data structure containing all the
 + * data read from secure world
 + */
-+__ffa_runtime_data struct ffa_prvdata *ffa_priv_data;
++struct ffa_prvdata *ffa_priv_data;
 +
 +/* Error mapping declarations */
 +
-+__ffa_runtime_data int ffa_to_std_errmap[MAX_NUMBER_FFA_ERR] = {
-+	0,
-+	-EOPNOTSUPP,	/* NOT_SUPPORTED */
-+	-EINVAL,	/* INVALID_PARAMETERS */
-+	-ENOMEM,	/* NO_MEMORY */
-+	-EBUSY,		/* BUSY */
-+	-EINTR,		/* INTERRUPTED */
-+	-EACCES,	/* DENIED */
-+	-EAGAIN,	/* RETRY */
-+	-ECANCELED,	/* ABORTED */
++int ffa_to_std_errmap[MAX_NUMBER_FFA_ERR] = {
++	[NOT_SUPPORTED] = -EOPNOTSUPP,
++	[INVALID_PARAMETERS] = -EINVAL,
++	[NO_MEMORY] = -ENOMEM,
++	[BUSY] = -EBUSY,
++	[INTERRUPTED] = -EINTR,
++	[DENIED] = -EACCES,
++	[RETRY] = -EAGAIN,
++	[ABORTED] = -ECANCELED,
 +};
 +
 +struct ffa_abi_errmap err_msg_map[FFA_ERRMAP_COUNT] = {
 +	[FFA_ID_TO_ERRMAP_ID(FFA_VERSION)] = {
 +		{
-+			"",
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: A Firmware Framework implementation does not exist",
-+			"", /* INVALID_PARAMETERS */
-+			"", /* NO_MEMORY */
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
-+			"", /* DENIED */
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_ID_GET)] = {
 +		{
-+			"",
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: This function is not implemented at this FF-A instance",
-+			"", /* INVALID_PARAMETERS */
-+			"", /* NO_MEMORY */
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
-+			"", /* DENIED */
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_FEATURES)] = {
 +		{
-+			"",
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: FFA_RXTX_MAP is not implemented at this FF-A instance",
-+			"", /* INVALID_PARAMETERS */
-+			"", /* NO_MEMORY */
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
-+			"", /* DENIED */
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_PARTITION_INFO_GET)] = {
 +		{
-+			"",
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: This function is not implemented at this FF-A instance",
++			[INVALID_PARAMETERS] =
 +			"INVALID_PARAMETERS: Unrecognized UUID",
++			[NO_MEMORY] =
 +			"NO_MEMORY: Results cannot fit in RX buffer of the caller",
++			[BUSY] =
 +			"BUSY: RX buffer of the caller is not free",
-+			"", /* INTERRUPTED */
++			[DENIED] =
 +			"DENIED: Callee is not in a state to handle this request",
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_RXTX_UNMAP)] = {
-+			{
-+			"",
++		{
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: FFA_RXTX_UNMAP is not implemented at this FF-A instance",
++			[INVALID_PARAMETERS] =
 +			"INVALID_PARAMETERS: No buffer pair registered on behalf of the caller",
-+			"", /* NO_MEMORY */
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
-+			"", /* DENIED */
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_RX_RELEASE)] = {
-+			{
-+			"",
++		{
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: FFA_RX_RELEASE is not implemented at this FF-A instance",
-+			"", /* INVALID_PARAMETERS */
-+			"", /* NO_MEMORY */
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
++			[DENIED] =
 +			"DENIED: Caller did not have ownership of the RX buffer",
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +	[FFA_ID_TO_ERRMAP_ID(FFA_RXTX_MAP)] = {
-+			{
-+			"",
++		{
++			[NOT_SUPPORTED] =
 +			"NOT_SUPPORTED: This function is not implemented at this FF-A instance",
++			[INVALID_PARAMETERS] =
 +			"INVALID_PARAMETERS: Field(s) in input parameters incorrectly encoded",
++			[NO_MEMORY] =
 +			"NO_MEMORY: Not enough memory",
-+			"", /* BUSY */
-+			"", /* INTERRUPTED */
++			[DENIED] =
 +			"DENIED: Buffer pair already registered",
-+			"", /* RETRY */
-+			"", /* ABORTED */
 +		},
 +	},
 +};
@@ -761,14 +800,14 @@
 + * ffa_to_std_errno - convert FF-A error code to standard error code
 + * @ffa_errno:	Error code returned by the FF-A ABI
 + *
-+ * This runtime function maps the given FF-A error code as specified
++ * This function maps the given FF-A error code as specified
 + * by the spec to a u-boot standard error code.
 + *
 + * Return:
 + *
 + * The standard error code on success. . Otherwise, failure
 + */
-+__ffa_runtime int ffa_to_std_errno(int ffa_errno)
++int ffa_to_std_errno(int ffa_errno)
 +{
 +	int err_idx = -ffa_errno;
 +
@@ -783,7 +822,7 @@
 + * @ffa_id:	FF-A ABI ID
 + * @ffa_errno:	Error code returned by the FF-A ABI
 + *
-+ * This boot time function maps the FF-A error code to the error log relevant to the
++ * This function maps the FF-A error code to the error log relevant to the
 + * selected FF-A ABI. Then the error log is printed.
 + *
 + * Return:
@@ -806,7 +845,7 @@
 +	if (abi_idx < 0 || abi_idx >= FFA_ERRMAP_COUNT)
 +		return -EINVAL;
 +
-+	if (!err_msg_map[abi_idx].err_str || !err_msg_map[abi_idx].err_str[err_idx])
++	if (!err_msg_map[abi_idx].err_str[err_idx])
 +		return -EINVAL;
 +
 +	ffa_err("%s", err_msg_map[abi_idx].err_str[err_idx]);
@@ -822,7 +861,7 @@
 + * ffa_remove_device - removes the arm_ffa device
 + * @dev:	the device to be removed
 + *
-+ * This boot time function makes sure the arm_ffa device is removed
++ * This function makes sure the arm_ffa device is removed
 + * No need to free the kmalloced data when the device is destroyed.
 + * It's automatically done by devm management by
 + * device_remove() -> device_free() -> devres_release_probe().
@@ -861,26 +900,24 @@
 +
 +/**
 + * ffa_device_get - create, bind and probe the arm_ffa device
++ * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created
++ *       successfully)
 + *
-+ * This boot time function makes sure the arm_ffa device is
++ * This function makes sure the arm_ffa device is
 + * created, bound to this driver, probed and ready to use.
-+ * Arm FF-A transport is implemented through a single u-boot
++ * Arm FF-A transport is implemented through a single U-Boot
 + * device managing the FF-A bus (arm_ffa).
 + *
 + * Return:
 + *
 + * 0 on success. Otherwise, failure
 + */
-+int ffa_device_get(void)
++int ffa_device_get(struct udevice **pdev)
 +{
 +	int ret;
 +	struct udevice *dev = NULL;
 +
-+	ret = device_bind(dm_root(),
-+			  DM_DRIVER_GET(arm_ffa),
-+			  FFA_DRV_NAME,
-+			  NULL,
-+			  ofnode_null(),
++	ret = device_bind(dm_root(), DM_DRIVER_GET(arm_ffa), FFA_DRV_NAME, NULL, ofnode_null(),
 +			  &dev);
 +	if (ret)
 +		return ret;
@@ -893,13 +930,16 @@
 +		return ret;
 +	}
 +
++	if (pdev)
++		*pdev = dev;
++
 +	return 0;
 +}
 +
 +/**
 + * ffa_get_version - FFA_VERSION handler function
 + *
-+ * This is the boot time function that implements FFA_VERSION FF-A function
++ * This function implements FFA_VERSION FF-A function
 + * to get from the secure world the FF-A framework version
 + *
 + * Return:
@@ -913,18 +953,17 @@
 +	int ffa_errno;
 +
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
-+			.a0 = FFA_SMC_32(FFA_VERSION),
-+			.a1 = FFA_VERSION_1_0, .a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
++			.a0 = FFA_SMC_32(FFA_VERSION), .a1 = FFA_VERSION_1_0,
 +			}, &res);
 +
-+	ffa_errno = (int)res.a0;
++	ffa_errno = res.a0;
 +	if (ffa_errno < 0) {
 +		ffa_print_error_log(FFA_VERSION, ffa_errno);
 +		return ffa_to_std_errno(ffa_errno);
 +	}
 +
-+	major = GET_FFA_MAJOR_VERSION((u32)res.a0);
-+	minor = GET_FFA_MINOR_VERSION((u32)res.a0);
++	major = GET_FFA_MAJOR_VERSION(res.a0);
++	minor = GET_FFA_MINOR_VERSION(res.a0);
 +
 +	ffa_info("FF-A driver %d.%d\nFF-A framework %d.%d",
 +		 FFA_MAJOR_VERSION, FFA_MINOR_VERSION, major, minor);
@@ -932,7 +971,7 @@
 +	if ((major == FFA_MAJOR_VERSION && minor >= FFA_MINOR_VERSION)) {
 +		ffa_info("Versions are compatible ");
 +
-+		ffa_priv_data->fwk_version = (u32)res.a0;
++		ffa_priv_data->fwk_version = res.a0;
 +
 +		return 0;
 +	}
@@ -946,7 +985,7 @@
 +/**
 + * ffa_get_endpoint_id - FFA_ID_GET handler function
 + *
-+ * This is the boot time function that implements FFA_ID_GET FF-A function
++ * This function implements FFA_ID_GET FF-A function
 + * to get from the secure world u-boot endpoint ID
 + *
 + * Return:
@@ -960,7 +999,6 @@
 +
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
 +			.a0 = FFA_SMC_32(FFA_ID_GET),
-+			.a1 = 0, .a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -970,7 +1008,7 @@
 +		return 0;
 +	}
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +
 +	ffa_print_error_log(FFA_ID_GET, ffa_errno);
 +
@@ -981,7 +1019,7 @@
 + * ffa_set_rxtx_buffers_pages_cnt - sets the minimum number of pages in each of the RX/TX buffers
 + * @prop_field: properties field obtained from FFA_FEATURES ABI
 + *
-+ * This boot time function sets the minimum number of pages
++ * This function sets the minimum number of pages
 + *  in each of the RX/TX buffers in the private data structure
 + *
 + * Return:
@@ -1015,7 +1053,7 @@
 +/**
 + * ffa_get_rxtx_map_features - FFA_FEATURES handler function with FFA_RXTX_MAP argument
 + *
-+ * This is the boot time function that implements FFA_FEATURES FF-A function
++ * This function implements FFA_FEATURES FF-A function
 + * to retrieve the FFA_RXTX_MAP features
 + *
 + * Return:
@@ -1030,13 +1068,12 @@
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
 +			.a0 = FFA_SMC_32(FFA_FEATURES),
 +			.a1 = FFA_SMC_64(FFA_RXTX_MAP),
-+			.a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS))
-+		return ffa_set_rxtx_buffers_pages_cnt((u32)res.a2);
++		return ffa_set_rxtx_buffers_pages_cnt(res.a2);
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	ffa_print_error_log(FFA_FEATURES, ffa_errno);
 +
 +	return ffa_to_std_errno(ffa_errno);
@@ -1045,7 +1082,7 @@
 +/**
 + * ffa_free_rxtx_buffers - frees the RX/TX buffers
 + *
-+ * This is the boot time function used to free the RX/TX buffers
++ * This  function  frees the RX/TX buffers
 + *
 + */
 +static void ffa_free_rxtx_buffers(void)
@@ -1066,7 +1103,7 @@
 +/**
 + * ffa_alloc_rxtx_buffers - allocates the RX/TX buffers
 + *
-+ * This is the boot time function used by ffa_map_rxtx_buffers to allocate
++ * This function is used by ffa_map_rxtx_buffers to allocate
 + * the RX/TX buffers before mapping them. The allocated memory is physically
 + * contiguous since memalign ends up calling malloc which allocates
 + * contiguous memory in u-boot.
@@ -1084,9 +1121,12 @@
 +
 +	bytes = ffa_priv_data->pair.rxtx_min_pages * SZ_4K;
 +
-+	/* RX/TX buffers addresses should be PAGE_SIZE aligned */
++	/*
++	 * The alignment of the RX and TX buffers must be equal
++	 * to the larger translation granule size
++	 */
 +
-+	ffa_priv_data->pair.rxbuf = (u64)memalign(PAGE_SIZE, bytes);
++	ffa_priv_data->pair.rxbuf = (u64)memalign(bytes, bytes);
 +	if (!ffa_priv_data->pair.rxbuf) {
 +		ffa_err("failure to allocate RX buffer");
 +		return -ENOBUFS;
@@ -1094,7 +1134,7 @@
 +
 +	ffa_info("RX buffer at virtual address 0x%llx", ffa_priv_data->pair.rxbuf);
 +
-+	ffa_priv_data->pair.txbuf = (u64)memalign(PAGE_SIZE, bytes);
++	ffa_priv_data->pair.txbuf = (u64)memalign(bytes, bytes);
 +	if (!ffa_priv_data->pair.txbuf) {
 +		free((void *)ffa_priv_data->pair.rxbuf);
 +		ffa_priv_data->pair.rxbuf = 0;
@@ -1116,7 +1156,7 @@
 +/**
 + * ffa_map_rxtx_buffers - FFA_RXTX_MAP handler function
 + *
-+ * This is the boot time function that implements FFA_RXTX_MAP FF-A function
++ * This function implements FFA_RXTX_MAP FF-A function
 + * to map the RX/TX buffers
 + *
 + * Return:
@@ -1136,7 +1176,7 @@
 +	/*
 +	 * we need to pass the physical addresses of the RX/TX buffers
 +	 * in u-boot physical/virtual mapping is 1:1
-+	 *no need to convert from virtual to physical
++	 * no need to convert from virtual to physical
 +	 */
 +
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
@@ -1144,7 +1184,6 @@
 +			.a1 = ffa_priv_data->pair.txbuf,
 +			.a2 = ffa_priv_data->pair.rxbuf,
 +			.a3 = ffa_priv_data->pair.rxtx_min_pages,
-+			.a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -1152,7 +1191,7 @@
 +		return 0;
 +	}
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	ffa_print_error_log(FFA_RXTX_MAP, ffa_errno);
 +
 +	ffa_free_rxtx_buffers();
@@ -1162,15 +1201,16 @@
 +
 +/**
 + * ffa_unmap_rxtx_buffers - FFA_RXTX_UNMAP handler function
++ *	@dev: The arm_ffa bus device
 + *
-+ * This is the boot time function that implements FFA_RXTX_UNMAP FF-A function
++ * This function implements FFA_RXTX_UNMAP FF-A function
 + * to unmap the RX/TX buffers
 + *
 + * Return:
 + *
 + * 0 on success. Otherwise, failure
 + */
-+static int ffa_unmap_rxtx_buffers(void)
++static int ffa_unmap_rxtx_buffers(struct udevice *dev)
 +{
 +	ffa_value_t res = {0};
 +	int ffa_errno;
@@ -1178,7 +1218,6 @@
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
 +			.a0 = FFA_SMC_32(FFA_RXTX_UNMAP),
 +			.a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id),
-+			.a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -1186,7 +1225,7 @@
 +		return 0;
 +	}
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	ffa_print_error_log(FFA_RXTX_UNMAP, ffa_errno);
 +
 +	return ffa_to_std_errno(ffa_errno);
@@ -1195,7 +1234,7 @@
 +/**
 + * ffa_release_rx_buffer - FFA_RX_RELEASE handler function
 + *
-+ * This is the boot time function that invokes FFA_RX_RELEASE FF-A function
++ * This function invokes FFA_RX_RELEASE FF-A function
 + * to release the ownership of the RX buffer
 + *
 + * Return:
@@ -1209,13 +1248,12 @@
 +
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
 +			.a0 = FFA_SMC_32(FFA_RX_RELEASE),
-+			.a1 = 0, .a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS))
 +		return 0;
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	ffa_print_error_log(FFA_RX_RELEASE, ffa_errno);
 +
 +	return ffa_to_std_errno(ffa_errno);
@@ -1226,20 +1264,20 @@
 + * @uuid1: first UUID
 + * @uuid2: second UUID
 + *
-+ * This is a boot time function used by ffa_read_partitions_info to search
++ * This function is used by ffa_read_partitions_info to search
 + * for a UUID in the partitions descriptors table
 + *
 + * Return:
 + *
 + * 1 when UUIDs match. Otherwise, 0
 + */
-+int ffa_uuid_are_identical(const struct ffa_partition_uuid *uuid1,
-+			   const struct ffa_partition_uuid *uuid2)
++bool ffa_uuid_are_identical(const struct ffa_partition_uuid *uuid1,
++			    const struct ffa_partition_uuid *uuid2)
 +{
 +	if (!uuid1 || !uuid2)
 +		return 0;
 +
-+	return (!memcmp(uuid1, uuid2, sizeof(struct ffa_partition_uuid)));
++	return !memcmp(uuid1, uuid2, sizeof(struct ffa_partition_uuid));
 +}
 +
 +/**
@@ -1248,7 +1286,7 @@
 + * @count: The number of partitions queried
 + * @part_uuid: Pointer to the partition(s) UUID
 + *
-+ * This is the boot time function that reads the partitions information
++ * This function reads the partitions information
 + * returned by the FFA_PARTITION_INFO_GET and saves it in the private
 + * data structure.
 + *
@@ -1288,8 +1326,8 @@
 +			return -ENOMEM;
 +		}
 +
-+		ffa_priv_data->partitions.descs = (struct ffa_partition_desc *)
-+			devm_kmalloc(ffa_priv_data->dev, data_bytes, __GFP_ZERO);
++		ffa_priv_data->partitions.descs = devm_kmalloc(ffa_priv_data->dev, data_bytes,
++							       __GFP_ZERO);
 +		if (!ffa_priv_data->partitions.descs) {
 +			ffa_err("cannot  allocate partitions data buffer");
 +			return -ENOMEM;
@@ -1357,7 +1395,7 @@
 + * @part_uuid: Pointer to the partition(s) UUID
 + * @pcount: Pointer to the number of partitions variable filled when querying
 + *
-+ * This is the boot time function that executes the FFA_PARTITION_INFO_GET
++ * This function executes the FFA_PARTITION_INFO_GET
 + * to query the partitions data. Then, it calls ffa_read_partitions_info
 + * to save the data in the private data structure.
 + *
@@ -1398,9 +1436,6 @@
 +			.a2 = query_uuid.a2,
 +			.a3 = query_uuid.a3,
 +			.a4 = query_uuid.a4,
-+			.a5 = 0,
-+			.a6 = 0,
-+			.a7 = 0,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -1435,7 +1470,7 @@
 +		return ret;
 +	}
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	ffa_print_error_log(FFA_PARTITION_INFO_GET, ffa_errno);
 +
 +	return ffa_to_std_errno(ffa_errno);
@@ -1448,19 +1483,21 @@
 + * Mode 1: When getting from the driver the number of
 + *	secure partitions:
 + *	@uuid_str: pointer to the UUID string
-+ *	@parts_size: pointer to the variable that contains the number of partitions
++ *	@sp_count: pointer to the variable that contains the number of partitions
 + *			 The variable will be set by the driver
 + *	@buffer: NULL
 + *
 + * Mode 2: When requesting the driver to return the
 + *	partitions information:
++ *	@dev: The arm_ffa bus device
 + *	@uuid_str: pointer to the UUID string
-+ *	@parts_size: pointer to the size of the SPs information buffer in bytes
++ *	@sp_count: pointer to the variable that contains the number of empty partition descriptors
++ *			 The variable will be read by the driver
 + *	@buffer: pointer to SPs information buffer
-+ *		(allocated by the client).
++ *		(allocated by the client and contains empty @sp_count descriptors).
 + *		The buffer will be filled by the driver
 + *
-+ * This is the boot time function that queries the secure partition data from
++ * This function queries the secure partition data from
 + * the private data structure. If not found, it invokes FFA_PARTITION_INFO_GET
 + * FF-A function to query the partition information from secure world.
 + *
@@ -1491,27 +1528,25 @@
 + *
 + * Return:
 + *
-+ * @parts_size: When pointing to the number of partitions variable, the number is
++ * @sp_count: When pointing to the number of partitions variable, the number is
 + * set by the driver.
 + * When pointing to the partitions information buffer size, the buffer will be
 + * filled by the driver.
 + *
 + * On success 0 is returned. Otherwise, failure
 + */
-+static int ffa_get_partitions_info(const char *uuid_str,
-+				   u32 *parts_size, struct ffa_partition_info *buffer)
++static int ffa_get_partitions_info(struct udevice *dev, const char *uuid_str,
++				   u32 *sp_count, struct ffa_partition_info *buffer)
 +{
 +	/*
 +	 * fill_data:
 +	 * 0: return the SP count
 +	 * 1: fill SP data and return it to the caller
-+	 * -1: undefined mode
 +	 */
-+	int fill_data = -1;
++	bool fill_data = 0;
 +	u32 desc_idx, client_desc_idx;
 +	struct ffa_partition_uuid part_uuid = {0};
-+	u32 client_desc_max_cnt;
-+	u32 parts_found = 0;
++	u32 sp_found = 0;
 +
 +	if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs) {
 +		ffa_err("no partition installed");
@@ -1523,12 +1558,12 @@
 +		return -EINVAL;
 +	}
 +
-+	if (!parts_size) {
++	if (!sp_count) {
 +		ffa_err("no size/count provided");
 +		return -EINVAL;
 +	}
 +
-+	if (be_uuid_str_to_le_bin(uuid_str, (unsigned char *)&part_uuid)) {
++	if (uuid_str_to_le_bin(uuid_str, (unsigned char *)&part_uuid)) {
 +		ffa_err("invalid UUID");
 +		return -EINVAL;
 +	}
@@ -1540,19 +1575,13 @@
 +
 +		ffa_info("Preparing for checking partitions count");
 +
-+	} else if ((*parts_size >= sizeof(struct ffa_partition_info)) &&
-+		   !(*parts_size % sizeof(struct ffa_partition_info))) {
++	} else if (*sp_count) {
 +		/* Mode 2: retrieving the partitions information */
 +
 +		fill_data = 1;
 +
 +		client_desc_idx = 0;
 +
-+		/*
-+		 * number of empty descriptors preallocated by the caller
-+		 */
-+		client_desc_max_cnt = *parts_size / sizeof(struct ffa_partition_info);
-+
 +		ffa_info("Preparing for filling partitions info");
 +
 +	} else {
@@ -1573,14 +1602,14 @@
 +			ffa_info("Partition ID %x matches the provided UUID",
 +				 ffa_priv_data->partitions.descs[desc_idx].info.id);
 +
-+			parts_found++;
++			sp_found++;
 +
 +			if (fill_data) {
 +				/*
 +				 * trying to fill the partition info in the input buffer
 +				 */
 +
-+				if (client_desc_idx < client_desc_max_cnt) {
++				if (client_desc_idx < *sp_count) {
 +					buffer[client_desc_idx++] =
 +						ffa_priv_data->partitions.descs[desc_idx].info;
 +					continue;
@@ -1592,27 +1621,28 @@
 +		}
 +	}
 +
-+	if (!parts_found) {
++	if (!sp_found) {
 +		int ret;
 +
 +		ffa_info("No partition found. Querying framework ...");
 +
-+		ret = ffa_query_partitions_info(&part_uuid, &parts_found);
++		ret = ffa_query_partitions_info(&part_uuid, &sp_found);
 +
 +		if (ret == 0) {
 +			if (!fill_data) {
-+				*parts_size = parts_found;
++				*sp_count = sp_found;
 +
 +				ffa_info("Number of partition(s) found matching the UUID: %d",
-+					 parts_found);
++					 sp_found);
 +			} else {
 +				/*
 +				 * If SPs data detected, they are already in the private data
 +				 * structure, retry searching SP data again to return them
 +				 *  to the caller
 +				 */
-+				if (parts_found)
-+					ret = ffa_get_partitions_info(uuid_str, parts_size, buffer);
++				if (sp_found)
++					ret = ffa_get_partitions_info(dev, uuid_str, sp_count,
++								      buffer);
 +				else
 +					ret = -ENODATA;
 +			}
@@ -1623,7 +1653,7 @@
 +
 +	/* partition(s) found */
 +	if (!fill_data)
-+		*parts_size = parts_found;
++		*sp_count = sp_found;
 +
 +	return 0;
 +}
@@ -1631,7 +1661,7 @@
 +/**
 + * ffa_cache_partitions_info - Queries and saves all secure partitions data
 + *
-+ * This is a boot time function that invokes FFA_PARTITION_INFO_GET FF-A
++ * This function invokes FFA_PARTITION_INFO_GET FF-A
 + * function to query from secure world all partitions information.
 + *
 + * The FFA_PARTITION_INFO_GET call is issued with nil UUID as an argument.
@@ -1653,10 +1683,12 @@
 +
 +/**
 + * ffa_msg_send_direct_req - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function
++ * @dev: The arm_ffa bus device
 + * @dst_part_id: destination partition ID
 + * @msg: pointer to the message data preallocated by the client (in/out)
++ * @is_smc64: select 64-bit or 32-bit FF-A ABI
 + *
-+ * This is the runtime function that implements FFA_MSG_SEND_DIRECT_{REQ,RESP}
++ * This function implements FFA_MSG_SEND_DIRECT_{REQ,RESP}
 + * FF-A functions.
 + *
 + * FFA_MSG_SEND_DIRECT_REQ is used to send the data to the secure partition.
@@ -1671,10 +1703,12 @@
 + *
 + * 0 on success. Otherwise, failure
 + */
-+static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_send_direct_data *msg)
++static int ffa_msg_send_direct_req(struct udevice *dev, u16 dst_part_id,
++				   struct ffa_send_direct_data *msg, bool is_smc64)
 +{
 +	ffa_value_t res = {0};
 +	int ffa_errno;
++	u64 req_mode, resp_mode;
 +
 +	if (!ffa_priv_data || !ffa_priv_data->invoke_ffa_fn)
 +		return -EINVAL;
@@ -1683,8 +1717,16 @@
 +	if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs)
 +		return -ENODEV;
 +
++	if (is_smc64) {
++		req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ);
++		resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP);
++	} else {
++		req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ);
++		resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP);
++	}
++
 +	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
-+			.a0 = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ),
++			.a0 = req_mode,
 +			.a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id) |
 +				PREP_PART_ENDPOINT_ID(dst_part_id),
 +			.a2 = 0,
@@ -1698,7 +1740,7 @@
 +	while (res.a0 == FFA_SMC_32(FFA_INTERRUPT))
 +		ffa_priv_data->invoke_ffa_fn((ffa_value_t){
 +			.a0 = FFA_SMC_32(FFA_RUN),
-+			.a1 = res.a1, .a2 = 0, .a3 = 0, .a4 = 0, .a5 = 0, .a6 = 0, .a7 = 0,
++			.a1 = res.a1,
 +			}, &res);
 +
 +	if (res.a0 == FFA_SMC_32(FFA_SUCCESS)) {
@@ -1706,7 +1748,7 @@
 +		return 0;
 +	}
 +
-+	if (res.a0 == FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP)) {
++	if (res.a0 == resp_mode) {
 +		/*
 +		 * Message sent with response
 +		 * extract the return data
@@ -1720,7 +1762,7 @@
 +		return 0;
 +	}
 +
-+	ffa_errno = (int)res.a2;
++	ffa_errno = res.a2;
 +	return ffa_to_std_errno(ffa_errno);
 +}
 +
@@ -1733,7 +1775,7 @@
 + *
 + * Return: void
 + */
-+void __ffa_runtime __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
++void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
 +{
 +	arm_smccc_1_2_smc(&args, res);
 +}
@@ -1741,7 +1783,7 @@
 +/**
 + * ffa_set_smc_conduit - Set the SMC conduit
 + *
-+ * This boot time function selects the SMC conduit by setting the driver invoke function
++ * This function selects the SMC conduit by setting the driver invoke function
 + * to SMC assembly function
 + *
 + * Return:
@@ -1779,7 +1821,7 @@
 + * ffa_alloc_prvdata - allocate the driver main data structure and sets the device
 + * @dev:	the arm_ffa device
 + *
-+ * This boot time function creates the main data structure embedding all the driver data.
++ * This function creates the main data structure embedding all the driver data.
 + *
 + * Return:
 + *
@@ -1879,7 +1921,7 @@
 +{
 +	ffa_info("removing the device");
 +
-+	ffa_unmap_rxtx_buffers();
++	ffa_unmap_rxtx_buffers(dev);
 +
 +	if (ffa_priv_data->pair.rxbuf || ffa_priv_data->pair.txbuf)
 +		ffa_free_rxtx_buffers();
@@ -1908,9 +1950,9 @@
 + * ffa_bus_ops_get - bus driver operations getter
 + *
 + * Return:
-+ * This runtime function returns a pointer to the driver operations structure
++ * This function returns a pointer to the driver operations structure
 + */
-+const struct ffa_bus_ops * __ffa_runtime ffa_bus_ops_get(void)
++const struct ffa_bus_ops *ffa_bus_ops_get(void)
 +{
 +	return &ffa_priv_data->ffa_ops;
 +}
@@ -1919,20 +1961,20 @@
 + * ffa_bus_prvdata_get - bus driver private data getter
 + *
 + * Return:
-+ * This boot time function returns a pointer to the main private data structure
++ * This function returns a pointer to the main private data structure
 + */
-+struct ffa_prvdata **ffa_bus_prvdata_get(void)
++struct ffa_prvdata *ffa_bus_prvdata_get(void)
 +{
-+	return &ffa_priv_data;
++	return ffa_priv_data;
 +}
 +
 +/**
-+ * ffa_bus_discover - discover FF-A bus and probe the arm_ffa device
++ * ffa_bus_discover - discover FF-A bus and probe arm_ffa device
++ * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created
++ *       successfully)
 + *
-+ * This boot time function makes sure the FF-A bus is discoverable.
-+ * Then, the arm_ffa device is probed and ready to use.
-+ * This function is called automatically at initcalls
-+ * level (after u-boot relocation).
++ * This function makes sure the FF-A bus is discoverable.
++ * When probing succeeds FF-A discovery is done. The arm_ffa device is ready to use.
 + *
 + * When the bus was already discovered successfully the discovery will not run again.
 + *
@@ -1944,12 +1986,12 @@
 + *
 + * 0 on success. Otherwise, failure
 + */
-+int ffa_bus_discover(void)
++int ffa_bus_discover(struct udevice **pdev)
 +{
 +	int ret = 0;
 +
-+	if (!ffa_priv_data)
-+		ret = ffa_device_get();
++	if (!ffa_priv_data) {
++		ret = ffa_device_get(pdev);
 +
 +	return ret;
 +}
@@ -1965,112 +2007,12 @@
 +	.remove		= ffa_remove,
 +	.unbind		= ffa_unbind,
 +};
-diff --git a/drivers/firmware/arm-ffa/efi_ffa_runtime_data_mgr.c b/drivers/firmware/arm-ffa/efi_ffa_runtime_data_mgr.c
-new file mode 100644
-index 0000000000..c76cf2147b
---- /dev/null
-+++ b/drivers/firmware/arm-ffa/efi_ffa_runtime_data_mgr.c
-@@ -0,0 +1,94 @@
-+// SPDX-License-Identifier: GPL-2.0+
-+/*
-+ * (C) Copyright 2022 ARM Limited
-+ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-+ */
-+
-+#include "arm_ffa_prv.h"
-+
-+/**
-+ * ffa_copy_runtime_data - copy the private data structure  to the runtime area
-+ *
-+ * This boot time function copies the arm_ffa driver data structures including
-+ *  partitions data to the EFI runtime data section.
-+ *
-+ * Return:
-+ *
-+ * 0 on success. Otherwise, failure
-+ */
-+efi_status_t ffa_copy_runtime_data(void)
-+{
-+	efi_status_t efi_ret;
-+	efi_uintn_t prvdata_pages;
-+	efi_uintn_t descs_pages;
-+	struct ffa_prvdata **prvdata = NULL; /* Pointer to the current structure */
-+	struct ffa_prvdata *runtime_prvdata = NULL; /* Pointer to the structure runtime copy */
-+	u64 runtime_descs = 0;
-+
-+	prvdata = ffa_bus_prvdata_get();
-+
-+	printf("INFO: EFI: FFA: prv data area at 0x%llx\n", (u64)prvdata);
-+
-+	/* allocate private data runtime area */
-+
-+	prvdata_pages = efi_size_in_pages(sizeof(struct ffa_prvdata));
-+	efi_ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
-+				     EFI_RUNTIME_SERVICES_DATA,
-+				     prvdata_pages,
-+				     (u64 *)&runtime_prvdata);
-+
-+	if (efi_ret != EFI_SUCCESS) {
-+		printf("ERROR: EFI: FFA: allocating runtime data (err: 0x%lx, addr 0x%llx)\n",
-+		       efi_ret, (u64)runtime_prvdata);
-+
-+		return efi_ret;
-+	}
-+
-+	printf("INFO: EFI: FFA: runtime data area at 0x%llx\n", (u64)runtime_prvdata);
-+
-+	if (!runtime_prvdata)
-+		return EFI_INVALID_PARAMETER;
-+
-+	/* allocate the partition data runtime area */
-+
-+	descs_pages = efi_size_in_pages((*prvdata)->partitions.count *
-+					sizeof(struct ffa_partition_desc));
-+	efi_ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
-+				     EFI_RUNTIME_SERVICES_DATA,
-+				     descs_pages,
-+				     &runtime_descs);
-+
-+	if (efi_ret != EFI_SUCCESS) {
-+		printf("ERROR: EFI: FFA: allocating runtime SPs data (err: 0x%lx, addr 0x%llx)\n",
-+		       efi_ret, runtime_descs);
-+
-+		efi_free_pages((u64)runtime_prvdata, prvdata_pages);
-+
-+		return efi_ret;
-+	}
-+
-+	printf("INFO: EFI: FFA: SPs runtime area at 0x%llx\n", (u64)runtime_descs);
-+
-+	if (!runtime_descs)
-+		return EFI_INVALID_PARAMETER;
-+
-+	*runtime_prvdata = **prvdata;
-+
-+	runtime_prvdata->dev = NULL;
-+	runtime_prvdata->ffa_ops.partition_info_get = NULL;
-+	runtime_prvdata->ffa_ops.rxtx_unmap = NULL;
-+	runtime_prvdata->partitions.descs = (struct ffa_partition_desc *)runtime_descs;
-+	runtime_prvdata->pair.rxbuf = 0;
-+	runtime_prvdata->pair.txbuf = 0;
-+
-+	/*
-+	 * Update the private data structure pointer in the driver
-+	 * no need to free the old structure. devm takes care of that
-+	 */
-+	*prvdata = runtime_prvdata;
-+
-+	printf("INFO: EFI: FFA: runtime prv data now at 0x%llx , SPs count %d\n",
-+	       (u64)*prvdata, (*prvdata)->partitions.count);
-+
-+	return 0;
-+}
 diff --git a/include/arm_ffa.h b/include/arm_ffa.h
 new file mode 100644
-index 0000000000..f17b100497
+index 0000000000..74b16174c2
 --- /dev/null
 +++ b/include/arm_ffa.h
-@@ -0,0 +1,127 @@
+@@ -0,0 +1,97 @@
 +/* SPDX-License-Identifier: GPL-2.0+ */
 +/*
 + * (C) Copyright 2022 ARM Limited
@@ -2103,7 +2045,7 @@
 + * Data structure containing information about partitions instantiated in the system
 + * This structure is filled with the data queried by FFA_PARTITION_INFO_GET
 + */
-+struct  __packed ffa_partition_info {
++struct ffa_partition_info {
 +	u16 id;
 +	u16 exec_ctxt;
 +/* partition supports receipt of direct requests */
@@ -2125,7 +2067,7 @@
 + */
 +
 +/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */
-+struct __packed ffa_send_direct_data {
++struct ffa_send_direct_data {
 +	unsigned long data0; /* w3/x3 */
 +	unsigned long data1; /* w4/x4 */
 +	unsigned long data2; /* w5/x5 */
@@ -2133,30 +2075,7 @@
 +	unsigned long data4; /* w7/x7 */
 +};
 +
-+#if CONFIG_IS_ENABLED(ARM_FFA_EFI_RUNTIME_MODE)
-+
-+#include <efi_loader.h>
-+
-+/*
-+ *  __ffa_runtime - controls whether functions are
-+ * available after calling the EFI ExitBootServices service.
-+ * Functions tagged with these keywords are resident (available at boot time and
-+ * at runtime)
-+ */
-+
-+#define __ffa_runtime_data __efi_runtime_data
-+#define __ffa_runtime __efi_runtime
-+
-+#else
-+
-+/*
-+ *  The FF-A driver is independent from EFI
-+ */
-+
-+#define __ffa_runtime_data
-+#define __ffa_runtime
-+
-+#endif
++struct udevice;
 +
 +/**
 + * struct ffa_bus_ops - The driver operations structure
@@ -2168,10 +2087,12 @@
 + * This structure is EFI runtime resident.
 + */
 +struct ffa_bus_ops {
-+	int (*partition_info_get)(const char *uuid_str,
-+				  u32 *parts_size, struct ffa_partition_info *buffer);
-+	int (*sync_send_receive)(u16 dst_part_id, struct ffa_send_direct_data *msg);
-+	int (*rxtx_unmap)(void);
++	int (*partition_info_get)(struct udevice *dev, const char *uuid_str,
++				  u32 *sp_count, struct ffa_partition_info *buffer);
++	int (*sync_send_receive)(struct udevice *dev, u16 dst_part_id,
++				 struct ffa_send_direct_data *msg,
++				 bool is_smc64);
++	int (*rxtx_unmap)(struct udevice *dev);
 +};
 +
 +/**
@@ -2181,65 +2102,36 @@
 +/**
 + * ffa_bus_ops_get - driver operations getter
 + */
-+const struct ffa_bus_ops * __ffa_runtime ffa_bus_ops_get(void);
++const struct ffa_bus_ops *ffa_bus_ops_get(void);
 +
 +/**
 + * ffa_bus_discover - discover FF-A bus and probes the arm_ffa device
 + */
-+int ffa_bus_discover(void);
-+
-+#if CONFIG_IS_ENABLED(ARM_FFA_EFI_RUNTIME_MODE)
-+
-+/**
-+ * ffa_copy_runtime_data - copy the private data structure and the SPs data to the runtime area
-+ */
-+efi_status_t ffa_copy_runtime_data(void);
-+
-+#endif
++int ffa_bus_discover(struct udevice **pdev);
 +
 +#endif
 diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
-index 3ba69ad9a0..7324418245 100644
+index a432e43871..5dd698b7a9 100644
 --- a/include/dm/uclass-id.h
 +++ b/include/dm/uclass-id.h
-@@ -55,6 +55,7 @@ enum uclass_id {
+@@ -4,6 +4,9 @@
+  *
+  * (C) Copyright 2012
+  * Pavel Herrmann <morpheus.ibis@gmail.com>
++ *
++ * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ 
+ #ifndef _DM_UCLASS_ID_H
+@@ -55,6 +58,7 @@ enum uclass_id {
  	UCLASS_EFI_MEDIA,	/* Devices provided by UEFI firmware */
  	UCLASS_ETH,		/* Ethernet device */
  	UCLASS_ETH_PHY,		/* Ethernet PHY device */
 +	UCLASS_FFA,		/* Arm Firmware Framework for Armv8-A */
  	UCLASS_FIRMWARE,	/* Firmware */
+ 	UCLASS_FUZZING_ENGINE,	/* Fuzzing engine */
  	UCLASS_FS_FIRMWARE_LOADER,		/* Generic loader */
- 	UCLASS_GPIO,		/* Bank of general-purpose I/O pins */
-diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index 4da64b5d29..0ec002ac8b 100644
---- a/lib/efi_loader/efi_boottime.c
-+++ b/lib/efi_loader/efi_boottime.c
-@@ -23,6 +23,10 @@
- #include <asm/setjmp.h>
- #include <linux/libfdt_env.h>
- 
-+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
-+#include <arm_ffa.h>
-+#endif
-+
- DECLARE_GLOBAL_DATA_PTR;
- 
- /* Task priority level */
-@@ -2173,6 +2177,14 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
- 		dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
- 	}
- 
-+#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
-+		/* unmap FF-A RX/TX buffers */
-+		if (ffa_bus_ops_get()->rxtx_unmap())
-+			debug("[efi_boottime][ERROR]: can not unmap FF-A RX/TX buffers\n");
-+		else
-+			debug("[efi_boottime][INFO]: FF-A RX/TX buffers unmapped\n");
-+#endif
-+
- 	/* Patch out unsupported runtime function */
- 	efi_runtime_detach();
- 
 -- 
 2.17.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-usb-common-move-urb-code-to-common.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-usb-common-move-urb-code-to-common.patch
deleted file mode 100644
index 7e726fe..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0003-usb-common-move-urb-code-to-common.patch
+++ /dev/null
@@ -1,498 +0,0 @@
-From 178da5bee196f44c4c10e9804674fe5ac0bc1176 Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Mon, 28 Jun 2021 23:20:55 +0100
-Subject: [PATCH 03/26] usb: common: move urb code to common
-
-Move urb code from musb only use to a more common scope, so other
-drivers in the future can use the handling of urb in usb.
-
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Accepted [2022.10-rc1]
----
- drivers/usb/common/Makefile                   |   2 +
- drivers/usb/common/usb_urb.c                  | 160 ++++++++++++++++++
- drivers/usb/host/r8a66597-hcd.c               |  30 +---
- drivers/usb/musb-new/musb_core.c              |   2 +-
- drivers/usb/musb-new/musb_host.c              |   2 +-
- drivers/usb/musb-new/musb_host.h              |   2 +-
- drivers/usb/musb-new/musb_uboot.c             |  38 +----
- drivers/usb/musb-new/musb_uboot.h             |   2 +-
- .../linux/usb/usb_urb_compat.h                |  46 ++++-
- include/usb_defs.h                            |  32 ++++
- 10 files changed, 240 insertions(+), 76 deletions(-)
- create mode 100644 drivers/usb/common/usb_urb.c
- rename drivers/usb/musb-new/usb-compat.h => include/linux/usb/usb_urb_compat.h (60%)
-
-diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
-index 3bedbf213f..dc05cb0a50 100644
---- a/drivers/usb/common/Makefile
-+++ b/drivers/usb/common/Makefile
-@@ -4,5 +4,7 @@
- #
- 
- obj-$(CONFIG_$(SPL_)DM_USB) += common.o
-+obj-$(CONFIG_USB_MUSB_HCD) += usb_urb.o
-+obj-$(CONFIG_USB_MUSB_UDC) += usb_urb.o
- obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
- obj-$(CONFIG_USB_XHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
-diff --git a/drivers/usb/common/usb_urb.c b/drivers/usb/common/usb_urb.c
-new file mode 100644
-index 0000000000..be3b6b9f32
---- /dev/null
-+++ b/drivers/usb/common/usb_urb.c
-@@ -0,0 +1,160 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Common code for usb urb handling, based on the musb-new code
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ */
-+
-+#include <dm/device.h>
-+#include <dm/device_compat.h>
-+#include <linux/usb/usb_urb_compat.h>
-+
-+#include <time.h>
-+#include <usb.h>
-+
-+#if CONFIG_IS_ENABLED(DM_USB)
-+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-+{
-+	struct udevice *parent = udev->dev->parent;
-+
-+	/*
-+	 * When called from usb-uclass.c: usb_scan_device() udev->dev points
-+	 * to the parent udevice, not the actual udevice belonging to the
-+	 * udev as the device is not instantiated yet.
-+	 *
-+	 * If dev is an usb-bus, then we are called from usb_scan_device() for
-+	 * an usb-device plugged directly into the root port, return NULL.
-+	 */
-+	if (device_get_uclass_id(udev->dev) == UCLASS_USB)
-+		return NULL;
-+
-+	/*
-+	 * If these 2 are not the same we are being called from
-+	 * usb_scan_device() and udev itself is the parent.
-+	 */
-+	if (dev_get_parent_priv(udev->dev) != udev)
-+		return udev;
-+
-+	/* We are being called normally, use the parent pointer */
-+	if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
-+		return dev_get_parent_priv(parent);
-+
-+	return NULL;
-+}
-+#else
-+struct usb_device *usb_dev_get_parent(struct usb_device *udev)
-+{
-+	return udev->parent;
-+}
-+#endif
-+
-+static void usb_urb_complete(struct urb *urb)
-+{
-+	urb->dev->status &= ~USB_ST_NOT_PROC;
-+	urb->dev->act_len = urb->actual_length;
-+
-+	if (urb->status == -EINPROGRESS)
-+		urb->status = 0;
-+}
-+
-+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
-+		  struct usb_device *dev, int endpoint_type,
-+		  unsigned long pipe, void *buffer, int len,
-+		  struct devrequest *setup, int interval)
-+{
-+	int epnum = usb_pipeendpoint(pipe);
-+	int is_in = usb_pipein(pipe);
-+	u16 maxpacketsize = is_in ? dev->epmaxpacketin[epnum] :
-+					dev->epmaxpacketout[epnum];
-+
-+	memset(urb, 0, sizeof(struct urb));
-+	memset(hep, 0, sizeof(struct usb_host_endpoint));
-+	INIT_LIST_HEAD(&hep->urb_list);
-+	INIT_LIST_HEAD(&urb->urb_list);
-+	urb->ep = hep;
-+	urb->complete = usb_urb_complete;
-+	urb->status = -EINPROGRESS;
-+	urb->dev = dev;
-+	urb->pipe = pipe;
-+	urb->transfer_buffer = buffer;
-+	urb->transfer_dma = (unsigned long)buffer;
-+	urb->transfer_buffer_length = len;
-+	urb->setup_packet = (unsigned char *)setup;
-+
-+	urb->ep->desc.wMaxPacketSize = __cpu_to_le16(maxpacketsize);
-+	urb->ep->desc.bmAttributes = endpoint_type;
-+	urb->ep->desc.bEndpointAddress = ((is_in ? USB_DIR_IN : USB_DIR_OUT) |
-+					  epnum);
-+	urb->ep->desc.bInterval = interval;
-+}
-+
-+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb)
-+{
-+	const struct usb_urb_ops *ops = hcd->urb_ops;
-+	unsigned long timeout;
-+	int ret;
-+
-+	if (!ops)
-+		return -EINVAL;
-+
-+	ret = ops->urb_enqueue(hcd, urb, 0);
-+	if (ret < 0) {
-+		printf("Failed to enqueue URB to controller\n");
-+		return ret;
-+	}
-+
-+	timeout = get_timer(0) + USB_TIMEOUT_MS(urb->pipe);
-+	do {
-+		if (ctrlc())
-+			return -EIO;
-+		ops->isr(0, hcd);
-+	} while (urb->status == -EINPROGRESS && get_timer(0) < timeout);
-+
-+	if (urb->status == -EINPROGRESS)
-+		ops->urb_dequeue(hcd, urb, -ETIME);
-+
-+	return urb->status;
-+}
-+
-+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
-+			   struct usb_host_endpoint *hep,
-+			   struct usb_device *dev, unsigned long pipe,
-+			   void *buffer, int len, struct devrequest *setup,
-+			   int interval, enum usb_device_speed speed)
-+{
-+	const struct usb_urb_ops *ops = hcd->urb_ops;
-+
-+	usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_CONTROL, pipe, buffer,
-+		     len, setup, 0);
-+
-+	/* Fix speed for non hub-attached devices */
-+	if (!usb_dev_get_parent(dev)) {
-+		dev->speed = speed;
-+		if (ops->hub_control)
-+			return ops->hub_control(hcd, dev, pipe, buffer, len,
-+						setup);
-+	}
-+
-+	return usb_urb_submit(hcd, urb);
-+}
-+
-+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
-+			struct usb_host_endpoint *hep, struct usb_device *dev,
-+			unsigned long pipe, void *buffer, int len)
-+{
-+	usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_BULK, pipe, buffer, len,
-+		     NULL, 0);
-+
-+	return usb_urb_submit(hcd, urb);
-+}
-+
-+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
-+		       struct usb_host_endpoint *hep, struct usb_device *dev,
-+		       unsigned long pipe, void *buffer, int len, int interval)
-+{
-+	usb_urb_fill(urb, hep, dev, USB_ENDPOINT_XFER_INT, pipe, buffer, len,
-+		     NULL, interval);
-+
-+	return usb_urb_submit(hcd, urb);
-+}
-diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
-index f1fc93f3d4..3ccbc16da3 100644
---- a/drivers/usb/host/r8a66597-hcd.c
-+++ b/drivers/usb/host/r8a66597-hcd.c
-@@ -14,6 +14,7 @@
- #include <dm/device_compat.h>
- #include <linux/delay.h>
- #include <linux/iopoll.h>
-+#include <linux/usb/usb_urb_compat.h>
- #include <power/regulator.h>
- 
- #include "r8a66597.h"
-@@ -24,35 +25,6 @@
- #define R8A66597_DPRINT(...)
- #endif
- 
--static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
--{
--	struct udevice *parent = udev->dev->parent;
--
--	/*
--	 * When called from usb-uclass.c: usb_scan_device() udev->dev points
--	 * to the parent udevice, not the actual udevice belonging to the
--	 * udev as the device is not instantiated yet.
--	 *
--	 * If dev is an usb-bus, then we are called from usb_scan_device() for
--	 * an usb-device plugged directly into the root port, return NULL.
--	 */
--	if (device_get_uclass_id(udev->dev) == UCLASS_USB)
--		return NULL;
--
--	/*
--	 * If these 2 are not the same we are being called from
--	 * usb_scan_device() and udev itself is the parent.
--	 */
--	if (dev_get_parent_priv(udev->dev) != udev)
--		return udev;
--
--	/* We are being called normally, use the parent pointer */
--	if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
--		return dev_get_parent_priv(parent);
--
--	return NULL;
--}
--
- static void get_hub_data(struct usb_device *dev, u16 *hub_devnum, u16 *hubport)
- {
- 	struct usb_device *parent = usb_dev_get_parent(dev);
-diff --git a/drivers/usb/musb-new/musb_core.c b/drivers/usb/musb-new/musb_core.c
-index 18d9bc805f..fc7af7484e 100644
---- a/drivers/usb/musb-new/musb_core.c
-+++ b/drivers/usb/musb-new/musb_core.c
-@@ -89,9 +89,9 @@
- #include <linux/usb/ch9.h>
- #include <linux/usb/gadget.h>
- #include <linux/usb/musb.h>
-+#include <linux/usb/usb_urb_compat.h>
- #include <asm/io.h>
- #include "linux-compat.h"
--#include "usb-compat.h"
- #endif
- 
- #include "musb_core.h"
-diff --git a/drivers/usb/musb-new/musb_host.c b/drivers/usb/musb-new/musb_host.c
-index acb2d40f3b..e5905d90d6 100644
---- a/drivers/usb/musb-new/musb_host.c
-+++ b/drivers/usb/musb-new/musb_host.c
-@@ -26,8 +26,8 @@
- #include <dm/device_compat.h>
- #include <usb.h>
- #include <linux/bug.h>
-+#include <linux/usb/usb_urb_compat.h>
- #include "linux-compat.h"
--#include "usb-compat.h"
- #endif
- 
- #include "musb_core.h"
-diff --git a/drivers/usb/musb-new/musb_host.h b/drivers/usb/musb-new/musb_host.h
-index afc8fa35a7..5a604bdb0c 100644
---- a/drivers/usb/musb-new/musb_host.h
-+++ b/drivers/usb/musb-new/musb_host.h
-@@ -10,7 +10,7 @@
- #ifndef _MUSB_HOST_H
- #define _MUSB_HOST_H
- #ifdef __UBOOT__
--#include "usb-compat.h"
-+#include <linux/usb/usb_urb_compat.h>
- #endif
- 
- static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
-diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c
-index 61ff68def2..d186facc7e 100644
---- a/drivers/usb/musb-new/musb_uboot.c
-+++ b/drivers/usb/musb-new/musb_uboot.c
-@@ -8,10 +8,10 @@
- #include <linux/errno.h>
- #include <linux/usb/ch9.h>
- #include <linux/usb/gadget.h>
-+#include <linux/usb/usb_urb_compat.h>
- 
- #include <usb.h>
- #include "linux-compat.h"
--#include "usb-compat.h"
- #include "musb_core.h"
- #include "musb_host.h"
- #include "musb_gadget.h"
-@@ -453,39 +453,3 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata,
- 
- 	return *musbp;
- }
--
--#if CONFIG_IS_ENABLED(DM_USB)
--struct usb_device *usb_dev_get_parent(struct usb_device *udev)
--{
--	struct udevice *parent = udev->dev->parent;
--
--	/*
--	 * When called from usb-uclass.c: usb_scan_device() udev->dev points
--	 * to the parent udevice, not the actual udevice belonging to the
--	 * udev as the device is not instantiated yet.
--	 *
--	 * If dev is an usb-bus, then we are called from usb_scan_device() for
--	 * an usb-device plugged directly into the root port, return NULL.
--	 */
--	if (device_get_uclass_id(udev->dev) == UCLASS_USB)
--		return NULL;
--
--	/*
--	 * If these 2 are not the same we are being called from
--	 * usb_scan_device() and udev itself is the parent.
--	 */
--	if (dev_get_parent_priv(udev->dev) != udev)
--		return udev;
--
--	/* We are being called normally, use the parent pointer */
--	if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
--		return dev_get_parent_priv(parent);
--
--	return NULL;
--}
--#else
--struct usb_device *usb_dev_get_parent(struct usb_device *udev)
--{
--	return udev->parent;
--}
--#endif
-diff --git a/drivers/usb/musb-new/musb_uboot.h b/drivers/usb/musb-new/musb_uboot.h
-index 18282efccc..6b162f03b1 100644
---- a/drivers/usb/musb-new/musb_uboot.h
-+++ b/drivers/usb/musb-new/musb_uboot.h
-@@ -8,8 +8,8 @@
- #define __MUSB_UBOOT_H__
- 
- #include <usb.h>
-+#include <linux/usb/usb_urb_compat.h>
- #include "linux-compat.h"
--#include "usb-compat.h"
- #include "musb_core.h"
- 
- struct musb_host_data {
-diff --git a/drivers/usb/musb-new/usb-compat.h b/include/linux/usb/usb_urb_compat.h
-similarity index 60%
-rename from drivers/usb/musb-new/usb-compat.h
-rename to include/linux/usb/usb_urb_compat.h
-index df68c9220a..5ed96fa64e 100644
---- a/drivers/usb/musb-new/usb-compat.h
-+++ b/include/linux/usb/usb_urb_compat.h
-@@ -1,16 +1,31 @@
--#ifndef __USB_COMPAT_H__
--#define __USB_COMPAT_H__
-+#ifndef __USB_URB_COMPAT_H__
-+#define __USB_URB_COMPAT_H__
- 
--#include "usb.h"
-+#include <linux/compat.h>
-+#include <usb.h>
- 
- struct udevice;
-+struct urb;
-+struct usb_hcd;
-+
-+
-+struct usb_urb_ops {
-+	int (*urb_enqueue)(struct usb_hcd *hcd, struct urb *urb,
-+			   gfp_t mem_flags);
-+	int (*urb_dequeue)(struct usb_hcd *hcd, struct urb *urb, int status);
-+	int (*hub_control)(struct usb_hcd *hcd, struct usb_device *dev,
-+			   unsigned long pipe, void *buffer, int len,
-+			   struct devrequest *setup);
-+	irqreturn_t (*isr)(int irq, void *priv);
-+};
- 
- struct usb_hcd {
- 	void *hcd_priv;
-+	const struct usb_urb_ops *urb_ops;
- };
- 
- struct usb_host_endpoint {
--	struct usb_endpoint_descriptor		desc;
-+	struct usb_endpoint_descriptor desc;
- 	struct list_head urb_list;
- 	void *hcpriv;
- };
-@@ -23,8 +38,6 @@ struct usb_host_endpoint {
- #define URB_SHORT_NOT_OK	0x0001	/* report short reads as errors */
- #define URB_ZERO_PACKET		0x0040	/* Finish bulk OUT with short packet */
- 
--struct urb;
--
- typedef void (*usb_complete_t)(struct urb *);
- 
- struct urb {
-@@ -76,4 +89,25 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
-  */
- struct usb_device *usb_dev_get_parent(struct usb_device *udev);
- 
-+int usb_urb_submit_control(struct usb_hcd *hcd, struct urb *urb,
-+			   struct usb_host_endpoint *hep,
-+			   struct usb_device *dev, unsigned long pipe,
-+			   void *buffer, int len, struct devrequest *setup,
-+			   int interval, enum usb_device_speed speed);
-+
-+int usb_urb_submit_bulk(struct usb_hcd *hcd, struct urb *urb,
-+			struct usb_host_endpoint *hep, struct usb_device *dev,
-+			unsigned long pipe, void *buffer, int len);
-+
-+int usb_urb_submit_irq(struct usb_hcd *hcd, struct urb *urb,
-+		       struct usb_host_endpoint *hep, struct usb_device *dev,
-+		       unsigned long pipe, void *buffer, int len, int interval);
-+
-+void usb_urb_fill(struct urb *urb, struct usb_host_endpoint *hep,
-+		  struct usb_device *dev, int endpoint_type,
-+		  unsigned long pipe, void *buffer, int len,
-+		  struct devrequest *setup, int interval);
-+
-+int usb_urb_submit(struct usb_hcd *hcd, struct urb *urb);
-+
- #endif /* __USB_COMPAT_H__ */
-diff --git a/include/usb_defs.h b/include/usb_defs.h
-index 6dd2c997f9..ec00161710 100644
---- a/include/usb_defs.h
-+++ b/include/usb_defs.h
-@@ -81,6 +81,32 @@
- #define EndpointOutRequest \
- 	((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
- 
-+/* class requests from the USB 2.0 hub spec, table 11-15 */
-+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
-+/* GetBusState and SetHubDescriptor are optional, omitted */
-+#define ClearHubFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
-+					      USB_REQ_CLEAR_FEATURE)
-+#define ClearPortFeature	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
-+					      USB_REQ_CLEAR_FEATURE)
-+#define GetHubDescriptor	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
-+					      USB_REQ_GET_DESCRIPTOR)
-+#define GetHubStatus		HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, \
-+					      USB_REQ_GET_STATUS)
-+#define GetPortStatus		HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
-+					      USB_REQ_GET_STATUS)
-+#define SetHubFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, \
-+					      USB_REQ_SET_FEATURE)
-+#define SetPortFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
-+					      USB_REQ_SET_FEATURE)
-+#define ClearTTBuffer		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
-+					      HUB_CLEAR_TT_BUFFER)
-+#define ResetTT			HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
-+					      HUB_RESET_TT)
-+#define GetTTState		HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, \
-+					      HUB_GET_TT_STATE)
-+#define StopTT			HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, \
-+					      HUB_STOP_TT)
-+
- /* Descriptor types */
- #define USB_DT_DEVICE        0x01
- #define USB_DT_CONFIG        0x02
-@@ -289,10 +315,16 @@
- #define USB_SS_PORT_STAT_C_CONFIG_ERROR	0x0080
- 
- /* wHubCharacteristics (masks) */
-+#define HUB_CHAR_COMMON_OCPM        0x0000 /* All ports Over-Current reporting */
-+#define HUB_CHAR_INDV_PORT_LPSM     0x0001 /* per-port power control */
-+#define HUB_CHAR_NO_LPSM            0x0002 /* no power switching */
- #define HUB_CHAR_LPSM               0x0003
- #define HUB_CHAR_COMPOUND           0x0004
-+#define HUB_CHAR_INDV_PORT_OCPM     0x0008 /* per-port Over-current reporting */
-+#define HUB_CHAR_NO_OCPM            0x0010 /* No Over-current Protection support */
- #define HUB_CHAR_OCPM               0x0018
- #define HUB_CHAR_TTTT               0x0060 /* TT Think Time mask */
-+#define HUB_CHAR_PORTIND            0x0080 /* per-port indicators (LEDs) */
- 
- /*
-  * Hub Status & Hub Change bit masks
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch
new file mode 100644
index 0000000..f20cc28
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-arm_ffa-efi-unmap-RX-TX-buffers.patch
@@ -0,0 +1,73 @@
+From 3035651bfc0dcdfd48d28acff6efe2f29bbe9439 Mon Sep 17 00:00:00 2001
+From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Date: Thu, 6 Oct 2022 15:04:25 +0100
+Subject: [PATCH 04/25] arm_ffa: efi: unmap RX/TX buffers
+
+unmap RX/TX buffers at ExitBootServices()
+
+Unmapping the RX/TX buffers created by u-boot is needed before EFI
+runtime.
+
+At EFI runtime the linux kernel takes care of allocating its own RX/TX
+buffers and registering them with the secure world.
+
+Secure world should be using the RX/TX buffers created by the kernel.
+So, RX/TX buffers created by u-boot must be unmapped.
+
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
+
+Changelog:
+===============
+
+v8: pass NULL device pointer to the FF-A bus operation
+v7: replace debug() by log_err()
+---
+ lib/efi_loader/efi_boottime.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
+index 6f7333638a..caa64028be 100644
+--- a/lib/efi_loader/efi_boottime.c
++++ b/lib/efi_loader/efi_boottime.c
+@@ -3,6 +3,9 @@
+  * EFI application boot time services
+  *
+  * Copyright (c) 2016 Alexander Graf
++ *
++ * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ 
+ #include <common.h>
+@@ -23,6 +26,10 @@
+ #include <asm/setjmp.h>
+ #include <linux/libfdt_env.h>
+ 
++#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
++#include <arm_ffa.h>
++#endif
++
+ DECLARE_GLOBAL_DATA_PTR;
+ 
+ /* Task priority level */
+@@ -2178,6 +2185,12 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
+ 		dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
+ 	}
+ 
++#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
++		/* unmap FF-A RX/TX buffers */
++		if (ffa_bus_ops_get()->rxtx_unmap(NULL))
++			log_err("Can't unmap FF-A RX/TX buffers\n");
++#endif
++
+ 	/* Patch out unsupported runtime function */
+ 	efi_runtime_detach();
+ 
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-usb-add-isp1760-family-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-usb-add-isp1760-family-driver.patch
deleted file mode 100644
index 794389e..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0004-usb-add-isp1760-family-driver.patch
+++ /dev/null
@@ -1,3806 +0,0 @@
-From 83ba88292211394ce6b3a21fbc0f702dae543290 Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Mon, 28 Jun 2021 23:31:25 +0100
-Subject: [PATCH 04/26] usb: add isp1760 family driver
-
-ISP1760/61/63 are a family of usb controllers, blah, blah, more info
-here.
-
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Accepted [2022.10-rc1]
----
- Makefile                            |    1 +
- drivers/usb/Kconfig                 |    2 +
- drivers/usb/common/Makefile         |    1 +
- drivers/usb/isp1760/Kconfig         |   12 +
- drivers/usb/isp1760/Makefile        |    6 +
- drivers/usb/isp1760/isp1760-core.c  |  378 ++++
- drivers/usb/isp1760/isp1760-core.h  |   96 +
- drivers/usb/isp1760/isp1760-hcd.c   | 2574 +++++++++++++++++++++++++++
- drivers/usb/isp1760/isp1760-hcd.h   |   82 +
- drivers/usb/isp1760/isp1760-if.c    |  127 ++
- drivers/usb/isp1760/isp1760-regs.h  |  292 +++
- drivers/usb/isp1760/isp1760-uboot.c |   76 +
- drivers/usb/isp1760/isp1760-uboot.h |   27 +
- 13 files changed, 3674 insertions(+)
- create mode 100644 drivers/usb/isp1760/Kconfig
- create mode 100644 drivers/usb/isp1760/Makefile
- create mode 100644 drivers/usb/isp1760/isp1760-core.c
- create mode 100644 drivers/usb/isp1760/isp1760-core.h
- create mode 100644 drivers/usb/isp1760/isp1760-hcd.c
- create mode 100644 drivers/usb/isp1760/isp1760-hcd.h
- create mode 100644 drivers/usb/isp1760/isp1760-if.c
- create mode 100644 drivers/usb/isp1760/isp1760-regs.h
- create mode 100644 drivers/usb/isp1760/isp1760-uboot.c
- create mode 100644 drivers/usb/isp1760/isp1760-uboot.h
-
-diff --git a/Makefile b/Makefile
-index 98867fbe06..67851020f5 100644
---- a/Makefile
-+++ b/Makefile
-@@ -841,6 +841,7 @@ libs-y += drivers/usb/host/
- libs-y += drivers/usb/mtu3/
- libs-y += drivers/usb/musb/
- libs-y += drivers/usb/musb-new/
-+libs-y += drivers/usb/isp1760/
- libs-y += drivers/usb/phy/
- libs-y += drivers/usb/ulpi/
- ifdef CONFIG_POST
-diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
-index ab1d061bd0..bbe07be02c 100644
---- a/drivers/usb/Kconfig
-+++ b/drivers/usb/Kconfig
-@@ -78,6 +78,8 @@ source "drivers/usb/musb/Kconfig"
- 
- source "drivers/usb/musb-new/Kconfig"
- 
-+source "drivers/usb/isp1760/Kconfig"
-+
- source "drivers/usb/emul/Kconfig"
- 
- source "drivers/usb/phy/Kconfig"
-diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
-index dc05cb0a50..f08b064d24 100644
---- a/drivers/usb/common/Makefile
-+++ b/drivers/usb/common/Makefile
-@@ -4,6 +4,7 @@
- #
- 
- obj-$(CONFIG_$(SPL_)DM_USB) += common.o
-+obj-$(CONFIG_USB_ISP1760) += usb_urb.o
- obj-$(CONFIG_USB_MUSB_HCD) += usb_urb.o
- obj-$(CONFIG_USB_MUSB_UDC) += usb_urb.o
- obj-$(CONFIG_USB_EHCI_FSL) += fsl-dt-fixup.o fsl-errata.o
-diff --git a/drivers/usb/isp1760/Kconfig b/drivers/usb/isp1760/Kconfig
-new file mode 100644
-index 0000000000..993d71e74c
---- /dev/null
-+++ b/drivers/usb/isp1760/Kconfig
-@@ -0,0 +1,12 @@
-+# SPDX-License-Identifier: GPL-2.0
-+
-+config USB_ISP1760
-+	tristate "NXP ISP 1760/1761/1763 support"
-+	select DM_USB
-+	select USB_HOST
-+	help
-+	  Say Y or M here if your system as an ISP1760/1761/1763 USB host
-+	  controller.
-+
-+	  This USB controller is usually attached to a non-DMA-Master
-+	  capable bus.
-diff --git a/drivers/usb/isp1760/Makefile b/drivers/usb/isp1760/Makefile
-new file mode 100644
-index 0000000000..2c809c01b1
---- /dev/null
-+++ b/drivers/usb/isp1760/Makefile
-@@ -0,0 +1,6 @@
-+# SPDX-License-Identifier: GPL-2.0
-+isp1760-y := isp1760-core.o isp1760-if.o isp1760-uboot.o isp1760-hcd.o
-+
-+#isp1760-hcd.o
-+
-+obj-$(CONFIG_USB_ISP1760) += isp1760.o
-diff --git a/drivers/usb/isp1760/isp1760-core.c b/drivers/usb/isp1760/isp1760-core.c
-new file mode 100644
-index 0000000000..3080595549
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-core.c
-@@ -0,0 +1,378 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ * This is based on linux kernel driver, original developed:
-+ * Copyright 2014 Laurent Pinchart
-+ * Copyright 2007 Sebastian Siewior
-+ *
-+ */
-+
-+#include <dm.h>
-+#include <dm/device-internal.h>
-+#include <dm/device_compat.h>
-+#include <dm/devres.h>
-+#include <linux/compat.h>
-+#include <linux/delay.h>
-+#include <linux/io.h>
-+#include <linux/kernel.h>
-+#include <regmap.h>
-+#include <usb.h>
-+
-+#include "isp1760-core.h"
-+#include "isp1760-hcd.h"
-+#include "isp1760-regs.h"
-+
-+#define msleep(a) udelay(a * 1000)
-+
-+static int isp1760_init_core(struct isp1760_device *isp)
-+{
-+	struct isp1760_hcd *hcd = &isp->hcd;
-+
-+	/*
-+	 * Reset the host controller, including the CPU interface
-+	 * configuration.
-+	 */
-+	isp1760_field_set(hcd->fields, SW_RESET_RESET_ALL);
-+	msleep(100);
-+
-+	/* Setup HW Mode Control: This assumes a level active-low interrupt */
-+	if ((isp->devflags & ISP1760_FLAG_ANALOG_OC) && hcd->is_isp1763)
-+		return -EINVAL;
-+
-+	if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_16)
-+		isp1760_field_clear(hcd->fields, HW_DATA_BUS_WIDTH);
-+	if (isp->devflags & ISP1760_FLAG_BUS_WIDTH_8)
-+		isp1760_field_set(hcd->fields, HW_DATA_BUS_WIDTH);
-+	if (isp->devflags & ISP1760_FLAG_ANALOG_OC)
-+		isp1760_field_set(hcd->fields, HW_ANA_DIGI_OC);
-+	if (isp->devflags & ISP1760_FLAG_DACK_POL_HIGH)
-+		isp1760_field_set(hcd->fields, HW_DACK_POL_HIGH);
-+	if (isp->devflags & ISP1760_FLAG_DREQ_POL_HIGH)
-+		isp1760_field_set(hcd->fields, HW_DREQ_POL_HIGH);
-+	if (isp->devflags & ISP1760_FLAG_INTR_POL_HIGH)
-+		isp1760_field_set(hcd->fields, HW_INTR_HIGH_ACT);
-+	if (isp->devflags & ISP1760_FLAG_INTR_EDGE_TRIG)
-+		isp1760_field_set(hcd->fields, HW_INTR_EDGE_TRIG);
-+
-+	/*
-+	 * The ISP1761 has a dedicated DC IRQ line but supports sharing the HC
-+	 * IRQ line for both the host and device controllers. Hardcode IRQ
-+	 * sharing for now and disable the DC interrupts globally to avoid
-+	 * spurious interrupts during HCD registration.
-+	 */
-+	if (isp->devflags & ISP1760_FLAG_ISP1761) {
-+		isp1760_reg_write(hcd->regs, ISP176x_DC_MODE, 0);
-+		isp1760_field_set(hcd->fields, HW_COMN_IRQ);
-+	}
-+
-+	/*
-+	 * PORT 1 Control register of the ISP1760 is the OTG control register
-+	 * on ISP1761.
-+	 *
-+	 * TODO: Really support OTG. For now we configure port 1 in device mode
-+	 */
-+	if (((isp->devflags & ISP1760_FLAG_ISP1761) ||
-+	     (isp->devflags & ISP1760_FLAG_ISP1763)) &&
-+	    (isp->devflags & ISP1760_FLAG_PERIPHERAL_EN)) {
-+		isp1760_field_set(hcd->fields, HW_DM_PULLDOWN);
-+		isp1760_field_set(hcd->fields, HW_DP_PULLDOWN);
-+		isp1760_field_set(hcd->fields, HW_OTG_DISABLE);
-+	} else {
-+		isp1760_field_set(hcd->fields, HW_SW_SEL_HC_DC);
-+		isp1760_field_set(hcd->fields, HW_VBUS_DRV);
-+		isp1760_field_set(hcd->fields, HW_SEL_CP_EXT);
-+	}
-+
-+	printf( "%s bus width: %u, oc: %s\n",
-+		 hcd->is_isp1763 ? "isp1763" : "isp1760",
-+		 isp->devflags & ISP1760_FLAG_BUS_WIDTH_8 ? 8 :
-+		 isp->devflags & ISP1760_FLAG_BUS_WIDTH_16 ? 16 : 32,
-+		 hcd->is_isp1763 ? "not available" :
-+		 isp->devflags & ISP1760_FLAG_ANALOG_OC ? "analog" : "digital");
-+
-+	return 0;
-+}
-+
-+void isp1760_set_pullup(struct isp1760_device *isp, bool enable)
-+{
-+	struct isp1760_hcd *hcd = &isp->hcd;
-+
-+	if (enable)
-+		isp1760_field_set(hcd->fields, HW_DP_PULLUP);
-+	else
-+		isp1760_field_set(hcd->fields, HW_DP_PULLUP_CLEAR);
-+}
-+
-+/*
-+ * ISP1760/61:
-+ *
-+ * 60kb divided in:
-+ * - 32 blocks @ 256  bytes
-+ * - 20 blocks @ 1024 bytes
-+ * -  4 blocks @ 8192 bytes
-+ */
-+static const struct isp1760_memory_layout isp176x_memory_conf = {
-+	.blocks[0]		= 32,
-+	.blocks_size[0]		= 256,
-+	.blocks[1]		= 20,
-+	.blocks_size[1]		= 1024,
-+	.blocks[2]		= 4,
-+	.blocks_size[2]		= 8192,
-+
-+	.slot_num		= 32,
-+	.payload_blocks		= 32 + 20 + 4,
-+	.payload_area_size	= 0xf000,
-+};
-+
-+/*
-+ * ISP1763:
-+ *
-+ * 20kb divided in:
-+ * - 8 blocks @ 256  bytes
-+ * - 2 blocks @ 1024 bytes
-+ * - 4 blocks @ 4096 bytes
-+ */
-+static const struct isp1760_memory_layout isp1763_memory_conf = {
-+	.blocks[0]		= 8,
-+	.blocks_size[0]		= 256,
-+	.blocks[1]		= 2,
-+	.blocks_size[1]		= 1024,
-+	.blocks[2]		= 4,
-+	.blocks_size[2]		= 4096,
-+
-+	.slot_num		= 16,
-+	.payload_blocks		= 8 + 2 + 4,
-+	.payload_area_size	= 0x5000,
-+};
-+
-+static const struct regmap_config isp1760_hc_regmap_conf = {
-+	.width = REGMAP_SIZE_16,
-+};
-+
-+static const struct reg_field isp1760_hc_reg_fields[] = {
-+	[HCS_PPC]		= REG_FIELD(ISP176x_HC_HCSPARAMS, 4, 4),
-+	[HCS_N_PORTS]		= REG_FIELD(ISP176x_HC_HCSPARAMS, 0, 3),
-+	[HCC_ISOC_CACHE]	= REG_FIELD(ISP176x_HC_HCCPARAMS, 7, 7),
-+	[HCC_ISOC_THRES]	= REG_FIELD(ISP176x_HC_HCCPARAMS, 4, 6),
-+	[CMD_LRESET]		= REG_FIELD(ISP176x_HC_USBCMD, 7, 7),
-+	[CMD_RESET]		= REG_FIELD(ISP176x_HC_USBCMD, 1, 1),
-+	[CMD_RUN]		= REG_FIELD(ISP176x_HC_USBCMD, 0, 0),
-+	[STS_PCD]		= REG_FIELD(ISP176x_HC_USBSTS, 2, 2),
-+	[HC_FRINDEX]		= REG_FIELD(ISP176x_HC_FRINDEX, 0, 13),
-+	[FLAG_CF]		= REG_FIELD(ISP176x_HC_CONFIGFLAG, 0, 0),
-+	[HC_ISO_PTD_DONEMAP]	= REG_FIELD(ISP176x_HC_ISO_PTD_DONEMAP, 0, 31),
-+	[HC_ISO_PTD_SKIPMAP]	= REG_FIELD(ISP176x_HC_ISO_PTD_SKIPMAP, 0, 31),
-+	[HC_ISO_PTD_LASTPTD]	= REG_FIELD(ISP176x_HC_ISO_PTD_LASTPTD, 0, 31),
-+	[HC_INT_PTD_DONEMAP]	= REG_FIELD(ISP176x_HC_INT_PTD_DONEMAP, 0, 31),
-+	[HC_INT_PTD_SKIPMAP]	= REG_FIELD(ISP176x_HC_INT_PTD_SKIPMAP, 0, 31),
-+	[HC_INT_PTD_LASTPTD]	= REG_FIELD(ISP176x_HC_INT_PTD_LASTPTD, 0, 31),
-+	[HC_ATL_PTD_DONEMAP]	= REG_FIELD(ISP176x_HC_ATL_PTD_DONEMAP, 0, 31),
-+	[HC_ATL_PTD_SKIPMAP]	= REG_FIELD(ISP176x_HC_ATL_PTD_SKIPMAP, 0, 31),
-+	[HC_ATL_PTD_LASTPTD]	= REG_FIELD(ISP176x_HC_ATL_PTD_LASTPTD, 0, 31),
-+	[PORT_OWNER]		= REG_FIELD(ISP176x_HC_PORTSC1, 13, 13),
-+	[PORT_POWER]		= REG_FIELD(ISP176x_HC_PORTSC1, 12, 12),
-+	[PORT_LSTATUS]		= REG_FIELD(ISP176x_HC_PORTSC1, 10, 11),
-+	[PORT_RESET]		= REG_FIELD(ISP176x_HC_PORTSC1, 8, 8),
-+	[PORT_SUSPEND]		= REG_FIELD(ISP176x_HC_PORTSC1, 7, 7),
-+	[PORT_RESUME]		= REG_FIELD(ISP176x_HC_PORTSC1, 6, 6),
-+	[PORT_PE]		= REG_FIELD(ISP176x_HC_PORTSC1, 2, 2),
-+	[PORT_CSC]		= REG_FIELD(ISP176x_HC_PORTSC1, 1, 1),
-+	[PORT_CONNECT]		= REG_FIELD(ISP176x_HC_PORTSC1, 0, 0),
-+	[ALL_ATX_RESET]		= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 31, 31),
-+	[HW_ANA_DIGI_OC]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 15, 15),
-+	[HW_COMN_IRQ]		= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 10, 10),
-+	[HW_DATA_BUS_WIDTH]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 8, 8),
-+	[HW_DACK_POL_HIGH]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 6, 6),
-+	[HW_DREQ_POL_HIGH]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 5, 5),
-+	[HW_INTR_HIGH_ACT]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 2, 2),
-+	[HW_INTR_EDGE_TRIG]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 1, 1),
-+	[HW_GLOBAL_INTR_EN]	= REG_FIELD(ISP176x_HC_HW_MODE_CTRL, 0, 0),
-+	[HC_CHIP_REV]		= REG_FIELD(ISP176x_HC_CHIP_ID, 16, 31),
-+	[HC_CHIP_ID_HIGH]	= REG_FIELD(ISP176x_HC_CHIP_ID, 8, 15),
-+	[HC_CHIP_ID_LOW]	= REG_FIELD(ISP176x_HC_CHIP_ID, 0, 7),
-+	[HC_SCRATCH]		= REG_FIELD(ISP176x_HC_SCRATCH, 0, 31),
-+	[SW_RESET_RESET_ALL]	= REG_FIELD(ISP176x_HC_RESET, 0, 0),
-+	[ISO_BUF_FILL]		= REG_FIELD(ISP176x_HC_BUFFER_STATUS, 2, 2),
-+	[INT_BUF_FILL]		= REG_FIELD(ISP176x_HC_BUFFER_STATUS, 1, 1),
-+	[ATL_BUF_FILL]		= REG_FIELD(ISP176x_HC_BUFFER_STATUS, 0, 0),
-+	[MEM_BANK_SEL]		= REG_FIELD(ISP176x_HC_MEMORY, 16, 17),
-+	[MEM_START_ADDR]	= REG_FIELD(ISP176x_HC_MEMORY, 0, 15),
-+	[HC_INTERRUPT]		= REG_FIELD(ISP176x_HC_INTERRUPT, 0, 9),
-+	[HC_ATL_IRQ_ENABLE]	= REG_FIELD(ISP176x_HC_INTERRUPT_ENABLE, 8, 8),
-+	[HC_INT_IRQ_ENABLE]	= REG_FIELD(ISP176x_HC_INTERRUPT_ENABLE, 7, 7),
-+	[HC_ISO_IRQ_MASK_OR]	= REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_OR, 0, 31),
-+	[HC_INT_IRQ_MASK_OR]	= REG_FIELD(ISP176x_HC_INT_IRQ_MASK_OR, 0, 31),
-+	[HC_ATL_IRQ_MASK_OR]	= REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_OR, 0, 31),
-+	[HC_ISO_IRQ_MASK_AND]	= REG_FIELD(ISP176x_HC_ISO_IRQ_MASK_AND, 0, 31),
-+	[HC_INT_IRQ_MASK_AND]	= REG_FIELD(ISP176x_HC_INT_IRQ_MASK_AND, 0, 31),
-+	[HC_ATL_IRQ_MASK_AND]	= REG_FIELD(ISP176x_HC_ATL_IRQ_MASK_AND, 0, 31),
-+	[HW_OTG_DISABLE]	= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 10, 10),
-+	[HW_SW_SEL_HC_DC]	= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 7, 7),
-+	[HW_VBUS_DRV]		= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 4, 4),
-+	[HW_SEL_CP_EXT]		= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 3, 3),
-+	[HW_DM_PULLDOWN]	= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 2, 2),
-+	[HW_DP_PULLDOWN]	= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 1, 1),
-+	[HW_DP_PULLUP]		= REG_FIELD(ISP176x_HC_OTG_CTRL_SET, 0, 0),
-+	[HW_OTG_DISABLE_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 10, 10),
-+	[HW_SW_SEL_HC_DC_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 7, 7),
-+	[HW_VBUS_DRV_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 4, 4),
-+	[HW_SEL_CP_EXT_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 3, 3),
-+	[HW_DM_PULLDOWN_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 2, 2),
-+	[HW_DP_PULLDOWN_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 1, 1),
-+	[HW_DP_PULLUP_CLEAR]	= REG_FIELD(ISP176x_HC_OTG_CTRL_CLEAR, 0, 0),
-+};
-+
-+static const struct regmap_config isp1763_hc_regmap_conf = {
-+	.width = REGMAP_SIZE_16,
-+};
-+
-+static const struct reg_field isp1763_hc_reg_fields[] = {
-+	[CMD_LRESET]		= REG_FIELD(ISP1763_HC_USBCMD, 7, 7),
-+	[CMD_RESET]		= REG_FIELD(ISP1763_HC_USBCMD, 1, 1),
-+	[CMD_RUN]		= REG_FIELD(ISP1763_HC_USBCMD, 0, 0),
-+	[STS_PCD]		= REG_FIELD(ISP1763_HC_USBSTS, 2, 2),
-+	[HC_FRINDEX]		= REG_FIELD(ISP1763_HC_FRINDEX, 0, 13),
-+	[FLAG_CF]		= REG_FIELD(ISP1763_HC_CONFIGFLAG, 0, 0),
-+	[HC_ISO_PTD_DONEMAP]	= REG_FIELD(ISP1763_HC_ISO_PTD_DONEMAP, 0, 15),
-+	[HC_ISO_PTD_SKIPMAP]	= REG_FIELD(ISP1763_HC_ISO_PTD_SKIPMAP, 0, 15),
-+	[HC_ISO_PTD_LASTPTD]	= REG_FIELD(ISP1763_HC_ISO_PTD_LASTPTD, 0, 15),
-+	[HC_INT_PTD_DONEMAP]	= REG_FIELD(ISP1763_HC_INT_PTD_DONEMAP, 0, 15),
-+	[HC_INT_PTD_SKIPMAP]	= REG_FIELD(ISP1763_HC_INT_PTD_SKIPMAP, 0, 15),
-+	[HC_INT_PTD_LASTPTD]	= REG_FIELD(ISP1763_HC_INT_PTD_LASTPTD, 0, 15),
-+	[HC_ATL_PTD_DONEMAP]	= REG_FIELD(ISP1763_HC_ATL_PTD_DONEMAP, 0, 15),
-+	[HC_ATL_PTD_SKIPMAP]	= REG_FIELD(ISP1763_HC_ATL_PTD_SKIPMAP, 0, 15),
-+	[HC_ATL_PTD_LASTPTD]	= REG_FIELD(ISP1763_HC_ATL_PTD_LASTPTD, 0, 15),
-+	[PORT_OWNER]		= REG_FIELD(ISP1763_HC_PORTSC1, 13, 13),
-+	[PORT_POWER]		= REG_FIELD(ISP1763_HC_PORTSC1, 12, 12),
-+	[PORT_LSTATUS]		= REG_FIELD(ISP1763_HC_PORTSC1, 10, 11),
-+	[PORT_RESET]		= REG_FIELD(ISP1763_HC_PORTSC1, 8, 8),
-+	[PORT_SUSPEND]		= REG_FIELD(ISP1763_HC_PORTSC1, 7, 7),
-+	[PORT_RESUME]		= REG_FIELD(ISP1763_HC_PORTSC1, 6, 6),
-+	[PORT_PE]		= REG_FIELD(ISP1763_HC_PORTSC1, 2, 2),
-+	[PORT_CSC]		= REG_FIELD(ISP1763_HC_PORTSC1, 1, 1),
-+	[PORT_CONNECT]		= REG_FIELD(ISP1763_HC_PORTSC1, 0, 0),
-+	[HW_DATA_BUS_WIDTH]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 4, 4),
-+	[HW_DACK_POL_HIGH]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 6, 6),
-+	[HW_DREQ_POL_HIGH]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 5, 5),
-+	[HW_INTF_LOCK]		= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 3, 3),
-+	[HW_INTR_HIGH_ACT]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 2, 2),
-+	[HW_INTR_EDGE_TRIG]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 1, 1),
-+	[HW_GLOBAL_INTR_EN]	= REG_FIELD(ISP1763_HC_HW_MODE_CTRL, 0, 0),
-+	[SW_RESET_RESET_ATX]	= REG_FIELD(ISP1763_HC_RESET, 3, 3),
-+	[SW_RESET_RESET_ALL]	= REG_FIELD(ISP1763_HC_RESET, 0, 0),
-+	[HC_CHIP_ID_HIGH]	= REG_FIELD(ISP1763_HC_CHIP_ID, 0, 15),
-+	[HC_CHIP_ID_LOW]	= REG_FIELD(ISP1763_HC_CHIP_REV, 8, 15),
-+	[HC_CHIP_REV]		= REG_FIELD(ISP1763_HC_CHIP_REV, 0, 7),
-+	[HC_SCRATCH]		= REG_FIELD(ISP1763_HC_SCRATCH, 0, 15),
-+	[ISO_BUF_FILL]		= REG_FIELD(ISP1763_HC_BUFFER_STATUS, 2, 2),
-+	[INT_BUF_FILL]		= REG_FIELD(ISP1763_HC_BUFFER_STATUS, 1, 1),
-+	[ATL_BUF_FILL]		= REG_FIELD(ISP1763_HC_BUFFER_STATUS, 0, 0),
-+	[MEM_START_ADDR]	= REG_FIELD(ISP1763_HC_MEMORY, 0, 15),
-+	[HC_DATA]		= REG_FIELD(ISP1763_HC_DATA, 0, 15),
-+	[HC_INTERRUPT]		= REG_FIELD(ISP1763_HC_INTERRUPT, 0, 10),
-+	[HC_ATL_IRQ_ENABLE]	= REG_FIELD(ISP1763_HC_INTERRUPT_ENABLE, 8, 8),
-+	[HC_INT_IRQ_ENABLE]	= REG_FIELD(ISP1763_HC_INTERRUPT_ENABLE, 7, 7),
-+	[HC_ISO_IRQ_MASK_OR]	= REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_OR, 0, 15),
-+	[HC_INT_IRQ_MASK_OR]	= REG_FIELD(ISP1763_HC_INT_IRQ_MASK_OR, 0, 15),
-+	[HC_ATL_IRQ_MASK_OR]	= REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_OR, 0, 15),
-+	[HC_ISO_IRQ_MASK_AND]	= REG_FIELD(ISP1763_HC_ISO_IRQ_MASK_AND, 0, 15),
-+	[HC_INT_IRQ_MASK_AND]	= REG_FIELD(ISP1763_HC_INT_IRQ_MASK_AND, 0, 15),
-+	[HC_ATL_IRQ_MASK_AND]	= REG_FIELD(ISP1763_HC_ATL_IRQ_MASK_AND, 0, 15),
-+	[HW_HC_2_DIS]		= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 15, 15),
-+	[HW_OTG_DISABLE]	= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 10, 10),
-+	[HW_SW_SEL_HC_DC]	= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 7, 7),
-+	[HW_VBUS_DRV]		= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 4, 4),
-+	[HW_SEL_CP_EXT]		= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 3, 3),
-+	[HW_DM_PULLDOWN]	= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 2, 2),
-+	[HW_DP_PULLDOWN]	= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 1, 1),
-+	[HW_DP_PULLUP]		= REG_FIELD(ISP1763_HC_OTG_CTRL_SET, 0, 0),
-+	[HW_HC_2_DIS_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 15, 15),
-+	[HW_OTG_DISABLE_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 10, 10),
-+	[HW_SW_SEL_HC_DC_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 7, 7),
-+	[HW_VBUS_DRV_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 4, 4),
-+	[HW_SEL_CP_EXT_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 3, 3),
-+	[HW_DM_PULLDOWN_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 2, 2),
-+	[HW_DP_PULLDOWN_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 1, 1),
-+	[HW_DP_PULLUP_CLEAR]	= REG_FIELD(ISP1763_HC_OTG_CTRL_CLEAR, 0, 0),
-+};
-+
-+int isp1760_register(struct isp1760_device *isp, struct resource *mem, int irq,
-+		     unsigned long irqflags)
-+{
-+	const struct regmap_config *hc_regmap;
-+	const struct reg_field *hc_reg_fields;
-+	struct isp1760_hcd *hcd;
-+	struct regmap_field *f;
-+	unsigned int devflags;
-+	struct udevice *dev;
-+	int ret;
-+	int i;
-+
-+	hcd = &isp->hcd;
-+	devflags = isp->devflags;
-+	dev = isp->dev;
-+
-+	hcd->is_isp1763 = !!(devflags & ISP1760_FLAG_ISP1763);
-+
-+	if (!hcd->is_isp1763 && (devflags & ISP1760_FLAG_BUS_WIDTH_8)) {
-+		dev_err(dev, "isp1760/61 do not support data width 8\n");
-+		return -EINVAL;
-+	}
-+
-+	if (hcd->is_isp1763) {
-+		hc_regmap = &isp1763_hc_regmap_conf;
-+		hc_reg_fields = &isp1763_hc_reg_fields[0];
-+	} else {
-+		hc_regmap = &isp1760_hc_regmap_conf;
-+		hc_reg_fields = &isp1760_hc_reg_fields[0];
-+	}
-+
-+	hcd->base = devm_ioremap(dev, mem->start, resource_size(mem));
-+	if (IS_ERR(hcd->base))
-+		return PTR_ERR(hcd->base);
-+
-+	hcd->regs = devm_regmap_init(dev, NULL, NULL, hc_regmap);
-+	if (IS_ERR(hcd->regs))
-+		return PTR_ERR(hcd->regs);
-+
-+	for (i = 0; i < HC_FIELD_MAX; i++) {
-+		f = devm_regmap_field_alloc(dev, hcd->regs, hc_reg_fields[i]);
-+		if (IS_ERR(f))
-+			return PTR_ERR(f);
-+
-+		hcd->fields[i] = f;
-+	}
-+
-+	if (hcd->is_isp1763)
-+		hcd->memory_layout = &isp1763_memory_conf;
-+	else
-+		hcd->memory_layout = &isp176x_memory_conf;
-+
-+	ret = isp1760_init_core(isp);
-+	if (ret < 0)
-+		return ret;
-+
-+	hcd->dev = dev;
-+
-+	ret = isp1760_hcd_register(hcd, mem, irq, irqflags, dev);
-+	if (ret < 0)
-+		return ret;
-+
-+	ret = isp1760_hcd_lowlevel_init(hcd);
-+	if (ret < 0)
-+		return ret;
-+
-+	dev_set_drvdata(dev, isp);
-+
-+	return 0;
-+}
-+
-+void isp1760_unregister(struct isp1760_device *isp)
-+{
-+	isp1760_hcd_unregister(&isp->hcd);
-+
-+	return;
-+}
-diff --git a/drivers/usb/isp1760/isp1760-core.h b/drivers/usb/isp1760/isp1760-core.h
-new file mode 100644
-index 0000000000..0a60e30b5f
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-core.h
-@@ -0,0 +1,96 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva
-+ * Copyright 2014 Laurent Pinchart
-+ * Copyright 2007 Sebastian Siewior
-+ *
-+ * Contacts:
-+ *	Sebastian Siewior <bigeasy@linutronix.de>
-+ *	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-+ *	Rui Miguel Silva <rui.silva@linaro.org>
-+ */
-+
-+#ifndef _ISP1760_CORE_H_
-+#define _ISP1760_CORE_H_
-+
-+#include <linux/compat.h>
-+#include <linux/ioport.h>
-+#include <regmap.h>
-+
-+#include "isp1760-hcd.h"
-+
-+struct device;
-+struct gpio_desc;
-+
-+/*
-+ * Device flags that can vary from board to board.  All of these
-+ * indicate the most "atypical" case, so that a devflags of 0 is
-+ * a sane default configuration.
-+ */
-+#define ISP1760_FLAG_BUS_WIDTH_16	0x00000002 /* 16-bit data bus width */
-+#define ISP1760_FLAG_PERIPHERAL_EN	0x00000004 /* Port 1 supports Peripheral mode*/
-+#define ISP1760_FLAG_ANALOG_OC		0x00000008 /* Analog overcurrent */
-+#define ISP1760_FLAG_DACK_POL_HIGH	0x00000010 /* DACK active high */
-+#define ISP1760_FLAG_DREQ_POL_HIGH	0x00000020 /* DREQ active high */
-+#define ISP1760_FLAG_ISP1761		0x00000040 /* Chip is ISP1761 */
-+#define ISP1760_FLAG_INTR_POL_HIGH	0x00000080 /* Interrupt polarity active high */
-+#define ISP1760_FLAG_INTR_EDGE_TRIG	0x00000100 /* Interrupt edge triggered */
-+#define ISP1760_FLAG_ISP1763		0x00000200 /* Chip is ISP1763 */
-+#define ISP1760_FLAG_BUS_WIDTH_8	0x00000400 /* 8-bit data bus width */
-+
-+struct isp1760_device {
-+	struct udevice *dev;
-+
-+	unsigned int devflags;
-+	struct gpio_desc *rst_gpio;
-+
-+	struct isp1760_hcd hcd;
-+};
-+
-+int isp1760_register(struct isp1760_device *isp, struct resource *mem, int irq,
-+		     unsigned long irqflags);
-+void isp1760_unregister(struct isp1760_device *isp);
-+
-+void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
-+
-+static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
-+{
-+	unsigned int val;
-+
-+	regmap_field_read(fields[field], &val);
-+
-+	return val;
-+}
-+
-+static inline void isp1760_field_write(struct regmap_field **fields, u32 field,
-+				       u32 val)
-+{
-+	regmap_field_write(fields[field], val);
-+}
-+
-+static inline void isp1760_field_set(struct regmap_field **fields, u32 field)
-+{
-+	isp1760_field_write(fields, field, 0xFFFFFFFF);
-+}
-+
-+static inline void isp1760_field_clear(struct regmap_field **fields, u32 field)
-+{
-+	isp1760_field_write(fields, field, 0);
-+}
-+
-+static inline u32 isp1760_reg_read(struct regmap *regs, u32 reg)
-+{
-+	unsigned int val;
-+
-+	regmap_read(regs, reg, &val);
-+
-+	return val;
-+}
-+
-+static inline void isp1760_reg_write(struct regmap *regs, u32 reg, u32 val)
-+{
-+	regmap_write(regs, reg, val);
-+}
-+#endif
-diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
-new file mode 100644
-index 0000000000..b1d86dd69b
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-hcd.c
-@@ -0,0 +1,2574 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ */
-+
-+#include <hexdump.h>
-+#include <common.h>
-+#include <asm/cache.h>
-+#include <cpu_func.h>
-+#include <dm.h>
-+#include <dm/device-internal.h>
-+#include <dm/device_compat.h>
-+#include <linux/bug.h>
-+#include <linux/kernel.h>
-+#include <linux/list.h>
-+#include <linux/usb/usb_urb_compat.h>
-+#include <usb.h>
-+#include <linux/io.h>
-+#include <linux/iopoll.h>
-+#include <asm/unaligned.h>
-+
-+#include "isp1760-core.h"
-+#include "isp1760-hcd.h"
-+#include "isp1760-regs.h"
-+#include "isp1760-uboot.h"
-+
-+static struct kmem_cache *qtd_cachep;
-+static struct kmem_cache *qh_cachep;
-+static struct kmem_cache *urb_listitem_cachep;
-+
-+typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
-+			      struct isp1760_qtd *qtd);
-+
-+static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd)
-+{
-+	return hcd->hcd_priv;
-+}
-+
-+#define dw_to_le32(x)	(cpu_to_le32((__force u32)x))
-+#define le32_to_dw(x)	((__force __dw)(le32_to_cpu(x)))
-+
-+/* urb state*/
-+#define DELETE_URB		(0x0008)
-+#define NO_TRANSFER_ACTIVE	(0xffffffff)
-+
-+/* Philips Proprietary Transfer Descriptor (PTD) */
-+typedef __u32 __bitwise __dw;
-+struct ptd {
-+	__dw dw0;
-+	__dw dw1;
-+	__dw dw2;
-+	__dw dw3;
-+	__dw dw4;
-+	__dw dw5;
-+	__dw dw6;
-+	__dw dw7;
-+};
-+
-+struct ptd_le32 {
-+	__le32 dw0;
-+	__le32 dw1;
-+	__le32 dw2;
-+	__le32 dw3;
-+	__le32 dw4;
-+	__le32 dw5;
-+	__le32 dw6;
-+	__le32 dw7;
-+};
-+
-+#define PTD_OFFSET		0x0400
-+#define ISO_PTD_OFFSET		0x0400
-+#define INT_PTD_OFFSET		0x0800
-+#define ATL_PTD_OFFSET		0x0c00
-+#define PAYLOAD_OFFSET		0x1000
-+
-+#define ISP_BANK_0		0x00
-+#define ISP_BANK_1		0x01
-+#define ISP_BANK_2		0x02
-+#define ISP_BANK_3		0x03
-+
-+#define TO_DW(x)	((__force __dw)x)
-+#define TO_U32(x)	((__force u32)x)
-+
-+ /* ATL */
-+ /* DW0 */
-+#define DW0_VALID_BIT			TO_DW(1)
-+#define FROM_DW0_VALID(x)		(TO_U32(x) & 0x01)
-+#define TO_DW0_LENGTH(x)		TO_DW((((u32)x) << 3))
-+#define TO_DW0_MAXPACKET(x)		TO_DW((((u32)x) << 18))
-+#define TO_DW0_MULTI(x)			TO_DW((((u32)x) << 29))
-+#define TO_DW0_ENDPOINT(x)		TO_DW((((u32)x) << 31))
-+/* DW1 */
-+#define TO_DW1_DEVICE_ADDR(x)		TO_DW((((u32)x) << 3))
-+#define TO_DW1_PID_TOKEN(x)		TO_DW((((u32)x) << 10))
-+#define DW1_TRANS_BULK			TO_DW(((u32)2 << 12))
-+#define DW1_TRANS_INT			TO_DW(((u32)3 << 12))
-+#define DW1_TRANS_SPLIT			TO_DW(((u32)1 << 14))
-+#define DW1_SE_USB_LOSPEED		TO_DW(((u32)2 << 16))
-+#define TO_DW1_PORT_NUM(x)		TO_DW((((u32)x) << 18))
-+#define TO_DW1_HUB_NUM(x)		TO_DW((((u32)x) << 25))
-+/* DW2 */
-+#define TO_DW2_DATA_START_ADDR(x)	TO_DW((((u32)x) << 8))
-+#define TO_DW2_RL(x)			TO_DW(((x) << 25))
-+#define FROM_DW2_RL(x)			((TO_U32(x) >> 25) & 0xf)
-+/* DW3 */
-+#define FROM_DW3_NRBYTESTRANSFERRED(x)		TO_U32((x) & 0x3fff)
-+#define FROM_DW3_SCS_NRBYTESTRANSFERRED(x)	TO_U32((x) & 0x07ff)
-+#define TO_DW3_NAKCOUNT(x)		TO_DW(((x) << 19))
-+#define FROM_DW3_NAKCOUNT(x)		((TO_U32(x) >> 19) & 0xf)
-+#define TO_DW3_CERR(x)			TO_DW(((x) << 23))
-+#define FROM_DW3_CERR(x)		((TO_U32(x) >> 23) & 0x3)
-+#define TO_DW3_DATA_TOGGLE(x)		TO_DW(((x) << 25))
-+#define FROM_DW3_DATA_TOGGLE(x)		((TO_U32(x) >> 25) & 0x1)
-+#define TO_DW3_PING(x)			TO_DW(((x) << 26))
-+#define FROM_DW3_PING(x)		((TO_U32(x) >> 26) & 0x1)
-+#define DW3_ERROR_BIT			TO_DW((1 << 28))
-+#define DW3_BABBLE_BIT			TO_DW((1 << 29))
-+#define DW3_HALT_BIT			TO_DW((1 << 30))
-+#define DW3_ACTIVE_BIT			TO_DW((1 << 31))
-+#define FROM_DW3_ACTIVE(x)		((TO_U32(x) >> 31) & 0x01)
-+
-+#define INT_UNDERRUN			(1 << 2)
-+#define INT_BABBLE			(1 << 1)
-+#define INT_EXACT			(1 << 0)
-+
-+#define SETUP_PID	(2)
-+#define IN_PID		(1)
-+#define OUT_PID		(0)
-+
-+/* Errata 1 */
-+#define RL_COUNTER	(0)
-+#define NAK_COUNTER	(0)
-+#define ERR_COUNTER	(3)
-+
-+struct isp1760_qtd {
-+	u8 packet_type;
-+	void *data_buffer;
-+	u32 payload_addr;
-+
-+	/* the rest is HCD-private */
-+	struct list_head qtd_list;
-+	struct urb *urb;
-+	size_t length;
-+	size_t actual_length;
-+
-+	/* QTD_ENQUEUED:	waiting for transfer (inactive) */
-+	/* QTD_PAYLOAD_ALLOC:	chip mem has been allocated for payload */
-+	/* QTD_XFER_STARTED:	valid ptd has been written to isp176x - only
-+				interrupt handler may touch this qtd! */
-+	/* QTD_XFER_COMPLETE:	payload has been transferred successfully */
-+	/* QTD_RETIRE:		transfer error/abort qtd */
-+#define QTD_ENQUEUED		0
-+#define QTD_PAYLOAD_ALLOC	1
-+#define QTD_XFER_STARTED	2
-+#define QTD_XFER_COMPLETE	3
-+#define QTD_RETIRE		4
-+	u32 status;
-+};
-+
-+/* Queue head, one for each active endpoint */
-+struct isp1760_qh {
-+	struct list_head qh_list;
-+	struct list_head qtd_list;
-+	int epnum;
-+	u32 toggle;
-+	u32 ping;
-+	int slot;
-+	int tt_buffer_dirty;	/* See USB2.0 spec section 11.17.5 */
-+};
-+
-+struct urb_listitem {
-+	struct list_head urb_list;
-+	struct urb *urb;
-+};
-+
-+static const u32 isp1763_hc_portsc1_fields[] = {
-+	[PORT_OWNER]		= BIT(13),
-+	[PORT_POWER]		= BIT(12),
-+	[PORT_LSTATUS]		= BIT(10),
-+	[PORT_RESET]		= BIT(8),
-+	[PORT_SUSPEND]		= BIT(7),
-+	[PORT_RESUME]		= BIT(6),
-+	[PORT_PE]		= BIT(2),
-+	[PORT_CSC]		= BIT(1),
-+	[PORT_CONNECT]		= BIT(0),
-+};
-+
-+static struct descriptor {
-+	struct usb_device_descriptor device;
-+	struct usb_config_descriptor config;
-+	struct usb_interface_descriptor interface;
-+	struct usb_endpoint_descriptor endpoint;
-+} __packed rh_descriptor = {
-+	{
-+		/* usb 2.0 root hub device descriptor */
-+		0x12,       /*  __u8  bLength; */
-+		USB_DT_DEVICE, /* __u8 bDescriptorType; Device */
-+		0x0002, /*  __le16 bcdUSB; v2.0 */
-+
-+		0x09,       /*  __u8  bDeviceClass; HUB_CLASSCODE */
-+		0x00,       /*  __u8  bDeviceSubClass; */
-+		0x00,       /*  __u8  bDeviceProtocol; [ usb 2.0 no TT ] */
-+		0x40,       /*  __u8  bMaxPacketSize0; 64 Bytes */
-+
-+		0x6b1d,     /*  __le16 idVendor; Linux Foundation 0x1d6b */
-+		0x0200,     /*  __le16 idProduct; device 0x0002 */
-+		0x0001,     /*  __le16 bcdDevice */
-+
-+		0x03,       /*  __u8  iManufacturer; */
-+		0x02,       /*  __u8  iProduct; */
-+		0x01,       /*  __u8  iSerialNumber; */
-+		0x01        /*  __u8  bNumConfigurations; */
-+	}, {
-+		/* one configuration */
-+		0x09,       /*  __u8  bLength; */
-+		USB_DT_CONFIG, /* __u8 bDescriptorType; Configuration */
-+		0x1900,     /*  __le16 wTotalLength; */
-+		0x01,       /*  __u8  bNumInterfaces; (1) */
-+		0x01,       /*  __u8  bConfigurationValue; */
-+		0x00,       /*  __u8  iConfiguration; */
-+		0xc0,       /*  __u8  bmAttributes;
-+					Bit 7: must be set,
-+					6: Self-powered,
-+					5: Remote wakeup,
-+					4..0: resvd */
-+		0x00,       /*  __u8  MaxPower; */
-+	}, {
-+		/* one interface */
-+		0x09,       /*  __u8  if_bLength; */
-+		USB_DT_INTERFACE, /* __u8 if_bDescriptorType; Interface */
-+		0x00,       /*  __u8  if_bInterfaceNumber; */
-+		0x00,       /*  __u8  if_bAlternateSetting; */
-+		0x01,       /*  __u8  if_bNumEndpoints; */
-+		0x09,       /*  __u8  if_bInterfaceClass; HUB_CLASSCODE */
-+		0x00,       /*  __u8  if_bInterfaceSubClass; */
-+		0x00,       /*  __u8  if_bInterfaceProtocol; [usb1.1 or single tt] */
-+		0x00,       /*  __u8  if_iInterface; */
-+	}, {
-+		/* one endpoint (status change endpoint) */
-+		0x07,       /*  __u8  ep_bLength; */
-+		USB_DT_ENDPOINT, /* __u8 ep_bDescriptorType; Endpoint */
-+		0x81,       /*  __u8  ep_bEndpointAddress; IN Endpoint 1 */
-+		0x03,       /*  __u8  ep_bmAttributes; Interrupt */
-+			/* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8)
-+			* see hub.c:hub_configure() for details. */
-+		(USB_MAXCHILDREN + 1 + 7) / 8, 0x00,
-+		0x0c        /*  __u8  ep_bInterval; (256ms -- usb 2.0 spec) */
-+	},
-+};
-+
-+/*
-+ * Access functions for isp176x registers regmap fields
-+ */
-+static u32 isp1760_hcd_read(struct usb_hcd *hcd, u32 field)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	return isp1760_field_read(priv->fields, field);
-+}
-+
-+/*
-+ * We need, in isp1763, to write directly the values to the portsc1
-+ * register so it will make the other values to trigger.
-+ */
-+static void isp1760_hcd_portsc1_set_clear(struct isp1760_hcd *priv, u32 field,
-+					  u32 val)
-+{
-+	u32 bit = isp1763_hc_portsc1_fields[field];
-+	u32 port_status = readl(priv->base + ISP1763_HC_PORTSC1);
-+
-+	if (val)
-+		writel(port_status | bit, priv->base + ISP1763_HC_PORTSC1);
-+	else
-+		writel(port_status & ~bit, priv->base + ISP1763_HC_PORTSC1);
-+}
-+
-+static void isp1760_hcd_write(struct usb_hcd *hcd, u32 field, u32 val)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (unlikely(priv->is_isp1763 &&
-+		     (field >= PORT_OWNER && field <= PORT_CONNECT)))
-+		return isp1760_hcd_portsc1_set_clear(priv, field, val);
-+
-+	isp1760_field_write(priv->fields, field, val);
-+}
-+
-+static void isp1760_hcd_set(struct usb_hcd *hcd, u32 field)
-+{
-+	isp1760_hcd_write(hcd, field, 0xFFFFFFFF);
-+}
-+
-+static void isp1760_hcd_clear(struct usb_hcd *hcd, u32 field)
-+{
-+	isp1760_hcd_write(hcd, field, 0);
-+}
-+
-+static int isp1760_hcd_set_and_wait(struct usb_hcd *hcd, u32 field,
-+				    u32 timeout_us)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 val;
-+
-+	isp1760_hcd_set(hcd, field);
-+
-+	return regmap_field_read_poll_timeout(priv->fields[field], val,
-+					      val, 10, timeout_us);
-+}
-+
-+static int isp1760_hcd_set_and_wait_swap(struct usb_hcd *hcd, u32 field,
-+					 u32 timeout_us)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 val;
-+
-+	isp1760_hcd_set(hcd, field);
-+
-+	return regmap_field_read_poll_timeout(priv->fields[field], val,
-+					      !val, 10, timeout_us);
-+}
-+
-+static int isp1760_hcd_clear_and_wait(struct usb_hcd *hcd, u32 field,
-+				      u32 timeout_us)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 val;
-+
-+	isp1760_hcd_clear(hcd, field);
-+
-+	return regmap_field_read_poll_timeout(priv->fields[field], val,
-+					      !val, 10, timeout_us);
-+}
-+
-+static bool isp1760_hcd_is_set(struct usb_hcd *hcd, u32 field)
-+{
-+	return !!isp1760_hcd_read(hcd, field);
-+}
-+
-+static bool isp1760_hcd_ppc_is_set(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (priv->is_isp1763)
-+		return true;
-+
-+	return isp1760_hcd_is_set(hcd, HCS_PPC);
-+}
-+
-+static u32 isp1760_hcd_n_ports(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (priv->is_isp1763)
-+		return 1;
-+
-+	return isp1760_hcd_read(hcd, HCS_N_PORTS);
-+}
-+
-+/*
-+ * Access functions for isp176x memory (offset >= 0x0400).
-+ *
-+ * bank_reads8() reads memory locations prefetched by an earlier write to
-+ * HC_MEMORY_REG (see isp176x datasheet). Unless you want to do fancy multi-
-+ * bank optimizations, you should use the more generic mem_read() below.
-+ *
-+ * For access to ptd memory, use the specialized ptd_read() and ptd_write()
-+ * below.
-+ *
-+ * These functions copy via MMIO data to/from the device. memcpy_{to|from}io()
-+ * doesn't quite work because some people have to enforce 32-bit access
-+ */
-+static void bank_reads8(void __iomem *src_base, u32 src_offset, u32 bank_addr,
-+							__u32 *dst, u32 bytes)
-+{
-+	__u32 __iomem *src;
-+	u32 val;
-+	__u8 *src_byteptr;
-+	__u8 *dst_byteptr;
-+
-+	src = src_base + (bank_addr | src_offset);
-+
-+	if (src_offset < PAYLOAD_OFFSET) {
-+		while (bytes >= 4) {
-+			*dst = readl_relaxed(src);
-+			bytes -= 4;
-+			src++;
-+			dst++;
-+		}
-+	} else {
-+		while (bytes >= 4) {
-+			*dst = __raw_readl(src);
-+			bytes -= 4;
-+			src++;
-+			dst++;
-+		}
-+	}
-+
-+	if (!bytes)
-+		return;
-+
-+	/* in case we have 3, 2 or 1 by left. The dst buffer may not be fully
-+	 * allocated.
-+	 */
-+	if (src_offset < PAYLOAD_OFFSET)
-+		val = readl_relaxed(src);
-+	else
-+		val = __raw_readl(src);
-+
-+	dst_byteptr = (void *) dst;
-+	src_byteptr = (void *) &val;
-+	while (bytes > 0) {
-+		*dst_byteptr = *src_byteptr;
-+		dst_byteptr++;
-+		src_byteptr++;
-+		bytes--;
-+	}
-+}
-+
-+static void isp1760_mem_read(struct usb_hcd *hcd, u32 src_offset, void *dst,
-+			     u32 bytes)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	isp1760_hcd_write(hcd, MEM_BANK_SEL, ISP_BANK_0);
-+	isp1760_hcd_write(hcd, MEM_START_ADDR, src_offset);
-+	ndelay(100);
-+
-+	bank_reads8(priv->base, src_offset, ISP_BANK_0, dst, bytes);
-+}
-+
-+/*
-+ * ISP1763 does not have the banks direct host controller memory access,
-+ * needs to use the HC_DATA register. Add data read/write according to this,
-+ * and also adjust 16bit access.
-+ */
-+static void isp1763_mem_read(struct usb_hcd *hcd, u16 srcaddr,
-+			     u16 *dstptr, u32 bytes)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+
-+	/* Write the starting device address to the hcd memory register */
-+	isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, srcaddr);
-+	ndelay(100); /* Delay between consecutive access */
-+
-+	/* As long there are at least 16-bit to read ... */
-+	while (bytes >= 2) {
-+		*dstptr = __raw_readw(priv->base + ISP1763_HC_DATA);
-+		bytes -= 2;
-+		dstptr++;
-+	}
-+
-+	/* If there are no more bytes to read, return */
-+	if (bytes <= 0)
-+		return;
-+
-+	*((u8 *)dstptr) = (u8)(readw(priv->base + ISP1763_HC_DATA) & 0xFF);
-+}
-+
-+static void mem_read(struct usb_hcd *hcd, u32 src_offset, __u32 *dst,
-+		     u32 bytes)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (!priv->is_isp1763)
-+		return isp1760_mem_read(hcd, src_offset, (u16 *)dst, bytes);
-+
-+	isp1763_mem_read(hcd, (u16)src_offset, (u16 *)dst, bytes);
-+}
-+
-+static void isp1760_mem_write(void __iomem *dst_base, u32 dst_offset,
-+			      __u32 const *src, u32 bytes)
-+{
-+	__u32 __iomem *dst;
-+
-+	dst = dst_base + dst_offset;
-+
-+	if (dst_offset < PAYLOAD_OFFSET) {
-+		while (bytes >= 4) {
-+			writel_relaxed(*src, dst);
-+			bytes -= 4;
-+			src++;
-+			dst++;
-+		}
-+	} else {
-+		while (bytes >= 4) {
-+			__raw_writel(*src, dst);
-+			bytes -= 4;
-+			src++;
-+			dst++;
-+		}
-+	}
-+
-+	if (!bytes)
-+		return;
-+	/* in case we have 3, 2 or 1 bytes left. The buffer is allocated and the
-+	 * extra bytes should not be read by the HW.
-+	 */
-+
-+	if (dst_offset < PAYLOAD_OFFSET)
-+		writel_relaxed(*src, dst);
-+	else
-+		__raw_writel(*src, dst);
-+}
-+
-+static void isp1763_mem_write(struct usb_hcd *hcd, u16 dstaddr, u16 *src,
-+			      u32 bytes)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	/* Write the starting device address to the hcd memory register */
-+	isp1760_reg_write(priv->regs, ISP1763_HC_MEMORY, dstaddr);
-+	ndelay(100); /* Delay between consecutive access */
-+
-+	while (bytes >= 2) {
-+		/* Get and write the data; then adjust the data ptr and len */
-+		__raw_writew(*src, priv->base + ISP1763_HC_DATA);
-+		bytes -= 2;
-+		src++;
-+	}
-+
-+	/* If there are no more bytes to process, return */
-+	if (bytes <= 0)
-+		return;
-+
-+	/*
-+	 * The only way to get here is if there is a single byte left,
-+	 * get it and write it to the data reg;
-+	 */
-+	writew(*((u8 *)src), priv->base + ISP1763_HC_DATA);
-+}
-+
-+static void mem_write(struct usb_hcd *hcd, u32 dst_offset, __u32 *src,
-+		      u32 bytes)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (!priv->is_isp1763)
-+		return isp1760_mem_write(priv->base, dst_offset, src, bytes);
-+
-+	isp1763_mem_write(hcd, dst_offset, (u16 *)src, bytes);
-+}
-+
-+/*
-+ * Read and write ptds. 'ptd_offset' should be one of ISO_PTD_OFFSET,
-+ * INT_PTD_OFFSET, and ATL_PTD_OFFSET. 'slot' should be less than 32.
-+ */
-+static void isp1760_ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,
-+			     struct ptd *ptd)
-+{
-+	u16 src_offset = ptd_offset + slot * sizeof(*ptd);
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	isp1760_hcd_write(hcd, MEM_BANK_SEL, ISP_BANK_0);
-+	isp1760_hcd_write(hcd, MEM_START_ADDR, src_offset);
-+	ndelay(90);
-+
-+	bank_reads8(priv->base, src_offset, ISP_BANK_0, (void *)ptd,
-+		    sizeof(*ptd));
-+}
-+
-+static void isp1763_ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,
-+			     struct ptd *ptd)
-+{
-+	u16 src_offset = ptd_offset + slot * sizeof(*ptd);
-+	struct ptd_le32 le32_ptd;
-+
-+	isp1763_mem_read(hcd, src_offset, (u16 *)&le32_ptd, sizeof(le32_ptd));
-+	/* Normalize the data obtained */
-+	ptd->dw0 = le32_to_dw(le32_ptd.dw0);
-+	ptd->dw1 = le32_to_dw(le32_ptd.dw1);
-+	ptd->dw2 = le32_to_dw(le32_ptd.dw2);
-+	ptd->dw3 = le32_to_dw(le32_ptd.dw3);
-+	ptd->dw4 = le32_to_dw(le32_ptd.dw4);
-+	ptd->dw5 = le32_to_dw(le32_ptd.dw5);
-+	ptd->dw6 = le32_to_dw(le32_ptd.dw6);
-+	ptd->dw7 = le32_to_dw(le32_ptd.dw7);
-+}
-+
-+static void ptd_read(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,
-+		     struct ptd *ptd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (!priv->is_isp1763)
-+		return isp1760_ptd_read(hcd, ptd_offset, slot, ptd);
-+
-+	isp1763_ptd_read(hcd, ptd_offset, slot, ptd);
-+}
-+
-+static void isp1763_ptd_write(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,
-+			      struct ptd *cpu_ptd)
-+{
-+	u16 dst_offset = ptd_offset + slot * sizeof(*cpu_ptd);
-+	struct ptd_le32 ptd;
-+
-+	ptd.dw0 = dw_to_le32(cpu_ptd->dw0);
-+	ptd.dw1 = dw_to_le32(cpu_ptd->dw1);
-+	ptd.dw2 = dw_to_le32(cpu_ptd->dw2);
-+	ptd.dw3 = dw_to_le32(cpu_ptd->dw3);
-+	ptd.dw4 = dw_to_le32(cpu_ptd->dw4);
-+	ptd.dw5 = dw_to_le32(cpu_ptd->dw5);
-+	ptd.dw6 = dw_to_le32(cpu_ptd->dw6);
-+	ptd.dw7 = dw_to_le32(cpu_ptd->dw7);
-+
-+	isp1763_mem_write(hcd, dst_offset,  (u16 *)&ptd.dw0,
-+			  8 * sizeof(ptd.dw0));
-+}
-+
-+static void isp1760_ptd_write(void __iomem *base, u32 ptd_offset, u32 slot,
-+			      struct ptd *ptd)
-+{
-+	u32 dst_offset = ptd_offset + slot * sizeof(*ptd);
-+
-+	/*
-+	 * Make sure dw0 gets written last (after other dw's and after payload)
-+	 *  since it contains the enable bit
-+	 */
-+	isp1760_mem_write(base, dst_offset + sizeof(ptd->dw0),
-+			  (__force u32 *)&ptd->dw1, 7 * sizeof(ptd->dw1));
-+	wmb();
-+	isp1760_mem_write(base, dst_offset, (__force u32 *)&ptd->dw0,
-+			  sizeof(ptd->dw0));
-+}
-+
-+static void ptd_write(struct usb_hcd *hcd, u32 ptd_offset, u32 slot,
-+		      struct ptd *ptd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	if (!priv->is_isp1763)
-+		return isp1760_ptd_write(priv->base, ptd_offset, slot, ptd);
-+
-+	isp1763_ptd_write(hcd, ptd_offset, slot, ptd);
-+}
-+
-+/* memory management of the 60kb on the chip from 0x1000 to 0xffff */
-+static void init_memory(struct isp1760_hcd *priv)
-+{
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	int i, j, curr;
-+	u32 payload_addr;
-+
-+	payload_addr = PAYLOAD_OFFSET;
-+
-+	for (i = 0, curr = 0; i < ARRAY_SIZE(mem->blocks); i++) {
-+		for (j = 0; j < mem->blocks[i]; j++, curr++) {
-+			priv->memory_pool[curr + j].start = payload_addr;
-+			priv->memory_pool[curr + j].size = mem->blocks_size[i];
-+			priv->memory_pool[curr + j].free = 1;
-+			payload_addr += priv->memory_pool[curr + j].size;
-+		}
-+	}
-+
-+	WARN_ON(payload_addr - priv->memory_pool[0].start >
-+		mem->payload_area_size);
-+}
-+
-+static void alloc_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	int i;
-+
-+	WARN_ON(qtd->payload_addr);
-+
-+	if (!qtd->length)
-+		return;
-+
-+	for (i = 0; i < mem->payload_blocks; i++) {
-+		if (priv->memory_pool[i].size >= qtd->length &&
-+				priv->memory_pool[i].free) {
-+			priv->memory_pool[i].free = 0;
-+			qtd->payload_addr = priv->memory_pool[i].start;
-+			return;
-+		}
-+	}
-+}
-+
-+static void free_mem(struct usb_hcd *hcd, struct isp1760_qtd *qtd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	int i;
-+
-+	if (!qtd->payload_addr)
-+		return;
-+
-+	for (i = 0; i < mem->payload_blocks; i++) {
-+		if (priv->memory_pool[i].start == qtd->payload_addr) {
-+			WARN_ON(priv->memory_pool[i].free);
-+			priv->memory_pool[i].free = 1;
-+			qtd->payload_addr = 0;
-+			return;
-+		}
-+	}
-+
-+	WARN_ON(1);
-+	qtd->payload_addr = 0;
-+}
-+
-+/* reset a non-running (STS_HALT == 1) controller */
-+static int ehci_reset(struct usb_hcd *hcd)
-+{
-+	return isp1760_hcd_set_and_wait_swap(hcd, CMD_RESET, 250 * 1000);
-+}
-+
-+static struct isp1760_qh *qh_alloc(gfp_t flags)
-+{
-+	struct isp1760_qh *qh;
-+
-+	qh = kmem_cache_alloc(qh_cachep, flags);
-+	if (!qh)
-+		return NULL;
-+
-+	memset(qh, '\0', qh_cachep->sz);
-+	INIT_LIST_HEAD(&qh->qh_list);
-+	INIT_LIST_HEAD(&qh->qtd_list);
-+	qh->slot = -1;
-+
-+	return qh;
-+}
-+
-+static void qh_free(struct isp1760_qh *qh)
-+{
-+	WARN_ON(!list_empty(&qh->qtd_list));
-+	WARN_ON(qh->slot > -1);
-+	kmem_cache_free(qh_cachep, qh);
-+}
-+
-+/* one-time init, only for memory state */
-+static int priv_init(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 isoc_cache;
-+	u32 isoc_thres;
-+	int i;
-+
-+	spin_lock_init(&priv->lock);
-+
-+	for (i = 0; i < QH_END; i++)
-+		INIT_LIST_HEAD(&priv->qh_list[i]);
-+
-+	/*
-+	 * hw default: 1K periodic list heads, one per frame.
-+	 * periodic_size can shrink by USBCMD update if hcc_params allows.
-+	 */
-+	priv->periodic_size = DEFAULT_I_TDPS;
-+
-+	if (priv->is_isp1763) {
-+		priv->i_thresh = 2;
-+		return 0;
-+	}
-+
-+	/* controllers may cache some of the periodic schedule ... */
-+	isoc_cache = isp1760_hcd_read(hcd, HCC_ISOC_CACHE);
-+	isoc_thres = isp1760_hcd_read(hcd, HCC_ISOC_THRES);
-+
-+	/* full frame cache */
-+	if (isoc_cache)
-+		priv->i_thresh = 8;
-+	else /* N microframes cached */
-+		priv->i_thresh = 2 + isoc_thres;
-+
-+	return 0;
-+}
-+
-+static int isp1760_hc_setup(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 atx_reset;
-+	int result;
-+	u32 scratch;
-+	u32 pattern;
-+
-+	if (priv->is_isp1763)
-+		pattern = 0xcafe;
-+	else
-+		pattern = 0xdeadcafe;
-+
-+	isp1760_hcd_write(hcd, HC_SCRATCH, pattern);
-+
-+	/* Change bus pattern */
-+	scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);
-+	scratch = isp1760_hcd_read(hcd, HC_SCRATCH);
-+	if (scratch != pattern) {
-+		printf("Scratch test failed. 0x%08x\n", scratch);
-+		return -ENODEV;
-+	}
-+
-+	/*
-+	 * The RESET_HC bit in the SW_RESET register is supposed to reset the
-+	 * host controller without touching the CPU interface registers, but at
-+	 * least on the ISP1761 it seems to behave as the RESET_ALL bit and
-+	 * reset the whole device. We thus can't use it here, so let's reset
-+	 * the host controller through the EHCI USB Command register. The device
-+	 * has been reset in core code anyway, so this shouldn't matter.
-+	 */
-+	isp1760_hcd_clear(hcd, ISO_BUF_FILL);
-+	isp1760_hcd_clear(hcd, INT_BUF_FILL);
-+	isp1760_hcd_clear(hcd, ATL_BUF_FILL);
-+
-+	isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP);
-+
-+	result = ehci_reset(hcd);
-+	if (result)
-+		return result;
-+
-+	/* Step 11 passed */
-+
-+	/* ATL reset */
-+	if (priv->is_isp1763)
-+		atx_reset = SW_RESET_RESET_ATX;
-+	else
-+		atx_reset = ALL_ATX_RESET;
-+
-+	isp1760_hcd_set(hcd, atx_reset);
-+	mdelay(10);
-+	isp1760_hcd_clear(hcd, atx_reset);
-+
-+	if (priv->is_isp1763) {
-+		isp1760_hcd_set(hcd, HW_OTG_DISABLE);
-+		isp1760_hcd_set(hcd, HW_SW_SEL_HC_DC_CLEAR);
-+		isp1760_hcd_set(hcd, HW_HC_2_DIS_CLEAR);
-+		isp1760_hcd_set(hcd, HW_DM_PULLDOWN);
-+		isp1760_hcd_set(hcd, HW_DP_PULLDOWN);
-+		mdelay(10);
-+
-+		isp1760_hcd_set(hcd, HW_INTF_LOCK);
-+	}
-+
-+	isp1760_hcd_set(hcd, HC_INT_IRQ_ENABLE);
-+	isp1760_hcd_set(hcd, HC_ATL_IRQ_ENABLE);
-+
-+	return priv_init(hcd);
-+}
-+
-+static u32 base_to_chip(u32 base)
-+{
-+	return ((base - 0x400) >> 3);
-+}
-+
-+static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh)
-+{
-+	struct urb *urb;
-+
-+	if (list_is_last(&qtd->qtd_list, &qh->qtd_list))
-+		return 1;
-+
-+	urb = qtd->urb;
-+	qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list);
-+
-+	return (qtd->urb != urb);
-+}
-+
-+/* magic numbers that can affect system performance */
-+#define	EHCI_TUNE_CERR		3	/* 0-3 qtd retries; 0 == don't stop */
-+#define	EHCI_TUNE_RL_HS		4	/* nak throttle; see 4.9 */
-+#define	EHCI_TUNE_RL_TT		0
-+#define	EHCI_TUNE_MULT_HS	1	/* 1-3 transactions/uframe; 4.10.3 */
-+#define	EHCI_TUNE_MULT_TT	1
-+#define	EHCI_TUNE_FLS		2	/* (small) 256 frame schedule */
-+
-+static void create_ptd_atl(struct isp1760_qh *qh, struct isp1760_qtd *qtd,
-+			   struct ptd *ptd)
-+{
-+	u32 maxpacket;
-+	u32 multi;
-+	u32 rl = RL_COUNTER;
-+	u32 nak = NAK_COUNTER;
-+	u8 portnr;
-+	u8 hubaddr;
-+
-+	memset(ptd, 0, sizeof(*ptd));
-+
-+	/* according to 3.6.2, max packet len can not be > 0x400 */
-+	maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe);
-+	multi =  1 + ((maxpacket >> 11) & 0x3);
-+	maxpacket &= 0x7ff;
-+
-+	/* DW0 */
-+	ptd->dw0 = DW0_VALID_BIT;
-+	ptd->dw0 |= TO_DW0_LENGTH(qtd->length);
-+	ptd->dw0 |= TO_DW0_MAXPACKET(maxpacket);
-+	ptd->dw0 |= TO_DW0_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe));
-+
-+	/* DW1 */
-+	ptd->dw1 = TO_DW((usb_pipeendpoint(qtd->urb->pipe) >> 1));
-+	ptd->dw1 |= TO_DW1_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe));
-+	ptd->dw1 |= TO_DW1_PID_TOKEN(qtd->packet_type);
-+
-+	if (usb_pipebulk(qtd->urb->pipe))
-+		ptd->dw1 |= DW1_TRANS_BULK;
-+	else if  (usb_pipeint(qtd->urb->pipe))
-+		ptd->dw1 |= DW1_TRANS_INT;
-+
-+	if (qtd->urb->dev->speed != USB_SPEED_HIGH) {
-+		/* split transaction */
-+
-+		ptd->dw1 |= DW1_TRANS_SPLIT;
-+		if (qtd->urb->dev->speed == USB_SPEED_LOW)
-+			ptd->dw1 |= DW1_SE_USB_LOSPEED;
-+
-+		if (!qtd->urb->dev->dev->parent_priv_) {
-+			portnr = qtd->urb->dev->portnr;
-+			hubaddr = qtd->urb->dev->devnum;
-+		} else {
-+			usb_find_usb2_hub_address_port(qtd->urb->dev, &hubaddr,
-+						       &portnr);
-+		}
-+
-+		ptd->dw1 |= TO_DW1_PORT_NUM(portnr);
-+		ptd->dw1 |= TO_DW1_HUB_NUM(hubaddr);
-+
-+		/* SE bit for Split INT transfers */
-+		if (usb_pipeint(qtd->urb->pipe) &&
-+				(qtd->urb->dev->speed == USB_SPEED_LOW))
-+			ptd->dw1 |= DW1_SE_USB_LOSPEED;
-+
-+		rl = 0;
-+		nak = 0;
-+	} else {
-+		ptd->dw0 |= TO_DW0_MULTI(multi);
-+		if (usb_pipecontrol(qtd->urb->pipe) ||
-+						usb_pipebulk(qtd->urb->pipe))
-+			ptd->dw3 |= TO_DW3_PING(qh->ping);
-+	}
-+	/* DW2 */
-+	ptd->dw2 = 0;
-+	ptd->dw2 |= TO_DW2_DATA_START_ADDR(base_to_chip(qtd->payload_addr));
-+	ptd->dw2 |= TO_DW2_RL(rl);
-+
-+	/* DW3 */
-+	ptd->dw3 |= TO_DW3_NAKCOUNT(nak);
-+	ptd->dw3 |= TO_DW3_DATA_TOGGLE(qh->toggle);
-+
-+	if (usb_pipecontrol(qtd->urb->pipe)) {
-+		if (qtd->data_buffer == qtd->urb->setup_packet) {
-+			ptd->dw3 &= ~TO_DW3_DATA_TOGGLE(1);
-+		} else if (last_qtd_of_urb(qtd, qh)) {
-+			ptd->dw3 |= TO_DW3_DATA_TOGGLE(1);
-+		}
-+	}
-+
-+	ptd->dw3 |= DW3_ACTIVE_BIT;
-+	/* Cerr */
-+	ptd->dw3 |= TO_DW3_CERR(ERR_COUNTER);
-+}
-+
-+static void transform_add_int(struct isp1760_qh *qh, struct isp1760_qtd *qtd,
-+			      struct ptd *ptd)
-+{
-+	struct usb_host_endpoint *hep = qtd->urb->ep;
-+	struct usb_endpoint_descriptor *epd = &hep->desc;
-+	u32 usof;
-+	u32 period;
-+
-+	/*
-+	 * Most of this is guessing. ISP1761 datasheet is quite unclear, and
-+	 * the algorithm from the original Philips driver code, which was
-+	 * pretty much used in this driver before as well, is quite horrendous
-+	 * and, i believe, incorrect. The code below follows the datasheet and
-+	 * USB2.0 spec as far as I can tell, and plug/unplug seems to be much
-+	 * more reliable this way (fingers crossed...).
-+	 */
-+
-+	if (qtd->urb->dev->speed == USB_SPEED_HIGH) {
-+		/* urb->interval is in units of microframes (1/8 ms) */
-+		period = epd->bInterval >> 3;
-+
-+		if (epd->bInterval > 4)
-+			usof = 0x01; /* One bit set =>
-+						interval 1 ms * uFrame-match */
-+		else if (epd->bInterval > 2)
-+			usof = 0x22; /* Two bits set => interval 1/2 ms */
-+		else if (epd->bInterval > 1)
-+			usof = 0x55; /* Four bits set => interval 1/4 ms */
-+		else
-+			usof = 0xff; /* All bits set => interval 1/8 ms */
-+	} else {
-+		/* urb->interval is in units of frames (1 ms) */
-+		period = epd->bInterval;
-+		usof = 0x0f;		/* Execute Start Split on any of the
-+					   four first uFrames */
-+
-+		/*
-+		 * First 8 bits in dw5 is uSCS and "specifies which uSOF the
-+		 * complete split needs to be sent. Valid only for IN." Also,
-+		 * "All bits can be set to one for every transfer." (p 82,
-+		 * ISP1761 data sheet.) 0x1c is from Philips driver. Where did
-+		 * that number come from? 0xff seems to work fine...
-+		 */
-+		/* ptd->dw5 = 0x1c; */
-+		ptd->dw5 = TO_DW(0xff); /* Execute Complete Split on any uFrame */
-+	}
-+
-+	period = period >> 1;/* Ensure equal or shorter period than requested */
-+	period &= 0xf8; /* Mask off too large values and lowest unused 3 bits */
-+
-+	ptd->dw2 |= TO_DW(period);
-+	ptd->dw4 = TO_DW(usof);
-+}
-+
-+static void create_ptd_int(struct isp1760_qh *qh, struct isp1760_qtd *qtd,
-+			   struct ptd *ptd)
-+{
-+	create_ptd_atl(qh, qtd, ptd);
-+	transform_add_int(qh, qtd, ptd);
-+}
-+
-+static void isp1760_urb_done(struct usb_hcd *hcd, struct urb *urb)
-+{
-+	if (usb_pipein(urb->pipe) && usb_pipetype(urb->pipe) != PIPE_CONTROL) {
-+		void *ptr;
-+		for (ptr = urb->transfer_buffer;
-+		     ptr < urb->transfer_buffer + urb->transfer_buffer_length;
-+		     ptr += PAGE_SIZE)
-+			flush_dcache_range((unsigned  long)ptr,
-+					   (unsigned long)ptr + PAGE_SIZE);
-+	}
-+
-+	/* complete() can reenter this HCD */
-+	usb_hcd_unlink_urb_from_ep(hcd, urb);
-+	usb_hcd_giveback_urb(hcd, urb, urb->status);
-+}
-+
-+static struct isp1760_qtd *qtd_alloc(gfp_t flags, struct urb *urb,
-+				     u8 packet_type)
-+{
-+	struct isp1760_qtd *qtd;
-+
-+	qtd = kmem_cache_alloc(qtd_cachep, flags);
-+	if (!qtd)
-+		return NULL;
-+
-+	memset(qtd, '\0', sizeof(*qtd));
-+	INIT_LIST_HEAD(&qtd->qtd_list);
-+	qtd->urb = urb;
-+	qtd->packet_type = packet_type;
-+	qtd->status = QTD_ENQUEUED;
-+	qtd->actual_length = 0;
-+
-+	return qtd;
-+}
-+
-+static void qtd_free(struct isp1760_qtd *qtd)
-+{
-+	WARN_ON(qtd->payload_addr);
-+	kmem_cache_free(qtd_cachep, qtd);
-+}
-+
-+static void start_bus_transfer(struct usb_hcd *hcd, u32 ptd_offset, int slot,
-+				struct isp1760_slotinfo *slots,
-+				struct isp1760_qtd *qtd, struct isp1760_qh *qh,
-+				struct ptd *ptd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	int skip_map;
-+
-+	WARN_ON((slot < 0) || (slot > mem->slot_num - 1));
-+	WARN_ON(qtd->length && !qtd->payload_addr);
-+	WARN_ON(slots[slot].qtd);
-+	WARN_ON(slots[slot].qh);
-+	WARN_ON(qtd->status != QTD_PAYLOAD_ALLOC);
-+
-+	if (priv->is_isp1763)
-+		ndelay(100);
-+
-+	/* Make sure done map has not triggered from some unlinked transfer */
-+	if (ptd_offset == ATL_PTD_OFFSET) {
-+		skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP);
-+		isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP,
-+				  skip_map | (1 << slot));
-+		priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP);
-+		priv->atl_done_map &= ~(1 << slot);
-+	} else {
-+		skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP);
-+		isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP,
-+				  skip_map | (1 << slot));
-+		priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP);
-+		priv->int_done_map &= ~(1 << slot);
-+	}
-+
-+	skip_map &= ~(1 << slot);
-+	qh->slot = slot;
-+	qtd->status = QTD_XFER_STARTED;
-+	slots[slot].qtd = qtd;
-+	slots[slot].qh = qh;
-+
-+	ptd_write(hcd, ptd_offset, slot, ptd);
-+
-+	if (ptd_offset == ATL_PTD_OFFSET)
-+		isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map);
-+	else
-+		isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map);
-+}
-+
-+static int is_short_bulk(struct isp1760_qtd *qtd)
-+{
-+	return (usb_pipebulk(qtd->urb->pipe) &&
-+					(qtd->actual_length < qtd->length));
-+}
-+
-+static void collect_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh,
-+						struct list_head *urb_list)
-+{
-+	struct isp1760_qtd *qtd, *qtd_next;
-+	struct urb_listitem *urb_listitem;
-+	int last_qtd;
-+
-+	list_for_each_entry_safe(qtd, qtd_next, &qh->qtd_list, qtd_list) {
-+		if (qtd->status < QTD_XFER_COMPLETE)
-+			break;
-+
-+		last_qtd = last_qtd_of_urb(qtd, qh);
-+
-+		if ((!last_qtd) && (qtd->status == QTD_RETIRE))
-+			qtd_next->status = QTD_RETIRE;
-+
-+		if (qtd->status == QTD_XFER_COMPLETE) {
-+			if (qtd->actual_length) {
-+				switch (qtd->packet_type) {
-+				case IN_PID:
-+					mem_read(hcd, qtd->payload_addr,
-+						 qtd->data_buffer,
-+						 qtd->actual_length);
-+					fallthrough;
-+				case OUT_PID:
-+					qtd->urb->actual_length +=
-+							qtd->actual_length;
-+					fallthrough;
-+				case SETUP_PID:
-+					break;
-+				}
-+			}
-+
-+			if (is_short_bulk(qtd)) {
-+				if (qtd->urb->transfer_flags & URB_SHORT_NOT_OK)
-+					qtd->urb->status = -EREMOTEIO;
-+				if (!last_qtd)
-+					qtd_next->status = QTD_RETIRE;
-+			}
-+		}
-+
-+		if (qtd->payload_addr)
-+			free_mem(hcd, qtd);
-+
-+		if (last_qtd) {
-+			if ((qtd->status == QTD_RETIRE) &&
-+					(qtd->urb->status == -EINPROGRESS))
-+				qtd->urb->status = -EPIPE;
-+			/* Defer calling of urb_done() since it releases lock */
-+			urb_listitem = kmem_cache_alloc(urb_listitem_cachep,
-+								GFP_ATOMIC);
-+			if (unlikely(!urb_listitem))
-+				break; /* Try again on next call */
-+			urb_listitem->urb = qtd->urb;
-+			list_add_tail(&urb_listitem->urb_list, urb_list);
-+		}
-+
-+		list_del(&qtd->qtd_list);
-+		qtd_free(qtd);
-+	}
-+}
-+
-+#define ENQUEUE_DEPTH	2
-+static void enqueue_qtds(struct usb_hcd *hcd, struct isp1760_qh *qh)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	int slot_num = mem->slot_num;
-+	int ptd_offset;
-+	struct isp1760_slotinfo *slots;
-+	int curr_slot, free_slot;
-+	int n;
-+	struct ptd ptd;
-+	struct isp1760_qtd *qtd;
-+
-+	if (unlikely(list_empty(&qh->qtd_list)))
-+		return;
-+
-+	/* Make sure this endpoint's TT buffer is clean before queueing ptds */
-+	if (qh->tt_buffer_dirty)
-+		return;
-+
-+	if (usb_pipeint(list_entry(qh->qtd_list.next, struct isp1760_qtd,
-+				   qtd_list)->urb->pipe)) {
-+		ptd_offset = INT_PTD_OFFSET;
-+		slots = priv->int_slots;
-+	} else {
-+		ptd_offset = ATL_PTD_OFFSET;
-+		slots = priv->atl_slots;
-+	}
-+
-+	free_slot = -1;
-+	for (curr_slot = 0; curr_slot < slot_num; curr_slot++) {
-+		if ((free_slot == -1) && (slots[curr_slot].qtd == NULL))
-+			free_slot = curr_slot;
-+		if (slots[curr_slot].qh == qh)
-+			break;
-+	}
-+
-+	n = 0;
-+	list_for_each_entry(qtd, &qh->qtd_list, qtd_list) {
-+		if (qtd->status == QTD_ENQUEUED) {
-+			WARN_ON(qtd->payload_addr);
-+			alloc_mem(hcd, qtd);
-+			if ((qtd->length) && (!qtd->payload_addr))
-+				break;
-+
-+			if (qtd->length && (qtd->packet_type == SETUP_PID ||
-+					    qtd->packet_type == OUT_PID)) {
-+				mem_write(hcd, qtd->payload_addr,
-+					  qtd->data_buffer, qtd->length);
-+			}
-+
-+			qtd->status = QTD_PAYLOAD_ALLOC;
-+		}
-+
-+		if (qtd->status == QTD_PAYLOAD_ALLOC) {
-+/*
-+			if ((curr_slot > 31) && (free_slot == -1))
-+				printf("%s: No slot "
-+					"available for transfer\n", __func__);
-+*/
-+			/* Start xfer for this endpoint if not already done */
-+			if ((curr_slot > slot_num - 1) && (free_slot > -1)) {
-+				if (usb_pipeint(qtd->urb->pipe))
-+					create_ptd_int(qh, qtd, &ptd);
-+				else
-+					create_ptd_atl(qh, qtd, &ptd);
-+
-+				start_bus_transfer(hcd, ptd_offset, free_slot,
-+							slots, qtd, qh, &ptd);
-+				curr_slot = free_slot;
-+			}
-+
-+			n++;
-+			if (n >= ENQUEUE_DEPTH)
-+				break;
-+		}
-+	}
-+}
-+
-+static void schedule_ptds(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv;
-+	struct isp1760_qh *qh, *qh_next;
-+	struct list_head *ep_queue;
-+	LIST_HEAD(urb_list);
-+	struct urb_listitem *urb_listitem, *urb_listitem_next;
-+	int i;
-+
-+	if (!hcd) {
-+		WARN_ON(1);
-+		return;
-+	}
-+
-+	priv = hcd_to_priv(hcd);
-+
-+	/*
-+	 * check finished/retired xfers, transfer payloads, call urb_done()
-+	 */
-+	for (i = 0; i < QH_END; i++) {
-+		ep_queue = &priv->qh_list[i];
-+		list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list)
-+			collect_qtds(hcd, qh, &urb_list);
-+	}
-+
-+	list_for_each_entry_safe(urb_listitem, urb_listitem_next, &urb_list,
-+				 urb_list) {
-+		isp1760_urb_done(hcd, urb_listitem->urb);
-+		kmem_cache_free(urb_listitem_cachep, urb_listitem);
-+	}
-+
-+	/*
-+	 * Schedule packets for transfer.
-+	 *
-+	 * According to USB2.0 specification:
-+	 *
-+	 * 1st prio: interrupt xfers, up to 80 % of bandwidth
-+	 * 2nd prio: control xfers
-+	 * 3rd prio: bulk xfers
-+	 *
-+	 * ... but let's use a simpler scheme here (mostly because ISP1761 doc
-+	 * is very unclear on how to prioritize traffic):
-+	 *
-+	 * 1) Enqueue any queued control transfers, as long as payload chip mem
-+	 *    and PTD ATL slots are available.
-+	 * 2) Enqueue any queued INT transfers, as long as payload chip mem
-+	 *    and PTD INT slots are available.
-+	 * 3) Enqueue any queued bulk transfers, as long as payload chip mem
-+	 *    and PTD ATL slots are available.
-+	 *
-+	 * Use double buffering (ENQUEUE_DEPTH==2) as a compromise between
-+	 * conservation of chip mem and performance.
-+	 *
-+	 * I'm sure this scheme could be improved upon!
-+	 */
-+	for (i = 0; i < QH_END; i++) {
-+		ep_queue = &priv->qh_list[i];
-+		list_for_each_entry_safe(qh, qh_next, ep_queue, qh_list)
-+			enqueue_qtds(hcd, qh);
-+	}
-+}
-+
-+#define PTD_STATE_QTD_DONE	1
-+#define PTD_STATE_QTD_RELOAD	2
-+#define PTD_STATE_URB_RETIRE	3
-+
-+static int check_int_transfer(struct usb_hcd *hcd, struct ptd *ptd,
-+								struct urb *urb)
-+{
-+	u32 dw4;
-+	int i;
-+
-+	dw4 = TO_U32(ptd->dw4);
-+	dw4 >>= 8;
-+
-+	/* FIXME: ISP1761 datasheet does not say what to do with these. Do we
-+	   need to handle these errors? Is it done in hardware? */
-+	if (ptd->dw3 & DW3_HALT_BIT) {
-+
-+		urb->status = -EPROTO; /* Default unknown error */
-+
-+		for (i = 0; i < 8; i++) {
-+			switch (dw4 & 0x7) {
-+			case INT_UNDERRUN:
-+				printf("underrun during uFrame %d\n", i);
-+				urb->status = -ECOMM; /* Could not write data */
-+				break;
-+			case INT_EXACT:
-+				printf("transaction error uFrame %d\n", i);
-+				urb->status = -EPROTO; /* timeout, bad CRC, PID
-+							  error etc. */
-+				break;
-+			case INT_BABBLE:
-+				printf("babble error during uFrame %d\n", i);
-+				urb->status = -EOVERFLOW;
-+				break;
-+			}
-+			dw4 >>= 3;
-+		}
-+
-+		return PTD_STATE_URB_RETIRE;
-+	}
-+
-+	return PTD_STATE_QTD_DONE;
-+}
-+
-+static int check_atl_transfer(struct usb_hcd *hcd, struct ptd *ptd,
-+			      struct urb *urb)
-+{
-+	WARN_ON(!ptd);
-+	if (ptd->dw3 & DW3_HALT_BIT) {
-+		if (ptd->dw3 & DW3_BABBLE_BIT)
-+			urb->status = -EOVERFLOW;
-+		else if (FROM_DW3_CERR(ptd->dw3))
-+			urb->status = -EPIPE;  /* Stall */
-+		else
-+			urb->status = -EPROTO; /* Unknown */
-+
-+		/* usefull debug
-+		printf("%s: ptd error:\n"
-+			"        dw0: %08x dw1: %08x dw2: %08x dw3: %08x\n"
-+			"        dw4: %08x dw5: %08x dw6: %08x dw7: %08x\n",
-+			__func__,
-+			ptd->dw0, ptd->dw1, ptd->dw2, ptd->dw3,
-+			ptd->dw4, ptd->dw5, ptd->dw6, ptd->dw7);
-+		*/
-+
-+		return PTD_STATE_URB_RETIRE;
-+	}
-+
-+	/* Transfer Error, *but* active and no HALT -> reload */
-+	if ((ptd->dw3 & DW3_ERROR_BIT) && (ptd->dw3 & DW3_ACTIVE_BIT))
-+		return PTD_STATE_QTD_RELOAD;
-+
-+	/*
-+	* NAKs are handled in HW by the chip. Usually if the
-+	* device is not able to send data fast enough.
-+	* This happens mostly on slower hardware.
-+	*/
-+	if (!FROM_DW3_NAKCOUNT(ptd->dw3) && (ptd->dw3 & DW3_ACTIVE_BIT))
-+		return PTD_STATE_QTD_RELOAD;
-+
-+	return PTD_STATE_QTD_DONE;
-+}
-+
-+static void handle_done_ptds(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	struct isp1760_slotinfo *slots;
-+	struct isp1760_qtd *qtd;
-+	struct isp1760_qh *qh;
-+	struct ptd ptd;
-+	u32 ptd_offset;
-+	int modified;
-+	int skip_map;
-+	int state;
-+	int slot;
-+
-+	skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP);
-+	priv->int_done_map &= ~skip_map;
-+	skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP);
-+	priv->atl_done_map &= ~skip_map;
-+
-+	modified = priv->int_done_map || priv->atl_done_map;
-+
-+	while (priv->int_done_map || priv->atl_done_map) {
-+		if (priv->int_done_map) {
-+			/* INT ptd */
-+			slot = __ffs(priv->int_done_map);
-+			priv->int_done_map &= ~(1 << slot);
-+			slots = priv->int_slots;
-+			/* This should not trigger, and could be removed if
-+			   noone have any problems with it triggering: */
-+			if (!slots[slot].qh) {
-+				WARN_ON(1);
-+				continue;
-+			}
-+			ptd_offset = INT_PTD_OFFSET;
-+			ptd_read(hcd, INT_PTD_OFFSET, slot, &ptd);
-+			state = check_int_transfer(hcd, &ptd,
-+						   slots[slot].qtd->urb);
-+		} else {
-+			/* ATL ptd */
-+			slot = __ffs(priv->atl_done_map);
-+			priv->atl_done_map &= ~(1 << slot);
-+			slots = priv->atl_slots;
-+			/* This should not trigger, and could be removed if
-+			   noone have any problems with it triggering: */
-+			if (!slots[slot].qh) {
-+				WARN_ON(1);
-+				continue;
-+			}
-+			ptd_offset = ATL_PTD_OFFSET;
-+			ptd_read(hcd, ATL_PTD_OFFSET, slot, &ptd);
-+			state = check_atl_transfer(hcd, &ptd,
-+						   slots[slot].qtd->urb);
-+		}
-+
-+		qtd = slots[slot].qtd;
-+		slots[slot].qtd = NULL;
-+		qh = slots[slot].qh;
-+		slots[slot].qh = NULL;
-+		qh->slot = -1;
-+
-+		WARN_ON(qtd->status != QTD_XFER_STARTED);
-+
-+		switch (state) {
-+		case PTD_STATE_QTD_DONE:
-+			if ((usb_pipeint(qtd->urb->pipe)) &&
-+			    (qtd->urb->dev->speed != USB_SPEED_HIGH))
-+				qtd->actual_length =
-+				       FROM_DW3_SCS_NRBYTESTRANSFERRED(ptd.dw3);
-+			else
-+				qtd->actual_length =
-+					FROM_DW3_NRBYTESTRANSFERRED(ptd.dw3);
-+
-+			qtd->status = QTD_XFER_COMPLETE;
-+
-+			if (list_is_last(&qtd->qtd_list, &qh->qtd_list) ||
-+			    is_short_bulk(qtd))
-+				qtd = NULL;
-+			else
-+				qtd = list_entry(qtd->qtd_list.next,
-+							typeof(*qtd), qtd_list);
-+
-+			qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3);
-+			qh->ping = FROM_DW3_PING(ptd.dw3);
-+
-+			break;
-+
-+		case PTD_STATE_QTD_RELOAD: /* QTD_RETRY, for atls only */
-+			qtd->status = QTD_PAYLOAD_ALLOC;
-+			ptd.dw0 |= DW0_VALID_BIT;
-+			/* RL counter = ERR counter */
-+			ptd.dw3 &= ~TO_DW3_NAKCOUNT(0xf);
-+			ptd.dw3 |= TO_DW3_NAKCOUNT(FROM_DW2_RL(ptd.dw2));
-+			ptd.dw3 &= ~TO_DW3_CERR(3);
-+			ptd.dw3 |= TO_DW3_CERR(ERR_COUNTER);
-+
-+			qh->toggle = FROM_DW3_DATA_TOGGLE(ptd.dw3);
-+			qh->ping = FROM_DW3_PING(ptd.dw3);
-+			break;
-+
-+		case PTD_STATE_URB_RETIRE:
-+			qtd->status = QTD_RETIRE;
-+			qtd = NULL;
-+			qh->toggle = 0;
-+			qh->ping = 0;
-+			break;
-+
-+		default:
-+			WARN_ON(1);
-+			continue;
-+		}
-+
-+		if (qtd && (qtd->status == QTD_PAYLOAD_ALLOC)) {
-+			if (slots == priv->int_slots) {
-+				if (state == PTD_STATE_QTD_RELOAD)
-+					dev_err(priv->dev,
-+						"%s: PTD_STATE_QTD_RELOAD on "
-+						"interrupt packet\n", __func__);
-+				if (state != PTD_STATE_QTD_RELOAD)
-+					create_ptd_int(qh, qtd, &ptd);
-+			} else {
-+				if (state != PTD_STATE_QTD_RELOAD)
-+					create_ptd_atl(qh, qtd, &ptd);
-+			}
-+
-+			start_bus_transfer(hcd, ptd_offset, slot, slots, qtd,
-+				qh, &ptd);
-+		}
-+	}
-+
-+	if (modified)
-+		schedule_ptds(hcd);
-+}
-+
-+static irqreturn_t isp1760_irq(int irq, void *__hci)
-+{
-+	struct usb_hcd *hcd = __hci;
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	irqreturn_t irqret = IRQ_NONE;
-+	u32 int_reg;
-+	u32 imask;
-+
-+	imask = isp1760_hcd_read(hcd, HC_INTERRUPT);
-+	if (unlikely(!imask))
-+		return irqret;
-+
-+	int_reg = priv->is_isp1763 ? ISP1763_HC_INTERRUPT :
-+		ISP176x_HC_INTERRUPT;
-+	isp1760_reg_write(priv->regs, int_reg, imask);
-+
-+	priv->int_done_map |= isp1760_hcd_read(hcd, HC_INT_PTD_DONEMAP);
-+	priv->atl_done_map |= isp1760_hcd_read(hcd, HC_ATL_PTD_DONEMAP);
-+
-+	handle_done_ptds(hcd);
-+
-+	irqret = IRQ_HANDLED;
-+
-+	return irqret;
-+}
-+
-+static int isp1763_run(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	int retval;
-+	u32 chipid_h;
-+	u32 chipid_l;
-+	u32 chip_rev;
-+	u32 ptd_atl_int;
-+	u32 ptd_iso;
-+
-+	chipid_h = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);
-+	chipid_l = isp1760_hcd_read(hcd, HC_CHIP_ID_LOW);
-+	chip_rev = isp1760_hcd_read(hcd, HC_CHIP_REV);
-+	printf("USB ISP %02x%02x HW rev. %d started\n", chipid_h,
-+	       chipid_l, chip_rev);
-+
-+	isp1760_hcd_clear(hcd, ISO_BUF_FILL);
-+	isp1760_hcd_clear(hcd, INT_BUF_FILL);
-+	isp1760_hcd_clear(hcd, ATL_BUF_FILL);
-+
-+	isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP);
-+	ndelay(100);
-+	isp1760_hcd_clear(hcd, HC_ATL_PTD_DONEMAP);
-+	isp1760_hcd_clear(hcd, HC_INT_PTD_DONEMAP);
-+	isp1760_hcd_clear(hcd, HC_ISO_PTD_DONEMAP);
-+
-+	isp1760_hcd_set(hcd, HW_OTG_DISABLE);
-+	isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(7));
-+	isp1760_reg_write(priv->regs, ISP1763_HC_OTG_CTRL_CLEAR, BIT(15));
-+	mdelay(10);
-+
-+	isp1760_hcd_set(hcd, HC_INT_IRQ_ENABLE);
-+	isp1760_hcd_set(hcd, HC_ATL_IRQ_ENABLE);
-+
-+	isp1760_hcd_set(hcd, HW_GLOBAL_INTR_EN);
-+
-+	isp1760_hcd_clear(hcd, HC_ATL_IRQ_MASK_AND);
-+	isp1760_hcd_clear(hcd, HC_INT_IRQ_MASK_AND);
-+	isp1760_hcd_clear(hcd, HC_ISO_IRQ_MASK_AND);
-+
-+	isp1760_hcd_set(hcd, HC_ATL_IRQ_MASK_OR);
-+	isp1760_hcd_set(hcd, HC_INT_IRQ_MASK_OR);
-+	isp1760_hcd_set(hcd, HC_ISO_IRQ_MASK_OR);
-+
-+	ptd_atl_int = 0x8000;
-+	ptd_iso = 0x0001;
-+
-+	isp1760_hcd_write(hcd, HC_ATL_PTD_LASTPTD, ptd_atl_int);
-+	isp1760_hcd_write(hcd, HC_INT_PTD_LASTPTD, ptd_atl_int);
-+	isp1760_hcd_write(hcd, HC_ISO_PTD_LASTPTD, ptd_iso);
-+
-+	isp1760_hcd_set(hcd, ATL_BUF_FILL);
-+	isp1760_hcd_set(hcd, INT_BUF_FILL);
-+
-+	isp1760_hcd_clear(hcd, CMD_LRESET);
-+	isp1760_hcd_clear(hcd, CMD_RESET);
-+
-+	retval = isp1760_hcd_set_and_wait(hcd, CMD_RUN, 250 * 1000);
-+	if (retval)
-+		return retval;
-+
-+	down_write(&ehci_cf_port_reset_rwsem);
-+	retval = isp1760_hcd_set_and_wait(hcd, FLAG_CF, 250 * 1000);
-+	up_write(&ehci_cf_port_reset_rwsem);
-+	retval = 0;
-+	if (retval)
-+		return retval;
-+
-+	return 0;
-+}
-+
-+static int isp1760_run(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	int retval;
-+	u32 chipid_h;
-+	u32 chipid_l;
-+	u32 chip_rev;
-+	u32 ptd_atl_int;
-+	u32 ptd_iso;
-+
-+	/*
-+	 * ISP1763 have some differences in the setup and order to enable
-+	 * the ports, disable otg, setup buffers, and ATL, INT, ISO status.
-+	 * So, just handle it a separate sequence.
-+	 */
-+	if (priv->is_isp1763)
-+		return isp1763_run(hcd);
-+
-+	/* Set PTD interrupt AND & OR maps */
-+	isp1760_hcd_clear(hcd, HC_ATL_IRQ_MASK_AND);
-+	isp1760_hcd_clear(hcd, HC_INT_IRQ_MASK_AND);
-+	isp1760_hcd_clear(hcd, HC_ISO_IRQ_MASK_AND);
-+
-+	isp1760_hcd_set(hcd, HC_ATL_IRQ_MASK_OR);
-+	isp1760_hcd_set(hcd, HC_INT_IRQ_MASK_OR);
-+	isp1760_hcd_set(hcd, HC_ISO_IRQ_MASK_OR);
-+
-+	/* step 23 passed */
-+
-+	isp1760_hcd_set(hcd, HW_GLOBAL_INTR_EN);
-+
-+	isp1760_hcd_clear(hcd, CMD_LRESET);
-+	isp1760_hcd_clear(hcd, CMD_RESET);
-+
-+	retval = isp1760_hcd_set_and_wait(hcd, CMD_RUN, 250 * 1000);
-+	if (retval)
-+		return retval;
-+
-+	/*
-+	 * XXX
-+	 * Spec says to write FLAG_CF as last config action, priv code grabs
-+	 * the semaphore while doing so.
-+	 */
-+	down_write(&ehci_cf_port_reset_rwsem);
-+
-+	retval = isp1760_hcd_set_and_wait(hcd, FLAG_CF, 250 * 1000);
-+	up_write(&ehci_cf_port_reset_rwsem);
-+	if (retval)
-+		return retval;
-+
-+	chipid_h = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);
-+	chipid_l = isp1760_hcd_read(hcd, HC_CHIP_ID_LOW);
-+	chip_rev = isp1760_hcd_read(hcd, HC_CHIP_REV);
-+	dev_info(priv->dev, "USB ISP %02x%02x HW rev. %d started\n",
-+		 chipid_h, chipid_l, chip_rev);
-+
-+	/* PTD Register Init Part 2, Step 28 */
-+
-+	/* Setup registers controlling PTD checking */
-+	ptd_atl_int = 0x80000000;
-+	ptd_iso = 0x00000001;
-+
-+	isp1760_hcd_write(hcd, HC_ATL_PTD_LASTPTD, ptd_atl_int);
-+	isp1760_hcd_write(hcd, HC_INT_PTD_LASTPTD, ptd_atl_int);
-+	isp1760_hcd_write(hcd, HC_ISO_PTD_LASTPTD, ptd_iso);
-+
-+	isp1760_hcd_set(hcd, HC_ATL_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_INT_PTD_SKIPMAP);
-+	isp1760_hcd_set(hcd, HC_ISO_PTD_SKIPMAP);
-+
-+	isp1760_hcd_set(hcd, ATL_BUF_FILL);
-+	isp1760_hcd_set(hcd, INT_BUF_FILL);
-+
-+	/* GRR this is run-once init(), being done every time the HC starts.
-+	 * So long as they're part of class devices, we can't do it init()
-+	 * since the class device isn't created that early.
-+	 */
-+	return 0;
-+}
-+
-+static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len)
-+{
-+	qtd->data_buffer = databuffer;
-+
-+	qtd->length = len;
-+
-+	return qtd->length;
-+}
-+
-+static void qtd_list_free(struct list_head *qtd_list)
-+{
-+	struct isp1760_qtd *qtd, *qtd_next;
-+
-+	list_for_each_entry_safe(qtd, qtd_next, qtd_list, qtd_list) {
-+		list_del(&qtd->qtd_list);
-+		qtd_free(qtd);
-+	}
-+}
-+
-+/*
-+ * Packetize urb->transfer_buffer into list of packets of size wMaxPacketSize.
-+ * Also calculate the PID type (SETUP/IN/OUT) for each packet.
-+ */
-+#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
-+static void packetize_urb(struct usb_hcd *hcd,
-+		struct urb *urb, struct list_head *head, gfp_t flags)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+	struct isp1760_qtd *qtd;
-+	void *buf;
-+	int len, maxpacketsize;
-+	u8 packet_type;
-+
-+	/*
-+	 * URBs map to sequences of QTDs:  one logical transaction
-+	 */
-+
-+	if (!urb->transfer_buffer && urb->transfer_buffer_length) {
-+		/* XXX This looks like usb storage / SCSI bug */
-+		dev_err(priv->dev, "buf is null, dma is %08lx len is %d\n",
-+			(long unsigned)urb->transfer_dma,
-+			urb->transfer_buffer_length);
-+		WARN_ON(1);
-+	}
-+
-+	if (usb_pipein(urb->pipe))
-+		packet_type = IN_PID;
-+	else
-+		packet_type = OUT_PID;
-+
-+	if (usb_pipecontrol(urb->pipe)) {
-+		qtd = qtd_alloc(flags, urb, SETUP_PID);
-+		if (!qtd)
-+			goto cleanup;
-+		qtd_fill(qtd, urb->setup_packet, sizeof(struct usb_ctrlrequest));
-+		list_add_tail(&qtd->qtd_list, head);
-+
-+		/* for zero length DATA stages, STATUS is always IN */
-+		if (urb->transfer_buffer_length == 0)
-+			packet_type = IN_PID;
-+	}
-+
-+	maxpacketsize = max_packet(usb_maxpacket(urb->dev, urb->pipe));
-+
-+	/*
-+	 * buffer gets wrapped in one or more qtds;
-+	 * last one may be "short" (including zero len)
-+	 * and may serve as a control status ack
-+	 */
-+	buf = urb->transfer_buffer;
-+	len = urb->transfer_buffer_length;
-+
-+	for (;;) {
-+		int this_qtd_len;
-+
-+		qtd = qtd_alloc(flags, urb, packet_type);
-+		if (!qtd)
-+			goto cleanup;
-+
-+		if (len > mem->blocks_size[ISP176x_BLOCK_NUM - 1])
-+			len = mem->blocks_size[ISP176x_BLOCK_NUM - 1];
-+
-+		this_qtd_len = qtd_fill(qtd, buf, len);
-+		list_add_tail(&qtd->qtd_list, head);
-+
-+		len -= this_qtd_len;
-+		buf += this_qtd_len;
-+
-+		if (len <= 0)
-+			break;
-+	}
-+
-+	/*
-+	 * control requests may need a terminating data "status" ack;
-+	 * bulk ones may need a terminating short packet (zero length).
-+	 */
-+	if (urb->transfer_buffer_length != 0) {
-+		int one_more = 0;
-+
-+		if (usb_pipecontrol(urb->pipe)) {
-+			one_more = 1;
-+			if (packet_type == IN_PID)
-+				packet_type = OUT_PID;
-+			else
-+				packet_type = IN_PID;
-+		} else if (usb_pipebulk(urb->pipe)
-+			   && (urb->transfer_flags & URB_ZERO_PACKET)
-+			   && !(urb->transfer_buffer_length %
-+				maxpacketsize)) {
-+			one_more = 1;
-+		}
-+		if (one_more) {
-+			qtd = qtd_alloc(flags, urb, packet_type);
-+			if (!qtd)
-+				goto cleanup;
-+
-+			/* never any data in such packets */
-+			qtd_fill(qtd, NULL, 0);
-+			list_add_tail(&qtd->qtd_list, head);
-+		}
-+	}
-+
-+	return;
-+
-+cleanup:
-+	qtd_list_free(head);
-+}
-+
-+static int isp1760_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
-+			       gfp_t mem_flags)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	struct isp1760_qh *qh = NULL;
-+	struct list_head *ep_queue;
-+	LIST_HEAD(new_qtds);
-+	int qh_in_queue;
-+	int retval;
-+	int epnum;
-+
-+	switch (usb_pipetype(urb->pipe)) {
-+	case PIPE_CONTROL:
-+		ep_queue = &priv->qh_list[QH_CONTROL];
-+		break;
-+	case PIPE_BULK:
-+		ep_queue = &priv->qh_list[QH_BULK];
-+		break;
-+	case PIPE_INTERRUPT:
-+		ep_queue = &priv->qh_list[QH_INTERRUPT];
-+		break;
-+	case PIPE_ISOCHRONOUS:
-+		printf("isochronous USB packets not yet supported\n");
-+		return -EPIPE;
-+	default:
-+		printf("unknown pipe type\n");
-+		return -EPIPE;
-+	}
-+
-+	if (usb_pipein(urb->pipe))
-+		urb->actual_length = 0;
-+
-+	packetize_urb(hcd, urb, &new_qtds, mem_flags);
-+	if (list_empty(&new_qtds))
-+		return -ENOMEM;
-+
-+	retval = usb_hcd_link_urb_to_ep(hcd, urb);
-+	if (retval) {
-+		qtd_list_free(&new_qtds);
-+		goto out;
-+	}
-+
-+	epnum = usb_pipeendpoint(urb->pipe);
-+
-+	qh_in_queue = 0;
-+	list_for_each_entry(qh, ep_queue, qh_list) {
-+		if (qh->epnum == epnum) {
-+			qh_in_queue = 1;
-+			break;
-+		}
-+	}
-+
-+	if (!qh_in_queue) {
-+		qh = qh_alloc(GFP_ATOMIC);
-+		if (!qh) {
-+			retval = -ENOMEM;
-+			usb_hcd_unlink_urb_from_ep(hcd, urb);
-+			qtd_list_free(&new_qtds);
-+			goto out;
-+		}
-+
-+		qh->epnum = epnum;
-+		list_add_tail(&qh->qh_list, ep_queue);
-+		urb->ep->hcpriv = qh;
-+	}
-+
-+	list_splice_tail(&new_qtds, &qh->qtd_list);
-+	schedule_ptds(hcd);
-+
-+out:
-+	return retval;
-+}
-+
-+static void kill_transfer(struct usb_hcd *hcd, struct urb *urb,
-+		struct isp1760_qh *qh)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	int skip_map;
-+
-+	WARN_ON(qh->slot == -1);
-+
-+	/* We need to forcefully reclaim the slot since some transfers never
-+	   return, e.g. interrupt transfers and NAKed bulk transfers. */
-+	if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) {
-+		skip_map = isp1760_hcd_read(hcd, HC_ATL_PTD_SKIPMAP);
-+		skip_map |= (1 << qh->slot);
-+		isp1760_hcd_write(hcd, HC_ATL_PTD_SKIPMAP, skip_map);
-+		ndelay(100);
-+		priv->atl_slots[qh->slot].qh = NULL;
-+		priv->atl_slots[qh->slot].qtd = NULL;
-+	} else {
-+		skip_map = isp1760_hcd_read(hcd, HC_INT_PTD_SKIPMAP);
-+		skip_map |= (1 << qh->slot);
-+		isp1760_hcd_write(hcd, HC_INT_PTD_SKIPMAP, skip_map);
-+		priv->int_slots[qh->slot].qh = NULL;
-+		priv->int_slots[qh->slot].qtd = NULL;
-+	}
-+
-+	qh->slot = -1;
-+}
-+
-+/*
-+ * Retire the qtds beginning at 'qtd' and belonging all to the same urb, killing
-+ * any active transfer belonging to the urb in the process.
-+ */
-+static void dequeue_urb_from_qtd(struct usb_hcd *hcd, struct isp1760_qh *qh,
-+				 struct isp1760_qtd *qtd)
-+{
-+	struct urb *urb;
-+	int urb_was_running;
-+
-+	urb = qtd->urb;
-+	urb_was_running = 0;
-+	list_for_each_entry_from(qtd, &qh->qtd_list, qtd_list) {
-+		if (qtd->urb != urb)
-+			break;
-+
-+		if (qtd->status >= QTD_XFER_STARTED)
-+			urb_was_running = 1;
-+		if (last_qtd_of_urb(qtd, qh) &&
-+					(qtd->status >= QTD_XFER_COMPLETE))
-+			urb_was_running = 0;
-+
-+		if (qtd->status == QTD_XFER_STARTED)
-+			kill_transfer(hcd, urb, qh);
-+		qtd->status = QTD_RETIRE;
-+	}
-+}
-+
-+int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
-+{
-+	struct isp1760_qtd *qtd;
-+	struct isp1760_qh *qh;
-+	int retval = 0;
-+
-+	retval = usb_hcd_check_unlink_urb(hcd, urb, status);
-+	if (retval)
-+		goto out;
-+
-+	qh = urb->ep->hcpriv;
-+	if (!qh) {
-+		retval = -EINVAL;
-+		goto out;
-+	}
-+
-+	list_for_each_entry(qtd, &qh->qtd_list, qtd_list)
-+		if (qtd->urb == urb) {
-+			dequeue_urb_from_qtd(hcd, qh, qtd);
-+			list_move(&qtd->qtd_list, &qh->qtd_list);
-+			break;
-+		}
-+
-+	urb->status = status;
-+	schedule_ptds(hcd);
-+
-+out:
-+	return retval;
-+}
-+
-+static void isp1760_hub_descriptor(struct isp1760_hcd *priv,
-+				   struct usb_hub_descriptor *desc)
-+{
-+	int ports;
-+	u16 temp;
-+
-+	ports = isp1760_hcd_n_ports(priv->hcd);
-+
-+	desc->bDescriptorType = USB_DT_HUB;
-+	/* priv 1.0, 2.3.9 says 20ms max */
-+	desc->bPwrOn2PwrGood = 10;
-+	desc->bHubContrCurrent = 0;
-+
-+	desc->bNbrPorts = ports;
-+	temp = 1 + (ports / 8);
-+	desc->bLength = 7 + 2 * temp;
-+
-+	/* ports removable, and usb 1.0 legacy PortPwrCtrlMask */
-+	memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
-+	memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
-+
-+	/* per-port overcurrent reporting */
-+	temp = HUB_CHAR_INDV_PORT_OCPM;
-+	if (isp1760_hcd_ppc_is_set(priv->hcd))
-+		/* per-port power control */
-+		temp |= HUB_CHAR_INDV_PORT_LPSM;
-+	else
-+		/* no power switching */
-+		temp |= HUB_CHAR_NO_LPSM;
-+	desc->wHubCharacteristics = cpu_to_le16(temp);
-+}
-+
-+#define	PORT_WAKE_BITS	(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
-+
-+static void check_reset_complete(struct usb_hcd *hcd, int index)
-+{
-+	if (!(isp1760_hcd_is_set(hcd, PORT_CONNECT)))
-+		return;
-+
-+	/* if reset finished and it's still not enabled -- handoff */
-+	if (!isp1760_hcd_is_set(hcd, PORT_PE)) {
-+		printf("port %d full speed --> companion\n", index + 1);
-+
-+		isp1760_hcd_set(hcd, PORT_OWNER);
-+
-+		isp1760_hcd_clear(hcd, PORT_CSC);
-+	} else {
-+		printf("port %d high speed\n", index + 1);
-+	}
-+
-+	return;
-+}
-+
-+static int isp1760_hub_control(struct usb_hcd *hcd, struct usb_device *dev,
-+			       unsigned long pipe, void *buffer, int length,
-+			       struct devrequest *setup)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u16 typeReq, wValue, wIndex;
-+	unsigned long flags;
-+	char *buf = buffer;
-+	void *src = NULL;
-+	int src_len = 0;
-+	int retval = 0;
-+	u32 status;
-+	int ports;
-+
-+	if (!setup)
-+		return -EINVAL;
-+
-+	ports = isp1760_hcd_n_ports(hcd);
-+
-+	typeReq = setup->request | (setup->requesttype << 8);
-+	wValue = le16_to_cpu(setup->value);
-+	wIndex = le16_to_cpu(setup->index);
-+
-+	/*
-+	 * FIXME:  support SetPortFeatures USB_PORT_FEAT_INDICATOR.
-+	 * HCS_INDICATOR may say we can change LEDs to off/amber/green.
-+	 * (track current state ourselves) ... blink for diagnostics,
-+	 * power, "this is the one", etc.  EHCI spec supports this.
-+	 */
-+
-+	switch (typeReq) {
-+	case DeviceOutRequest | USB_REQ_SET_ADDRESS:
-+		break;
-+	case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
-+		/* Nothing to do */
-+		break;
-+	case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
-+		switch (wValue & 0xff00) {
-+		case USB_DT_DEVICE << 8:
-+			src = &rh_descriptor.device;
-+			src_len = 0x12;
-+			break;
-+		case USB_DT_CONFIG << 8:
-+			src = &rh_descriptor.config;
-+			src_len = 0x09;
-+			break;
-+		case USB_DT_STRING << 8:
-+			switch (wValue & 0xff) {
-+			case 0:	/* Language */
-+				src = "\4\3\19\4";
-+				src_len = 4;
-+				break;
-+			case 1:	/* Vendor String  */
-+				src = "\16\3U\0-\0B\0o\0o\0t\0";
-+				src_len = 14;
-+				break;
-+			case 2:	/* Product Name */
-+				src = "\52\3I\0S\0P\0-\0 "
-+					 "\0H\0o\0s\0t\0 "
-+					 "\0C\0o\0n\0t\0r\0o\0l\0l\0e\0r\0";
-+				src_len = 42;
-+				break;
-+			default:
-+				goto error;
-+			}
-+			break;
-+		}
-+		break;
-+	case ClearHubFeature:
-+		switch (wValue) {
-+		case C_HUB_LOCAL_POWER:
-+		case C_HUB_OVER_CURRENT:
-+			/* no hub-wide feature/status flags */
-+			break;
-+		default:
-+			goto error;
-+		}
-+		break;
-+	case ClearPortFeature:
-+		if (!wIndex || wIndex > ports)
-+			goto error;
-+		wIndex--;
-+
-+		/*
-+		 * Even if OWNER is set, so the port is owned by the
-+		 * companion controller, hub_wq needs to be able to clear
-+		 * the port-change status bits (especially
-+		 * USB_PORT_STAT_C_CONNECTION).
-+		 */
-+
-+		switch (wValue) {
-+		case USB_PORT_FEAT_ENABLE:
-+			isp1760_hcd_clear(hcd, PORT_PE);
-+			break;
-+		case USB_PORT_FEAT_C_ENABLE:
-+			/* XXX error? */
-+			break;
-+		case USB_PORT_FEAT_SUSPEND:
-+			if (isp1760_hcd_is_set(hcd, PORT_RESET))
-+				goto error;
-+
-+			if (isp1760_hcd_is_set(hcd, PORT_SUSPEND)) {
-+				if (!isp1760_hcd_is_set(hcd, PORT_PE))
-+					goto error;
-+				/* resume signaling for 20 msec */
-+				isp1760_hcd_clear(hcd, PORT_CSC);
-+				isp1760_hcd_set(hcd, PORT_RESUME);
-+
-+				priv->reset_done = get_timer(0) + 40;
-+			}
-+			break;
-+		case USB_PORT_FEAT_C_SUSPEND:
-+			/* we auto-clear this feature */
-+			break;
-+		case USB_PORT_FEAT_POWER:
-+			if (isp1760_hcd_ppc_is_set(hcd))
-+				isp1760_hcd_clear(hcd, PORT_POWER);
-+			break;
-+		case USB_PORT_FEAT_C_CONNECTION:
-+			isp1760_hcd_set(hcd, PORT_CSC);
-+			break;
-+		case USB_PORT_FEAT_C_OVER_CURRENT:
-+			/* XXX error ?*/
-+			break;
-+		case USB_PORT_FEAT_C_RESET:
-+			/* GetPortStatus clears reset */
-+			break;
-+		default:
-+			goto error;
-+		}
-+		isp1760_hcd_read(hcd, CMD_RUN);
-+		break;
-+	case GetHubDescriptor:
-+		isp1760_hub_descriptor(priv, (struct usb_hub_descriptor *) buf);
-+		break;
-+	case GetHubStatus:
-+		/* no hub-wide feature/status flags */
-+		memset(buf, 0, 4);
-+		break;
-+	case GetPortStatus:
-+		if (!wIndex || wIndex > ports)
-+			goto error;
-+		wIndex--;
-+		status = 0;
-+
-+		/* wPortChange bits */
-+		if (isp1760_hcd_is_set(hcd, PORT_CSC))
-+			status |= USB_PORT_STAT_C_CONNECTION << 16;
-+
-+		/* whoever resumes must GetPortStatus to complete it!! */
-+		if (isp1760_hcd_is_set(hcd, PORT_RESUME)) {
-+			status |= USB_PORT_STAT_C_SUSPEND << 16;
-+
-+			if (!priv->reset_done) {
-+				priv->reset_done = get_timer(0) + 20;
-+			} else if (get_timer(0) > priv->reset_done) {
-+				/* stop resume signaling */
-+				isp1760_hcd_clear(hcd, PORT_CSC);
-+
-+				retval = isp1760_hcd_clear_and_wait(hcd,
-+								    PORT_RESUME, 2000);
-+				if (retval != 0) {
-+					printf("port %d resume error %d\n",
-+					       wIndex + 1, retval);
-+					goto error;
-+				}
-+			}
-+		}
-+
-+		/* whoever resets must GetPortStatus to complete it!! */
-+		if (isp1760_hcd_is_set(hcd, PORT_RESET) &&
-+		    get_timer(0) > priv->reset_done) {
-+			status |= USB_PORT_STAT_C_RESET << 16;
-+			priv->reset_done = 0;
-+
-+			/* force reset to complete */
-+			/* REVISIT:  some hardware needs 550+ usec to clear
-+			 * this bit; seems too long to spin routinely...
-+			 */
-+			retval = isp1760_hcd_clear_and_wait(hcd, PORT_RESET,
-+							    750);
-+			if (retval != 0) {
-+				printf("port %d reset error %d\n", wIndex + 1,
-+				       retval);
-+				goto error;
-+			}
-+
-+			/* see what we found out */
-+			check_reset_complete(hcd, wIndex);
-+		}
-+		/*
-+		 * Even if OWNER is set, there's no harm letting hub_wq
-+		 * see the wPortStatus values (they should all be 0 except
-+		 * for PORT_POWER anyway).
-+		 */
-+
-+		if (isp1760_hcd_is_set(hcd, PORT_OWNER))
-+			printf("PORT_OWNER is set\n");
-+
-+		if (isp1760_hcd_is_set(hcd, PORT_CONNECT)) {
-+			status |= USB_PORT_STAT_CONNECTION;
-+
-+			/* status may be from integrated TT */
-+			status |= USB_PORT_STAT_HIGH_SPEED;
-+		}
-+		if (isp1760_hcd_is_set(hcd, PORT_PE))
-+			status |= USB_PORT_STAT_ENABLE;
-+		if (isp1760_hcd_is_set(hcd, PORT_SUSPEND) &&
-+		    isp1760_hcd_is_set(hcd, PORT_RESUME))
-+			status |= USB_PORT_STAT_SUSPEND;
-+		if (isp1760_hcd_is_set(hcd, PORT_RESET))
-+			status |= USB_PORT_STAT_RESET;
-+		if (isp1760_hcd_is_set(hcd, PORT_POWER))
-+			status |= USB_PORT_STAT_POWER;
-+
-+		put_unaligned(cpu_to_le32(status), (__le32 *) buf);
-+		break;
-+	case SetHubFeature:
-+		switch (wValue) {
-+		case C_HUB_LOCAL_POWER:
-+		case C_HUB_OVER_CURRENT:
-+			/* no hub-wide feature/status flags */
-+			break;
-+		default:
-+			goto error;
-+		}
-+		break;
-+	case SetPortFeature:
-+		wIndex &= 0xff;
-+		if (!wIndex || wIndex > ports)
-+			goto error;
-+		wIndex--;
-+
-+		if (isp1760_hcd_is_set(hcd, PORT_OWNER))
-+			break;
-+
-+		switch (wValue) {
-+		case USB_PORT_FEAT_ENABLE:
-+			isp1760_hcd_set(hcd, PORT_PE);
-+			break;
-+
-+		case USB_PORT_FEAT_SUSPEND:
-+			if (!isp1760_hcd_is_set(hcd, PORT_PE) ||
-+			    isp1760_hcd_is_set(hcd, PORT_RESET))
-+				goto error;
-+
-+			isp1760_hcd_set(hcd, PORT_SUSPEND);
-+			break;
-+		case USB_PORT_FEAT_POWER:
-+			if (isp1760_hcd_ppc_is_set(hcd))
-+				isp1760_hcd_set(hcd, PORT_POWER);
-+			break;
-+		case USB_PORT_FEAT_RESET:
-+			if (isp1760_hcd_is_set(hcd, PORT_RESUME))
-+				goto error;
-+			/* line status bits may report this as low speed,
-+			 * which can be fine if this root hub has a
-+			 * transaction translator built in.
-+			 */
-+			if ((isp1760_hcd_is_set(hcd, PORT_CONNECT) &&
-+			     !isp1760_hcd_is_set(hcd, PORT_PE)) &&
-+			    (isp1760_hcd_read(hcd, PORT_LSTATUS) == 1)) {
-+				isp1760_hcd_set(hcd, PORT_OWNER);
-+			} else {
-+				isp1760_hcd_set(hcd, PORT_RESET);
-+				isp1760_hcd_clear(hcd, PORT_PE);
-+
-+				priv->reset_done = get_timer(0) + 50;
-+			}
-+			break;
-+		default:
-+			goto error;
-+		}
-+		break;
-+
-+	default:
-+		printf("root: unknown request: 0x%0x\n", typeReq);
-+		goto error;
-+	}
-+	spin_unlock_irqrestore(&priv->lock, flags);
-+
-+	if (src_len) {
-+		length = min(src_len, length);
-+
-+		if (src != NULL && length > 0)
-+			memcpy(buffer, src, length);
-+		else
-+			printf("zero copy USB descriptor\n");
-+	}
-+
-+	dev->act_len = length;
-+	dev->status = 0;
-+
-+	return 0;
-+
-+error:
-+	/* "stall" on error */
-+	dev->act_len = 0;
-+	dev->status = USB_ST_STALLED;
-+	return -EPIPE;
-+}
-+
-+#ifndef __UBOOT__
-+static int isp1760_hub_status_data(struct usb_hcd *hcd, char *buf)
-+{
-+	u32 status = 0;
-+	int retval = 1;
-+
-+	/* init status to no-changes */
-+	buf[0] = 0;
-+
-+	if (isp1760_hcd_is_set(hcd, PORT_OWNER) &&
-+	    isp1760_hcd_is_set(hcd, PORT_CSC)) {
-+		isp1760_hcd_clear(hcd, PORT_CSC);
-+		goto done;
-+	}
-+
-+done:
-+	return status ? retval : 0;
-+}
-+
-+static void isp1760_endpoint_disable(struct usb_hcd *hcd,
-+		struct usb_host_endpoint *ep)
-+{
-+	struct isp1760_qh *qh, *qh_iter;
-+	unsigned long spinflags;
-+	int i;
-+
-+	qh = ep->hcpriv;
-+	if (!qh)
-+		return;
-+
-+	WARN_ON(!list_empty(&qh->qtd_list));
-+
-+	for (i = 0; i < QH_END; i++)
-+		list_for_each_entry(qh_iter, &priv->qh_list[i], qh_list)
-+			if (qh_iter == qh) {
-+				list_del(&qh_iter->qh_list);
-+				i = QH_END;
-+				break;
-+			}
-+	qh_free(qh);
-+	ep->hcpriv = NULL;
-+
-+	schedule_ptds(hcd);
-+}
-+
-+static int isp1760_get_frame(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+	u32 fr;
-+
-+	fr = isp1760_hcd_read(hcd, HC_FRINDEX);
-+	return (fr >> 3) % priv->periodic_size;
-+}
-+
-+static void isp1760_stop(struct usb_hcd *hcd)
-+{
-+	struct isp1760_hcd *priv = hcd_to_priv(hcd);
-+
-+	msleep(20);
-+
-+	spin_lock_irq(&priv->lock);
-+	ehci_reset(hcd);
-+	/* Disable IRQ */
-+	isp1760_hcd_clear(hcd, HW_GLOBAL_INTR_EN);
-+	spin_unlock_irq(&priv->lock);
-+
-+	isp1760_hcd_clear(hcd, FLAG_CF);
-+}
-+
-+static void isp1760_shutdown(struct usb_hcd *hcd)
-+{
-+	isp1760_stop(hcd);
-+
-+	isp1760_hcd_clear(hcd, HW_GLOBAL_INTR_EN);
-+
-+	isp1760_hcd_clear(hcd, CMD_RUN);
-+}
-+
-+static void isp1760_clear_tt_buffer_complete(struct usb_hcd *hcd,
-+						struct usb_host_endpoint *ep)
-+{
-+	struct isp1760_qh *qh = ep->hcpriv;
-+	unsigned long spinflags;
-+
-+	if (!qh)
-+		return;
-+
-+	qh->tt_buffer_dirty = 0;
-+	schedule_ptds(hcd);
-+}
-+
-+
-+static const struct hc_driver isp1760_hc_driver = {
-+	.description		= "isp1760-hcd",
-+	.product_desc		= "NXP ISP1760 USB Host Controller",
-+	.hcd_priv_size		= sizeof(struct isp1760_hcd *),
-+	.irq			= isp1760_irq,
-+	.flags			= HCD_MEMORY | HCD_USB2,
-+	.reset			= isp1760_hc_setup,
-+	.start			= isp1760_run,
-+	.stop			= isp1760_stop,
-+	.shutdown		= isp1760_shutdown,
-+	.urb_enqueue		= isp1760_urb_enqueue,
-+	.urb_dequeue		= isp1760_urb_dequeue,
-+	.endpoint_disable	= isp1760_endpoint_disable,
-+	.get_frame_number	= isp1760_get_frame,
-+	.hub_status_data	= isp1760_hub_status_data,
-+	.hub_control		= isp1760_hub_control,
-+	.clear_tt_buffer_complete	= isp1760_clear_tt_buffer_complete,
-+};
-+#endif // __UBOOT__
-+
-+int __init isp1760_init_kmem_once(void)
-+{
-+	urb_listitem_cachep = kmem_cache_create("isp1760_urb_listitem",
-+			sizeof(struct urb_listitem), 0, SLAB_TEMPORARY |
-+			SLAB_MEM_SPREAD, NULL);
-+
-+	if (!urb_listitem_cachep)
-+		return -ENOMEM;
-+
-+	qtd_cachep = kmem_cache_create("isp1760_qtd",
-+			sizeof(struct isp1760_qtd), 0, SLAB_TEMPORARY |
-+			SLAB_MEM_SPREAD, NULL);
-+
-+	if (!qtd_cachep)
-+		return -ENOMEM;
-+
-+	qh_cachep = kmem_cache_create("isp1760_qh", sizeof(struct isp1760_qh),
-+			0, SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
-+
-+	if (!qh_cachep) {
-+		kmem_cache_destroy(qtd_cachep);
-+		return -ENOMEM;
-+	}
-+
-+	return 0;
-+}
-+
-+void isp1760_deinit_kmem_cache(void)
-+{
-+	kmem_cache_destroy(qtd_cachep);
-+	kmem_cache_destroy(qh_cachep);
-+	kmem_cache_destroy(urb_listitem_cachep);
-+}
-+
-+int isp1760_hcd_lowlevel_init(struct isp1760_hcd *priv)
-+{
-+	int ret;
-+
-+	ret = isp1760_hc_setup(priv->hcd);
-+	if (ret < 0)
-+		return ret;
-+
-+	ret = isp1760_run(priv->hcd);
-+	if (ret < 0)
-+		return ret;
-+
-+	return 0;
-+}
-+
-+static const struct usb_urb_ops isp1760_urb_ops = {
-+	.urb_enqueue = isp1760_urb_enqueue,
-+	.urb_dequeue = isp1760_urb_dequeue,
-+	.hub_control = isp1760_hub_control,
-+	.isr = isp1760_irq,
-+};
-+
-+int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
-+			 int irq, unsigned long irqflags,
-+			 struct udevice *dev)
-+{
-+	const struct isp1760_memory_layout *mem_layout = priv->memory_layout;
-+	struct isp1760_host_data *host = dev_get_priv(dev);
-+	struct usb_hcd *hcd = &host->hcd;
-+	int ret;
-+
-+	priv->hcd = hcd;
-+
-+	hcd->hcd_priv = priv;
-+
-+	priv->hcd = hcd;
-+
-+	hcd->urb_ops = &isp1760_urb_ops;
-+
-+	priv->atl_slots = kcalloc(mem_layout->slot_num,
-+				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
-+	if (!priv->atl_slots)
-+		return -ENOMEM;
-+
-+	priv->int_slots = kcalloc(mem_layout->slot_num,
-+				  sizeof(struct isp1760_slotinfo), GFP_KERNEL);
-+	if (!priv->int_slots) {
-+		ret = -ENOMEM;
-+		goto free_atl_slots;
-+	}
-+
-+	host->host_speed = USB_SPEED_HIGH;
-+
-+	init_memory(priv);
-+
-+	return 0;
-+
-+free_atl_slots:
-+	kfree(priv->atl_slots);
-+
-+	return ret;
-+}
-+
-+void isp1760_hcd_unregister(struct isp1760_hcd *priv)
-+{
-+	struct isp1760_qh *qh, *qh_next;
-+	int i;
-+
-+	for (i = 0; i < QH_END; i++)
-+		list_for_each_entry_safe(qh, qh_next, &priv->qh_list[i],
-+					 qh_list) {
-+			qtd_list_free(&qh->qtd_list);
-+			list_del(&qh->qh_list);
-+			qh_free(qh);
-+		}
-+
-+	kfree(priv->atl_slots);
-+	kfree(priv->int_slots);
-+}
-diff --git a/drivers/usb/isp1760/isp1760-hcd.h b/drivers/usb/isp1760/isp1760-hcd.h
-new file mode 100644
-index 0000000000..00f5ca8c1f
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-hcd.h
-@@ -0,0 +1,82 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+#ifndef _ISP1760_HCD_H_
-+#define _ISP1760_HCD_H_
-+
-+#include <regmap.h>
-+
-+#include "isp1760-regs.h"
-+
-+struct isp1760_qh;
-+struct isp1760_qtd;
-+struct resource;
-+struct usb_hcd;
-+
-+struct isp1760_slotinfo {
-+	struct isp1760_qh *qh;
-+	struct isp1760_qtd *qtd;
-+	unsigned long timestamp;
-+};
-+
-+/* chip memory management */
-+#define ISP176x_BLOCK_MAX (32 + 20 + 4)
-+#define ISP176x_BLOCK_NUM 3
-+
-+struct isp1760_memory_layout {
-+	unsigned int blocks[ISP176x_BLOCK_NUM];
-+	unsigned int blocks_size[ISP176x_BLOCK_NUM];
-+
-+	unsigned int slot_num;
-+	unsigned int payload_blocks;
-+	unsigned int payload_area_size;
-+};
-+
-+struct isp1760_memory_chunk {
-+	unsigned int start;
-+	unsigned int size;
-+	unsigned int free;
-+};
-+
-+enum isp1760_queue_head_types {
-+	QH_CONTROL,
-+	QH_BULK,
-+	QH_INTERRUPT,
-+	QH_END
-+};
-+
-+struct isp1760_hcd {
-+	struct usb_hcd		*hcd;
-+	struct udevice		*dev;
-+
-+	void __iomem		*base;
-+
-+	struct regmap		*regs;
-+	struct regmap_field	*fields[HC_FIELD_MAX];
-+
-+	bool			is_isp1763;
-+	const struct isp1760_memory_layout	*memory_layout;
-+
-+	spinlock_t		lock;
-+	struct isp1760_slotinfo	*atl_slots;
-+	int			atl_done_map;
-+	struct isp1760_slotinfo	*int_slots;
-+	int			int_done_map;
-+	struct isp1760_memory_chunk memory_pool[ISP176x_BLOCK_MAX];
-+	struct list_head	qh_list[QH_END];
-+
-+	/* periodic schedule support */
-+#define	DEFAULT_I_TDPS		1024
-+	unsigned		periodic_size;
-+	unsigned		i_thresh;
-+	unsigned long		reset_done;
-+	unsigned long		next_statechange;
-+};
-+
-+int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
-+			 int irq, unsigned long irqflags, struct udevice *dev);
-+void isp1760_hcd_unregister(struct isp1760_hcd *priv);
-+int isp1760_hcd_lowlevel_init(struct isp1760_hcd *priv);
-+
-+int isp1760_init_kmem_once(void);
-+void isp1760_deinit_kmem_cache(void);
-+
-+#endif /* _ISP1760_HCD_H_ */
-diff --git a/drivers/usb/isp1760/isp1760-if.c b/drivers/usb/isp1760/isp1760-if.c
-new file mode 100644
-index 0000000000..c610da6b23
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-if.c
-@@ -0,0 +1,127 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ * based on original code from:
-+ * (c) 2007 Sebastian Siewior <bigeasy@linutronix.de>
-+ */
-+
-+#include <common.h>
-+#include <dm.h>
-+#include <dm/device-internal.h>
-+#include <dm/device_compat.h>
-+#include <dm/devres.h>
-+#include <dm/lists.h>
-+#include <linux/bug.h>
-+#include <linux/io.h>
-+#include <linux/kernel.h>
-+#include <linux/usb/otg.h>
-+#include <log.h>
-+#include <usb.h>
-+
-+#include "isp1760-core.h"
-+#include "isp1760-regs.h"
-+#include "isp1760-uboot.h"
-+
-+
-+static int isp1760_of_to_plat(struct udevice *dev)
-+{
-+	struct isp1760_device *isp = dev_get_plat(dev);
-+	unsigned int devflags = 0;
-+	u32 bus_width = 0;
-+	ofnode dp;
-+
-+
-+	if (!dev_has_ofnode(dev)) {
-+		/* select isp1763 as the default device */
-+		devflags = ISP1760_FLAG_ISP1763 | ISP1760_FLAG_BUS_WIDTH_16;
-+		pr_err("isp1760: no platform data\n");
-+		goto isp_setup;
-+	}
-+
-+	dp = dev_ofnode(dev);
-+
-+	if (ofnode_device_is_compatible(dp, "nxp,usb-isp1761"))
-+		devflags |= ISP1760_FLAG_ISP1761;
-+
-+	if (ofnode_device_is_compatible(dp, "nxp,usb-isp1763"))
-+		devflags |= ISP1760_FLAG_ISP1763;
-+
-+	/*
-+	* Some systems wire up only 8 of 16 data lines or
-+	* 16 of the 32 data lines
-+	*/
-+	bus_width = ofnode_read_u32_default(dp, "bus-width", 16);
-+	if (bus_width == 16)
-+		devflags |= ISP1760_FLAG_BUS_WIDTH_16;
-+	else if (bus_width == 8)
-+		devflags |= ISP1760_FLAG_BUS_WIDTH_8;
-+
-+	if (usb_get_dr_mode(dev_ofnode(dev)) == USB_DR_MODE_PERIPHERAL)
-+		devflags |= ISP1760_FLAG_PERIPHERAL_EN;
-+
-+	if (ofnode_read_bool(dp, "analog-oc"))
-+		devflags |= ISP1760_FLAG_ANALOG_OC;
-+
-+	if (ofnode_read_bool(dp, "dack-polarity"))
-+		devflags |= ISP1760_FLAG_DACK_POL_HIGH;
-+
-+	if (ofnode_read_bool(dp, "dreq-polarity"))
-+		devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
-+
-+isp_setup:
-+	isp->devflags = devflags;
-+	isp->dev = dev;
-+
-+	return 0;
-+}
-+
-+static int isp1760_plat_probe(struct udevice *dev)
-+{
-+	struct isp1760_device *isp = dev_get_plat(dev);
-+	struct resource mem_res;
-+	struct resource irq_res;
-+	int ret;
-+
-+	dev_read_resource(dev, 0, &mem_res);
-+	dev_read_resource(dev, 1, &irq_res);
-+
-+	isp1760_init_kmem_once();
-+
-+	ret = isp1760_register(isp, &mem_res, irq_res.start, irq_res.flags);
-+	if (ret < 0) {
-+		isp1760_deinit_kmem_cache();
-+		return ret;
-+	}
-+
-+	return 0;
-+}
-+
-+static int isp1760_plat_remove(struct udevice *dev)
-+{
-+	struct isp1760_device *isp = dev_get_plat(dev);
-+
-+	isp1760_deinit_kmem_cache();
-+	isp1760_unregister(isp);
-+
-+	return 0;
-+}
-+
-+static const struct udevice_id isp1760_ids[] = {
-+	{ .compatible = "nxp,usb-isp1760", },
-+	{ .compatible = "nxp,usb-isp1761", },
-+	{ .compatible = "nxp,usb-isp1763", },
-+	{ },
-+};
-+
-+U_BOOT_DRIVER(isp1760) = {
-+	.name		= "isp1760",
-+	.id		= UCLASS_USB,
-+	.of_match	= isp1760_ids,
-+	.of_to_plat	= isp1760_of_to_plat,
-+	.ops		= &isp1760_usb_ops,
-+	.probe		= isp1760_plat_probe,
-+	.remove		= isp1760_plat_remove,
-+	.plat_auto	= sizeof(struct isp1760_device),
-+	.priv_auto	= sizeof(struct isp1760_host_data),
-+};
-diff --git a/drivers/usb/isp1760/isp1760-regs.h b/drivers/usb/isp1760/isp1760-regs.h
-new file mode 100644
-index 0000000000..94ea60c20b
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-regs.h
-@@ -0,0 +1,292 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva
-+ * Copyright 2014 Laurent Pinchart
-+ * Copyright 2007 Sebastian Siewior
-+ *
-+ * Contacts:
-+ *     Sebastian Siewior <bigeasy@linutronix.de>
-+ *     Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-+ *     Rui Miguel Silva <rui.silva@linaro.org>
-+ */
-+
-+#ifndef _ISP176x_REGS_H_
-+#define _ISP176x_REGS_H_
-+
-+/* -----------------------------------------------------------------------------
-+ * Host Controller
-+ */
-+
-+/* ISP1760/31 */
-+/* EHCI capability registers */
-+#define ISP176x_HC_VERSION		0x002
-+#define ISP176x_HC_HCSPARAMS		0x004
-+#define ISP176x_HC_HCCPARAMS		0x008
-+
-+/* EHCI operational registers */
-+#define ISP176x_HC_USBCMD		0x020
-+#define ISP176x_HC_USBSTS		0x024
-+#define ISP176x_HC_FRINDEX		0x02c
-+
-+#define ISP176x_HC_CONFIGFLAG		0x060
-+#define ISP176x_HC_PORTSC1		0x064
-+
-+#define ISP176x_HC_ISO_PTD_DONEMAP	0x130
-+#define ISP176x_HC_ISO_PTD_SKIPMAP	0x134
-+#define ISP176x_HC_ISO_PTD_LASTPTD	0x138
-+#define ISP176x_HC_INT_PTD_DONEMAP	0x140
-+#define ISP176x_HC_INT_PTD_SKIPMAP	0x144
-+#define ISP176x_HC_INT_PTD_LASTPTD	0x148
-+#define ISP176x_HC_ATL_PTD_DONEMAP	0x150
-+#define ISP176x_HC_ATL_PTD_SKIPMAP	0x154
-+#define ISP176x_HC_ATL_PTD_LASTPTD	0x158
-+
-+/* Configuration Register */
-+#define ISP176x_HC_HW_MODE_CTRL		0x300
-+#define ISP176x_HC_CHIP_ID		0x304
-+#define ISP176x_HC_SCRATCH		0x308
-+#define ISP176x_HC_RESET		0x30c
-+#define ISP176x_HC_BUFFER_STATUS	0x334
-+#define ISP176x_HC_MEMORY		0x33c
-+
-+/* Interrupt Register */
-+#define ISP176x_HC_INTERRUPT		0x310
-+#define ISP176x_HC_INTERRUPT_ENABLE	0x314
-+#define ISP176x_HC_ISO_IRQ_MASK_OR	0x318
-+#define ISP176x_HC_INT_IRQ_MASK_OR	0x31c
-+#define ISP176x_HC_ATL_IRQ_MASK_OR	0x320
-+#define ISP176x_HC_ISO_IRQ_MASK_AND	0x324
-+#define ISP176x_HC_INT_IRQ_MASK_AND	0x328
-+#define ISP176x_HC_ATL_IRQ_MASK_AND	0x32c
-+
-+#define ISP176x_HC_OTG_CTRL_SET		0x374
-+#define ISP176x_HC_OTG_CTRL_CLEAR	0x376
-+
-+enum isp176x_host_controller_fields {
-+	/* HC_PORTSC1 */
-+	PORT_OWNER, PORT_POWER, PORT_LSTATUS, PORT_RESET, PORT_SUSPEND,
-+	PORT_RESUME, PORT_PE, PORT_CSC, PORT_CONNECT,
-+	/* HC_HCSPARAMS */
-+	HCS_PPC, HCS_N_PORTS,
-+	/* HC_HCCPARAMS */
-+	HCC_ISOC_CACHE, HCC_ISOC_THRES,
-+	/* HC_USBCMD */
-+	CMD_LRESET, CMD_RESET, CMD_RUN,
-+	/* HC_USBSTS */
-+	STS_PCD,
-+	/* HC_FRINDEX */
-+	HC_FRINDEX,
-+	/* HC_CONFIGFLAG */
-+	FLAG_CF,
-+	/* ISO/INT/ATL PTD */
-+	HC_ISO_PTD_DONEMAP, HC_ISO_PTD_SKIPMAP, HC_ISO_PTD_LASTPTD,
-+	HC_INT_PTD_DONEMAP, HC_INT_PTD_SKIPMAP, HC_INT_PTD_LASTPTD,
-+	HC_ATL_PTD_DONEMAP, HC_ATL_PTD_SKIPMAP, HC_ATL_PTD_LASTPTD,
-+	/* HC_HW_MODE_CTRL */
-+	ALL_ATX_RESET, HW_ANA_DIGI_OC, HW_DEV_DMA, HW_COMN_IRQ, HW_COMN_DMA,
-+	HW_DATA_BUS_WIDTH, HW_DACK_POL_HIGH, HW_DREQ_POL_HIGH, HW_INTR_HIGH_ACT,
-+	HW_INTF_LOCK, HW_INTR_EDGE_TRIG, HW_GLOBAL_INTR_EN,
-+	/* HC_CHIP_ID */
-+	HC_CHIP_ID_HIGH, HC_CHIP_ID_LOW, HC_CHIP_REV,
-+	/* HC_SCRATCH */
-+	HC_SCRATCH,
-+	/* HC_RESET */
-+	SW_RESET_RESET_ATX, SW_RESET_RESET_HC, SW_RESET_RESET_ALL,
-+	/* HC_BUFFER_STATUS */
-+	ISO_BUF_FILL, INT_BUF_FILL, ATL_BUF_FILL,
-+	/* HC_MEMORY */
-+	MEM_BANK_SEL, MEM_START_ADDR,
-+	/* HC_DATA */
-+	HC_DATA,
-+	/* HC_INTERRUPT */
-+	HC_INTERRUPT,
-+	/* HC_INTERRUPT_ENABLE */
-+	HC_INT_IRQ_ENABLE, HC_ATL_IRQ_ENABLE,
-+	/* INTERRUPT MASKS */
-+	HC_ISO_IRQ_MASK_OR, HC_INT_IRQ_MASK_OR, HC_ATL_IRQ_MASK_OR,
-+	HC_ISO_IRQ_MASK_AND, HC_INT_IRQ_MASK_AND, HC_ATL_IRQ_MASK_AND,
-+	/* HW_OTG_CTRL_SET */
-+	HW_OTG_DISABLE, HW_SW_SEL_HC_DC, HW_VBUS_DRV, HW_SEL_CP_EXT,
-+	HW_DM_PULLDOWN, HW_DP_PULLDOWN, HW_DP_PULLUP, HW_HC_2_DIS,
-+	/* HW_OTG_CTRL_CLR */
-+	HW_OTG_DISABLE_CLEAR, HW_SW_SEL_HC_DC_CLEAR, HW_VBUS_DRV_CLEAR,
-+	HW_SEL_CP_EXT_CLEAR, HW_DM_PULLDOWN_CLEAR, HW_DP_PULLDOWN_CLEAR,
-+	HW_DP_PULLUP_CLEAR, HW_HC_2_DIS_CLEAR,
-+	/* Last element */
-+	HC_FIELD_MAX,
-+};
-+
-+/* ISP1763 */
-+/* EHCI operational registers */
-+#define ISP1763_HC_USBCMD		0x8c
-+#define ISP1763_HC_USBSTS		0x90
-+#define ISP1763_HC_FRINDEX		0x98
-+
-+#define ISP1763_HC_CONFIGFLAG		0x9c
-+#define ISP1763_HC_PORTSC1		0xa0
-+
-+#define ISP1763_HC_ISO_PTD_DONEMAP	0xa4
-+#define ISP1763_HC_ISO_PTD_SKIPMAP	0xa6
-+#define ISP1763_HC_ISO_PTD_LASTPTD	0xa8
-+#define ISP1763_HC_INT_PTD_DONEMAP	0xaa
-+#define ISP1763_HC_INT_PTD_SKIPMAP	0xac
-+#define ISP1763_HC_INT_PTD_LASTPTD	0xae
-+#define ISP1763_HC_ATL_PTD_DONEMAP	0xb0
-+#define ISP1763_HC_ATL_PTD_SKIPMAP	0xb2
-+#define ISP1763_HC_ATL_PTD_LASTPTD	0xb4
-+
-+/* Configuration Register */
-+#define ISP1763_HC_HW_MODE_CTRL		0xb6
-+#define ISP1763_HC_CHIP_REV		0x70
-+#define ISP1763_HC_CHIP_ID		0x72
-+#define ISP1763_HC_SCRATCH		0x78
-+#define ISP1763_HC_RESET		0xb8
-+#define ISP1763_HC_BUFFER_STATUS	0xba
-+#define ISP1763_HC_MEMORY		0xc4
-+#define ISP1763_HC_DATA			0xc6
-+
-+/* Interrupt Register */
-+#define ISP1763_HC_INTERRUPT		0xd4
-+#define ISP1763_HC_INTERRUPT_ENABLE	0xd6
-+#define ISP1763_HC_ISO_IRQ_MASK_OR	0xd8
-+#define ISP1763_HC_INT_IRQ_MASK_OR	0xda
-+#define ISP1763_HC_ATL_IRQ_MASK_OR	0xdc
-+#define ISP1763_HC_ISO_IRQ_MASK_AND	0xde
-+#define ISP1763_HC_INT_IRQ_MASK_AND	0xe0
-+#define ISP1763_HC_ATL_IRQ_MASK_AND	0xe2
-+
-+#define ISP1763_HC_OTG_CTRL_SET		0xe4
-+#define ISP1763_HC_OTG_CTRL_CLEAR	0xe6
-+
-+/* -----------------------------------------------------------------------------
-+ * Peripheral Controller
-+ */
-+
-+#define DC_IEPTX(n)			(1 << (11 + 2 * (n)))
-+#define DC_IEPRX(n)			(1 << (10 + 2 * (n)))
-+#define DC_IEPRXTX(n)			(3 << (10 + 2 * (n)))
-+
-+#define ISP176x_DC_CDBGMOD_ACK		BIT(6)
-+#define ISP176x_DC_DDBGMODIN_ACK	BIT(4)
-+#define ISP176x_DC_DDBGMODOUT_ACK	BIT(2)
-+
-+#define ISP176x_DC_IEP0SETUP		BIT(8)
-+#define ISP176x_DC_IEVBUS		BIT(7)
-+#define ISP176x_DC_IEHS_STA		BIT(5)
-+#define ISP176x_DC_IERESM		BIT(4)
-+#define ISP176x_DC_IESUSP		BIT(3)
-+#define ISP176x_DC_IEBRST		BIT(0)
-+
-+#define ISP176x_DC_ENDPTYP_ISOC		0x01
-+#define ISP176x_DC_ENDPTYP_BULK		0x02
-+#define ISP176x_DC_ENDPTYP_INTERRUPT	0x03
-+
-+/* Initialization Registers */
-+#define ISP176x_DC_ADDRESS		0x0200
-+#define ISP176x_DC_MODE			0x020c
-+#define ISP176x_DC_INTCONF		0x0210
-+#define ISP176x_DC_DEBUG		0x0212
-+#define ISP176x_DC_INTENABLE		0x0214
-+
-+/* Data Flow Registers */
-+#define ISP176x_DC_EPMAXPKTSZ		0x0204
-+#define ISP176x_DC_EPTYPE		0x0208
-+
-+#define ISP176x_DC_BUFLEN		0x021c
-+#define ISP176x_DC_BUFSTAT		0x021e
-+#define ISP176x_DC_DATAPORT		0x0220
-+
-+#define ISP176x_DC_CTRLFUNC		0x0228
-+#define ISP176x_DC_EPINDEX		0x022c
-+
-+/* DMA Registers */
-+#define ISP176x_DC_DMACMD		0x0230
-+#define ISP176x_DC_DMATXCOUNT		0x0234
-+#define ISP176x_DC_DMACONF		0x0238
-+#define ISP176x_DC_DMAHW		0x023c
-+#define ISP176x_DC_DMAINTREASON		0x0250
-+#define ISP176x_DC_DMAINTEN		0x0254
-+#define ISP176x_DC_DMAEP		0x0258
-+#define ISP176x_DC_DMABURSTCOUNT	0x0264
-+
-+/* General Registers */
-+#define ISP176x_DC_INTERRUPT		0x0218
-+#define ISP176x_DC_CHIPID		0x0270
-+#define ISP176x_DC_FRAMENUM		0x0274
-+#define ISP176x_DC_SCRATCH		0x0278
-+#define ISP176x_DC_UNLOCKDEV		0x027c
-+#define ISP176x_DC_INTPULSEWIDTH	0x0280
-+#define ISP176x_DC_TESTMODE		0x0284
-+
-+enum isp176x_device_controller_fields {
-+	/* DC_ADDRESS */
-+	DC_DEVEN, DC_DEVADDR,
-+	/* DC_MODE */
-+	DC_VBUSSTAT, DC_SFRESET, DC_GLINTENA,
-+	/* DC_INTCONF */
-+	DC_CDBGMOD_ACK, DC_DDBGMODIN_ACK, DC_DDBGMODOUT_ACK, DC_INTPOL,
-+	/* DC_INTENABLE */
-+	DC_IEPRXTX_7, DC_IEPRXTX_6, DC_IEPRXTX_5, DC_IEPRXTX_4, DC_IEPRXTX_3,
-+	DC_IEPRXTX_2, DC_IEPRXTX_1, DC_IEPRXTX_0,
-+	DC_IEP0SETUP, DC_IEVBUS, DC_IEHS_STA, DC_IERESM, DC_IESUSP, DC_IEBRST,
-+	/* DC_EPINDEX */
-+	DC_EP0SETUP, DC_ENDPIDX, DC_EPDIR,
-+	/* DC_CTRLFUNC */
-+	DC_CLBUF, DC_VENDP, DC_DSEN, DC_STATUS, DC_STALL,
-+	/* DC_BUFLEN */
-+	DC_BUFLEN,
-+	/* DC_EPMAXPKTSZ */
-+	DC_FFOSZ,
-+	/* DC_EPTYPE */
-+	DC_EPENABLE, DC_ENDPTYP,
-+	/* DC_FRAMENUM */
-+	DC_FRAMENUM, DC_UFRAMENUM,
-+	/* DC_CHIP_ID */
-+	DC_CHIP_ID_HIGH, DC_CHIP_ID_LOW,
-+	/* DC_SCRATCH */
-+	DC_SCRATCH,
-+	/* Last element */
-+	DC_FIELD_MAX,
-+};
-+
-+/* ISP1763 */
-+/* Initialization Registers */
-+#define ISP1763_DC_ADDRESS		0x00
-+#define ISP1763_DC_MODE			0x0c
-+#define ISP1763_DC_INTCONF		0x10
-+#define ISP1763_DC_INTENABLE		0x14
-+
-+/* Data Flow Registers */
-+#define ISP1763_DC_EPMAXPKTSZ		0x04
-+#define ISP1763_DC_EPTYPE		0x08
-+
-+#define ISP1763_DC_BUFLEN		0x1c
-+#define ISP1763_DC_BUFSTAT		0x1e
-+#define ISP1763_DC_DATAPORT		0x20
-+
-+#define ISP1763_DC_CTRLFUNC		0x28
-+#define ISP1763_DC_EPINDEX		0x2c
-+
-+/* DMA Registers */
-+#define ISP1763_DC_DMACMD		0x30
-+#define ISP1763_DC_DMATXCOUNT		0x34
-+#define ISP1763_DC_DMACONF		0x38
-+#define ISP1763_DC_DMAHW		0x3c
-+#define ISP1763_DC_DMAINTREASON		0x50
-+#define ISP1763_DC_DMAINTEN		0x54
-+#define ISP1763_DC_DMAEP		0x58
-+#define ISP1763_DC_DMABURSTCOUNT	0x64
-+
-+/* General Registers */
-+#define ISP1763_DC_INTERRUPT		0x18
-+#define ISP1763_DC_CHIPID_LOW		0x70
-+#define ISP1763_DC_CHIPID_HIGH		0x72
-+#define ISP1763_DC_FRAMENUM		0x74
-+#define ISP1763_DC_SCRATCH		0x78
-+#define ISP1763_DC_UNLOCKDEV		0x7c
-+#define ISP1763_DC_INTPULSEWIDTH	0x80
-+#define ISP1763_DC_TESTMODE		0x84
-+
-+#endif
-diff --git a/drivers/usb/isp1760/isp1760-uboot.c b/drivers/usb/isp1760/isp1760-uboot.c
-new file mode 100644
-index 0000000000..7635210fe2
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-uboot.c
-@@ -0,0 +1,76 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ */
-+
-+#include <common.h>
-+#include <dm.h>
-+#include <dm/device-internal.h>
-+#include <dm/device_compat.h>
-+#include <dm/devres.h>
-+#include <dm/lists.h>
-+#include <linux/bug.h>
-+#include <linux/io.h>
-+#include <linux/kernel.h>
-+#include <linux/usb/otg.h>
-+#include <linux/usb/usb_urb_compat.h>
-+#include <log.h>
-+#include <usb.h>
-+
-+#include "isp1760-core.h"
-+#include "isp1760-hcd.h"
-+#include "isp1760-regs.h"
-+#include "isp1760-uboot.h"
-+
-+static int isp1760_msg_submit_control(struct udevice *dev,
-+				      struct usb_device *udev,
-+				      unsigned long pipe, void *buffer,
-+				      int length, struct devrequest *setup)
-+{
-+	struct isp1760_host_data *host = dev_get_priv(dev);
-+
-+	return usb_urb_submit_control(&host->hcd, &host->urb, &host->hep, udev,
-+				      pipe, buffer, length, setup, 0,
-+				      host->host_speed);
-+}
-+
-+static int isp1760_msg_submit_bulk(struct udevice *dev, struct usb_device *udev,
-+				   unsigned long pipe, void *buffer, int length)
-+{
-+	struct isp1760_host_data *host = dev_get_priv(dev);
-+
-+	return usb_urb_submit_bulk(&host->hcd, &host->urb, &host->hep, udev,
-+				   pipe, buffer, length);
-+}
-+
-+static int isp1760_msg_submit_irq(struct udevice *dev, struct usb_device *udev,
-+				  unsigned long pipe, void *buffer, int length,
-+				  int interval, bool nonblock)
-+{
-+	struct isp1760_host_data *host = dev_get_priv(dev);
-+
-+	return usb_urb_submit_irq(&host->hcd, &host->urb, &host->hep, udev,
-+				  pipe, buffer, length, interval);
-+}
-+
-+static int isp1760_get_max_xfer_size(struct udevice *dev, size_t *size)
-+{
-+	struct isp1760_host_data *host = dev_get_priv(dev);
-+	struct isp1760_hcd *priv = host->hcd.hcd_priv;
-+	const struct isp1760_memory_layout *mem = priv->memory_layout;
-+
-+	*size = mem->blocks_size[ISP176x_BLOCK_NUM - 1];
-+
-+	return 0;
-+}
-+
-+
-+struct dm_usb_ops isp1760_usb_ops = {
-+	.control		= isp1760_msg_submit_control,
-+	.bulk			= isp1760_msg_submit_bulk,
-+	.interrupt		= isp1760_msg_submit_irq,
-+	.get_max_xfer_size	= isp1760_get_max_xfer_size,
-+};
-diff --git a/drivers/usb/isp1760/isp1760-uboot.h b/drivers/usb/isp1760/isp1760-uboot.h
-new file mode 100644
-index 0000000000..2486de6f9e
---- /dev/null
-+++ b/drivers/usb/isp1760/isp1760-uboot.h
-@@ -0,0 +1,27 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Driver for the NXP ISP1760 chip
-+ *
-+ * Copyright 2021 Linaro, Rui Miguel Silva <rui.silva@linaro.org>
-+ *
-+ */
-+
-+#ifndef __ISP1760_UBOOT_H__
-+#define __ISP1760_UBOOT_H__
-+
-+#include <linux/usb/usb_urb_compat.h>
-+#include <usb.h>
-+
-+#include "isp1760-core.h"
-+
-+struct isp1760_host_data {
-+	struct isp1760_hcd *priv;
-+	struct usb_hcd hcd;
-+	enum usb_device_speed host_speed;
-+	struct usb_host_endpoint hep;
-+	struct urb urb;
-+};
-+
-+extern struct dm_usb_ops isp1760_usb_ops;
-+
-+#endif
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-introduce-armffa-command.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch
similarity index 83%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-introduce-armffa-command.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch
index f52f88d..44afdd5 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-introduce-armffa-command.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-arm_ffa-introduce-armffa-command.patch
@@ -1,20 +1,35 @@
-From a09ed2542f4d991fef61bd51f87d373f44ad1ff3 Mon Sep 17 00:00:00 2001
+From e9ec690a3f0d34631729a17c1734d66111e768e1 Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 Date: Mon, 6 Jun 2022 12:46:38 +0100
-Subject: [PATCH 10/26] arm_ffa: introduce armffa command
+Subject: [PATCH 05/25] arm_ffa: introduce armffa command
 
 Provide armffa command showcasing the use of the FF-A driver
 
 The armffa command allows to query secure partitions data from
-the secure world and exchanging messages with the partitions.
+the secure world and exchanging messages with the partitions
+using 64-bit FF-A direct messaging.
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v8:
+
+* update partition_info_get() second argument to be an SP count
+* pass NULL device pointer to the FF-A bus discovery and operations
+
+v7:
+
+* adapt do_ffa_dev_list() following the recent update on
+  uclass_first_device/uclass_next_device functions (they return void now)
+* set armffa command to use 64-bit direct messaging
+
 v4:
 
 * remove pattern data in do_ffa_msg_send_direct_req
@@ -32,32 +47,32 @@
 v1:
 
 * introduce armffa command
-
+---
  MAINTAINERS                      |   1 +
  cmd/Kconfig                      |  10 ++
  cmd/Makefile                     |   2 +
- cmd/armffa.c                     | 242 +++++++++++++++++++++++++++++++
+ cmd/armffa.c                     | 237 +++++++++++++++++++++++++++++++
  drivers/firmware/arm-ffa/Kconfig |   1 +
- 5 files changed, 256 insertions(+)
+ 5 files changed, 251 insertions(+)
  create mode 100644 cmd/armffa.c
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index e760b4ca3a..9f0a1b7387 100644
+index 734fcb10c4..d50bdddea8 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -247,6 +247,7 @@ F:	include/configs/turris_*.h
+@@ -251,6 +251,7 @@ F:	configs/cortina_presidio-asic-pnand_defconfig
  ARM FF-A
  M:	Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
  S:	Maintained
 +F:	cmd/armffa.c
- F:	doc/README.ffa.drv
+ F:	doc/arch/arm64.ffa.rst
  F:	drivers/firmware/arm-ffa/
  F:	include/arm_ffa.h
 diff --git a/cmd/Kconfig b/cmd/Kconfig
-index ba2f321ae9..090e668125 100644
+index 0e0be94f41..013d4c3da7 100644
 --- a/cmd/Kconfig
 +++ b/cmd/Kconfig
-@@ -873,6 +873,16 @@ endmenu
+@@ -912,6 +912,16 @@ endmenu
  
  menu "Device access commands"
  
@@ -75,7 +90,7 @@
  	#depends on FLASH_CFI_DRIVER
  	bool "armflash"
 diff --git a/cmd/Makefile b/cmd/Makefile
-index 5e43a1e022..e40f52f1e4 100644
+index 6e87522b62..979c6d59df 100644
 --- a/cmd/Makefile
 +++ b/cmd/Makefile
 @@ -12,6 +12,8 @@ obj-y += panic.o
@@ -89,10 +104,10 @@
  obj-$(CONFIG_CMD_AES) += aes.o
 diff --git a/cmd/armffa.c b/cmd/armffa.c
 new file mode 100644
-index 0000000000..9b56e8a830
+index 0000000000..d2e8687bfb
 --- /dev/null
 +++ b/cmd/armffa.c
-@@ -0,0 +1,242 @@
+@@ -0,0 +1,237 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * (C) Copyright 2022 ARM Limited
@@ -126,7 +141,7 @@
 +static int do_ffa_get_singular_partition_info(struct cmd_tbl *cmdtp, int flag, int argc,
 +					      char *const argv[])
 +{
-+	u32 count = 0, size = 0;
++	u32 count = 0;
 +	int ret;
 +	struct ffa_partition_info *parts_info;
 +	u32 info_idx;
@@ -135,7 +150,7 @@
 +		return -EINVAL;
 +
 +	/* Mode 1: getting the number of secure partitions */
-+	ret = ffa_bus_ops_get()->partition_info_get(argv[0], &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, NULL);
 +	if (ret != 0) {
 +		ffa_err("Failure in querying partitions count (error code: %d)", ret);
 +		return ret;
@@ -157,13 +172,11 @@
 +	if (!parts_info)
 +		return -EINVAL;
 +
-+	size = count * sizeof(struct ffa_partition_info);
-+
 +	/*
 +	 * ask the driver to fill the buffer with the SPs info
 +	 */
 +
-+	ret = ffa_bus_ops_get()->partition_info_get(argv[0], &size, parts_info);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, argv[0], &count, parts_info);
 +	if (ret != 0) {
 +		ffa_err("Failure in querying partition(s) info (error code: %d)", ret);
 +		free(parts_info);
@@ -224,7 +237,7 @@
 +		return -EINVAL;
 +	}
 +
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
++	ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
 +	if (ret == 0) {
 +		u8 cnt;
 +
@@ -257,16 +270,13 @@
 +int do_ffa_dev_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 +{
 +	struct udevice *dev = NULL;
-+	int i, ret;
++	int i;
 +
 +	ffa_info("arm_ffa uclass entries:");
 +
-+	for (i = 0, ret = uclass_first_device(UCLASS_FFA, &dev);
++	for (i = 0, uclass_first_device(UCLASS_FFA, &dev);
 +	     dev;
-+	     ret = uclass_next_device(&dev), i++) {
-+		if (ret)
-+			break;
-+
++	     uclass_next_device(&dev), i++) {
 +		ffa_info("entry %d - instance %08x, ops %08x, plat %08x",
 +			 i,
 +			 (u32)map_to_sysmem(dev),
@@ -274,7 +284,7 @@
 +			 (u32)map_to_sysmem(dev_get_plat(dev)));
 +	}
 +
-+	return cmd_process_error(cmdtp, ret);
++	return 0;
 +}
 +
 +static struct cmd_tbl armffa_commands[] = {
@@ -315,7 +325,7 @@
 +	if (!armffa_cmd || argc > armffa_cmd->maxargs)
 +		return CMD_RET_USAGE;
 +
-+	ret = ffa_bus_discover();
++	ret = ffa_bus_discover(NULL);
 +	if (ret != 0)
 +		return cmd_process_error(cmdtp, ret);
 +
@@ -336,7 +346,7 @@
 +	   "devlist\n"
 +	   "	 - displays the arm_ffa device info\n");
 diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig
-index aceb61cf49..40b467b0a5 100644
+index e4914b9bc7..be4df89d23 100644
 --- a/drivers/firmware/arm-ffa/Kconfig
 +++ b/drivers/firmware/arm-ffa/Kconfig
 @@ -4,6 +4,7 @@ config ARM_FFA_TRANSPORT
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-corstone1000-enable-isp1763-usb-controller.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-corstone1000-enable-isp1763-usb-controller.patch
deleted file mode 100644
index 6ebba56..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0005-corstone1000-enable-isp1763-usb-controller.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-From 8717357eff3f4172c74f0b10078c31cdff9bcc41 Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Thu, 3 Mar 2022 16:52:02 +0000
-Subject: [PATCH 05/26] corstone1000: enable isp1763 usb controller
-
-MPS3 board have a ISP1763 usb controller, add the
-correspondent mmio area and enable it to be used for mass
-storage access for example.
-
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Accepted [2022.10-rc1]
----
- configs/corstone1000_defconfig | 1 +
- include/configs/corstone1000.h | 6 ++++++
- 2 files changed, 7 insertions(+)
-
-diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
-index 02f931b0d4..e573fe6fe6 100644
---- a/configs/corstone1000_defconfig
-+++ b/configs/corstone1000_defconfig
-@@ -42,6 +42,7 @@ CONFIG_REGMAP=y
- CONFIG_DM_SERIAL=y
- CONFIG_USB=y
- CONFIG_DM_USB=y
-+CONFIG_USB_ISP1760=y
- CONFIG_USB_STORAGE=y
- CONFIG_EFI_MM_COMM_TEE=y
- # CONFIG_OPTEE is not set
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index cf166f107e..8ba0effb0a 100644
---- a/include/configs/corstone1000.h
-+++ b/include/configs/corstone1000.h
-@@ -55,7 +55,13 @@
- #define CONFIG_SYS_CBSIZE	512	/* Console I/O Buffer Size */
- #define CONFIG_SYS_MAXARGS	64	/* max command args */
- 
-+#define BOOT_TARGET_DEVICES(func) \
-+	func(USB, usb, 0)
-+
-+#include <config_distro_bootcmd.h>
-+
- #define CONFIG_EXTRA_ENV_SETTINGS							\
-+				BOOTENV							\
- 				"usb_pgood_delay=250\0"					\
- 				"boot_bank_flag=0x08002000\0"				\
- 				"kernel_addr_bank_0=0x083EE000\0"			\
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch
similarity index 91%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch
index 739f781..9d86dd5 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch
@@ -1,7 +1,7 @@
-From 553b57e39808ef04bc6aa54e0324f92b0175e476 Mon Sep 17 00:00:00 2001
+From 6d28dcdc36ad87b6987c7f920e06165c74eca59d Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Mon, 6 Jun 2022 12:55:08 +0100
-Subject: [PATCH 11/26] arm_ffa: introduce the FF-A Sandbox driver
+Date: Tue, 29 Nov 2022 14:44:36 +0000
+Subject: [PATCH 06/25] arm_ffa: introduce the FF-A Sandbox driver
 
 Provide a Sandbox driver to emulate the FF-A ABIs
 
@@ -12,67 +12,63 @@
 application to read the status of all the inspected ABIs
 and perform functional tests based on that.
 
+sandbox driver supports only 64-bit direct messaging.
+
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v8: update ffa_bus_prvdata_get() to return a pointer rather than
+    a pointer address
+
+v7: state that sandbox driver supports only 64-bit direct messaging
+
 v4: align sandbox driver with the new FF-A driver interfaces
- and new way of error handling
+    and new way of error handling
 
 v1: introduce the sandbox driver
-
+---
  MAINTAINERS                                   |   1 +
- common/board_r.c                              |   2 +-
  configs/sandbox64_defconfig                   |   2 +
  configs/sandbox_defconfig                     |   2 +
  doc/arch/sandbox.rst                          |   1 +
- drivers/firmware/arm-ffa/Kconfig              |  10 +-
+ drivers/firmware/arm-ffa/Kconfig              |   9 +-
  drivers/firmware/arm-ffa/Makefile             |   1 +
  drivers/firmware/arm-ffa/arm_ffa_prv.h        |  15 +-
- drivers/firmware/arm-ffa/core.c               |  24 +-
+ drivers/firmware/arm-ffa/core.c               |  22 +-
  drivers/firmware/arm-ffa/sandbox.c            | 659 ++++++++++++++++++
  .../firmware/arm-ffa/sandbox_arm_ffa_prv.h    | 144 ++++
  include/arm_ffa.h                             |   2 +-
  include/sandbox_arm_ffa.h                     |  91 +++
  lib/efi_loader/efi_boottime.c                 |   2 +-
- 14 files changed, 941 insertions(+), 15 deletions(-)
+ 13 files changed, 938 insertions(+), 13 deletions(-)
  create mode 100644 drivers/firmware/arm-ffa/sandbox.c
  create mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_prv.h
  create mode 100644 include/sandbox_arm_ffa.h
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index 9f0a1b7387..96157db6b6 100644
+index d50bdddea8..23cebbd526 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -251,6 +251,7 @@ F:	cmd/armffa.c
- F:	doc/README.ffa.drv
+@@ -255,6 +255,7 @@ F:	cmd/armffa.c
+ F:	doc/arch/arm64.ffa.rst
  F:	drivers/firmware/arm-ffa/
  F:	include/arm_ffa.h
 +F:	include/sandbox_arm_ffa.h
  
  ARM FREESCALE IMX
  M:	Stefano Babic <sbabic@denx.de>
-diff --git a/common/board_r.c b/common/board_r.c
-index c75634286b..f838cd5958 100644
---- a/common/board_r.c
-+++ b/common/board_r.c
-@@ -783,7 +783,7 @@ static init_fnc_t init_sequence_r[] = {
- 	INIT_FUNC_WATCHDOG_RESET
- 	initr_net,
- #endif
--#ifdef CONFIG_ARM_FFA_TRANSPORT
-+#if defined(CONFIG_ARM_FFA_TRANSPORT) && !defined(CONFIG_SANDBOX_FFA)
- 	ffa_bus_discover,
- #endif
- #ifdef CONFIG_POST
 diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
-index d7f22b39ae..78bc5aaa96 100644
+index 290d1506c2..36e6448968 100644
 --- a/configs/sandbox64_defconfig
 +++ b/configs/sandbox64_defconfig
-@@ -250,3 +250,5 @@ CONFIG_TEST_FDTDEC=y
+@@ -248,3 +248,5 @@ CONFIG_TEST_FDTDEC=y
  CONFIG_UNIT_TEST=y
  CONFIG_UT_TIME=y
  CONFIG_UT_DM=y
@@ -80,10 +76,10 @@
 +CONFIG_SANDBOX_FFA=y
 \ No newline at end of file
 diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
-index c509a924e6..8942aa7157 100644
+index ab5d3f19bf..8bf3848788 100644
 --- a/configs/sandbox_defconfig
 +++ b/configs/sandbox_defconfig
-@@ -327,3 +327,5 @@ CONFIG_TEST_FDTDEC=y
+@@ -328,3 +328,5 @@ CONFIG_TEST_FDTDEC=y
  CONFIG_UNIT_TEST=y
  CONFIG_UT_TIME=y
  CONFIG_UT_DM=y
@@ -103,7 +99,7 @@
  - Chrome OS EC
  - GPIO
 diff --git a/drivers/firmware/arm-ffa/Kconfig b/drivers/firmware/arm-ffa/Kconfig
-index 40b467b0a5..263481de96 100644
+index be4df89d23..b86f16d778 100644
 --- a/drivers/firmware/arm-ffa/Kconfig
 +++ b/drivers/firmware/arm-ffa/Kconfig
 @@ -2,8 +2,8 @@
@@ -117,27 +113,26 @@
  	select CMD_ARMFFA
  	select LIB_UUID
  	select DEVRES
-@@ -38,3 +38,9 @@ config ARM_FFA_EFI_RUNTIME_MODE
- 	  The driver Code needed at runtime is placed at EFI runtime code section.
- 	  Turning this on makes ffa_copy_runtime_data available for use and the driver
- 	  code placed at EFI runtime code section.
-+
+@@ -29,3 +29,8 @@ config ARM_FFA_TRANSPORT
+ 
+ 	  For more details about the FF-A driver, please refer to doc/arch/arm64.ffa.rst
+ 
 +config SANDBOX_FFA
 +	bool "FF-A Sandbox driver"
 +	depends on ARM_FFA_TRANSPORT && SANDBOX
 +	help
 +	  This emulates the FF-A handling under Sandbox and allows to test the FF-A driver
 diff --git a/drivers/firmware/arm-ffa/Makefile b/drivers/firmware/arm-ffa/Makefile
-index 0b9b0a61b4..d50060b836 100644
+index 043a8915be..0d21d6b47a 100644
 --- a/drivers/firmware/arm-ffa/Makefile
 +++ b/drivers/firmware/arm-ffa/Makefile
-@@ -5,3 +5,4 @@
+@@ -4,3 +4,4 @@
+ # Abdellatif El Khlifi, Arm Limited, abdellatif.elkhlifi@arm.com.
  
  obj-y += arm-ffa-uclass.o core.o
- obj-$(CONFIG_ARM_FFA_EFI_RUNTIME_MODE) += efi_ffa_runtime_data_mgr.o
 +obj-$(CONFIG_SANDBOX_FFA) += sandbox.o
 diff --git a/drivers/firmware/arm-ffa/arm_ffa_prv.h b/drivers/firmware/arm-ffa/arm_ffa_prv.h
-index 7bc90f7f66..3e0d4c112c 100644
+index 4eea7dc036..bbc8b87069 100644
 --- a/drivers/firmware/arm-ffa/arm_ffa_prv.h
 +++ b/drivers/firmware/arm-ffa/arm_ffa_prv.h
 @@ -19,6 +19,16 @@
@@ -157,7 +152,7 @@
  /* FF-A driver version definitions */
  
  #define MAJOR_VERSION_MASK		GENMASK(30, 16)
-@@ -94,11 +104,6 @@ struct ffa_abi_errmap {
+@@ -103,11 +113,6 @@ struct ffa_abi_errmap {
  #define FFA_ERRMAP_COUNT (FFA_LAST_ID - FFA_FIRST_ID + 1)
  #define FFA_ID_TO_ERRMAP_ID(ffa_id) ((ffa_id) - FFA_FIRST_ID)
  
@@ -170,10 +165,10 @@
   * struct ffa_partition_uuid - 16 bytes UUID transmitted by FFA_PARTITION_INFO_GET
   * @a1-4:	32-bit words access to the UUID data
 diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c
-index 41c7b96e68..caba10caae 100644
+index 0b1f8e6a07..560603b28b 100644
 --- a/drivers/firmware/arm-ffa/core.c
 +++ b/drivers/firmware/arm-ffa/core.c
-@@ -1101,6 +1101,7 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
+@@ -1072,6 +1072,7 @@ static int ffa_msg_send_direct_req(struct udevice *dev, u16 dst_part_id,
  	return ffa_to_std_errno(ffa_errno);
  }
  
@@ -181,7 +176,7 @@
  /**
   * __arm_ffa_fn_smc - SMC wrapper
   * @args: FF-A ABI arguments to be copied to Xn registers
-@@ -1114,6 +1115,7 @@ void __ffa_runtime __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
+@@ -1085,6 +1086,7 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
  {
  	arm_smccc_1_2_smc(&args, res);
  }
@@ -189,7 +184,7 @@
  
  /**
   * ffa_set_smc_conduit - Set the SMC conduit
-@@ -1127,7 +1129,12 @@ void __ffa_runtime __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
+@@ -1098,7 +1100,12 @@ void __arm_ffa_fn_smc(ffa_value_t args, ffa_value_t *res)
   */
  static int ffa_set_smc_conduit(void)
  {
@@ -203,19 +198,19 @@
  
  	if (!ffa_priv_data->invoke_ffa_fn) {
  		ffa_err("failure to set the invoke function");
-@@ -1304,17 +1311,18 @@ struct ffa_prvdata **ffa_bus_prvdata_get(void)
+@@ -1275,17 +1282,18 @@ struct ffa_prvdata *ffa_bus_prvdata_get(void)
  }
  
  /**
-- * ffa_bus_discover - discover FF-A bus and probe the arm_ffa device
+- * ffa_bus_discover - discover FF-A bus and probe arm_ffa device
 + * ffa_bus_discover - discover FF-A bus and probe arm_ffa and sandbox_arm_ffa devices
+  * @pdev: the address of a device pointer (to be filled when the arm_ffa bus device is created
+  *       successfully)
   *
-  * This boot time function makes sure the FF-A bus is discoverable.
-- * Then, the arm_ffa device is probed and ready to use.
-+ * Then, the arm_ffa and sandbox_arm_ffa devices are ready to use.
-+ *
-  * This function is called automatically at initcalls
-  * level (after u-boot relocation).
+  * This function makes sure the FF-A bus is discoverable.
+- * When probing succeeds FF-A discovery is done. The arm_ffa device is ready to use.
++ * When probing succeeds FF-A discovery is done. The arm_ffa and sandbox_arm_ffa devices
++ * are ready to use.
   *
   * When the bus was already discovered successfully the discovery will not run again.
   *
@@ -225,13 +220,9 @@
   * All FF-A clients should use the arm_ffa device to use the FF-A transport.
   *
   * Return:
-@@ -1325,9 +1333,15 @@ int ffa_bus_discover(void)
- {
- 	int ret = 0;
- 
--	if (!ffa_priv_data)
-+	if (!ffa_priv_data) {
- 		ret = ffa_device_get();
+@@ -1299,6 +1307,12 @@ int ffa_bus_discover(struct udevice **pdev)
+ 	if (!ffa_priv_data) {
+ 		ret = ffa_device_get(pdev);
  
 +#if CONFIG_IS_ENABLED(SANDBOX_FFA)
 +		if (ret == 0)
@@ -244,7 +235,7 @@
  
 diff --git a/drivers/firmware/arm-ffa/sandbox.c b/drivers/firmware/arm-ffa/sandbox.c
 new file mode 100644
-index 0000000000..16e1fdc809
+index 0000000000..16f1ca926e
 --- /dev/null
 +++ b/drivers/firmware/arm-ffa/sandbox.c
 @@ -0,0 +1,659 @@
@@ -680,7 +671,7 @@
 + * @{a0-a7} , res: The SMC call arguments and return structure.
 + *
 + * This is the function that emulates FFA_MSG_SEND_DIRECT_{REQ,RESP}
-+ * FF-A functions.
++ * FF-A functions. Only SMC 64-bit is supported in Sandbox.
 + *
 + * Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not supported.
 + * In case of success FFA_MSG_SEND_DIRECT_RESP is returned with default pattern data (0xff).
@@ -743,13 +734,13 @@
 +	if (!func_data)
 +		return -EINVAL;
 +
-+	if (!func_data->data0 || func_data->data0_size != sizeof(struct ffa_prvdata **))
++	if (!func_data->data0 || func_data->data0_size != sizeof(struct ffa_prvdata *))
 +		return -EINVAL;
 +
-+	if (!func_data->data1 || func_data->data1_size != sizeof(struct sandbox_ffa_prvdata **))
++	if (!func_data->data1 || func_data->data1_size != sizeof(struct sandbox_ffa_prvdata *))
 +		return -EINVAL;
 +
-+	*((struct ffa_prvdata **)func_data->data0) = *(ffa_bus_prvdata_get());
++	*((struct ffa_prvdata **)func_data->data0) = ffa_bus_prvdata_get();
 +	*((struct sandbox_ffa_prvdata **)func_data->data1) = &sandbox_ffa_priv_data;
 +
 +	return 0;
@@ -1058,17 +1049,17 @@
 +
 +#endif
 diff --git a/include/arm_ffa.h b/include/arm_ffa.h
-index f17b100497..665413a0c5 100644
+index 74b16174c2..b88904fe50 100644
 --- a/include/arm_ffa.h
 +++ b/include/arm_ffa.h
-@@ -111,7 +111,7 @@ struct ffa_bus_ops {
- const struct ffa_bus_ops * __ffa_runtime ffa_bus_ops_get(void);
+@@ -90,7 +90,7 @@ struct ffa_bus_ops {
+ const struct ffa_bus_ops *ffa_bus_ops_get(void);
  
  /**
 - * ffa_bus_discover - discover FF-A bus and probes the arm_ffa device
 + * ffa_bus_discover - discover FF-A bus and probes the arm_ffa and sandbox_arm_ffa devices
   */
- int ffa_bus_discover(void);
+ int ffa_bus_discover(struct udevice **pdev);
  
 diff --git a/include/sandbox_arm_ffa.h b/include/sandbox_arm_ffa.h
 new file mode 100644
@@ -1168,18 +1159,18 @@
 +
 +#endif
 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index 0ec002ac8b..8fa9a58d76 100644
+index caa64028be..1099ccc800 100644
 --- a/lib/efi_loader/efi_boottime.c
 +++ b/lib/efi_loader/efi_boottime.c
-@@ -2177,7 +2177,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
+@@ -2185,7 +2185,7 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
  		dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
  	}
  
 -#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT)
 +#if CONFIG_IS_ENABLED(ARM_FFA_TRANSPORT) && !CONFIG_IS_ENABLED(SANDBOX_FFA)
  		/* unmap FF-A RX/TX buffers */
- 		if (ffa_bus_ops_get()->rxtx_unmap())
- 			debug("[efi_boottime][ERROR]: can not unmap FF-A RX/TX buffers\n");
+ 		if (ffa_bus_ops_get()->rxtx_unmap(NULL))
+ 			log_err("Can't unmap FF-A RX/TX buffers\n");
 -- 
 2.17.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm64-smccc-clear-the-Xn-registers-after-SMC-calls.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm64-smccc-clear-the-Xn-registers-after-SMC-calls.patch
deleted file mode 100644
index cedac06..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm64-smccc-clear-the-Xn-registers-after-SMC-calls.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From 83f9da30247c2d021658bc1b595c59ecc35eadf5 Mon Sep 17 00:00:00 2001
-From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Fri, 29 Jul 2022 13:07:43 +0100
-Subject: [PATCH 07/26] arm64: smccc: clear the Xn registers after SMC calls
-
-set to zero the x0-x17 registers
-
-As per the SMCCC v1.2 spec, unused result and scratch registers can leak
-information after an SMC call. We can mitigate against this risk by
-returning zero in each register.
-
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
-
-Changelog:
-===============
-
-v4:
-
-* move the clearing code into a new macro: clear_gp_regs
-
-v3:
-
-* clear the Xn registers after SMC calls
-
- arch/arm/cpu/armv8/smccc-call.S | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/arch/arm/cpu/armv8/smccc-call.S b/arch/arm/cpu/armv8/smccc-call.S
-index ec6f299bc9..32f3eb8eeb 100644
---- a/arch/arm/cpu/armv8/smccc-call.S
-+++ b/arch/arm/cpu/armv8/smccc-call.S
-@@ -50,6 +50,12 @@ ENDPROC(__arm_smccc_hvc)
- 
- #ifdef CONFIG_ARM64
- 
-+	.macro	clear_gp_regs
-+	.irp	n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
-+	mov	x\n, xzr
-+	.endr
-+	.endm
-+
- 	.macro SMCCC_1_2 instr
- 	/* Save `res` and free a GPR that won't be clobbered */
- 	stp     x1, x19, [sp, #-16]!
-@@ -84,6 +90,9 @@ ENDPROC(__arm_smccc_hvc)
- 	stp	x14, x15, [x19, #ARM_SMCCC_1_2_REGS_X14_OFFS]
- 	stp	x16, x17, [x19, #ARM_SMCCC_1_2_REGS_X16_OFFS]
- 
-+	/* x0-x17 registers can leak information after an SMC or HVC call. Let's clear them */
-+	clear_gp_regs
-+
- 	/* Restore original x19 */
- 	ldp     xzr, x19, [sp], #16
- 	ret
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch
similarity index 85%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch
index edc5ed6..62f6e43 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch
@@ -1,7 +1,7 @@
-From dbc51066367481b5a45ce24f91571f83a022576e Mon Sep 17 00:00:00 2001
+From de26427c9f9b450ab4a18352fa51f46b3b585bc1 Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 Date: Mon, 6 Jun 2022 17:26:06 +0100
-Subject: [PATCH 12/26] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
+Subject: [PATCH 07/25] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
 
 Add functional test cases for the FF-A core driver
 
@@ -9,28 +9,38 @@
  inspecting the FF-A core driver.
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v8:
+
+  * update partition_info_get() second argument to be an SP count
+  * pass NULL device pointer to the FF-A bus discovery and operations
+
+v7: set the tests to use 64-bit direct messaging
+
 v4: align sandbox tests with the new FF-A driver interfaces
  and new way of error handling
 
 v1: introduce sandbox tests
-
+---
  MAINTAINERS      |   1 +
- test/dm/Makefile |   1 +
- test/dm/ffa.c    | 394 +++++++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 396 insertions(+)
+ test/dm/Makefile |   2 +
+ test/dm/ffa.c    | 392 +++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 395 insertions(+)
  create mode 100644 test/dm/ffa.c
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index 96157db6b6..e5b71b0ade 100644
+index 23cebbd526..e682db8d8f 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -252,6 +252,7 @@ F:	doc/README.ffa.drv
+@@ -256,6 +256,7 @@ F:	doc/arch/arm64.ffa.rst
  F:	drivers/firmware/arm-ffa/
  F:	include/arm_ffa.h
  F:	include/sandbox_arm_ffa.h
@@ -39,10 +49,18 @@
  ARM FREESCALE IMX
  M:	Stefano Babic <sbabic@denx.de>
 diff --git a/test/dm/Makefile b/test/dm/Makefile
-index f0a7c97e3d..f96f848046 100644
+index 7543df8823..e5a791768e 100644
 --- a/test/dm/Makefile
 +++ b/test/dm/Makefile
-@@ -79,6 +79,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
+@@ -1,6 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0+
+ #
+ # Copyright (c) 2013 Google, Inc
++# (C) Copyright 2022 ARM Limited
+ 
+ obj-$(CONFIG_UT_DM) += test-dm.o
+ 
+@@ -81,6 +82,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
  obj-$(CONFIG_ACPI_PMC) += pmc.o
  obj-$(CONFIG_DM_PMIC) += pmic.o
  obj-$(CONFIG_DM_PWM) += pwm.o
@@ -52,10 +70,10 @@
  obj-y += regmap.o
 diff --git a/test/dm/ffa.c b/test/dm/ffa.c
 new file mode 100644
-index 0000000000..052d5fc3f4
+index 0000000000..128d8626a7
 --- /dev/null
 +++ b/test/dm/ffa.c
-@@ -0,0 +1,394 @@
+@@ -0,0 +1,392 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Functional tests for UCLASS_FFA  class
@@ -228,7 +246,7 @@
 +	struct ffa_send_direct_data msg = {0};
 +	u8 cnt;
 +
-+	ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg));
++	ut_assertok(ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1));
 +
 +	for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++)
 +		ut_assertok(((u64 *)&msg)[cnt] != 0xffffffffffffffff);
@@ -240,7 +258,7 @@
 +				     struct sandbox_ffa_prvdata *sdx_prvdata,
 +				     struct unit_test_state *uts)
 +{
-+	u32 count = 0, size = 0;
++	u32 count = 0;
 +	struct ffa_partition_info *parts_info;
 +	u32 info_idx, exp_info_idx;
 +	int ret;
@@ -248,7 +266,7 @@
 +	/*
 +	 * get from the driver the count of the SPs matching the UUID
 +	 */
-+	ret = ffa_bus_ops_get()->partition_info_get(service_uuid, &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, NULL);
 +	/* make sure partitions are detected */
 +	ut_assertok(ret != 0);
 +	ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
@@ -261,12 +279,10 @@
 +	parts_info = calloc(count, sizeof(struct ffa_partition_info));
 +	ut_assertok(!parts_info);
 +
-+	size = count * sizeof(struct ffa_partition_info);
-+
 +	/*
 +	 * ask the driver to fill the buffer with the SPs info
 +	 */
-+	ret = ffa_bus_ops_get()->partition_info_get(service_uuid, &size, parts_info);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, service_uuid, &count, parts_info);
 +	if (ret != 0) {
 +		free(parts_info);
 +		ut_assertok(ret != 0);
@@ -317,7 +333,7 @@
 +	int ret;
 +
 +	/*  test probing FF-A devices */
-+	ut_assertok(ffa_bus_discover());
++	ut_assertok(ffa_bus_discover(NULL));
 +
 +	/* get a pointer to the FF-A core and sandbox drivers private data */
 +	func_data.data0 = &prvdata;
@@ -374,7 +390,7 @@
 +	ut_assertok(check_rxbuf_release_flag(rxbuf_flag, uts));
 +
 +	/* test FFA_RXTX_UNMAP */
-+	ut_assertok(ffa_bus_ops_get()->rxtx_unmap());
++	ut_assertok(ffa_bus_ops_get()->rxtx_unmap(NULL));
 +
 +	rxbuf_flag = 1;
 +	ut_assertok(sandbox_ffa_query_core_state(FFA_RXTX_UNMAP, &func_data));
@@ -399,7 +415,7 @@
 +	u16 part_id = 0;
 +
 +	/*  test probing FF-A devices */
-+	ut_assertok(ffa_bus_discover());
++	ut_assertok(ffa_bus_discover(NULL));
 +
 +	/* get a pointer to the FF-A core and sandbox drivers private data */
 +	func_data.data0 = &prvdata;
@@ -418,32 +434,32 @@
 +	ut_assertok(check_sandbox_dev(sdx_prvdata, uts));
 +
 +	/* query partitions count using  invalid arguments  */
-+	ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid, NULL, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, NULL, NULL);
 +	ut_assertok(ret != -EINVAL);
 +
 +	/* query partitions count using an invalid UUID  string */
-+	ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid_str, &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid_str, &count, NULL);
 +	ut_assertok(ret != -EINVAL);
 +
 +	/* query partitions count using an invalid UUID (no matching SP) */
 +	count = 0;
-+	ret = ffa_bus_ops_get()->partition_info_get(unvalid_svc_uuid, &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, unvalid_svc_uuid, &count, NULL);
 +	ut_assertok(count != 0);
 +
 +	/* query partitions count using a valid UUID  */
 +	count = 0;
-+	ret = ffa_bus_ops_get()->partition_info_get(valid_svc_uuid, &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, valid_svc_uuid, &count, NULL);
 +	/* make sure partitions are detected */
 +	ut_assertok(ret != 0);
 +	ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
 +
 +	/* send data to an invalid partition */
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
++	ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
 +	ut_assertok(ret != -EINVAL);
 +
 +	/* send data to a valid partition */
 +	part_id = prvdata->partitions.descs[0].info.id;
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
++	ret = ffa_bus_ops_get()->sync_send_receive(NULL, part_id, &msg, 1);
 +	ut_assertok(ret != 0);
 +
 +	return CMD_RET_SUCCESS;
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-arm_ffa-introduce-armffa-command-Sandbox-test.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch
similarity index 67%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-arm_ffa-introduce-armffa-command-Sandbox-test.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch
index 9722677..db0d4b0 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-arm_ffa-introduce-armffa-command-Sandbox-test.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch
@@ -1,13 +1,16 @@
-From 5be8c1d52045cbdc1adf79299792a6a49fef66c3 Mon Sep 17 00:00:00 2001
+From 5507189fe37f1243d685c59ea52fa5643d3cc50c Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Mon, 6 Jun 2022 17:30:44 +0100
-Subject: [PATCH 13/26] arm_ffa: introduce armffa command Sandbox test
+Date: Tue, 29 Nov 2022 14:48:34 +0000
+Subject: [PATCH 08/25] arm_ffa: introduce armffa command Sandbox test
 
 Add Sandbox test for the armffa command
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
@@ -15,18 +18,18 @@
 v4: drop use of helper APIs
 
 v1: introduce armffa command sandbox test
-
+---
  MAINTAINERS       |  1 +
- test/cmd/Makefile |  1 +
- test/cmd/armffa.c | 40 ++++++++++++++++++++++++++++++++++++++++
+ test/cmd/Makefile |  2 ++
+ test/cmd/armffa.c | 39 +++++++++++++++++++++++++++++++++++++++
  3 files changed, 42 insertions(+)
  create mode 100644 test/cmd/armffa.c
 
 diff --git a/MAINTAINERS b/MAINTAINERS
-index e5b71b0ade..505fffff14 100644
+index e682db8d8f..72f01769c9 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
-@@ -252,6 +252,7 @@ F:	doc/README.ffa.drv
+@@ -256,6 +256,7 @@ F:	doc/arch/arm64.ffa.rst
  F:	drivers/firmware/arm-ffa/
  F:	include/arm_ffa.h
  F:	include/sandbox_arm_ffa.h
@@ -35,20 +38,28 @@
  
  ARM FREESCALE IMX
 diff --git a/test/cmd/Makefile b/test/cmd/Makefile
-index a59adb1e6d..d9dc0809d6 100644
+index c331757425..19e9d0a995 100644
 --- a/test/cmd/Makefile
 +++ b/test/cmd/Makefile
-@@ -11,3 +11,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
+@@ -1,6 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0+
+ #
+ # Copyright (c) 2013 Google, Inc
++# (C) Copyright 2022 ARM Limited
+ 
+ ifdef CONFIG_HUSH_PARSER
+ obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
+@@ -13,3 +14,4 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
  obj-$(CONFIG_CMD_PINMUX) += pinmux.o
  obj-$(CONFIG_CMD_PWM) += pwm.o
  obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
 +obj-$(CONFIG_SANDBOX_FFA) += armffa.o
 diff --git a/test/cmd/armffa.c b/test/cmd/armffa.c
 new file mode 100644
-index 0000000000..531f82066e
+index 0000000000..e04363ba63
 --- /dev/null
 +++ b/test/cmd/armffa.c
-@@ -0,0 +1,40 @@
+@@ -0,0 +1,39 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Test for armffa command
@@ -58,7 +69,6 @@
 + */
 +
 +#include <common.h>
-+#include <dm.h>
 +#include <dm/test.h>
 +#include <sandbox_arm_ffa.h>
 +#include <string.h>
@@ -72,7 +82,7 @@
 +{
 +	char ping_cmd[PING_CMD_SIZE] = {0};
 +
-+	ut_assertok(ffa_bus_discover());
++	ut_assertok(ffa_bus_discover(NULL));
 +
 +	/* armffa getpart <UUID> */
 +	ut_assertok(run_command("armffa getpart " SANDBOX_SERVICE1_UUID, 0));
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-lib-uuid-introduce-be_uuid_str_to_le_bin-function.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-lib-uuid-introduce-be_uuid_str_to_le_bin-function.patch
deleted file mode 100644
index 769209b..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0008-lib-uuid-introduce-be_uuid_str_to_le_bin-function.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-From af17d357674393565c8be15f21c86cba972963e7 Mon Sep 17 00:00:00 2001
-From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Thu, 4 Aug 2022 16:46:47 +0100
-Subject: [PATCH 08/26] lib: uuid: introduce be_uuid_str_to_le_bin function
-
-convert big endian UUID string to little endian buffer
-
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
-
-Changelog:
-===============
-
-v4:
-
-* rename ffa_uuid_str_to_bin to be_uuid_str_to_le_bin and put in
-  a standalone commit (the current)
-
-v3:
-
-* introduce ffa_uuid_str_to_bin (provided by
-  arm_ffa: introduce Arm FF-A low-level driver)
-
- include/uuid.h |  6 +++++
- lib/uuid.c     | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 69 insertions(+)
-
-diff --git a/include/uuid.h b/include/uuid.h
-index 4a4883d3b5..5355230b5e 100644
---- a/include/uuid.h
-+++ b/include/uuid.h
-@@ -44,4 +44,10 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
- const char *uuid_guid_get_str(const unsigned char *guid_bin);
- void gen_rand_uuid(unsigned char *uuid_bin);
- void gen_rand_uuid_str(char *uuid_str, int str_format);
-+
-+/**
-+ * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little endian buffer
-+ */
-+int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);
-+
- #endif
-diff --git a/lib/uuid.c b/lib/uuid.c
-index 284f8113ff..d0fa51d0bf 100644
---- a/lib/uuid.c
-+++ b/lib/uuid.c
-@@ -1,6 +1,7 @@
- // SPDX-License-Identifier: GPL-2.0+
- /*
-  * Copyright 2011 Calxeda, Inc.
-+ * Copyright 2022 ARM Limited
-  */
- 
- #include <common.h>
-@@ -342,6 +343,68 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
- 	return 0;
- }
- 
-+/**
-+ * be_uuid_str_to_le_bin - Converts a big endian UUID string to a little endian buffer
-+ * @uuid_str:	UUID string in big endian format (36 bytes wide + '/0')
-+ * @uuid_bin:	preallocated 16 bytes UUID buffer in little endian format
-+ *
-+ * UUID string is 36 characters (36 bytes):
-+ *
-+ * xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
-+ * be		     be	     be	      be      be
-+ *
-+ * where x is a hexadecimal character. Fields are separated by '-'s.
-+ * When converting to a binary UUID, these endianness rules apply:
-+ *     be: means the field in the string is considered a big endian hex number
-+ *	   and should be converted to little endian binary format
-+ *
-+ * Return:
-+ *
-+ *    uuid_bin filled with little endian UUID data
-+ *    On success 0 is returned. Otherwise, failure code.
-+ */
-+int be_uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
-+{
-+	u16 tmp16 = 0;
-+	u32 tmp32 = 0;
-+	u64 tmp64 = 0;
-+
-+	if (!uuid_str_valid(uuid_str) || !uuid_bin)
-+		return -EINVAL;
-+
-+	/*
-+	 * reverse bytes from big to little endian
-+	 */
-+	tmp32 = simple_strtoul(uuid_str, NULL, 16);
-+	memcpy(uuid_bin, &tmp32, 4);
-+
-+	/*
-+	 * reverse bytes from big to little endian
-+	 */
-+	tmp16 = simple_strtoul(uuid_str + 9, NULL, 16);
-+	memcpy(uuid_bin + 4, &tmp16, 2);
-+
-+	/*
-+	 * reverse bytes from big to little endian
-+	 */
-+	tmp16 = simple_strtoul(uuid_str + 14, NULL, 16);
-+	memcpy(uuid_bin + 6, &tmp16, 2);
-+
-+	/*
-+	 * reverse bytes from big to little endian
-+	 */
-+	tmp16 = simple_strtoul(uuid_str + 19, NULL, 16);
-+	memcpy(uuid_bin + 8, &tmp16, 2);
-+
-+	/*
-+	 * reverse bytes from big to little endian
-+	 */
-+	tmp64 = simple_strtoull(uuid_str + 24, NULL, 16);
-+	memcpy(uuid_bin + 10, (char *)&tmp64, 6);
-+
-+	return 0;
-+}
-+
- /*
-  * uuid_bin_to_str() - convert big endian binary data to string UUID or GUID.
-  *
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-arm_ffa-introduce-FF-A-MM-communication.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch
similarity index 61%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-arm_ffa-introduce-FF-A-MM-communication.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch
index 04e5557..e9ffd6b 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-arm_ffa-introduce-FF-A-MM-communication.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch
@@ -1,12 +1,10 @@
-From b3c7d84dcde6ee1cbc13e10664d24ffa220f5fb3 Mon Sep 17 00:00:00 2001
+From cefc1d101c62e62e66f9cbf1775defde7d2c3d27 Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 Date: Mon, 15 Aug 2022 15:12:49 +0100
-Subject: [PATCH 14/26] arm_ffa: introduce FF-A MM communication
+Subject: [PATCH 09/25] arm_ffa: efi: introduce FF-A MM communication
 
 Add MM communication support using FF-A transport
 
-Access an SP's service through EFI MM communication protocol.
-
 This feature allows accessing MM partitions services through
 EFI MM communication protocol. MM partitions such as StandAlonneMM
 or smm-gateway secure partitions which reside in secure world.
@@ -26,18 +24,41 @@
 The response data is copied back to the communication buffer and
 consumed by the EFI subsystem.
 
-FF-A driver private data is copied to EFI runtime section at
-ExitBootServices(). This garantees secure world partitions data are
-available at EFI runtime level.
+MM communication protocol supports FF-A 64-bit direct messaging.
 
 Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
 Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
 
 Changelog:
 ===============
 
+v8:
+
+* isolate the compilation choices between FF-A and OP-TEE
+* update partition_info_get() second argument to be an SP count
+* pass NULL device pointer to the FF-A bus discovery and operations
+
+v7:
+
+* set the MM door bell event to use 64-bit direct messaging
+* issue a compile time error when one of these macros are not found :
+  FFA_SHARED_MM_BUFFER_SIZE, FFA_SHARED_MM_BUFFER_OFFSET, FFA_SHARED_MM_BUFFER_ADDR
+* make mm_sp_svc_uuid static
+* replace EINVAL with ENOMEM in ffa_discover_mm_sp_id() when calloc() fails
+* improve use of unmap_sysmem() in ffa_mm_communicate()
+
+v6:
+
+* add FF-A runtime discovery at MM communication level
+* drop EFI runtime support for FF-A MM communication
+* revert the changes in include/mm_communication.h for
+  efi_mm_communicate_header and smm_variable_access structures
+
 v4:
 
 * use the new FF-A driver interfaces
@@ -45,7 +66,7 @@
 * copy FF-A driver private data to EFI runtime section at
   ExitBootServices()
 * drop use of FFA_ERR_STAT_SUCCESS error code
-* replace EFI_BUFFER_TOO_SMALL by EFI_OUT_OF_RESOURCES
+* replace EFI_BUFFER_TOO_SMALL with EFI_OUT_OF_RESOURCES
   in ffa_mm_communicate(). No need for efi_memcpy_runtime() anymore
 * revert the error log in mm_communicate() in case of failure
 * remove packed attribute from efi_mm_communicate_header and
@@ -58,93 +79,26 @@
 v1:
 
 * introduce FF-A MM communication
-
- arch/arm/cpu/armv8/cache.S        |  16 ++
- arch/arm/cpu/armv8/cache_v8.c     |   3 +-
- include/mm_communication.h        |   7 +-
+---
+ include/mm_communication.h        |   5 +
  lib/efi_loader/Kconfig            |  14 +-
- lib/efi_loader/efi_boottime.c     |   7 +
- lib/efi_loader/efi_variable_tee.c | 261 +++++++++++++++++++++++++++++-
- 6 files changed, 299 insertions(+), 9 deletions(-)
+ lib/efi_loader/efi_variable_tee.c | 294 +++++++++++++++++++++++++++++-
+ 3 files changed, 307 insertions(+), 6 deletions(-)
 
-diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S
-index d1cee23437..f69ef64ed6 100644
---- a/arch/arm/cpu/armv8/cache.S
-+++ b/arch/arm/cpu/armv8/cache.S
-@@ -21,7 +21,11 @@
-  * x1: 0 clean & invalidate, 1 invalidate only
-  * x2~x9: clobbered
-  */
-+#ifdef CONFIG_EFI_LOADER
-+.pushsection .text.efi_runtime, "ax"
-+#else
- .pushsection .text.__asm_dcache_level, "ax"
-+#endif
- ENTRY(__asm_dcache_level)
- 	lsl	x12, x0, #1
- 	msr	csselr_el1, x12		/* select cache level */
-@@ -65,7 +69,11 @@ ENDPROC(__asm_dcache_level)
-  *
-  * flush or invalidate all data cache by SET/WAY.
-  */
-+#ifdef CONFIG_EFI_LOADER
-+.pushsection .text.efi_runtime, "ax"
-+#else
- .pushsection .text.__asm_dcache_all, "ax"
-+#endif
- ENTRY(__asm_dcache_all)
- 	mov	x1, x0
- 	dsb	sy
-@@ -109,7 +117,11 @@ ENTRY(__asm_flush_dcache_all)
- ENDPROC(__asm_flush_dcache_all)
- .popsection
- 
-+#ifdef CONFIG_EFI_LOADER
-+.pushsection .text.efi_runtime, "ax"
-+#else
- .pushsection .text.__asm_invalidate_dcache_all, "ax"
-+#endif
- ENTRY(__asm_invalidate_dcache_all)
- 	mov	x0, #0x1
- 	b	__asm_dcache_all
-@@ -182,7 +194,11 @@ ENTRY(__asm_invalidate_icache_all)
- ENDPROC(__asm_invalidate_icache_all)
- .popsection
- 
-+#ifdef CONFIG_EFI_LOADER
-+.pushsection .text.efi_runtime, "ax"
-+#else
- .pushsection .text.__asm_invalidate_l3_dcache, "ax"
-+#endif
- WEAK(__asm_invalidate_l3_dcache)
- 	mov	x0, #0			/* return status as success */
- 	ret
-diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
-index e4736e5643..afbc487fa1 100644
---- a/arch/arm/cpu/armv8/cache_v8.c
-+++ b/arch/arm/cpu/armv8/cache_v8.c
-@@ -9,6 +9,7 @@
- 
- #include <common.h>
- #include <cpu_func.h>
-+#include <efi_loader.h>
- #include <hang.h>
- #include <log.h>
- #include <asm/cache.h>
-@@ -445,7 +446,7 @@ __weak void mmu_setup(void)
- /*
-  * Performs a invalidation of the entire data cache at all levels
-  */
--void invalidate_dcache_all(void)
-+void __efi_runtime invalidate_dcache_all(void)
- {
- 	__asm_invalidate_dcache_all();
- 	__asm_invalidate_l3_dcache();
 diff --git a/include/mm_communication.h b/include/mm_communication.h
-index e65fbde60d..32dc5dbac8 100644
+index e65fbde60d..d409bed777 100644
 --- a/include/mm_communication.h
 +++ b/include/mm_communication.h
-@@ -13,6 +13,9 @@
+@@ -6,6 +6,8 @@
+  *  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  *  Copyright (C) 2020 Linaro Ltd. <sughosh.ganu@linaro.org>
+  *  Copyright (C) 2020 Linaro Ltd. <ilias.apalodimas@linaro.org>
++ * (C) Copyright 2022 ARM Limited
++ * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ 
+ #ifndef _MM_COMMUNICATION_H_
+@@ -13,6 +15,9 @@
  
  #include <part_efi.h>
  
@@ -154,29 +108,11 @@
  /*
   * Interface to the pseudo Trusted Application (TA), which provides a
   * communication channel with the Standalone MM (Management Mode)
-@@ -43,7 +46,7 @@
-  * To avoid confusion in interpreting frames, the communication buffer should
-  * always begin with efi_mm_communicate_header.
-  */
--struct __packed efi_mm_communicate_header {
-+struct efi_mm_communicate_header {
- 	efi_guid_t header_guid;
- 	size_t     message_len;
- 	u8         data[];
-@@ -145,7 +148,7 @@ struct smm_variable_communicate_header {
-  * Defined in EDK2 as SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
-  *
-  */
--struct smm_variable_access {
-+struct __packed smm_variable_access {
- 	efi_guid_t  guid;
- 	efi_uintn_t data_size;
- 	efi_uintn_t name_size;
 diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
-index e3f2402d0e..2a6d70f862 100644
+index b8fb2701a7..d292f57244 100644
 --- a/lib/efi_loader/Kconfig
 +++ b/lib/efi_loader/Kconfig
-@@ -60,13 +60,23 @@ config EFI_VARIABLE_FILE_STORE
+@@ -61,13 +61,23 @@ config EFI_VARIABLE_FILE_STORE
  	  stored as file /ubootefi.var on the EFI system partition.
  
  config EFI_MM_COMM_TEE
@@ -202,29 +138,24 @@
  config EFI_VARIABLE_NO_STORE
  	bool "Don't persist non-volatile UEFI variables"
  	help
-diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index 8fa9a58d76..cede7826bd 100644
---- a/lib/efi_loader/efi_boottime.c
-+++ b/lib/efi_loader/efi_boottime.c
-@@ -2185,6 +2185,13 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
- 			debug("[efi_boottime][INFO]: FF-A RX/TX buffers unmapped\n");
- #endif
- 
-+#if CONFIG_IS_ENABLED(ARM_FFA_EFI_RUNTIME_MODE) && !CONFIG_IS_ENABLED(SANDBOX_FFA)
-+		if (ffa_copy_runtime_data())
-+			printf("ERROR: EFI: FFA: copying runtime data\n");
-+		else
-+			printf("INFO: EFI: FFA: runtime data copied\n");
-+#endif
-+
- 	/* Patch out unsupported runtime function */
- 	efi_runtime_detach();
- 
 diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
-index dfef18435d..7d9d577281 100644
+index dfef18435d..3933a24e8c 100644
 --- a/lib/efi_loader/efi_variable_tee.c
 +++ b/lib/efi_loader/efi_variable_tee.c
-@@ -15,6 +15,36 @@
+@@ -4,9 +4,12 @@
+  *
+  *  Copyright (C) 2019 Linaro Ltd. <sughosh.ganu@linaro.org>
+  *  Copyright (C) 2019 Linaro Ltd. <ilias.apalodimas@linaro.org>
++ *  Copyright (C) 2022 ARM Limited
++ *  Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+  */
+ 
+ #include <common.h>
++#include <dm.h>
+ #include <efi.h>
+ #include <efi_api.h>
+ #include <efi_loader.h>
+@@ -15,6 +18,36 @@
  #include <malloc.h>
  #include <mm_communication.h>
  
@@ -235,33 +166,33 @@
 +#include <mapmem.h>
 +
 +#ifndef FFA_SHARED_MM_BUFFER_SIZE
-+#warning "FFA_SHARED_MM_BUFFER_SIZE must be defined in include/configs/<board>.h"
++#error "FFA_SHARED_MM_BUFFER_SIZE must be defined in include/configs/<board>.h"
 +#define FFA_SHARED_MM_BUFFER_SIZE 0
 +#endif
 +
 +#ifndef FFA_SHARED_MM_BUFFER_OFFSET
-+#warning "FFA_SHARED_MM_BUFFER_OFFSET must be defined in include/configs/<board>.h"
++#error "FFA_SHARED_MM_BUFFER_OFFSET must be defined in include/configs/<board>.h"
 +#define FFA_SHARED_MM_BUFFER_OFFSET 0
 +#endif
 +
 +#ifndef FFA_SHARED_MM_BUFFER_ADDR
-+#warning "FFA_SHARED_MM_BUFFER_ADDR must be defined in include/configs/<board>.h"
++#error "FFA_SHARED_MM_BUFFER_ADDR must be defined in include/configs/<board>.h"
 +#define FFA_SHARED_MM_BUFFER_ADDR 0
 +#endif
 +
 +/* MM return codes */
 +#define MM_SUCCESS (0)
 +
-+const char *mm_sp_svc_uuid = MM_SP_UUID;
++static const char *mm_sp_svc_uuid = MM_SP_UUID;
 +
-+static __efi_runtime_data u16 mm_sp_id;
++static u16 mm_sp_id;
 +
 +#endif
 +
  extern struct efi_var_file __efi_runtime_data *efi_var_buf;
  static efi_uintn_t max_buffer_size;	/* comm + var + func + data */
  static efi_uintn_t max_payload_size;	/* func + data */
-@@ -24,6 +54,7 @@ struct mm_connection {
+@@ -24,6 +57,7 @@ struct mm_connection {
  	u32 session;
  };
  
@@ -269,7 +200,7 @@
  /**
   * get_connection() - Retrieve OP-TEE session for a specific UUID.
   *
-@@ -143,16 +174,227 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
+@@ -143,13 +177,248 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
  
  	return ret;
  }
@@ -290,7 +221,7 @@
 + *
 + * 0 on success
 + */
-+static int __efi_runtime ffa_notify_mm_sp(void)
++static int ffa_notify_mm_sp(void)
 +{
 +	struct ffa_send_direct_data msg = {0};
 +	int ret;
@@ -301,7 +232,7 @@
 +
 +	msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */
 +
-+	ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg);
++	ret = ffa_bus_ops_get()->sync_send_receive(NULL, mm_sp_id, &msg, 1);
 +	if (ret != 0)
 +		return ret;
 +
@@ -330,7 +261,7 @@
 + */
 +static int ffa_discover_mm_sp_id(void)
 +{
-+	u32 count = 0, size = 0;
++	u32 count = 0;
 +	int ret;
 +	struct ffa_partition_info *parts_info;
 +
@@ -340,7 +271,7 @@
 +	/*
 +	 * get from the driver the count of the SPs matching the UUID
 +	 */
-+	ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &count, NULL);
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, NULL);
 +	if (ret != 0) {
 +		log_err("EFI: Failure in querying partitions count (error code: %d)\n", ret);
 +		return ret;
@@ -358,18 +289,16 @@
 +
 +	log_info("EFI: Pre-allocating %d partition(s) info structures\n", count);
 +
-+	parts_info = calloc(count, sizeof(struct ffa_partition_info));
++	parts_info = calloc(count, sizeof(*parts_info));
 +	if (!parts_info)
-+		return -EINVAL;
-+
-+	size = count * sizeof(struct ffa_partition_info);
++		return -ENOMEM;
 +
 +	/*
 +	 * ask the driver to fill the
 +	 * buffer with the SPs info
 +	 */
-+	ret = ffa_bus_ops_get()->partition_info_get(mm_sp_svc_uuid, &size, parts_info);
-+	if (ret != 0) {
++	ret = ffa_bus_ops_get()->partition_info_get(NULL, mm_sp_svc_uuid, &count, parts_info);
++	if (ret) {
 +		log_err("EFI: Failure in querying partition(s) info (error code: %d)\n", ret);
 +		free(parts_info);
 +		return ret;
@@ -404,10 +333,11 @@
 + *
 + * EFI status code
 + */
-+static efi_status_t __efi_runtime ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
++static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)
 +{
 +	ulong tx_data_size;
 +	int ffa_ret;
++	efi_status_t efi_ret;
 +	struct efi_mm_communicate_header *mm_hdr;
 +	void *virt_shared_buf;
 +
@@ -429,7 +359,7 @@
 +	/* Copy the data to the shared buffer */
 +
 +	virt_shared_buf = (void *)map_sysmem((phys_addr_t)FFA_SHARED_MM_BUFFER_ADDR, 0);
-+	efi_memcpy_runtime(virt_shared_buf, comm_buf, tx_data_size);
++	memcpy(virt_shared_buf, comm_buf, tx_data_size);
 +
 +	/*
 +	 * The secure world might have cache disabled for
@@ -444,8 +374,6 @@
 +	/* Announce there is data in the shared buffer */
 +
 +	ffa_ret = ffa_notify_mm_sp();
-+	if (ffa_ret)
-+		unmap_sysmem(virt_shared_buf);
 +
 +	switch (ffa_ret) {
 +	case 0:
@@ -457,30 +385,57 @@
 +			sizeof(size_t);
 +
 +		if (rx_data_size > comm_buf_size) {
-+			unmap_sysmem(virt_shared_buf);
-+			return EFI_OUT_OF_RESOURCES;
++			efi_ret = EFI_OUT_OF_RESOURCES;
++			break;
 +		}
 +
-+		efi_memcpy_runtime(comm_buf, virt_shared_buf, rx_data_size);
-+		unmap_sysmem(virt_shared_buf);
-+
-+		return EFI_SUCCESS;
++		memcpy(comm_buf, virt_shared_buf, rx_data_size);
++		efi_ret = EFI_SUCCESS;
++		break;
 +	}
 +	case -EINVAL:
-+		return EFI_DEVICE_ERROR;
++		efi_ret = EFI_DEVICE_ERROR;
++		break;
 +	case -EPERM:
-+		return EFI_INVALID_PARAMETER;
++		efi_ret = EFI_INVALID_PARAMETER;
++		break;
 +	case -EACCES:
-+		return EFI_ACCESS_DENIED;
++		efi_ret = EFI_ACCESS_DENIED;
++		break;
 +	case -EBUSY:
-+		return EFI_OUT_OF_RESOURCES;
++		efi_ret = EFI_OUT_OF_RESOURCES;
++		break;
 +	default:
-+		return EFI_ACCESS_DENIED;
++		efi_ret = EFI_ACCESS_DENIED;
 +	}
++
++	unmap_sysmem(virt_shared_buf);
++	return efi_ret;
 +}
 +#endif
 +
 +/**
++ * select_ffa_mm_comms() - checks FF-A support availability
++ *
++ * Making sure FF-A is compiled in. If that's the case try to discover
++ * the FF-A bus.
++ *
++ * Return:
++ *
++ * 0: FF-A ready for use. Otherwise, failure
++ */
++static efi_status_t select_ffa_mm_comms(void)
++{
++	efi_status_t ret = EFI_UNSUPPORTED;
++#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
++	ret = ffa_bus_discover(NULL);
++	if (ret)
++		ret = EFI_NOT_READY;
++#endif
++	return ret;
++}
++
++/**
 + * mm_communicate() - Adjust the communication buffer to the MM SP and send
   * it to OP-TEE
   *
@@ -488,31 +443,34 @@
 + * @comm_buf:		locally allocated communication buffer
   * @dsize:		buffer size
 + *
-+ * The MM SP (also called partition) can be StandAlonneMM or smm-gateway.
++ * The SP (also called partition) can be any MM SP such as  StandAlonneMM or smm-gateway.
 + * The comm_buf format is the same for both partitions.
 + * When using the u-boot OP-TEE driver, StandAlonneMM is supported.
-+ * When using the u-boot FF-A  driver, StandAlonneMM and smm-gateway are supported.
++ * When using the u-boot FF-A  driver, any MM SP is supported.
 + *
   * Return:		status code
   */
--static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
-+static efi_status_t __efi_runtime mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
- {
- 	efi_status_t ret;
- 	struct efi_mm_communicate_header *mm_hdr;
-@@ -162,7 +404,11 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
+ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
+@@ -162,7 +431,17 @@ static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize)
  	mm_hdr = (struct efi_mm_communicate_header *)comm_buf;
  	var_hdr = (struct smm_variable_communicate_header *)mm_hdr->data;
  
-+	#if (IS_ENABLED(CONFIG_OPTEE))
- 	ret = optee_mm_communicate(comm_buf, dsize);
-+	#elif (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
-+	ret = ffa_mm_communicate(comm_buf, dsize);
-+	#endif
+-	ret = optee_mm_communicate(comm_buf, dsize);
++	ret = select_ffa_mm_comms();
++	if (ret != EFI_SUCCESS) {
++#if (IS_ENABLED(CONFIG_OPTEE))
++		ret = optee_mm_communicate(comm_buf, dsize);
++#endif
++	} else {
++#if (IS_ENABLED(CONFIG_ARM_FFA_TRANSPORT))
++		ret = ffa_mm_communicate(comm_buf, dsize);
++#endif
++	}
++
  	if (ret != EFI_SUCCESS) {
  		log_err("%s failed!\n", __func__);
  		return ret;
-@@ -258,6 +504,13 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
+@@ -258,6 +537,13 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
  		goto out;
  	}
  	*size = var_payload->size;
@@ -526,7 +484,7 @@
  	/*
  	 * There seems to be a bug in EDK2 miscalculating the boundaries and
  	 * size checks, so deduct 2 more bytes to fulfill this requirement. Fix
-@@ -697,7 +950,7 @@ void efi_variables_boot_exit_notify(void)
+@@ -697,7 +983,7 @@ void efi_variables_boot_exit_notify(void)
  		ret = EFI_NOT_FOUND;
  
  	if (ret != EFI_SUCCESS)
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch
new file mode 100644
index 0000000..1dfc19b
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch
@@ -0,0 +1,76 @@
+From 46cadb787a3b13da39419706fae7d1ba703f4b68 Mon Sep 17 00:00:00 2001
+From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Date: Fri, 23 Sep 2022 15:17:21 +0100
+Subject: [PATCH 10/25] arm_ffa: efi: corstone1000: enable MM communication
+
+turn on EFI MM communication
+
+On corstone1000 platform MM communication between u-boot
+and the secure world (Optee) is done using the FF-A bus.
+
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Cc: Tom Rini <trini@konsulko.com>
+Cc: Simon Glass <sjg@chromium.org>
+Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
+Cc: Jens Wiklander <jens.wiklander@linaro.org>
+Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20221122131751.22747-1-abdellatif.elkhlifi@arm.com/]
+
+Changelog:
+===============
+
+v8:
+
+* drop OP-TEE configs from Corstone-1000 defconfig
+
+v7:
+
+* improve the definition of FFA_SHARED_MM_BUFFER_ADDR and
+  FFA_SHARED_MM_BUFFER_OFFSET
+* update FFA_SHARED_MM_BUFFER_ADDR value
+
+v6:
+
+* corstone-1000: enable optee driver
+* corstone-1000: remove CONFIG_ARM_FFA_EFI_RUNTIME_MODE from the defconfig
+
+v4:
+
+* corstone-1000: turn on EFI MM communication
+---
+ configs/corstone1000_defconfig | 2 ++
+ include/configs/corstone1000.h | 9 +++++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
+index ed2e0fe70a..c26f99e7e5 100644
+--- a/configs/corstone1000_defconfig
++++ b/configs/corstone1000_defconfig
+@@ -52,3 +52,5 @@ CONFIG_DM_SERIAL=y
+ CONFIG_USB=y
+ CONFIG_USB_ISP1760=y
+ CONFIG_ERRNO_STR=y
++CONFIG_EFI_MM_COMM_TEE=y
++CONFIG_ARM_FFA_TRANSPORT=y
+diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
+index 8e0230c135..0362d29ac2 100644
+--- a/include/configs/corstone1000.h
++++ b/include/configs/corstone1000.h
+@@ -14,6 +14,15 @@
+ 
+ #include <linux/sizes.h>
+ 
++#define FFA_SHARED_MM_BUFFER_SIZE	SZ_4K /* 4 KB */
++
++/*
++ * shared buffer physical address used for communication between
++ * u-boot and the MM SP
++ */
++#define FFA_SHARED_MM_BUFFER_ADDR	0x02000000UL
++#define FFA_SHARED_MM_BUFFER_OFFSET	0
++
+ #define V2M_BASE		0x80000000
+ 
+ #define CONFIG_PL011_CLOCK	50000000
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi-corstone1000-introduce-EFI-capsule-update.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-introduce-EFI-capsule-update.patch
similarity index 83%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi-corstone1000-introduce-EFI-capsule-update.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-introduce-EFI-capsule-update.patch
index 291d15d..57f1b9a 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi-corstone1000-introduce-EFI-capsule-update.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0011-efi-corstone1000-introduce-EFI-capsule-update.patch
@@ -1,7 +1,7 @@
-From 10e155a677192731481ebe7f302e2d9ad790346a Mon Sep 17 00:00:00 2001
+From 7702c4aeda51011be95ecbaab0dc2e7373d04286 Mon Sep 17 00:00:00 2001
 From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Thu, 28 Jul 2022 15:01:55 +0100
-Subject: [PATCH 16/26] efi: corstone1000: introduce EFI capsule update
+Date: Tue, 29 Nov 2022 15:11:27 +0000
+Subject: [PATCH 11/25] efi: corstone1000: introduce EFI capsule update
 
 This commit provides capsule update feature for Corstone1000.
 
@@ -22,15 +22,43 @@
 Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
 Upstream-Status: Pending [Not submitted to upstream yet]
 ---
- include/configs/corstone1000.h |  18 +++++
- include/efi_loader.h           |   4 +-
- lib/efi_loader/efi_boottime.c  |  36 ++++++++++
- lib/efi_loader/efi_capsule.c   | 124 ++++++++++++++++++++++++++++++++-
- lib/efi_loader/efi_setup.c     |  15 ++++
- 5 files changed, 193 insertions(+), 4 deletions(-)
+ board/armltd/corstone1000/corstone1000.c |   4 +
+ configs/corstone1000_defconfig           |   3 +
+ include/configs/corstone1000.h           |  18 ++++
+ include/efi_loader.h                     |   4 +-
+ lib/efi_loader/efi_boottime.c            |  36 +++++++
+ lib/efi_loader/efi_capsule.c             | 124 ++++++++++++++++++++++-
+ lib/efi_loader/efi_setup.c               |  15 +++
+ 7 files changed, 200 insertions(+), 4 deletions(-)
 
+diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
+index 4f4b96a095..76816f8f4e 100644
+--- a/board/armltd/corstone1000/corstone1000.c
++++ b/board/armltd/corstone1000/corstone1000.c
+@@ -66,6 +66,10 @@ static struct mm_region corstone1000_mem_map[] = {
+ 
+ struct mm_region *mem_map = corstone1000_mem_map;
+ 
++void set_dfu_alt_info(char *interface, char *devstr)
++{
++}
++
+ int board_init(void)
+ {
+ 	return 0;
+diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
+index c26f99e7e5..c72d027711 100644
+--- a/configs/corstone1000_defconfig
++++ b/configs/corstone1000_defconfig
+@@ -54,3 +54,6 @@ CONFIG_USB_ISP1760=y
+ CONFIG_ERRNO_STR=y
+ CONFIG_EFI_MM_COMM_TEE=y
+ CONFIG_ARM_FFA_TRANSPORT=y
++CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
++CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
++CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
 diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 5960c6b4be..fe5ec0adcd 100644
+index 0362d29ac2..4d20090c9b 100644
 --- a/include/configs/corstone1000.h
 +++ b/include/configs/corstone1000.h
 @@ -14,6 +14,24 @@
@@ -59,10 +87,10 @@
  
  /*
 diff --git a/include/efi_loader.h b/include/efi_loader.h
-index 5b41985244..796419b69b 100644
+index 545ba06d94..773c4f6310 100644
 --- a/include/efi_loader.h
 +++ b/include/efi_loader.h
-@@ -984,11 +984,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit;
+@@ -993,11 +993,11 @@ extern const struct efi_firmware_management_protocol efi_fmp_fit;
  extern const struct efi_firmware_management_protocol efi_fmp_raw;
  
  /* Capsule update */
@@ -77,10 +105,10 @@
  		efi_uintn_t capsule_count,
  		u64 *maximum_capsule_size,
 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index cede7826bd..9bf2596597 100644
+index 1099ccc800..d9eed33ac8 100644
 --- a/lib/efi_loader/efi_boottime.c
 +++ b/lib/efi_loader/efi_boottime.c
-@@ -2095,6 +2095,33 @@ static void efi_exit_caches(void)
+@@ -2103,6 +2103,33 @@ static void efi_exit_caches(void)
  #endif
  }
  
@@ -106,7 +134,7 @@
 +	msg.data0 = CORSTONE1000_SEPROXY_UPDATE_SVC_ID; /* x3 */
 +	msg.data2 = CORSTONE1000_KERNEL_STARTED_EVT; /* x5 */
 +
-+	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
++	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
 +}
 +
 +#endif
@@ -114,7 +142,7 @@
  /**
   * efi_exit_boot_services() - stop all boot services
   * @image_handle: handle of the loaded image
-@@ -2210,6 +2237,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
+@@ -2209,6 +2236,15 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
  	/* Recalculate CRC32 */
  	efi_update_table_header_crc32(&systab.hdr);
  
@@ -131,7 +159,7 @@
  	efi_set_watchdog(0);
  	WATCHDOG_RESET();
 diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
-index a6b98f066a..c0f3427a60 100644
+index a6b98f066a..636b61f0ad 100644
 --- a/lib/efi_loader/efi_capsule.c
 +++ b/lib/efi_loader/efi_capsule.c
 @@ -25,6 +25,14 @@
@@ -221,7 +249,7 @@
 +	msg.data1 = capsule_image_size; /* x4 */
 +	msg.data2 = CORSTONE1000_BUFFER_READY_EVT; /* x5 */
 +
-+	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
++	return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
 +}
 +#endif
 +
@@ -301,7 +329,7 @@
  		efi_uintn_t capsule_count,
  		u64 *maximum_capsule_size,
 diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
-index 492ecf4cb1..bfd4687e10 100644
+index c633fcd91e..443f409906 100644
 --- a/lib/efi_loader/efi_setup.c
 +++ b/lib/efi_loader/efi_setup.c
 @@ -16,6 +16,13 @@
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-arm-corstone1000-fix-unrecognized-filesystem-type.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch
similarity index 86%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-arm-corstone1000-fix-unrecognized-filesystem-type.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch
index 1a28d6c..9b12ee9 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-arm-corstone1000-fix-unrecognized-filesystem-type.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch
@@ -1,7 +1,7 @@
-From 3f8d35ccbb0d59d4820b81f7f939ada95b3cd92c Mon Sep 17 00:00:00 2001
+From 71162273e8a6b28a6aaf8635cff752419d09a293 Mon Sep 17 00:00:00 2001
 From: Rui Miguel Silva <rui.silva@linaro.org>
 Date: Fri, 4 Mar 2022 15:56:09 +0000
-Subject: [PATCH 18/26] arm: corstone1000: fix unrecognized filesystem type
+Subject: [PATCH 12/25] arm: corstone1000: fix unrecognized filesystem type
 
 Some usb sticks are not recognized by usb, just add a
 delay before checking status.
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch
similarity index 89%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch
index 3d8a6216..9334b80 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch
@@ -1,7 +1,7 @@
-From 3bb5826af8e3891617d41a30419de0ce089f9fc3 Mon Sep 17 00:00:00 2001
+From f8ccaf53dec63d57bab2f86b822f9fb3ed06d132 Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Fri, 10 Dec 2021 20:03:35 +0000
-Subject: [PATCH 19/26] efi_capsule: corstone1000: pass interface id and buffer
+Subject: [PATCH 13/25] efi_capsule: corstone1000: pass interface id and buffer
  event id using register w4
 
 Initially the interface/event IDs are passed to the SP using register
@@ -23,7 +23,7 @@
  2 files changed, 13 insertions(+), 4 deletions(-)
 
 diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 2d89a8966e..4637dd5d5d 100644
+index 4d20090c9b..77f96e87a1 100644
 --- a/include/configs/corstone1000.h
 +++ b/include/configs/corstone1000.h
 @@ -24,6 +24,12 @@
@@ -40,7 +40,7 @@
  #define CORSTONE1000_CAPSULE_BUFFER_SIZE	(8192) /* 32 MB */
  
 diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
-index c0f3427a60..bf8bd68256 100644
+index 636b61f0ad..c22b9b5aa0 100644
 --- a/lib/efi_loader/efi_capsule.c
 +++ b/lib/efi_loader/efi_capsule.c
 @@ -28,6 +28,8 @@
@@ -67,7 +67,7 @@
 +	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
 +		PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */
  
- 	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ 	return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
  }
 -- 
 2.17.1
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-efi_boottime-corstone1000-pass-interface-id-and-kern.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch
similarity index 86%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-efi_boottime-corstone1000-pass-interface-id-and-kern.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch
index db2ff32..a8d2c81 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-efi_boottime-corstone1000-pass-interface-id-and-kern.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch
@@ -1,7 +1,7 @@
-From 668fe40ccb0db5542ef333cd4655511dbb8572f9 Mon Sep 17 00:00:00 2001
+From e4e7ccc77a4e6930a768cc1c1f6daf8907ac16c3 Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Fri, 10 Dec 2021 20:10:41 +0000
-Subject: [PATCH 20/26] efi_boottime: corstone1000: pass interface id and
+Subject: [PATCH 14/25] efi_boottime: corstone1000: pass interface id and
  kernel event id using register w4
 
 Initially the interface/event IDs are passed to the SP using register
@@ -22,10 +22,10 @@
  1 file changed, 10 insertions(+), 3 deletions(-)
 
 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index 9bf2596597..de815484d2 100644
+index d9eed33ac8..88f2d050be 100644
 --- a/lib/efi_loader/efi_boottime.c
 +++ b/lib/efi_loader/efi_boottime.c
-@@ -27,6 +27,11 @@
+@@ -30,6 +30,11 @@
  #include <arm_ffa.h>
  #endif
  
@@ -37,7 +37,7 @@
  DECLARE_GLOBAL_DATA_PTR;
  
  /* Task priority level */
-@@ -2112,10 +2117,12 @@ static int efi_corstone1000_kernel_started_event(void)
+@@ -2120,10 +2125,12 @@ static int efi_corstone1000_kernel_started_event(void)
  	log_debug("[%s]\n", __func__);
  
  	/*
@@ -51,7 +51,7 @@
 +	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
 +		PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
  
- 	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+ 	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
  }
 -- 
 2.17.1
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch
deleted file mode 100644
index dcc3ea7..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From 01d1487cebc37834e2a5d259e0417a610539a0f5 Mon Sep 17 00:00:00 2001
-From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Thu, 9 Jun 2022 12:47:35 +0100
-Subject: [PATCH 15/26] arm_ffa: corstone1000: enable FF-A and MM support
-
-This commit allows corstone1000 platform to perform
-MM communication between u-boot and the secure world
-using FF-A transport.
-
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Submitted [cover letter: https://lore.kernel.org/all/20220926101723.9965-1-abdellatif.elkhlifi@arm.com/]
----
- configs/corstone1000_defconfig | 2 ++
- include/configs/corstone1000.h | 9 +++++++++
- 2 files changed, 11 insertions(+)
-
-diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
-index e573fe6fe6..c299dda49f 100644
---- a/configs/corstone1000_defconfig
-+++ b/configs/corstone1000_defconfig
-@@ -44,6 +44,8 @@ CONFIG_USB=y
- CONFIG_DM_USB=y
- CONFIG_USB_ISP1760=y
- CONFIG_USB_STORAGE=y
-+CONFIG_ARM_FFA_TRANSPORT=y
-+CONFIG_ARM_FFA_EFI_RUNTIME_MODE=y
- CONFIG_EFI_MM_COMM_TEE=y
- # CONFIG_OPTEE is not set
- # CONFIG_GENERATE_SMBIOS_TABLE is not set
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 8ba0effb0a..5960c6b4be 100644
---- a/include/configs/corstone1000.h
-+++ b/include/configs/corstone1000.h
-@@ -14,6 +14,15 @@
- 
- #include <linux/sizes.h>
- 
-+#define FFA_SHARED_MM_BUFFER_SIZE	SZ_4K /* 4 KB */
-+
-+/*
-+ * shared buffer physical address used for communication between
-+ * u-boot and the MM SP
-+ */
-+#define FFA_SHARED_MM_BUFFER_ADDR	(0x023F8000)
-+#define FFA_SHARED_MM_BUFFER_OFFSET	(0)
-+
- #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x03f00000)
- #define CONFIG_SKIP_LOWLEVEL_INIT
- 
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-efi_loader-corstone1000-remove-guid-check-from-corst.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch
similarity index 90%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-efi_loader-corstone1000-remove-guid-check-from-corst.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch
index 38ef1c0..d028e3e 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-efi_loader-corstone1000-remove-guid-check-from-corst.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch
@@ -1,7 +1,7 @@
-From 4d7fd850347dbea10a73cd5cf6eb518607118414 Mon Sep 17 00:00:00 2001
+From caf6c4ec65fd0a5e945dd790f2369acd163d1daf Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Sat, 11 Dec 2021 13:23:55 +0000
-Subject: [PATCH 21/26] efi_loader: corstone1000: remove guid check from
+Subject: [PATCH 15/25] efi_loader: corstone1000: remove guid check from
  corstone1000 config option
 
 Use generic fmp guid and no separte check is required for
@@ -15,7 +15,7 @@
  1 file changed, 1 insertion(+), 15 deletions(-)
 
 diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
-index bf8bd68256..5db9d30d53 100644
+index c22b9b5aa0..0eee3c2d4c 100644
 --- a/lib/efi_loader/efi_capsule.c
 +++ b/lib/efi_loader/efi_capsule.c
 @@ -646,12 +646,6 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch
similarity index 86%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch
index 3cedaa7..934476b 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch
@@ -1,7 +1,7 @@
-From 720e5ada733b0f7b019baaec57d74603a9dff67e Mon Sep 17 00:00:00 2001
+From 41a2c8bb23e587e9abe7b8bc62db1a93c0e5d841 Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Fri, 17 Dec 2021 19:49:02 +0000
-Subject: [PATCH 22/26] efi_loader: populate ESRT table if EFI_ESRT config
+Subject: [PATCH 16/25] efi_loader: populate ESRT table if EFI_ESRT config
  option is set
 
 This change is to call efi_esrt_populate function if CONFIG_EFI_ESRT
@@ -15,7 +15,7 @@
  1 file changed, 7 insertions(+)
 
 diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
-index 5db9d30d53..65e2fc8296 100644
+index 0eee3c2d4c..94dc0dfe3d 100644
 --- a/lib/efi_loader/efi_capsule.c
 +++ b/lib/efi_loader/efi_capsule.c
 @@ -668,6 +668,13 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule(
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-corstone1000-Update-FFA-shared-buffer-address.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-corstone1000-Update-FFA-shared-buffer-address.patch
deleted file mode 100644
index 7f5464c..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-corstone1000-Update-FFA-shared-buffer-address.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From a84f6be14f1bb31edea987fc02efd5a079a28db1 Mon Sep 17 00:00:00 2001
-From: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
-Date: Wed, 17 Nov 2021 15:28:06 +0000
-Subject: [PATCH 17/26] corstone1000: Update FFA shared buffer address
-
-FFA shared buffer address changed to 0x02000000.
-
-The existing address 0x023F8000 is currently being used by
-Optee so the virtual address returned to the SMM gateway is 0x0000.
-So the buffer is moved to 0x02000000.
-
-Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Pending [Not submitted to upstream yet]
----
- include/configs/corstone1000.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index fe5ec0adcd..2d89a8966e 100644
---- a/include/configs/corstone1000.h
-+++ b/include/configs/corstone1000.h
-@@ -38,7 +38,7 @@
-  * shared buffer physical address used for communication between
-  * u-boot and the MM SP
-  */
--#define FFA_SHARED_MM_BUFFER_ADDR	(0x023F8000)
-+#define FFA_SHARED_MM_BUFFER_ADDR	(0x02000000)
- #define FFA_SHARED_MM_BUFFER_OFFSET	(0)
- 
- #define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x03f00000)
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-efi_firmware-add-get_image_info-for-corstone1000.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch
similarity index 96%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-efi_firmware-add-get_image_info-for-corstone1000.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch
index f6aafa3..2c0ad25 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-efi_firmware-add-get_image_info-for-corstone1000.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0017-efi_firmware-add-get_image_info-for-corstone1000.patch
@@ -1,7 +1,7 @@
-From 2cad562823976134f201d6e2ef187bf103e17d1e Mon Sep 17 00:00:00 2001
+From 323df950c63af6d1a9ba5bd16f4f9d9348e9afc2 Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Fri, 17 Dec 2021 19:50:25 +0000
-Subject: [PATCH 23/26] efi_firmware: add get_image_info for corstone1000
+Subject: [PATCH 17/25] efi_firmware: add get_image_info for corstone1000
 
 This change is to populate get_image_info which eventually
 will be populated in ESRT table
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-efi_loader-send-bootcomplete-message-to-secure-encla.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch
similarity index 91%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-efi_loader-send-bootcomplete-message-to-secure-encla.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch
index 35f5cb2..e95609a 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-efi_loader-send-bootcomplete-message-to-secure-encla.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch
@@ -1,7 +1,7 @@
-From 709e5d8ff07474f840f1d34d3077135f77795452 Mon Sep 17 00:00:00 2001
+From 7bf9c380c63726b7de8316e9c743cb06c9bc7842 Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Mon, 15 Aug 2022 15:46:18 +0100
-Subject: [PATCH 24/26] efi_loader: send bootcomplete message to secure enclave
+Subject: [PATCH 18/25] efi_loader: send bootcomplete message to secure enclave
 
 On corstone1000 platform, Secure Enclave will be expecting
 an event from uboot when it performs capsule update. Previously,
@@ -21,7 +21,7 @@
  4 files changed, 41 insertions(+), 45 deletions(-)
 
 diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 4637dd5d5d..333b1d93b6 100644
+index 77f96e87a1..4cf1170ffb 100644
 --- a/include/configs/corstone1000.h
 +++ b/include/configs/corstone1000.h
 @@ -22,7 +22,7 @@
@@ -34,10 +34,10 @@
  #define PREP_SEPROXY_SVC_ID_MASK	GENMASK(31, 16)
  #define PREP_SEPROXY_SVC_ID(x)	 (FIELD_PREP(PREP_SEPROXY_SVC_ID_MASK, (x)))
 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
-index de815484d2..cede7826bd 100644
+index 88f2d050be..1099ccc800 100644
 --- a/lib/efi_loader/efi_boottime.c
 +++ b/lib/efi_loader/efi_boottime.c
-@@ -27,11 +27,6 @@
+@@ -30,11 +30,6 @@
  #include <arm_ffa.h>
  #endif
  
@@ -49,7 +49,7 @@
  DECLARE_GLOBAL_DATA_PTR;
  
  /* Task priority level */
-@@ -2100,35 +2095,6 @@ static void efi_exit_caches(void)
+@@ -2108,35 +2103,6 @@ static void efi_exit_caches(void)
  #endif
  }
  
@@ -77,7 +77,7 @@
 -	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
 -		PREP_SEPROXY_EVT(CORSTONE1000_KERNEL_STARTED_EVT); /* w4 */
 -
--	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
+-	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
 -}
 -
 -#endif
@@ -85,7 +85,7 @@
  /**
   * efi_exit_boot_services() - stop all boot services
   * @image_handle: handle of the loaded image
-@@ -2244,15 +2210,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
+@@ -2243,15 +2209,6 @@ static efi_status_t EFIAPI efi_exit_boot_services(efi_handle_t image_handle,
  	/* Recalculate CRC32 */
  	efi_update_table_header_crc32(&systab.hdr);
  
@@ -115,7 +115,7 @@
  	}
  
 diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
-index bfd4687e10..6c9e14c37e 100644
+index 443f409906..c154eb0e9d 100644
 --- a/lib/efi_loader/efi_setup.c
 +++ b/lib/efi_loader/efi_setup.c
 @@ -17,6 +17,9 @@
@@ -156,7 +156,7 @@
 +	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
 +			PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */
 +
-+	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
++	return ffa_bus_ops_get()->sync_send_receive(NULL, CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
 +}
 +#endif
 +
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_loader-fix-null-pointer-exception-with-get_image.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_loader-fix-null-pointer-exception-with-get_image.patch
similarity index 94%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_loader-fix-null-pointer-exception-with-get_image.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_loader-fix-null-pointer-exception-with-get_image.patch
index dc9063a..e9bf495 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_loader-fix-null-pointer-exception-with-get_image.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0019-efi_loader-fix-null-pointer-exception-with-get_image.patch
@@ -1,7 +1,7 @@
-From 456e616401b02a579e9ea5ec3e5ab1d1c884b389 Mon Sep 17 00:00:00 2001
+From 28e7a47c7021b7d321bb6e4dbe1bd7d2ceb8aa6d Mon Sep 17 00:00:00 2001
 From: Vishnu Banavath <vishnu.banavath@arm.com>
 Date: Fri, 14 Jan 2022 15:24:18 +0000
-Subject: [PATCH 25/26] efi_loader: fix null pointer exception with
+Subject: [PATCH 19/25] efi_loader: fix null pointer exception with
  get_image_info
 
 get_img_info API implemented for corstone1000 target does not
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-arm-corstone1000-add-mmc-for-fvp.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-arm-corstone1000-add-mmc-for-fvp.patch
new file mode 100644
index 0000000..8743259
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0020-arm-corstone1000-add-mmc-for-fvp.patch
@@ -0,0 +1,99 @@
+From d662633cb8e90144969790b8abf047a3f777e47a Mon Sep 17 00:00:00 2001
+From: Rui Miguel Silva <rui.silva@linaro.org>
+Date: Wed, 30 Nov 2022 15:37:22 +0000
+Subject: [PATCH 20/25] arm:corstone1000: add mmc for fvp
+
+Enable support mmc/sdcard for the corstone1000 FVP.
+
+Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
+Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ board/armltd/corstone1000/corstone1000.c | 28 +++++++++++++++++++-----
+ configs/corstone1000_defconfig           |  8 ++++++-
+ include/configs/corstone1000.h           |  4 +++-
+ 3 files changed, 32 insertions(+), 8 deletions(-)
+
+diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
+index 76816f8f4e..d6ca6e8961 100644
+--- a/board/armltd/corstone1000/corstone1000.c
++++ b/board/armltd/corstone1000/corstone1000.c
+@@ -38,19 +38,35 @@ static struct mm_region corstone1000_mem_map[] = {
+ 	}, {
+ 		/* USB */
+ 		.virt = 0x40200000UL,
+-		.phys = 0x40200000UL,
++			.phys = 0x40200000UL,
++			.size = 0x00100000UL,
++			.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
++				PTE_BLOCK_NON_SHARE |
++				PTE_BLOCK_PXN | PTE_BLOCK_UXN
++	}, {
++		/* MMC0 */
++		.virt = 0x40300000UL,
++		.phys = 0x40300000UL,
+ 		.size = 0x00100000UL,
+ 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+-			PTE_BLOCK_NON_SHARE |
+-			PTE_BLOCK_PXN | PTE_BLOCK_UXN
++				 PTE_BLOCK_NON_SHARE |
++				 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ 	}, {
+ 		/* ethernet */
+ 		.virt = 0x40100000UL,
+-		.phys = 0x40100000UL,
++			.phys = 0x40100000UL,
++			.size = 0x00100000UL,
++			.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
++				PTE_BLOCK_NON_SHARE |
++				PTE_BLOCK_PXN | PTE_BLOCK_UXN
++	}, {
++		/* MMC1 */
++		.virt = 0x50000000UL,
++		.phys = 0x50000000UL,
+ 		.size = 0x00100000UL,
+ 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+-			PTE_BLOCK_NON_SHARE |
+-			PTE_BLOCK_PXN | PTE_BLOCK_UXN
++				 PTE_BLOCK_NON_SHARE |
++				 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ 	}, {
+ 		/* OCVM */
+ 		.virt = 0x80000000UL,
+diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
+index c72d027711..336da67a8d 100644
+--- a/configs/corstone1000_defconfig
++++ b/configs/corstone1000_defconfig
+@@ -40,7 +40,13 @@ CONFIG_VERSION_VARIABLE=y
+ CONFIG_NET_RANDOM_ETHADDR=y
+ CONFIG_REGMAP=y
+ CONFIG_MISC=y
+-# CONFIG_MMC is not set
++CONFIG_CLK=y
++CONFIG_CMD_MMC=y
++CONFIG_DM_MMC=y
++CONFIG_ARM_PL180_MMCI=y
++CONFIG_MMC_SDHCI_ADMA_HELPERS=y
++CONFIG_MMC_WRITE=y
++CONFIG_DM_GPIO=y
+ CONFIG_PHYLIB=y
+ CONFIG_PHY_SMSC=y
+ CONFIG_SMC911X=y
+diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
+index 4cf1170ffb..1f28a0f6c0 100644
+--- a/include/configs/corstone1000.h
++++ b/include/configs/corstone1000.h
+@@ -58,7 +58,9 @@
+ #define CONFIG_SYS_SDRAM_BASE	PHYS_SDRAM_1
+ 
+ #define BOOT_TARGET_DEVICES(func) \
+-	func(USB, usb, 0)
++	func(USB, usb, 0) \
++	func(MMC, mmc, 0) \
++	func(MMC, mmc, 1)
+ 
+ #include <config_distro_bootcmd.h>
+ 
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-corstone1000-add-compressed-kernel-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-corstone1000-add-compressed-kernel-support.patch
new file mode 100644
index 0000000..d237523
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0021-corstone1000-add-compressed-kernel-support.patch
@@ -0,0 +1,33 @@
+From 37ee9a07d168b43bde17b2ce3dbf637905af5bf2 Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@arm.com>
+Date: Wed, 30 Nov 2022 18:59:59 +0000
+Subject: [PATCH 21/25] corstone1000: add compressed kernel support
+
+The corstone1000 kernel has become too large to fit in the available
+storage.  Swtiching to a compressed kernel avoids the problem, but
+requires uncompressing it.  Add this decompression to the default boot
+instructions.
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ configs/corstone1000_defconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
+index 336da67a8d..eeb207aa5f 100644
+--- a/configs/corstone1000_defconfig
++++ b/configs/corstone1000_defconfig
+@@ -15,7 +15,7 @@ CONFIG_FIT=y
+ CONFIG_BOOTDELAY=3
+ CONFIG_USE_BOOTARGS=y
+ CONFIG_BOOTARGS="console=ttyAMA0 loglevel=9 ip=dhcp earlyprintk"
+-CONFIG_BOOTCOMMAND="run retrieve_kernel_load_addr; echo Loading kernel from $kernel_addr to memory ... ; loadm $kernel_addr $kernel_addr_r 0xc00000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;"
++CONFIG_BOOTCOMMAND="run retrieve_kernel_load_addr; echo Loading kernel from $kernel_addr to memory ... ; unzip $kernel_addr 0x90000000; loadm 0x90000000 $kernel_addr_r 0xf00000; usb start; usb reset; run distro_bootcmd; bootefi $kernel_addr_r $fdtcontroladdr;"
+ CONFIG_CONSOLE_RECORD=y
+ CONFIG_LOGLEVEL=7
+ # CONFIG_DISPLAY_CPUINFO is not set
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-Introduce-external-sys-driver-to-device-tree.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-Introduce-external-sys-driver-to-device-tree.patch
similarity index 74%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-Introduce-external-sys-driver-to-device-tree.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-Introduce-external-sys-driver-to-device-tree.patch
index bd9a6cf..91af426 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0028-Introduce-external-sys-driver-to-device-tree.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0022-Introduce-external-sys-driver-to-device-tree.patch
@@ -1,7 +1,7 @@
-From 83f16fe96a86b00f7a4b7c4c4f7416119b80eddd Mon Sep 17 00:00:00 2001
+From a3fae205de2fd6d2abdb8afca6475267c16e9e29 Mon Sep 17 00:00:00 2001
 From: Emekcan <emekcan.aras@arm.com>
-Date: Fri, 19 Aug 2022 16:04:48 +0100
-Subject: [PATCH] Introduce external sys driver to device-tree
+Date: Wed, 30 Nov 2022 19:02:26 +0000
+Subject: [PATCH 22/25] Introduce external sys driver to device-tree
 
 It adds external sys driver binding to u-boot
 device tree.
@@ -13,10 +13,10 @@
  1 file changed, 7 insertions(+)
 
 diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
-index d0194aa893..19b6e3ea72 100644
+index 4e46826f88..2c7185e139 100644
 --- a/arch/arm/dts/corstone1000.dtsi
 +++ b/arch/arm/dts/corstone1000.dtsi
-@@ -160,6 +160,13 @@
+@@ -160,5 +160,12 @@
  			secure-status = "okay";     /* secure-world-only */
  			status = "disabled";
  		};
@@ -28,8 +28,7 @@
 +			reg-names = "rstreg", "streg";
 +		};
  	};
- 
- 	arm_ffa: arm_ffa {
+ };
 -- 
 2.17.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch
similarity index 92%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch
index 57bdef4..04cbf76 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch
@@ -1,7 +1,7 @@
-From a1b8b91a43cfa9dbaa2d907a6d9629da6f93fa3e Mon Sep 17 00:00:00 2001
+From 55e2bc835be50b23ef04066b950bbe75c0065d19 Mon Sep 17 00:00:00 2001
 From: Emekcan <emekcan.aras@arm.com>
 Date: Mon, 12 Sep 2022 15:47:06 +0100
-Subject: [PATCH] Add mhu and rpmsg client to u-boot device tree
+Subject: [PATCH 23/25] Add mhu and rpmsg client to u-boot device tree
 
 Adds external system controller and mhu driver to u-boot
 device tree. This enables communication between host and
@@ -10,11 +10,11 @@
 Signed-off-by: Emekcan Aras <Emekcan.Aras@arm.com>
 Upstream-Status: Pending [Not submitted to upstream yet]
 ---
- arch/arm/dts/corstone1000.dtsi | 50 ++++++++++++++++++++++++++++++++
+ arch/arm/dts/corstone1000.dtsi | 50 ++++++++++++++++++++++++++++++++++
  1 file changed, 50 insertions(+)
 
 diff --git a/arch/arm/dts/corstone1000.dtsi b/arch/arm/dts/corstone1000.dtsi
-index 19b6e3ea72..61dd6c432c 100644
+index 2c7185e139..61e0c33247 100644
 --- a/arch/arm/dts/corstone1000.dtsi
 +++ b/arch/arm/dts/corstone1000.dtsi
 @@ -161,6 +161,56 @@
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-arm-corstone1000-esrt-support.patch
similarity index 92%
rename from meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch
rename to meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-arm-corstone1000-esrt-support.patch
index 2db5c2a..160ff8a 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0030-arm-corstone1000-esrt-support.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0024-arm-corstone1000-esrt-support.patch
@@ -1,7 +1,7 @@
-From d8fca6ebd5917df9a12dbf1da6a97f99af06eee9 Mon Sep 17 00:00:00 2001
+From 475f787ba7351282ca3ce0fcf9badc01821cd8a3 Mon Sep 17 00:00:00 2001
 From: Satish Kumar <satish.kumar01@arm.com>
-Date: Fri, 19 Aug 2022 09:18:33 +0100
-Subject: [PATCH] arm/corstone1000: esrt support
+Date: Wed, 30 Nov 2022 19:11:43 +0000
+Subject: [PATCH 24/25] arm/corstone1000: esrt support
 
 The implementation is platform specific and would require
 change in future.
@@ -15,14 +15,14 @@
 ---
  include/efi_api.h             |   2 +-
  lib/efi_loader/efi_firmware.c | 133 ++++++++++++++++++++++++++++++++++
- lib/efi_loader/efi_setup.c    |  16 ++--
- 3 files changed, 142 insertions(+), 9 deletions(-)
+ lib/efi_loader/efi_setup.c    |  17 +++--
+ 3 files changed, 143 insertions(+), 9 deletions(-)
 
 diff --git a/include/efi_api.h b/include/efi_api.h
-index 83c01085fd..26899afd01 100644
+index 9bb0d44ac8..fcf2643e14 100644
 --- a/include/efi_api.h
 +++ b/include/efi_api.h
-@@ -2014,7 +2014,7 @@ struct efi_firmware_image_descriptor {
+@@ -2030,7 +2030,7 @@ struct efi_firmware_image_descriptor {
  	u32 last_attempt_status;
  	u64 hardware_instance;
  	efi_firmware_image_dep_t *dependencies;
@@ -185,13 +185,14 @@
  	.set_image = efi_firmware_fit_set_image,
  	.check_image = efi_firmware_check_image_unsupported,
 diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
-index 6c9e14c37e..6ccda175ff 100644
+index c154eb0e9d..63329bbff8 100644
 --- a/lib/efi_loader/efi_setup.c
 +++ b/lib/efi_loader/efi_setup.c
-@@ -168,13 +168,6 @@ static efi_status_t efi_init_capsule(void)
+@@ -167,14 +167,6 @@ static efi_status_t efi_init_capsule(void)
+ 	efi_status_t ret = EFI_SUCCESS;
  
  #if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
- 	int ffa_ret;
+-	int ffa_ret;
 -
 -	ffa_ret = efi_corstone1000_uboot_efi_started_event();
 -	if (ffa_ret)
@@ -202,11 +203,10 @@
  	ret = efi_corstone1000_alloc_capsule_shared_buf();
  	if (ret != EFI_SUCCESS) {
  		printf("EFI: Corstone-1000: cannot allocate caspsule shared buffer\n");
-@@ -306,7 +299,14 @@ efi_status_t efi_init_obj_list(void)
- 		if (ret != EFI_SUCCESS)
- 			goto out;
- 	}
--
+@@ -308,6 +300,15 @@ efi_status_t efi_init_obj_list(void)
+ 	if (ret != EFI_SUCCESS)
+ 		goto out;
+ 
 +#if IS_ENABLED(CONFIG_TARGET_CORSTONE1000)
 +		int ffa_ret;
 +		ffa_ret = efi_corstone1000_uboot_efi_started_event();
@@ -215,9 +215,10 @@
 +		else
 +			debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
 +#endif
++
  	/* Initialize variable services */
  	ret = efi_init_variables();
  	if (ret != EFI_SUCCESS)
 -- 
-2.25.1
+2.17.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch
new file mode 100644
index 0000000..6c17786
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch
@@ -0,0 +1,50 @@
+From de5994cda7a35317f12dc1cedb28cae1b932283a Mon Sep 17 00:00:00 2001
+From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Date: Wed, 30 Nov 2022 19:14:52 +0000
+Subject: [PATCH 25/25] efi_setup: discover FF-A bus before raising EFI started
+ event
+
+add FF-A discovery to efi_corstone1000_uboot_efi_started_event()
+
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ lib/efi_loader/efi_setup.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
+index 63329bbff8..cf8abe3af0 100644
+--- a/lib/efi_loader/efi_setup.c
++++ b/lib/efi_loader/efi_setup.c
+@@ -142,9 +142,16 @@ static efi_status_t efi_init_secure_boot(void)
+ static int efi_corstone1000_uboot_efi_started_event(void)
+ {
+ 	struct ffa_send_direct_data msg = {0};
++	int ret;
+ 
+ 	log_debug("[%s]\n", __func__);
+ 
++	ret = ffa_bus_discover(NULL);
++	if (ret != 0) {
++		log_err("failure to discover FF-A bus\n");
++		return ret;
++	}
++
+ 	/*
+ 	 * setting the kernel started  event arguments:
+ 	 * setting capsule update interface ID(31:16)
+@@ -304,9 +311,9 @@ efi_status_t efi_init_obj_list(void)
+ 		int ffa_ret;
+ 		ffa_ret = efi_corstone1000_uboot_efi_started_event();
+ 		if (ffa_ret)
+-			debug("[efi_boottime][ERROR]: Failure to notify SE Proxy FW update service\n");
++			log_err("Failure to notify SE Proxy FW update service\n");
+ 		else
+-			debug("[efi_boottime][INFO]: SE Proxy FW update service notified\n");
++			debug("SE Proxy FW update service notified\n");
+ #endif
+ 
+ 	/* Initialize variable services */
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-arm-corstone1000-add-mmc-for-fvp.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-arm-corstone1000-add-mmc-for-fvp.patch
deleted file mode 100644
index d4bf652..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-arm-corstone1000-add-mmc-for-fvp.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-From 5e4c819c7ab0841429016c098106615b33486c8b Mon Sep 17 00:00:00 2001
-From: Rui Miguel Silva <rui.silva@linaro.org>
-Date: Tue, 5 Apr 2022 10:24:38 +0100
-Subject: [PATCH 26/26] arm:corstone1000: add mmc for fvp
-
-Enable support mmc/sdcard for the corstone1000 FVP.
-
-Signed-off-by: Vishnu Banavath <vishnu.banavath@arm.com>
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-Upstream-Status: Pending [Not submitted to upstream yet]
----
- arch/arm/dts/corstone1000-fvp.dts        | 28 +++++++++++++++
- board/armltd/corstone1000/corstone1000.c | 46 ++++++++++++++++--------
- configs/corstone1000_defconfig           |  8 ++++-
- include/configs/corstone1000.h           |  4 ++-
- 4 files changed, 69 insertions(+), 17 deletions(-)
-
-diff --git a/arch/arm/dts/corstone1000-fvp.dts b/arch/arm/dts/corstone1000-fvp.dts
-index 1fcc137a49..26b0f1b3ce 100644
---- a/arch/arm/dts/corstone1000-fvp.dts
-+++ b/arch/arm/dts/corstone1000-fvp.dts
-@@ -20,4 +20,32 @@
- 		interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
- 		reg-io-width = <2>;
- 	};
-+
-+	vmmc_v3_3d: fixed_v3_3d {
-+		compatible = "regulator-fixed";
-+		regulator-name = "vmmc_supply";
-+		regulator-min-microvolt = <3300000>;
-+		regulator-max-microvolt = <3300000>;
-+		regulator-always-on;
-+	};
-+
-+	sdmmc0: mmc@40300000 {
-+		compatible = "arm,pl18x", "arm,primecell";
-+		reg = <0x40300000 0x1000>;
-+		interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
-+		max-frequency = <12000000>;
-+		vmmc-supply = <&vmmc_v3_3d>;
-+		clocks = <&smbclk>, <&refclk100mhz>;
-+		clock-names = "smclk", "apb_pclk";
-+	};
-+
-+	sdmmc1: mmc@50000000 {
-+		compatible = "arm,pl18x", "arm,primecell";
-+		reg = <0x50000000 0x10000>;
-+		interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
-+		max-frequency = <12000000>;
-+		vmmc-supply = <&vmmc_v3_3d>;
-+		clocks = <&smbclk>, <&refclk100mhz>;
-+		clock-names = "smclk", "apb_pclk";
-+	};
- };
-diff --git a/board/armltd/corstone1000/corstone1000.c b/board/armltd/corstone1000/corstone1000.c
-index 2fa485ff37..3d537d7a90 100644
---- a/board/armltd/corstone1000/corstone1000.c
-+++ b/board/armltd/corstone1000/corstone1000.c
-@@ -46,22 +46,38 @@ static struct mm_region corstone1000_mem_map[] = {
- 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
- 			 PTE_BLOCK_NON_SHARE |
- 			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
--        }, {
--                /* USB */
--                .virt = 0x40200000UL,
--                .phys = 0x40200000UL,
--                .size = 0x00100000UL,
--                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
--                         PTE_BLOCK_NON_SHARE |
--                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
- 	}, {
--                 /* ethernet */
--                .virt = 0x40100000UL,
--                .phys = 0x40100000UL,
--                .size = 0x00100000UL,
--                .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
--                         PTE_BLOCK_NON_SHARE |
--                         PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+		/* USB */
-+		.virt = 0x40200000UL,
-+			.phys = 0x40200000UL,
-+			.size = 0x00100000UL,
-+			.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+				PTE_BLOCK_NON_SHARE |
-+				PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+	}, {
-+		/* MMC0 */
-+		.virt = 0x40300000UL,
-+		.phys = 0x40300000UL,
-+		.size = 0x00100000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+				 PTE_BLOCK_NON_SHARE |
-+				 PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+	}, {
-+		/* ethernet */
-+		.virt = 0x40100000UL,
-+			.phys = 0x40100000UL,
-+			.size = 0x00100000UL,
-+			.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+				PTE_BLOCK_NON_SHARE |
-+				PTE_BLOCK_PXN | PTE_BLOCK_UXN
-+	}, {
-+		/* MMC1 */
-+		.virt = 0x50000000UL,
-+		.phys = 0x50000000UL,
-+		.size = 0x00100000UL,
-+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-+				 PTE_BLOCK_NON_SHARE |
-+				 PTE_BLOCK_PXN | PTE_BLOCK_UXN
- 	}, {
- 		/* OCVM */
- 		.virt = 0x80000000UL,
-diff --git a/configs/corstone1000_defconfig b/configs/corstone1000_defconfig
-index c299dda49f..76e07fc20c 100644
---- a/configs/corstone1000_defconfig
-+++ b/configs/corstone1000_defconfig
-@@ -38,7 +38,13 @@ CONFIG_CMD_EFIDEBUG=y
- CONFIG_CMD_FAT=y
- CONFIG_OF_CONTROL=y
- CONFIG_REGMAP=y
--# CONFIG_MMC is not set
-+CONFIG_CLK=y
-+CONFIG_CMD_MMC=y
-+CONFIG_DM_MMC=y
-+CONFIG_ARM_PL180_MMCI=y
-+CONFIG_MMC_SDHCI_ADMA_HELPERS=y
-+CONFIG_MMC_WRITE=y
-+CONFIG_DM_GPIO=y
- CONFIG_DM_SERIAL=y
- CONFIG_USB=y
- CONFIG_DM_USB=y
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 333b1d93b6..815239590e 100644
---- a/include/configs/corstone1000.h
-+++ b/include/configs/corstone1000.h
-@@ -89,7 +89,9 @@
- #define CONFIG_SYS_MAXARGS	64	/* max command args */
- 
- #define BOOT_TARGET_DEVICES(func) \
--	func(USB, usb, 0)
-+	func(USB, usb, 0) \
-+	func(MMC, mmc, 0) \
-+	func(MMC, mmc, 1)
- 
- #include <config_distro_bootcmd.h>
- 
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-enable-distro-booting-command.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-enable-distro-booting-command.patch
new file mode 100644
index 0000000..a88180d
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0026-corstone1000-enable-distro-booting-command.patch
@@ -0,0 +1,27 @@
+From 15778524604652db60f704a772b6815d0f4305bf Mon Sep 17 00:00:00 2001
+From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Date: Mon, 5 Dec 2022 17:02:32 +0000
+Subject: [PATCH] corstone1000: enable distro booting command
+
+enable distro_bootcmd
+
+Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
+Upstream-Status: Pending [Not submitted to upstream yet]
+---
+ include/configs/corstone1000.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
+index 1f28a0f6c0..548856b970 100644
+--- a/include/configs/corstone1000.h
++++ b/include/configs/corstone1000.h
+@@ -64,5 +64,6 @@
+ 
+ #include <config_distro_bootcmd.h>
+ 
++#define CONFIG_EXTRA_ENV_SETTINGS BOOTENV
+ 
+ #endif
+-- 
+2.17.1
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-corstone1000-use-a-compressed-kernel.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-corstone1000-use-a-compressed-kernel.patch
deleted file mode 100644
index 59000cd..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0027-corstone1000-use-a-compressed-kernel.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 26c8a8528b794dbaba49bcf3e1bae8a1e15a8448 Mon Sep 17 00:00:00 2001
-From: Jon Mason <jon.mason@arm.com>
-Date: Thu, 25 Aug 2022 11:21:28 +0100
-Subject: [PATCH] corstone1000: add compressed kernel support
-
-The corstone1000 kernel has become too large to fit in the available
-storage.  Swtiching to a compressed kernel avoids the problem, but
-requires uncompressing it.  Add this decompression to the default boot
-instructions.
-
-Signed-off-by: Jon Mason <jon.mason@arm.com>
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Pending [Not submitted to upstream yet]
----
- include/configs/corstone1000.h | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/include/configs/corstone1000.h b/include/configs/corstone1000.h
-index 815239590e..a8aa105fe6 100644
---- a/include/configs/corstone1000.h
-+++ b/include/configs/corstone1000.h
-@@ -120,7 +120,8 @@
- #define CONFIG_BOOTCOMMAND								\
- 				"run retrieve_kernel_load_addr;"			\
- 				"echo Loading kernel from $kernel_addr to memory ... ;"	\
--				"loadm $kernel_addr $kernel_addr_r 0xc00000;"		\
-+				"unzip $kernel_addr 0x90000000;"	\
-+				"loadm 0x90000000 $kernel_addr_r 0xf00000;"		\
- 				"usb start; usb reset;"					\
- 				"run distro_bootcmd;"					\
- 				"bootefi $kernel_addr_r $fdtcontroladdr;"
--- 
-2.17.1
-
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-ffa-add-support-for-32-bit-direct-messaging.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-ffa-add-support-for-32-bit-direct-messaging.patch
deleted file mode 100644
index ac0638e..0000000
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone1000/0031-ffa-add-support-for-32-bit-direct-messaging.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-From 6cb8e5f83d53357fbc6e58c2c5c5a3450654f9e6 Mon Sep 17 00:00:00 2001
-From: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Date: Wed, 19 Oct 2022 17:51:10 +0100
-Subject: [PATCH] arm_ffa: add support for 32-bit direct messaging
-
-add 32-bit mode for FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP
-
-Tested-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com>
-Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
-Upstream-Status: Pending [Not submitted to upstream yet]
----
- cmd/armffa.c                       |  2 +-
- drivers/firmware/arm-ffa/core.c    | 17 ++++++++++++++---
- drivers/firmware/arm-ffa/sandbox.c |  2 +-
- include/arm_ffa.h                  |  2 +-
- lib/efi_loader/efi_capsule.c       |  2 +-
- lib/efi_loader/efi_setup.c         |  2 +-
- lib/efi_loader/efi_variable_tee.c  |  2 +-
- test/dm/ffa.c                      |  6 +++---
- 8 files changed, 23 insertions(+), 12 deletions(-)
-​
-diff --git a/cmd/armffa.c b/cmd/armffa.c
-index 9b56e8a830..9842b99181 100644
---- a/cmd/armffa.c
-+++ b/cmd/armffa.c
-@@ -129,7 +129,7 @@ int  do_ffa_msg_send_direct_req(struct cmd_tbl *cmdtp, int flag, int argc,
- 		return -EINVAL;
- 	}
- 
--	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
- 	if (ret == 0) {
- 		u8 cnt;
- 
-diff --git a/drivers/firmware/arm-ffa/core.c b/drivers/firmware/arm-ffa/core.c
-index caba10caae..ba1ba59937 100644
---- a/drivers/firmware/arm-ffa/core.c
-+++ b/drivers/firmware/arm-ffa/core.c
-@@ -1032,6 +1032,7 @@ static int ffa_cache_partitions_info(void)
-  * ffa_msg_send_direct_req - FFA_MSG_SEND_DIRECT_{REQ,RESP} handler function
-  * @dst_part_id: destination partition ID
-  * @msg: pointer to the message data preallocated by the client (in/out)
-+ * @is_smc64: select 64-bit or 32-bit FF-A ABI
-  *
-  * This is the runtime function that implements FFA_MSG_SEND_DIRECT_{REQ,RESP}
-  * FF-A functions.
-@@ -1048,10 +1049,12 @@ static int ffa_cache_partitions_info(void)
-  *
-  * 0 on success. Otherwise, failure
-  */
--static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_send_direct_data *msg)
-+static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_send_direct_data *msg,
-+						 u8 is_smc64)
- {
- 	ffa_value_t res = {0};
- 	int ffa_errno;
-+	u64 req_mode, resp_mode;
- 
- 	if (!ffa_priv_data || !ffa_priv_data->invoke_ffa_fn)
- 		return -EINVAL;
-@@ -1060,8 +1063,16 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
- 	if (!ffa_priv_data->partitions.count || !ffa_priv_data->partitions.descs)
- 		return -ENODEV;
- 
-+	if(is_smc64) {
-+		req_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ);
-+		resp_mode = FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP);
-+	} else {
-+		req_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_REQ);
-+		resp_mode = FFA_SMC_32(FFA_MSG_SEND_DIRECT_RESP);
-+	}
-+
- 	ffa_priv_data->invoke_ffa_fn((ffa_value_t){
--			.a0 = FFA_SMC_64(FFA_MSG_SEND_DIRECT_REQ),
-+			.a0 = req_mode,
- 			.a1 = PREP_SELF_ENDPOINT_ID(ffa_priv_data->id) |
- 				PREP_PART_ENDPOINT_ID(dst_part_id),
- 			.a2 = 0,
-@@ -1083,7 +1094,7 @@ static int __ffa_runtime ffa_msg_send_direct_req(u16 dst_part_id, struct ffa_sen
- 		return 0;
- 	}
- 
--	if (res.a0 == FFA_SMC_64(FFA_MSG_SEND_DIRECT_RESP)) {
-+	if (res.a0 == resp_mode){
- 		/*
- 		 * Message sent with response
- 		 * extract the return data
-diff --git a/drivers/firmware/arm-ffa/sandbox.c b/drivers/firmware/arm-ffa/sandbox.c
-index 16e1fdc809..8e8549441d 100644
---- a/drivers/firmware/arm-ffa/sandbox.c
-+++ b/drivers/firmware/arm-ffa/sandbox.c
-@@ -430,7 +430,7 @@ static int sandbox_ffa_sp_valid(u16 part_id)
-  * @{a0-a7} , res: The SMC call arguments and return structure.
-  *
-  * This is the function that emulates FFA_MSG_SEND_DIRECT_{REQ,RESP}
-- * FF-A functions.
-+ * FF-A functions. Only SMC 64-bit is supported in Sandbox.
-  *
-  * Emulating interrupts is not supported. So, FFA_RUN and FFA_INTERRUPT are not supported.
-  * In case of success FFA_MSG_SEND_DIRECT_RESP is returned with default pattern data (0xff).
-diff --git a/include/arm_ffa.h b/include/arm_ffa.h
-index 665413a0c5..4a7c59ff28 100644
---- a/include/arm_ffa.h
-+++ b/include/arm_ffa.h
-@@ -97,7 +97,7 @@ struct __packed ffa_send_direct_data {
- struct ffa_bus_ops {
- 	int (*partition_info_get)(const char *uuid_str,
- 				  u32 *parts_size, struct ffa_partition_info *buffer);
--	int (*sync_send_receive)(u16 dst_part_id, struct ffa_send_direct_data *msg);
-+	int (*sync_send_receive)(u16 dst_part_id, struct ffa_send_direct_data *msg, u8 is_smc64);
- 	int (*rxtx_unmap)(void);
- };
- 
-diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
-index 65e2fc8296..c479c53d04 100644
---- a/lib/efi_loader/efi_capsule.c
-+++ b/lib/efi_loader/efi_capsule.c
-@@ -591,7 +591,7 @@ static int __efi_runtime efi_corstone1000_buffer_ready_event(u32 capsule_image_s
- 	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
- 		PREP_SEPROXY_EVT(CORSTONE1000_BUFFER_READY_EVT); /* w4 */
- 
--	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
-+	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
- }
- #endif
- 
-diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
-index 6ccda175ff..416af8d663 100644
---- a/lib/efi_loader/efi_setup.c
-+++ b/lib/efi_loader/efi_setup.c
-@@ -153,7 +153,7 @@ static int efi_corstone1000_uboot_efi_started_event(void)
- 	msg.data1 = PREP_SEPROXY_SVC_ID(CORSTONE1000_SEPROXY_UPDATE_SVC_ID) |
- 			PREP_SEPROXY_EVT(CORSTONE1000_UBOOT_EFI_STARTED_EVT); /* w4 */
- 
--	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg);
-+	return ffa_bus_ops_get()->sync_send_receive(CORSTONE1000_SEPROXY_PART_ID, &msg, 0);
- }
- #endif
- 
-diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
-index 7d9d577281..05f3c02911 100644
---- a/lib/efi_loader/efi_variable_tee.c
-+++ b/lib/efi_loader/efi_variable_tee.c
-@@ -201,7 +201,7 @@ static int __efi_runtime ffa_notify_mm_sp(void)
- 
- 	msg.data0 = FFA_SHARED_MM_BUFFER_OFFSET; /* x3 */
- 
--	ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg);
-+	ret = ffa_bus_ops_get()->sync_send_receive(mm_sp_id, &msg, 1);
- 	if (ret != 0)
- 		return ret;
- 
-diff --git a/test/dm/ffa.c b/test/dm/ffa.c
-index 052d5fc3f4..14b19cf71e 100644
---- a/test/dm/ffa.c
-+++ b/test/dm/ffa.c
-@@ -170,7 +170,7 @@ static int  test_ffa_msg_send_direct_req(u16 part_id, struct unit_test_state *ut
- 	struct ffa_send_direct_data msg = {0};
- 	u8 cnt;
- 
--	ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg));
-+	ut_assertok(ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1));
- 
- 	for (cnt = 0; cnt < sizeof(struct ffa_send_direct_data) / sizeof(u64); cnt++)
- 		ut_assertok(((u64 *)&msg)[cnt] != 0xffffffffffffffff);
-@@ -380,12 +380,12 @@ static int dm_test_ffa_nack(struct unit_test_state *uts)
- 	ut_assertok(count != SANDBOX_SP_COUNT_PER_VALID_SERVICE);
- 
- 	/* send data to an invalid partition */
--	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
- 	ut_assertok(ret != -EINVAL);
- 
- 	/* send data to a valid partition */
- 	part_id = prvdata->partitions.descs[0].info.id;
--	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg);
-+	ret = ffa_bus_ops_get()->sync_send_receive(part_id, &msg, 1);
- 	ut_assertok(ret != 0);
- 
- 	return CMD_RET_SUCCESS;
--- 
-2.17.1
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch
index 9a29975..2cdafac 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0001-armv7-adding-generic-timer-access-through-MMIO.patch
@@ -1,4 +1,4 @@
-From d75d794785419592ba49046165d19a6ec9488b2d Mon Sep 17 00:00:00 2001
+From 787a802afb8c05fcb5117c1cbb612c51554aad24 Mon Sep 17 00:00:00 2001
 From: Rui Miguel Silva <rui.silva@linaro.org>
 Date: Wed, 18 Dec 2019 21:52:34 +0000
 Subject: [PATCH 1/2] armv7: adding generic timer access through MMIO
@@ -124,10 +124,10 @@
 +	return gd->arch.timer_rate_hz;
 +}
 diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
-index c61df4fb1c9b..cfb1c68b6297 100644
+index f505722f6b04..e0df0026c985 100644
 --- a/scripts/config_whitelist.txt
 +++ b/scripts/config_whitelist.txt
-@@ -1253,6 +1253,7 @@ CONFIG_SYS_MMC_U_BOOT_DST
+@@ -900,6 +900,7 @@ CONFIG_SYS_MMC_U_BOOT_DST
  CONFIG_SYS_MMC_U_BOOT_OFFS
  CONFIG_SYS_MMC_U_BOOT_SIZE
  CONFIG_SYS_MMC_U_BOOT_START
@@ -136,5 +136,5 @@
  CONFIG_SYS_MONITOR_SEC
  CONFIG_SYS_MOR_VAL
 -- 
-2.37.1
+2.38.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0002-board-arm-add-corstone500-board.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0002-board-arm-add-corstone500-board.patch
index c389a64..f76f449 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0002-board-arm-add-corstone500-board.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/corstone500/0002-board-arm-add-corstone500-board.patch
@@ -1,4 +1,4 @@
-From 3566cf4ab79ca78acd69cfb87e74587394e5aeb2 Mon Sep 17 00:00:00 2001
+From 70cf3f7498e98a98b21804f577f3b850018894da Mon Sep 17 00:00:00 2001
 From: Rui Miguel Silva <rui.silva@linaro.org>
 Date: Wed, 8 Jan 2020 09:48:11 +0000
 Subject: [PATCH 2/2] board: arm: add corstone500 board
@@ -11,18 +11,14 @@
 makefile for this system.
 
 Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
-
-%% original patch: 0002-board-arm-add-corstone500-board.patch
-
-Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
 ---
  arch/arm/Kconfig                       |  10 +++
  board/armltd/corstone500/Kconfig       |  12 +++
  board/armltd/corstone500/Makefile      |   8 ++
- board/armltd/corstone500/corstone500.c |  48 +++++++++++
- configs/corstone500_defconfig          |  40 +++++++++
- include/configs/corstone500.h          | 109 +++++++++++++++++++++++++
- 6 files changed, 227 insertions(+)
+ board/armltd/corstone500/corstone500.c |  48 ++++++++++++
+ configs/corstone500_defconfig          |  41 ++++++++++
+ include/configs/corstone500.h          | 102 +++++++++++++++++++++++++
+ 6 files changed, 221 insertions(+)
  create mode 100644 board/armltd/corstone500/Kconfig
  create mode 100644 board/armltd/corstone500/Makefile
  create mode 100644 board/armltd/corstone500/corstone500.c
@@ -30,12 +26,12 @@
  create mode 100644 include/configs/corstone500.h
 
 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
-index 9898c7d68e1b..8c60ed39712e 100644
+index 82cd456f51f1..a925e7759ee8 100644
 --- a/arch/arm/Kconfig
 +++ b/arch/arm/Kconfig
-@@ -718,6 +718,15 @@ config ARCH_BCMSTB
- 	  This enables support for Broadcom ARM-based set-top box
- 	  chipsets, including the 7445 family of chips.
+@@ -1349,6 +1349,15 @@ config TARGET_CORSTONE1000
+ 	select PL01X_SERIAL
+ 	select DM
  
 +config TARGET_CORSTONE500
 +	bool "Support Corstone500"
@@ -46,10 +42,10 @@
 +	  This enables support for Corstone500 ARM which is a
 +	  Cortex-A5 system
 +
- config TARGET_VEXPRESS_CA9X4
- 	bool "Support vexpress_ca9x4"
- 	select CPU_V7A
-@@ -2299,6 +2308,7 @@ source "board/bosch/shc/Kconfig"
+ config TARGET_TOTAL_COMPUTE
+ 	bool "Support Total Compute Platform"
+ 	select ARM64
+@@ -2302,6 +2311,7 @@ source "board/bosch/shc/Kconfig"
  source "board/bosch/guardian/Kconfig"
  source "board/Marvell/octeontx/Kconfig"
  source "board/Marvell/octeontx2/Kconfig"
@@ -145,22 +141,24 @@
 +
 diff --git a/configs/corstone500_defconfig b/configs/corstone500_defconfig
 new file mode 100644
-index 000000000000..d3161a4b40d8
+index 000000000000..e475cbe7e40d
 --- /dev/null
 +++ b/configs/corstone500_defconfig
-@@ -0,0 +1,40 @@
+@@ -0,0 +1,41 @@
 +CONFIG_ARM=y
 +CONFIG_SKIP_LOWLEVEL_INIT=y
 +CONFIG_TARGET_CORSTONE500=y
 +CONFIG_SYS_TEXT_BASE=0x88000000
 +CONFIG_SYS_MALLOC_LEN=0x840000
-+CONFIG_SYS_MALLOC_F_LEN=0x2000
 +CONFIG_NR_DRAM_BANKS=1
-+CONFIG_SYS_MEMTEST_START=0x80000000
-+CONFIG_SYS_MEMTEST_END=0xff000000
 +CONFIG_ENV_SIZE=0x40000
++CONFIG_SYS_PROMPT="corstone500# "
 +CONFIG_IDENT_STRING=" corstone500 aarch32"
 +CONFIG_SYS_LOAD_ADDR=0x90000000
++CONFIG_SYS_MEMTEST_START=0x80000000
++CONFIG_SYS_MEMTEST_END=0xff000000
++CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
++CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x83f00000
 +CONFIG_SUPPORT_RAW_INITRD=y
 +CONFIG_BOOTDELAY=1
 +CONFIG_USE_BOOTARGS=y
@@ -168,7 +166,6 @@
 +# CONFIG_DISPLAY_CPUINFO is not set
 +# CONFIG_DISPLAY_BOARDINFO is not set
 +CONFIG_HUSH_PARSER=y
-+CONFIG_SYS_PROMPT="corstone500# "
 +# CONFIG_CMD_CONSOLE is not set
 +CONFIG_CMD_BOOTZ=y
 +# CONFIG_CMD_XIMG is not set
@@ -191,10 +188,10 @@
 +CONFIG_OF_LIBFDT=y
 diff --git a/include/configs/corstone500.h b/include/configs/corstone500.h
 new file mode 100644
-index 000000000000..93c397d2f515
+index 000000000000..416f5fa4399d
 --- /dev/null
 +++ b/include/configs/corstone500.h
-@@ -0,0 +1,109 @@
+@@ -0,0 +1,102 @@
 +/* SPDX-License-Identifier: GPL-2.0+ */
 +/*
 + * (C) Copyright 2022 ARM Limited
@@ -208,8 +205,6 @@
 +#ifndef __CORSTONE500_H
 +#define __CORSTONE500_H
 +
-+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_SDRAM_BASE + 0x03f00000)
-+
 +/* Generic Timer Definitions */
 +#define CONFIG_SYS_HZ_CLOCK	7500000
 +#define CONFIG_SYS_HZ		1000
@@ -285,12 +280,7 @@
 +				"bootz $kernel_addr $initrd_addr:0x800000 $fdt_addr"
 +
 +/* Monitor Command Prompt */
-+#define CONFIG_SYS_CBSIZE		512     /* Console I/O Buffer Size */
-+#define CONFIG_SYS_MAXARGS		64      /* max command args */
-+
 +#define CONFIG_SYS_FLASH_BASE		0x80000000
-+/* 256 x 256KiB sectors */
-+#define CONFIG_SYS_MAX_FLASH_SECT	256
 +/* Store environment at top of flash */
 +#define CONFIG_ENV_ADDR			0x0a7c0000
 +#define CONFIG_ENV_SECT_SIZE		0x0040000
@@ -305,5 +295,5 @@
 +#define CONFIG_ENV_IS_IN_FLASH		1
 +#endif
 -- 
-2.37.1
+2.38.1
 
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0002-vexpress64-add-MPU-memory-map-for-the-BASER_FVP.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0002-vexpress64-add-MPU-memory-map-for-the-BASER_FVP.patch
index f405457..b8cab45 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0002-vexpress64-add-MPU-memory-map-for-the-BASER_FVP.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0002-vexpress64-add-MPU-memory-map-for-the-BASER_FVP.patch
@@ -1,4 +1,4 @@
-From 80c64d0c035a5cd0cb23c7b01be39f25e15c7193 Mon Sep 17 00:00:00 2001
+From 181f5efb401ffaa5ab0898b07a976796f75e502a Mon Sep 17 00:00:00 2001
 From: Qi Feng <qi.feng@arm.com>
 Date: Tue, 26 Jul 2022 18:13:23 +0800
 Subject: [PATCH 2/9] vexpress64: add MPU memory map for the BASER_FVP
@@ -17,7 +17,7 @@
  1 file changed, 22 insertions(+)
 
 diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
-index 709ebf3fb0..1791cd986f 100644
+index af326dc6f4..2310d18eb7 100644
 --- a/board/armltd/vexpress64/vexpress64.c
 +++ b/board/armltd/vexpress64/vexpress64.c
 @@ -19,6 +19,7 @@
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0003-armv8-Allow-disabling-exception-vectors-on-non-SPL-b.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0003-armv8-Allow-disabling-exception-vectors-on-non-SPL-b.patch
index e6ccc17..caabf80 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0003-armv8-Allow-disabling-exception-vectors-on-non-SPL-b.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0003-armv8-Allow-disabling-exception-vectors-on-non-SPL-b.patch
@@ -1,4 +1,4 @@
-From 61a2df4467c13bbc83bff8a3429e9ebb4b957b56 Mon Sep 17 00:00:00 2001
+From 07cc3e4af3def76d92faf39712d4fd8717b21d2b Mon Sep 17 00:00:00 2001
 From: Peter Hoyes <Peter.Hoyes@arm.com>
 Date: Fri, 10 Dec 2021 11:41:19 +0000
 Subject: [PATCH 3/9] armv8: Allow disabling exception vectors on non-SPL
@@ -27,7 +27,7 @@
  4 files changed, 13 insertions(+), 8 deletions(-)
 
 diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
-index 09f3f50fa2..031faa909c 100644
+index 1305238c9d..dec4be0e30 100644
 --- a/arch/arm/cpu/armv8/Kconfig
 +++ b/arch/arm/cpu/armv8/Kconfig
 @@ -1,8 +1,8 @@
@@ -55,7 +55,7 @@
          bool "Enable multiple CPUs to enter into U-Boot"
  
 diff --git a/arch/arm/cpu/armv8/Makefile b/arch/arm/cpu/armv8/Makefile
-index 85fe0475c8..8b3f695835 100644
+index 2e4bf9e038..001a31cae7 100644
 --- a/arch/arm/cpu/armv8/Makefile
 +++ b/arch/arm/cpu/armv8/Makefile
 @@ -13,10 +13,8 @@ ifndef CONFIG_$(SPL_)SYS_DCACHE_OFF
@@ -94,11 +94,11 @@
  	adr	x0, vectors
  	switch_el x1, 3f, 2f, 1f
 diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
-index a1c5d88717..1d5b7411f0 100644
+index 495eb1dee3..683d983c36 100644
 --- a/configs/vexpress_aemv8r_defconfig
 +++ b/configs/vexpress_aemv8r_defconfig
-@@ -13,3 +13,4 @@ CONFIG_BOOTARGS="console=ttyAMA0 earlycon=pl011,0x9c090000 rootfstype=ext4 root=
- CONFIG_SYS_PROMPT="VExpress64# "
+@@ -16,3 +16,4 @@ CONFIG_SYS_CBSIZE=512
+ CONFIG_SYS_PBSIZE=541
  # CONFIG_MMC is not set
  CONFIG_VIRTIO_MMIO=y
 +CONFIG_ARMV8_EXCEPTION_VECTORS=n
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0004-armv8-ARMV8_SWITCH_TO_EL1-improvements.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0004-armv8-ARMV8_SWITCH_TO_EL1-improvements.patch
index 84f6b4b..81758fc 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0004-armv8-ARMV8_SWITCH_TO_EL1-improvements.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0004-armv8-ARMV8_SWITCH_TO_EL1-improvements.patch
@@ -1,4 +1,4 @@
-From dbc1a218e9837e39cd50dd3c19f603f29a08ddba Mon Sep 17 00:00:00 2001
+From 30405f59881c73946b6b0ffdbf25804f9fbf1585 Mon Sep 17 00:00:00 2001
 From: Peter Hoyes <Peter.Hoyes@arm.com>
 Date: Wed, 14 Jul 2021 12:44:27 +0100
 Subject: [PATCH 4/9] armv8: ARMV8_SWITCH_TO_EL1 improvements
@@ -17,29 +17,11 @@
 Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
 Change-Id: If98478148d6d8d1f732acac5439276700614815f
 ---
- arch/arm/cpu/armv8/Kconfig           |  8 +++++++
  arch/arm/cpu/armv8/exception_level.c | 21 ++++++++++++++--
  arch/arm/lib/bootm.c                 | 36 ++++++++++++++++------------
  configs/vexpress_aemv8r_defconfig    |  1 +
- 4 files changed, 49 insertions(+), 17 deletions(-)
+ 3 files changed, 41 insertions(+), 17 deletions(-)
 
-diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
-index 031faa909c..110adf63b3 100644
---- a/arch/arm/cpu/armv8/Kconfig
-+++ b/arch/arm/cpu/armv8/Kconfig
-@@ -191,4 +191,12 @@ config ARMV8_EA_EL3_FIRST
- 	  Exception handling at all exception levels for External Abort and
- 	  SError interrupt exception are taken in EL3.
- 
-+config ARMV8_SWITCH_TO_EL1
-+	bool "Switch to EL1 before booting the operating system"
-+	default n
-+	help
-+	  Switch to EL1 before booting the operating system, if for example the
-+	  operating system does not support booting at EL2, or you wish to prevent
-+	  any hypervisors from running. Supported for bootm, booti and bootefi.
-+
- endif
 diff --git a/arch/arm/cpu/armv8/exception_level.c b/arch/arm/cpu/armv8/exception_level.c
 index b11936548f..4aad1550f4 100644
 --- a/arch/arm/cpu/armv8/exception_level.c
@@ -84,10 +66,10 @@
  	}
  }
 diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
-index a59a5e6c0e..e2cf2e6ec4 100644
+index 9f086f3b90..b044aeca88 100644
 --- a/arch/arm/lib/bootm.c
 +++ b/arch/arm/lib/bootm.c
-@@ -272,7 +272,6 @@ __weak void update_os_arch_secondary_cores(uint8_t os_arch)
+@@ -270,7 +270,6 @@ __weak void update_os_arch_secondary_cores(uint8_t os_arch)
  {
  }
  
@@ -95,7 +77,7 @@
  static void switch_to_el1(void)
  {
  	if ((IH_ARCH_DEFAULT == IH_ARCH_ARM64) &&
-@@ -287,7 +286,6 @@ static void switch_to_el1(void)
+@@ -285,7 +284,6 @@ static void switch_to_el1(void)
  				    ES_TO_AARCH64);
  }
  #endif
@@ -103,7 +85,7 @@
  
  /* Subcommand: GO */
  static void boot_jump_linux(bootm_headers_t *images, int flag)
-@@ -314,21 +312,29 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
+@@ -312,21 +310,29 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
  
  		update_os_arch_secondary_cores(images->os.arch);
  
@@ -147,10 +129,10 @@
  #else
  	unsigned long machid = gd->bd->bi_arch_number;
 diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
-index 1d5b7411f0..35e5e8a5e1 100644
+index 683d983c36..6044f82b00 100644
 --- a/configs/vexpress_aemv8r_defconfig
 +++ b/configs/vexpress_aemv8r_defconfig
-@@ -14,3 +14,4 @@ CONFIG_SYS_PROMPT="VExpress64# "
+@@ -17,3 +17,4 @@ CONFIG_SYS_PBSIZE=541
  # CONFIG_MMC is not set
  CONFIG_VIRTIO_MMIO=y
  CONFIG_ARMV8_EXCEPTION_VECTORS=n
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0005-armv8-Make-disabling-HVC-configurable-when-switching.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0005-armv8-Make-disabling-HVC-configurable-when-switching.patch
index b546026..f64db3b 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0005-armv8-Make-disabling-HVC-configurable-when-switching.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0005-armv8-Make-disabling-HVC-configurable-when-switching.patch
@@ -1,4 +1,4 @@
-From f75060be04aaed4bb5a07cb40361d694b3775f4a Mon Sep 17 00:00:00 2001
+From a6daca56b77d7f1b26483f10eb33ebdd6e157d3e Mon Sep 17 00:00:00 2001
 From: Peter Hoyes <Peter.Hoyes@arm.com>
 Date: Fri, 10 Dec 2021 16:37:26 +0000
 Subject: [PATCH 5/9] armv8: Make disabling HVC configurable when switching to
@@ -22,12 +22,12 @@
  3 files changed, 18 insertions(+), 2 deletions(-)
 
 diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig
-index 110adf63b3..a821e219d8 100644
+index dec4be0e30..95c03487a2 100644
 --- a/arch/arm/cpu/armv8/Kconfig
 +++ b/arch/arm/cpu/armv8/Kconfig
-@@ -199,4 +199,13 @@ config ARMV8_SWITCH_TO_EL1
- 	  operating system does not support booting at EL2, or you wish to prevent
- 	  any hypervisors from running. Supported for bootm, booti and bootefi.
+@@ -208,4 +208,13 @@ config ARMV8_CE_SHA256
+ 
+ endif
  
 +config ARMV8_DISABLE_HVC
 +	bool "Disable HVC calls before switching to EL1"
@@ -70,10 +70,10 @@
  
  	/* Return to AArch32 Supervisor mode from EL2 */
 diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
-index 35e5e8a5e1..605a724a61 100644
+index 6044f82b00..6226f6b2c1 100644
 --- a/configs/vexpress_aemv8r_defconfig
 +++ b/configs/vexpress_aemv8r_defconfig
-@@ -15,3 +15,4 @@ CONFIG_SYS_PROMPT="VExpress64# "
+@@ -18,3 +18,4 @@ CONFIG_SYS_PBSIZE=541
  CONFIG_VIRTIO_MMIO=y
  CONFIG_ARMV8_EXCEPTION_VECTORS=n
  CONFIG_ARMV8_SWITCH_TO_EL1=y
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0006-vexpress64-Do-not-set-COUNTER_FREQUENCY.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0006-vexpress64-Do-not-set-COUNTER_FREQUENCY.patch
index ca99d0e..ebbc939 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0006-vexpress64-Do-not-set-COUNTER_FREQUENCY.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0006-vexpress64-Do-not-set-COUNTER_FREQUENCY.patch
@@ -1,4 +1,4 @@
-From db7d4cc91ae19d0cbd05c0ff1b9bf6a55ac0d04a Mon Sep 17 00:00:00 2001
+From 862d3f1ac66a75cdf48adbdebd8adbaf671a9366 Mon Sep 17 00:00:00 2001
 From: Qi Feng <qi.feng@arm.com>
 Date: Thu, 28 Jul 2022 17:47:18 +0800
 Subject: [PATCH 6/9] vexpress64: Do not set COUNTER_FREQUENCY
@@ -18,7 +18,7 @@
  1 file changed, 1 deletion(-)
 
 diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
-index 605a724a61..153fa14efc 100644
+index 6226f6b2c1..b902a6a7d9 100644
 --- a/configs/vexpress_aemv8r_defconfig
 +++ b/configs/vexpress_aemv8r_defconfig
 @@ -1,5 +1,4 @@
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0007-vexpress64-Enable-LIBFDT_OVERLAY-in-the-vexpress_aem.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0007-vexpress64-Enable-LIBFDT_OVERLAY-in-the-vexpress_aem.patch
index 467fb40..8c09ed2 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0007-vexpress64-Enable-LIBFDT_OVERLAY-in-the-vexpress_aem.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0007-vexpress64-Enable-LIBFDT_OVERLAY-in-the-vexpress_aem.patch
@@ -1,4 +1,4 @@
-From f4986ed954ffad36abfa27db5520e702cba2531e Mon Sep 17 00:00:00 2001
+From 32beea722c1167c9b33f1ecfdc28d360cabd6823 Mon Sep 17 00:00:00 2001
 From: Peter Hoyes <Peter.Hoyes@arm.com>
 Date: Tue, 22 Feb 2022 15:32:51 +0000
 Subject: [PATCH 7/9] vexpress64: Enable LIBFDT_OVERLAY in the vexpress_aemv8r
@@ -14,10 +14,10 @@
  1 file changed, 1 insertion(+)
 
 diff --git a/configs/vexpress_aemv8r_defconfig b/configs/vexpress_aemv8r_defconfig
-index 153fa14efc..94651768b3 100644
+index b902a6a7d9..a58a9db385 100644
 --- a/configs/vexpress_aemv8r_defconfig
 +++ b/configs/vexpress_aemv8r_defconfig
-@@ -15,3 +15,4 @@ CONFIG_VIRTIO_MMIO=y
+@@ -18,3 +18,4 @@ CONFIG_VIRTIO_MMIO=y
  CONFIG_ARMV8_EXCEPTION_VECTORS=n
  CONFIG_ARMV8_SWITCH_TO_EL1=y
  CONFIG_ARMV8_DISABLE_HVC=n
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0008-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0008-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch
index 4b6daf8..8be14ee 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0008-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/fvp-baser-aemv8r64/0008-armv8-Allow-PRBAR-MPU-attributes-to-be-configured.patch
@@ -1,4 +1,4 @@
-From af05764e7b64e0704291ba2e71138f2345737afa Mon Sep 17 00:00:00 2001
+From 01490ab8deb0f0b61eeb55a02ee5ea430cfe7eee Mon Sep 17 00:00:00 2001
 From: Peter Hoyes <Peter.Hoyes@arm.com>
 Date: Wed, 18 May 2022 15:24:19 +0100
 Subject: [PATCH 8/9] armv8: Allow PRBAR MPU attributes to be configured
@@ -75,7 +75,7 @@
  
  extern struct mpu_region *mpu_mem_map;
 diff --git a/board/armltd/vexpress64/vexpress64.c b/board/armltd/vexpress64/vexpress64.c
-index 1791cd986f..7858521fec 100644
+index 2310d18eb7..531fa4d618 100644
 --- a/board/armltd/vexpress64/vexpress64.c
 +++ b/board/armltd/vexpress64/vexpress64.c
 @@ -42,15 +42,18 @@ static struct mpu_region vexpress64_aemv8r_mem_map[] = {
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/juno/0002-configs-vexpress-modify-to-boot-compressed-initramfs.patch b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/juno/0002-configs-vexpress-modify-to-boot-compressed-initramfs.patch
new file mode 100644
index 0000000..2bf68fe
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot/juno/0002-configs-vexpress-modify-to-boot-compressed-initramfs.patch
@@ -0,0 +1,41 @@
+From 097a43223da4fa42335944295903ede2755e2dfd Mon Sep 17 00:00:00 2001
+From: Jon Mason <jdmason@kudzu.us>
+Date: Mon, 19 Dec 2022 11:36:04 -0500
+Subject: [PATCH] configs: vexpress: modify to boot compressed initramfs
+
+Signed-off-by: Jon Mason <jdmason@kudzu.us>
+Upstream-Status: Inappropriate
+
+---
+ configs/vexpress_aemv8a_juno_defconfig | 1 +
+ include/configs/vexpress_aemv8.h       | 2 ++
+ 2 files changed, 3 insertions(+)
+
+diff --git a/configs/vexpress_aemv8a_juno_defconfig b/configs/vexpress_aemv8a_juno_defconfig
+index e02124cc7f54..6ffe8f5fe67e 100644
+--- a/configs/vexpress_aemv8a_juno_defconfig
++++ b/configs/vexpress_aemv8a_juno_defconfig
+@@ -16,6 +16,7 @@ CONFIG_SYS_LOAD_ADDR=0x90000000
+ CONFIG_BOOTDELAY=1
+ CONFIG_USE_BOOTARGS=y
+ CONFIG_BOOTARGS="console=ttyAMA0,115200n8 root=/dev/sda2 rw rootwait earlycon=pl011,0x7ff80000 debug user_debug=31 androidboot.hardware=juno loglevel=9"
++CONFIG_BOOTCOMMAND="echo running default boot command; afs load ${kernel_name} ${kernel_addr_r} ; if test $? -eq 1; then   echo Loading ${kernel_alt_name} instead of ${kernel_name};   afs load ${kernel_alt_name} ${kernel_addr_r};fi ; afs load  ${fdtfile} ${fdt_addr_r} ; if test $? -eq 1; then   echo Loading ${fdt_alt_name} instead of ${fdtfile};   afs load ${fdt_alt_name} ${fdt_addr_r}; fi ; fdt addr ${fdt_addr_r}; fdt resize; if afs load  ${initrd_name} ${initrd_addr_r} ; then   setenv initrd_param ${initrd_addr_r};   else setenv initrd_param -; fi ; booti ${kernel_addr_r} ${initrd_param} ${fdt_addr_r}"
+ # CONFIG_DISPLAY_CPUINFO is not set
+ # CONFIG_DISPLAY_BOARDINFO is not set
+ CONFIG_SYS_PROMPT="VExpress64# "
+diff --git a/include/configs/vexpress_aemv8.h b/include/configs/vexpress_aemv8.h
+index cd7f6c1b9ba0..c2f5eb302076 100644
+--- a/include/configs/vexpress_aemv8.h
++++ b/include/configs/vexpress_aemv8.h
+@@ -164,6 +164,8 @@
+ 				"kernel_name=norkern\0"	\
+ 				"kernel_alt_name=Image\0"	\
+ 				"kernel_addr_r=0x80080000\0" \
++				"kernel_comp_addr_r=0x90000000\0" \
++				"kernel_comp_size=0x3000000\0" \
+ 				"initrd_name=ramdisk.img\0"	\
+ 				"initrd_addr_r=0x88000000\0"	\
+ 				"fdtfile=board.dtb\0" \
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
index 6144e97..f26ab4a 100644
--- a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_%.bbappend
@@ -18,37 +18,32 @@
 SYSROOT_DIRS:append:corstone1000 = " /boot"
 
 SRC_URI:append:corstone1000 = " \
-        file://0001-cmd-load-add-load-command-for-memory-mapped.patch                 \
-        file://0002-arm-add-support-to-corstone1000-platform.patch		      \
-        file://0003-usb-common-move-urb-code-to-common.patch			      \
-        file://0004-usb-add-isp1760-family-driver.patch				      \
-        file://0005-corstone1000-enable-isp1763-usb-controller.patch		      \
-        file://0006-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch	      \
-        file://0007-arm64-smccc-clear-the-Xn-registers-after-SMC-calls.patch	      \
-        file://0008-lib-uuid-introduce-be_uuid_str_to_le_bin-function.patch	      \
-        file://0009-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch		      \
-        file://0010-arm_ffa-introduce-armffa-command.patch			      \
-        file://0011-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch		      \
-        file://0012-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch	      \
-        file://0013-arm_ffa-introduce-armffa-command-Sandbox-test.patch		      \
-        file://0014-arm_ffa-introduce-FF-A-MM-communication.patch		      \
-        file://0015-arm_ffa-corstone1000-enable-FF-A-and-MM-support.patch	      \
-        file://0016-efi-corstone1000-introduce-EFI-capsule-update.patch		      \
-	file://0017-corstone1000-Update-FFA-shared-buffer-address.patch		      \
-	file://0018-arm-corstone1000-fix-unrecognized-filesystem-type.patch	      \
-	file://0019-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch	      \
-	file://0020-efi_boottime-corstone1000-pass-interface-id-and-kern.patch	      \
-        file://0021-efi_loader-corstone1000-remove-guid-check-from-corst.patch	      \
-        file://0022-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch	      \
-        file://0023-efi_firmware-add-get_image_info-for-corstone1000.patch	      \
-        file://0024-efi_loader-send-bootcomplete-message-to-secure-encla.patch	      \
-        file://0025-efi_loader-fix-null-pointer-exception-with-get_image.patch	      \
-        file://0026-arm-corstone1000-add-mmc-for-fvp.patch			      \
-        file://0027-corstone1000-use-a-compressed-kernel.patch \
-        file://0028-Introduce-external-sys-driver-to-device-tree.patch \
-        file://0029-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch \
-        file://0030-arm-corstone1000-esrt-support.patch \
-        file://0031-ffa-add-support-for-32-bit-direct-messaging.patch  \
+        file://0001-arm64-smccc-add-support-for-SMCCCv1.2-x0-x17-registe.patch          \ 
+        file://0002-lib-uuid-introduce-uuid_str_to_le_bin-function.patch		\ 
+        file://0003-arm_ffa-introduce-Arm-FF-A-low-level-driver.patch			\ 
+        file://0004-arm_ffa-efi-unmap-RX-TX-buffers.patch				\ 
+        file://0005-arm_ffa-introduce-armffa-command.patch				\ 
+        file://0006-arm_ffa-introduce-the-FF-A-Sandbox-driver.patch			\ 
+        file://0007-arm_ffa-introduce-Sandbox-test-cases-for-UCLASS_FFA.patch		\ 
+        file://0008-arm_ffa-introduce-armffa-command-Sandbox-test.patch			\ 
+        file://0009-arm_ffa-efi-introduce-FF-A-MM-communication.patch			\ 
+        file://0010-arm_ffa-efi-corstone1000-enable-MM-communication.patch		\ 
+        file://0011-efi-corstone1000-introduce-EFI-capsule-update.patch			\ 
+        file://0012-arm-corstone1000-fix-unrecognized-filesystem-type.patch		\ 
+        file://0013-efi_capsule-corstone1000-pass-interface-id-and-buffe.patch		\ 
+        file://0014-efi_boottime-corstone1000-pass-interface-id-and-kern.patch		\ 
+        file://0015-efi_loader-corstone1000-remove-guid-check-from-corst.patch		\ 
+        file://0016-efi_loader-populate-ESRT-table-if-EFI_ESRT-config-op.patch		\ 
+        file://0017-efi_firmware-add-get_image_info-for-corstone1000.patch		\ 
+        file://0018-efi_loader-send-bootcomplete-message-to-secure-encla.patch		\ 
+        file://0019-efi_loader-fix-null-pointer-exception-with-get_image.patch		\ 
+        file://0020-arm-corstone1000-add-mmc-for-fvp.patch				\ 
+        file://0021-corstone1000-add-compressed-kernel-support.patch			\ 
+        file://0022-Introduce-external-sys-driver-to-device-tree.patch			\ 
+        file://0023-Add-mhu-and-rpmsg-client-to-u-boot-device-tree.patch		\ 
+        file://0024-arm-corstone1000-esrt-support.patch					\ 
+        file://0025-efi_setup-discover-FF-A-bus-before-raising-EFI-start.patch		\ 
+        file://0026-corstone1000-enable-distro-booting-command.patch                        \
         "
 
 #
@@ -82,7 +77,9 @@
 #
 # Juno Machines
 #
-SRC_URI:append:juno = " file://0001-arm-juno-add-custom-bootcmd-to-autoboot-from-uEnv.tx.patch"
+SRC_URI:append:juno = " file://0001-arm-juno-add-custom-bootcmd-to-autoboot-from-uEnv.tx.patch \
+                        file://0002-configs-vexpress-modify-to-boot-compressed-initramfs.patch \
+                      "
 
 
 #
diff --git a/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2022.10.bb b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2022.10.bb
new file mode 100644
index 0000000..905ae55
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-bsp/u-boot/u-boot_2022.10.bb
@@ -0,0 +1,26 @@
+HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome"
+DESCRIPTION = "U-Boot, a boot loader for Embedded boards based on PowerPC, \
+ARM, MIPS and several other processors, which can be installed in a boot \
+ROM and used to initialize and test the hardware or to download and run \
+application code."
+SECTION = "bootloaders"
+DEPENDS += "flex-native bison-native"
+
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://Licenses/README;md5=2ca5f2c35c8cc335f0a19756634782f1"
+PE = "1"
+
+# We use the revision in order to avoid having to fetch it from the
+# repo during parse
+SRCREV = "4debc57a3da6c3f4d3f89a637e99206f4cea0a96"
+
+SRC_URI = "git://git.denx.de/u-boot.git;branch=master \
+          "
+
+S = "${WORKDIR}/git"
+B = "${WORKDIR}/build"
+do_configure[cleandirs] = "${B}"
+
+require recipes-bsp/u-boot/u-boot.inc
+
+DEPENDS += "bc-native dtc-native gnutls-native"
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0001-arm64-dts-juno-Add-thermal-critical-trip-points.patch b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0001-arm64-dts-juno-Add-thermal-critical-trip-points.patch
new file mode 100644
index 0000000..1c0f25e
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0001-arm64-dts-juno-Add-thermal-critical-trip-points.patch
@@ -0,0 +1,60 @@
+From c4a7b9b587ca1bb4678d48d8be7132492b23a81c Mon Sep 17 00:00:00 2001
+From: Cristian Marussi <cristian.marussi@arm.com>
+Date: Fri, 28 Oct 2022 15:08:33 +0100
+Subject: [PATCH] arm64: dts: juno: Add thermal critical trip points
+
+When thermnal zones are defined, trip points definitions are mandatory.
+Define a couple of critical trip points for monitoring of existing
+PMIC and SOC thermal zones.
+
+This was lost between txt to yaml conversion and was re-enforced recently
+via the commit 8c596324232d ("dt-bindings: thermal: Fix missing required property")
+
+Cc: Rob Herring <robh+dt@kernel.org>
+Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
+Cc: devicetree@vger.kernel.org
+Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
+Fixes: f7b636a8d83c ("arm64: dts: juno: add thermal zones for scpi sensors")
+Link: https://lore.kernel.org/r/20221028140833.280091-8-cristian.marussi@arm.com
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Backport
+---
+ arch/arm64/boot/dts/arm/juno-base.dtsi | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/arm/juno-base.dtsi b/arch/arm64/boot/dts/arm/juno-base.dtsi
+index 2f27619d8abd..8b4d280b1e7e 100644
+--- a/arch/arm64/boot/dts/arm/juno-base.dtsi
++++ b/arch/arm64/boot/dts/arm/juno-base.dtsi
+@@ -751,12 +751,26 @@ pmic {
+ 			polling-delay = <1000>;
+ 			polling-delay-passive = <100>;
+ 			thermal-sensors = <&scpi_sensors0 0>;
++			trips {
++				pmic_crit0: trip0 {
++					temperature = <90000>;
++					hysteresis = <2000>;
++					type = "critical";
++				};
++			};
+ 		};
+ 
+ 		soc {
+ 			polling-delay = <1000>;
+ 			polling-delay-passive = <100>;
+ 			thermal-sensors = <&scpi_sensors0 3>;
++			trips {
++				soc_crit0: trip0 {
++					temperature = <80000>;
++					hysteresis = <2000>;
++					type = "critical";
++				};
++			};
+ 		};
+ 
+ 		big_cluster_thermal_zone: big-cluster {
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0002-arm64-dts-Update-cache-properties-for-Arm-Ltd-platfo.patch b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0002-arm64-dts-Update-cache-properties-for-Arm-Ltd-platfo.patch
new file mode 100644
index 0000000..f19fb8b
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0002-arm64-dts-Update-cache-properties-for-Arm-Ltd-platfo.patch
@@ -0,0 +1,141 @@
+From 59fb813f9742b349f48250bd7793279cafe2752c Mon Sep 17 00:00:00 2001
+From: Pierre Gondois <pierre.gondois@arm.com>
+Date: Mon, 7 Nov 2022 16:56:58 +0100
+Subject: [PATCH] arm64: dts: Update cache properties for Arm Ltd platforms
+
+The DeviceTree Specification v0.3 specifies that the cache node
+"compatible" and "cache-level" properties are required.
+
+Cf. s3.8 Multi-level and Shared Cache Nodes
+The 'cache-unified' property should be present if one of the properties
+for unified cache is present ('cache-size', ...).
+
+Update the relevant device trees nodes accordingly.
+
+Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
+Link: https://lore.kernel.org/r/20221107155825.1644604-6-pierre.gondois@arm.com
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Backport
+---
+ arch/arm64/boot/dts/arm/corstone1000.dtsi            | 1 +
+ arch/arm64/boot/dts/arm/foundation-v8.dtsi           | 1 +
+ arch/arm64/boot/dts/arm/juno-r1.dts                  | 2 ++
+ arch/arm64/boot/dts/arm/juno-r2.dts                  | 2 ++
+ arch/arm64/boot/dts/arm/juno.dts                     | 2 ++
+ arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts           | 1 +
+ arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts | 1 +
+ 7 files changed, 10 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/arm/corstone1000.dtsi b/arch/arm64/boot/dts/arm/corstone1000.dtsi
+index 4e46826f883a..21f1f952e985 100644
+--- a/arch/arm64/boot/dts/arm/corstone1000.dtsi
++++ b/arch/arm64/boot/dts/arm/corstone1000.dtsi
+@@ -53,6 +53,7 @@ gic: interrupt-controller@1c000000 {
+ 
+ 	L2_0: l2-cache0 {
+ 		compatible = "cache";
++		cache-unified;
+ 		cache-level = <2>;
+ 		cache-size = <0x80000>;
+ 		cache-line-size = <64>;
+diff --git a/arch/arm64/boot/dts/arm/foundation-v8.dtsi b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
+index 83e3e7e3984f..c8bd23b1a7ba 100644
+--- a/arch/arm64/boot/dts/arm/foundation-v8.dtsi
++++ b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
+@@ -58,6 +58,7 @@ cpu3: cpu@3 {
+ 
+ 		L2_0: l2-cache0 {
+ 			compatible = "cache";
++			cache-level = <2>;
+ 		};
+ 	};
+ 
+diff --git a/arch/arm64/boot/dts/arm/juno-r1.dts b/arch/arm64/boot/dts/arm/juno-r1.dts
+index 6451c62146fd..1d90eeebb37d 100644
+--- a/arch/arm64/boot/dts/arm/juno-r1.dts
++++ b/arch/arm64/boot/dts/arm/juno-r1.dts
+@@ -189,6 +189,7 @@ A53_3: cpu@103 {
+ 
+ 		A57_L2: l2-cache0 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x200000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <2048>;
+@@ -197,6 +198,7 @@ A57_L2: l2-cache0 {
+ 
+ 		A53_L2: l2-cache1 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x100000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <1024>;
+diff --git a/arch/arm64/boot/dts/arm/juno-r2.dts b/arch/arm64/boot/dts/arm/juno-r2.dts
+index 438cd1ff4bd0..d2ada69b0a43 100644
+--- a/arch/arm64/boot/dts/arm/juno-r2.dts
++++ b/arch/arm64/boot/dts/arm/juno-r2.dts
+@@ -195,6 +195,7 @@ A53_3: cpu@103 {
+ 
+ 		A72_L2: l2-cache0 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x200000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <2048>;
+@@ -203,6 +204,7 @@ A72_L2: l2-cache0 {
+ 
+ 		A53_L2: l2-cache1 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x100000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <1024>;
+diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
+index cf4a58211399..5e48a01a5b9f 100644
+--- a/arch/arm64/boot/dts/arm/juno.dts
++++ b/arch/arm64/boot/dts/arm/juno.dts
+@@ -194,6 +194,7 @@ A53_3: cpu@103 {
+ 
+ 		A57_L2: l2-cache0 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x200000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <2048>;
+@@ -202,6 +203,7 @@ A57_L2: l2-cache0 {
+ 
+ 		A53_L2: l2-cache1 {
+ 			compatible = "cache";
++			cache-unified;
+ 			cache-size = <0x100000>;
+ 			cache-line-size = <64>;
+ 			cache-sets = <1024>;
+diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
+index 258991ad7cc0..ef68f5aae7dd 100644
+--- a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
++++ b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
+@@ -71,6 +71,7 @@ cpu@3 {
+ 
+ 		L2_0: l2-cache0 {
+ 			compatible = "cache";
++			cache-level = <2>;
+ 		};
+ 	};
+ 
+diff --git a/arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts b/arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts
+index 5b6d9d8e934d..796cd7d02eb5 100644
+--- a/arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts
++++ b/arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts
+@@ -57,6 +57,7 @@ cpu@1 {
+ 
+ 		L2_0: l2-cache0 {
+ 			compatible = "cache";
++			cache-level = <2>;
+ 		};
+ 	};
+ 
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0003-arm64-dts-fvp-Add-SPE-to-Foundation-FVP.patch b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0003-arm64-dts-fvp-Add-SPE-to-Foundation-FVP.patch
new file mode 100644
index 0000000..34dd025
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0003-arm64-dts-fvp-Add-SPE-to-Foundation-FVP.patch
@@ -0,0 +1,38 @@
+From 3bd7a0219082c2c91570b81afc35f2aec57cade2 Mon Sep 17 00:00:00 2001
+From: James Clark <james.clark@arm.com>
+Date: Thu, 17 Nov 2022 10:25:36 +0000
+Subject: [PATCH] arm64: dts: fvp: Add SPE to Foundation FVP
+
+Add SPE DT node to FVP model. If the model doesn't support SPE (e.g.,
+turned off via parameter), the driver will skip the initialisation
+accordingly and thus is safe.
+
+Signed-off-by: James Clark <james.clark@arm.com>
+Link: https://lore.kernel.org/r/20221117102536.237515-1-james.clark@arm.com
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Backport
+---
+ arch/arm64/boot/dts/arm/foundation-v8.dtsi | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/arm/foundation-v8.dtsi b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
+index c8bd23b1a7ba..029578072d8f 100644
+--- a/arch/arm64/boot/dts/arm/foundation-v8.dtsi
++++ b/arch/arm64/boot/dts/arm/foundation-v8.dtsi
+@@ -85,6 +85,11 @@ pmu {
+ 			     <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+ 	};
+ 
++	spe-pmu {
++		compatible = "arm,statistical-profiling-extension-v1";
++		interrupts = <GIC_PPI 5 IRQ_TYPE_LEVEL_HIGH>;
++	};
++
+ 	watchdog@2a440000 {
+ 		compatible = "arm,sbsa-gwdt";
+ 		reg = <0x0 0x2a440000 0 0x1000>,
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0004-arm64-dts-fvp-Add-information-about-L1-and-L2-caches.patch b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0004-arm64-dts-fvp-Add-information-about-L1-and-L2-caches.patch
new file mode 100644
index 0000000..72f7161
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0004-arm64-dts-fvp-Add-information-about-L1-and-L2-caches.patch
@@ -0,0 +1,149 @@
+From b2d5025e129289d9b914c696646e64495a7453c0 Mon Sep 17 00:00:00 2001
+From: Sudeep Holla <sudeep.holla@arm.com>
+Date: Fri, 18 Nov 2022 15:10:17 +0000
+Subject: [PATCH] arm64: dts: fvp: Add information about L1 and L2 caches
+
+Add the information about L1 and L2 caches on FVP RevC platform.
+Though the cache size is configurable through the model parameters,
+having default values in the device tree helps to exercise and debug
+any code utilising the cache information without the need of real
+hardware.
+
+Link: https://lore.kernel.org/r/20221118151017.704716-1-sudeep.holla@arm.com
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Backport
+---
+ arch/arm64/boot/dts/arm/fvp-base-revc.dts | 73 +++++++++++++++++++++++
+ 1 file changed, 73 insertions(+)
+
+diff --git a/arch/arm64/boot/dts/arm/fvp-base-revc.dts b/arch/arm64/boot/dts/arm/fvp-base-revc.dts
+index 5f6f30c801a7..60472d65a355 100644
+--- a/arch/arm64/boot/dts/arm/fvp-base-revc.dts
++++ b/arch/arm64/boot/dts/arm/fvp-base-revc.dts
+@@ -47,48 +47,121 @@ cpu0: cpu@0 {
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x000>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C0_L2>;
+ 		};
+ 		cpu1: cpu@100 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x100>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C0_L2>;
+ 		};
+ 		cpu2: cpu@200 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x200>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C0_L2>;
+ 		};
+ 		cpu3: cpu@300 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x300>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C0_L2>;
+ 		};
+ 		cpu4: cpu@10000 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x10000>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C1_L2>;
+ 		};
+ 		cpu5: cpu@10100 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x10100>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C1_L2>;
+ 		};
+ 		cpu6: cpu@10200 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x10200>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C1_L2>;
+ 		};
+ 		cpu7: cpu@10300 {
+ 			device_type = "cpu";
+ 			compatible = "arm,armv8";
+ 			reg = <0x0 0x10300>;
+ 			enable-method = "psci";
++			i-cache-size = <0x8000>;
++			i-cache-line-size = <64>;
++			i-cache-sets = <256>;
++			d-cache-size = <0x8000>;
++			d-cache-line-size = <64>;
++			d-cache-sets = <256>;
++			next-level-cache = <&C1_L2>;
++		};
++		C0_L2: l2-cache0 {
++			compatible = "cache";
++			cache-size = <0x80000>;
++			cache-line-size = <64>;
++			cache-sets = <512>;
++			cache-level = <2>;
++			cache-unified;
++		};
++
++		C1_L2: l2-cache1 {
++			compatible = "cache";
++			cache-size = <0x80000>;
++			cache-line-size = <64>;
++			cache-sets = <512>;
++			cache-level = <2>;
++			cache-unified;
+ 		};
+ 	};
+ 
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0005-ARM-dts-vexpress-align-LED-node-names-with-dtschema.patch b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0005-ARM-dts-vexpress-align-LED-node-names-with-dtschema.patch
new file mode 100644
index 0000000..c551250
--- /dev/null
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/files/juno/0005-ARM-dts-vexpress-align-LED-node-names-with-dtschema.patch
@@ -0,0 +1,84 @@
+From e15031539490733279c41ba87f4ef2b440a685f5 Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Date: Fri, 25 Nov 2022 15:41:12 +0100
+Subject: [PATCH] ARM: dts: vexpress: align LED node names with dtschema
+
+The node names should be generic and DT schema expects certain pattern.
+
+  vexpress-v2p-ca9.dtb: leds: 'user1', 'user2', 'user3', 'user4', 'user5', 'user6', 'user7', 'user8' do not match any of the regexes: '(^led-[0-9a-f]$|led)', 'pinctrl-[0-9]+'
+
+Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
+Link: https://lore.kernel.org/r/20221125144112.476817-1-krzysztof.kozlowski@linaro.org
+Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Backport
+---
+ arch/arm/boot/dts/vexpress-v2m.dtsi | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/arch/arm/boot/dts/vexpress-v2m.dtsi b/arch/arm/boot/dts/vexpress-v2m.dtsi
+index f434fe5cf4a1..def538ce8769 100644
+--- a/arch/arm/boot/dts/vexpress-v2m.dtsi
++++ b/arch/arm/boot/dts/vexpress-v2m.dtsi
+@@ -383,49 +383,49 @@ v2m_refclk32khz: refclk32khz {
+ 			leds {
+ 				compatible = "gpio-leds";
+ 
+-				user1 {
++				led-user1 {
+ 					label = "v2m:green:user1";
+ 					gpios = <&v2m_led_gpios 0 0>;
+ 					linux,default-trigger = "heartbeat";
+ 				};
+ 
+-				user2 {
++				led-user2 {
+ 					label = "v2m:green:user2";
+ 					gpios = <&v2m_led_gpios 1 0>;
+ 					linux,default-trigger = "mmc0";
+ 				};
+ 
+-				user3 {
++				led-user3 {
+ 					label = "v2m:green:user3";
+ 					gpios = <&v2m_led_gpios 2 0>;
+ 					linux,default-trigger = "cpu0";
+ 				};
+ 
+-				user4 {
++				led-user4 {
+ 					label = "v2m:green:user4";
+ 					gpios = <&v2m_led_gpios 3 0>;
+ 					linux,default-trigger = "cpu1";
+ 				};
+ 
+-				user5 {
++				led-user5 {
+ 					label = "v2m:green:user5";
+ 					gpios = <&v2m_led_gpios 4 0>;
+ 					linux,default-trigger = "cpu2";
+ 				};
+ 
+-				user6 {
++				led-user6 {
+ 					label = "v2m:green:user6";
+ 					gpios = <&v2m_led_gpios 5 0>;
+ 					linux,default-trigger = "cpu3";
+ 				};
+ 
+-				user7 {
++				led-user7 {
+ 					label = "v2m:green:user7";
+ 					gpios = <&v2m_led_gpios 6 0>;
+ 					linux,default-trigger = "cpu4";
+ 				};
+ 
+-				user8 {
++				led-user8 {
+ 					label = "v2m:green:user8";
+ 					gpios = <&v2m_led_gpios 7 0>;
+ 					linux,default-trigger = "cpu5";
+-- 
+2.30.2
+
diff --git a/meta-arm/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc b/meta-arm/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
index df90610..4f9bcfd 100644
--- a/meta-arm/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
+++ b/meta-arm/meta-arm-bsp/recipes-kernel/linux/linux-arm-platforms.inc
@@ -100,6 +100,13 @@
 KBUILD_DEFCONFIG:juno = "defconfig"
 KCONFIG_MODE:juno = "--alldefconfig"
 FILESEXTRAPATHS:prepend:juno := "${ARMBSPFILESPATHS}"
+SRC_URI:append:juno = " \
+    file://0001-arm64-dts-juno-Add-thermal-critical-trip-points.patch \
+    file://0002-arm64-dts-Update-cache-properties-for-Arm-Ltd-platfo.patch \
+    file://0003-arm64-dts-fvp-Add-SPE-to-Foundation-FVP.patch \
+    file://0004-arm64-dts-fvp-Add-information-about-L1-and-L2-caches.patch \
+    file://0005-ARM-dts-vexpress-align-LED-node-names-with-dtschema.patch \
+    "
 
 #
 # Musca B1/S2 can't run Linux
diff --git a/meta-arm/meta-arm-toolchain/conf/distro/include/tcmode-external-arm.inc b/meta-arm/meta-arm-toolchain/conf/distro/include/tcmode-external-arm.inc
index 6d21891..71fac59 100644
--- a/meta-arm/meta-arm-toolchain/conf/distro/include/tcmode-external-arm.inc
+++ b/meta-arm/meta-arm-toolchain/conf/distro/include/tcmode-external-arm.inc
@@ -74,7 +74,6 @@
 
     d = e.data
     l = d.createCopy()
-    oe_import(l)
 
     external_toolchain = l.getVar('EXTERNAL_TOOLCHAIN', True)
     if not external_toolchain or external_toolchain == 'UNDEFINED':
diff --git a/meta-arm/meta-arm-toolchain/conf/layer.conf b/meta-arm/meta-arm-toolchain/conf/layer.conf
index bb37cd0..a6f403e 100644
--- a/meta-arm/meta-arm-toolchain/conf/layer.conf
+++ b/meta-arm/meta-arm-toolchain/conf/layer.conf
@@ -9,4 +9,4 @@
 BBFILE_PRIORITY_arm-toolchain = "5"
 
 LAYERDEPENDS_arm-toolchain = "core"
-LAYERSERIES_COMPAT_arm-toolchain = "langdale mickledore"
+LAYERSERIES_COMPAT_arm-toolchain = "mickledore"
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_11.2-2022.02.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.2.rel1.bb
similarity index 64%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_11.2-2022.02.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.2.rel1.bb
index 2a5a4ef..b3b09ba 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_11.2-2022.02.bb
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-aarch64-none-elf_12.2.rel1.bb
@@ -8,16 +8,16 @@
 SUMMARY = "Arm GNU Toolchain - AArch64 bare-metal target (aarch64-none-elf)"
 LICENSE = "GPL-3.0-with-GCC-exception & GPL-3.0-only"
 
-LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=be4f8b5ff7319cd54f6c52db5d6f36b0"
-LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=1f07179249795891179bb3798bac7887"
+LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=0aef214b835259b64f026f4ad00c703e"
+LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=7ba3bc8ef145b48e2756a844db2029a3"
 
 PROVIDES = "virtual/aarch64-none-elf-gcc"
 
-SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}"
-SRC_URI[gcc-aarch64.sha256sum] = "3b15725545a0211a17b63e72d4f10241f7ffbe7ce94cb9612590ceacde16992c"
-SRC_URI[gcc-x86_64.sha256sum] = "b0a015a9e8cbb44ed2fe5ad755a7a7ae254d54f93df3bf47378485b0ba8b828b"
+SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}"
+SRC_URI[gcc-aarch64.sha256sum] = "570a9bd42e2067d79d59b0747891681ebec66f30d989d17a05856563fe38f78b"
+SRC_URI[gcc-x86_64.sha256sum] = "62d66e0ad7bd7f2a183d236ee301a5c73c737c886c7944aa4f39415aab528daf"
 
-S = "${WORKDIR}/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}"
+S = "${WORKDIR}/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}"
 
 UPSTREAM_CHECK_URI = "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads"
 UPSTREAM_CHECK_REGEX = "gcc-arm-(?P<pver>.+)-${HOST_ARCH}-${BINNAME}\.tar\.\w+"
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_11.2-2022.02.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.2.rel1.bb
similarity index 64%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_11.2-2022.02.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.2.rel1.bb
index 26f0ee8..948933b 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_11.2-2022.02.bb
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/external-arm-toolchain/gcc-arm-none-eabi_12.2.rel1.bb
@@ -8,16 +8,16 @@
 SUMMARY = "Arm GNU Toolchain - AArch32 bare-metal target (arm-none-eabi)"
 LICENSE = "GPL-3.0-with-GCC-exception & GPL-3.0-only"
 
-LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=be4f8b5ff7319cd54f6c52db5d6f36b0"
-LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=1f07179249795891179bb3798bac7887"
+LIC_FILES_CHKSUM:aarch64 = "file://share/doc/gcc/Copying.html;md5=0aef214b835259b64f026f4ad00c703e"
+LIC_FILES_CHKSUM:x86-64 = "file://share/doc/gcc/Copying.html;md5=7ba3bc8ef145b48e2756a844db2029a3"
 
 PROVIDES = "virtual/arm-none-eabi-gcc"
 
-SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}"
-SRC_URI[gcc-aarch64.sha256sum] = "ef1d82e5894e3908cb7ed49c5485b5b95deefa32872f79c2b5f6f5447cabf55f"
-SRC_URI[gcc-x86_64.sha256sum] = "8c5acd5ae567c0100245b0556941c237369f210bceb196edfe5a2e7532c60326"
+SRC_URI = "https://developer.arm.com/-/media/Files/downloads/gnu/${PV}/binrel/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}.tar.xz;name=gcc-${HOST_ARCH}"
+SRC_URI[gcc-aarch64.sha256sum] = "7ee332f7558a984e239e768a13aed86c6c3ac85c90b91d27f4ed38d7ec6b3e8c"
+SRC_URI[gcc-x86_64.sha256sum] = "84be93d0f9e96a15addd490b6e237f588c641c8afdf90e7610a628007fc96867"
 
-S = "${WORKDIR}/gcc-arm-${PV}-${HOST_ARCH}-${BINNAME}"
+S = "${WORKDIR}/arm-gnu-toolchain-${PV}-${HOST_ARCH}-${BINNAME}"
 
 UPSTREAM_CHECK_URI = "https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads"
 UPSTREAM_CHECK_REGEX = "${BPN}-(?P<pver>.+)-${HOST_ARCH}-linux\.tar\.\w+"
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-42574.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-42574.patch
deleted file mode 100644
index 4d680cc..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-42574.patch
+++ /dev/null
@@ -1,2282 +0,0 @@
-From bd5e882cf6e0def3dd1bc106075d59a303fe0d1e Mon Sep 17 00:00:00 2001
-From: David Malcolm <dmalcolm@redhat.com>
-Date: Mon, 18 Oct 2021 18:55:31 -0400
-Subject: [PATCH] diagnostics: escape non-ASCII source bytes for certain
- diagnostics
-MIME-Version: 1.0
-Content-Type: text/plain; charset=utf8
-Content-Transfer-Encoding: 8bit
-
-This patch adds support to GCC's diagnostic subsystem for escaping certain
-bytes and Unicode characters when quoting source code.
-
-Specifically, this patch adds a new flag rich_location::m_escape_on_output
-which is a hint from a diagnostic that non-ASCII bytes in the pertinent
-lines of the user's source code should be escaped when printed.
-
-The patch sets this for the following diagnostics:
-- when complaining about stray bytes in the program (when these
-are non-printable)
-- when complaining about "null character(s) ignored");
-- for -Wnormalized= (and generate source ranges for such warnings)
-
-The escaping is controlled by a new option:
-  -fdiagnostics-escape-format=[unicode|bytes]
-
-For example, consider a diagnostic involing a source line containing the
-string "before" followed by the Unicode character U+03C0 ("GREEK SMALL
-LETTER PI", with UTF-8 encoding 0xCF 0x80) followed by the byte 0xBF
-(a stray UTF-8 trailing byte), followed by the string "after", where the
-diagnostic highlights the U+03C0 character.
-
-By default, this line will be printed verbatim to the user when
-reporting a diagnostic at it, as:
-
- beforeÏXafter
-       ^
-
-(using X for the stray byte to avoid putting invalid UTF-8 in this
-commit message)
-
-If the diagnostic sets the "escape" flag, it will be printed as:
-
- before<U+03C0><BF>after
-       ^~~~~~~~
-
-with -fdiagnostics-escape-format=unicode (the default), or as:
-
-  before<CF><80><BF>after
-        ^~~~~~~~
-
-if the user supplies -fdiagnostics-escape-format=bytes.
-
-This only affects how the source is printed; it does not affect
-how column numbers that are printed (as per -fdiagnostics-column-unit=
-and -fdiagnostics-column-origin=).
-
-gcc/c-family/ChangeLog:
-	* c-lex.c (c_lex_with_flags): When complaining about non-printable
-	CPP_OTHER tokens, set the "escape on output" flag.
-
-gcc/ChangeLog:
-	* common.opt (fdiagnostics-escape-format=): New.
-	(diagnostics_escape_format): New enum.
-	(DIAGNOSTICS_ESCAPE_FORMAT_UNICODE): New enum value.
-	(DIAGNOSTICS_ESCAPE_FORMAT_BYTES): Likewise.
-	* diagnostic-format-json.cc (json_end_diagnostic): Add
-	"escape-source" attribute.
-	* diagnostic-show-locus.c
-	(exploc_with_display_col::exploc_with_display_col): Replace
-	"tabstop" param with a cpp_char_column_policy and add an "aspect"
-	param.  Use these to compute m_display_col accordingly.
-	(struct char_display_policy): New struct.
-	(layout::m_policy): New field.
-	(layout::m_escape_on_output): New field.
-	(def_policy): New function.
-	(make_range): Update for changes to exploc_with_display_col ctor.
-	(default_print_decoded_ch): New.
-	(width_per_escaped_byte): New.
-	(escape_as_bytes_width): New.
-	(escape_as_bytes_print): New.
-	(escape_as_unicode_width): New.
-	(escape_as_unicode_print): New.
-	(make_policy): New.
-	(layout::layout): Initialize new fields.  Update m_exploc ctor
-	call for above change to ctor.
-	(layout::maybe_add_location_range): Update for changes to
-	exploc_with_display_col ctor.
-	(layout::calculate_x_offset_display): Update for change to
-	cpp_display_width.
-	(layout::print_source_line): Pass policy
-	to cpp_display_width_computation. Capture cpp_decoded_char when
-	calling process_next_codepoint.  Move printing of source code to
-	m_policy.m_print_cb.
-	(line_label::line_label): Pass in policy rather than context.
-	(layout::print_any_labels): Update for change to line_label ctor.
-	(get_affected_range): Pass in policy rather than context, updating
-	calls to location_compute_display_column accordingly.
-	(get_printed_columns): Likewise, also for cpp_display_width.
-	(correction::correction): Pass in policy rather than tabstop.
-	(correction::compute_display_cols): Pass m_policy rather than
-	m_tabstop to cpp_display_width.
-	(correction::m_tabstop): Replace with...
-	(correction::m_policy): ...this.
-	(line_corrections::line_corrections): Pass in policy rather than
-	context.
-	(line_corrections::m_context): Replace with...
-	(line_corrections::m_policy): ...this.
-	(line_corrections::add_hint): Update to use m_policy rather than
-	m_context.
-	(line_corrections::add_hint): Likewise.
-	(layout::print_trailing_fixits): Likewise.
-	(selftest::test_display_widths): New.
-	(selftest::test_layout_x_offset_display_utf8): Update to use
-	policy rather than tabstop.
-	(selftest::test_one_liner_labels_utf8): Add test of escaping
-	source lines.
-	(selftest::test_diagnostic_show_locus_one_liner_utf8): Update to
-	use policy rather than tabstop.
-	(selftest::test_overlapped_fixit_printing): Likewise.
-	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
-	(selftest::test_overlapped_fixit_printing_2): Likewise.
-	(selftest::test_tab_expansion): Likewise.
-	(selftest::test_escaping_bytes_1): New.
-	(selftest::test_escaping_bytes_2): New.
-	(selftest::diagnostic_show_locus_c_tests): Call the new tests.
-	* diagnostic.c (diagnostic_initialize): Initialize
-	context->escape_format.
-	(convert_column_unit): Update to use default character width policy.
-	(selftest::test_diagnostic_get_location_text): Likewise.
-	* diagnostic.h (enum diagnostics_escape_format): New enum.
-	(diagnostic_context::escape_format): New field.
-	* doc/invoke.texi (-fdiagnostics-escape-format=): New option.
-	(-fdiagnostics-format=): Add "escape-source" attribute to examples
-	of JSON output, and document it.
-	* input.c (location_compute_display_column): Pass in "policy"
-	rather than "tabstop", passing to
-	cpp_byte_column_to_display_column.
-	(selftest::test_cpp_utf8): Update to use cpp_char_column_policy.
-	* input.h (class cpp_char_column_policy): New forward decl.
-	(location_compute_display_column): Pass in "policy" rather than
-	"tabstop".
-	* opts.c (common_handle_option): Handle
-	OPT_fdiagnostics_escape_format_.
-	* selftest.c (temp_source_file::temp_source_file): New ctor
-	overload taking a size_t.
-	* selftest.h (temp_source_file::temp_source_file): Likewise.
-
-gcc/testsuite/ChangeLog:
-	* c-c++-common/diagnostic-format-json-1.c: Add regexp to consume
-	"escape-source" attribute.
-	* c-c++-common/diagnostic-format-json-2.c: Likewise.
-	* c-c++-common/diagnostic-format-json-3.c: Likewise.
-	* c-c++-common/diagnostic-format-json-4.c: Likewise, twice.
-	* c-c++-common/diagnostic-format-json-5.c: Likewise.
-	* gcc.dg/cpp/warn-normalized-4-bytes.c: New test.
-	* gcc.dg/cpp/warn-normalized-4-unicode.c: New test.
-	* gcc.dg/encoding-issues-bytes.c: New test.
-	* gcc.dg/encoding-issues-unicode.c: New test.
-	* gfortran.dg/diagnostic-format-json-1.F90: Add regexp to consume
-	"escape-source" attribute.
-	* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
-	* gfortran.dg/diagnostic-format-json-3.F90: Likewise.
-
-libcpp/ChangeLog:
-	* charset.c (convert_escape): Use encoding_rich_location when
-	complaining about nonprintable unknown escape sequences.
-	(cpp_display_width_computation::::cpp_display_width_computation):
-	Pass in policy rather than tabstop.
-	(cpp_display_width_computation::process_next_codepoint): Add "out"
-	param and populate *out if non-NULL.
-	(cpp_display_width_computation::advance_display_cols): Pass NULL
-	to process_next_codepoint.
-	(cpp_byte_column_to_display_column): Pass in policy rather than
-	tabstop.  Pass NULL to process_next_codepoint.
-	(cpp_display_column_to_byte_column): Pass in policy rather than
-	tabstop.
-	* errors.c (cpp_diagnostic_get_current_location): New function,
-	splitting out the logic from...
-	(cpp_diagnostic): ...here.
-	(cpp_warning_at): New function.
-	(cpp_pedwarning_at): New function.
-	* include/cpplib.h (cpp_warning_at): New decl for rich_location.
-	(cpp_pedwarning_at): Likewise.
-	(struct cpp_decoded_char): New.
-	(struct cpp_char_column_policy): New.
-	(cpp_display_width_computation::cpp_display_width_computation):
-	Replace "tabstop" param with "policy".
-	(cpp_display_width_computation::process_next_codepoint): Add "out"
-	param.
-	(cpp_display_width_computation::m_tabstop): Replace with...
-	(cpp_display_width_computation::m_policy): ...this.
-	(cpp_byte_column_to_display_column): Replace "tabstop" param with
-	"policy".
-	(cpp_display_width): Likewise.
-	(cpp_display_column_to_byte_column): Likewise.
-	* include/line-map.h (rich_location::escape_on_output_p): New.
-	(rich_location::set_escape_on_output): New.
-	(rich_location::m_escape_on_output): New.
-	* internal.h (cpp_diagnostic_get_current_location): New decl.
-	(class encoding_rich_location): New.
-	* lex.c (skip_whitespace): Use encoding_rich_location when
-	complaining about null characters.
-	(warn_about_normalization): Generate a source range when
-	complaining about improperly normalized tokens, rather than just a
-	point, and use encoding_rich_location so that the source code
-	is escaped on printing.
-	* line-map.c (rich_location::rich_location): Initialize
-	m_escape_on_output.
-
-Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-
-CVE: CVE-2021-42574
-Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=bd5e882cf6e0def3dd1bc106075d59a303fe0d1e]
-Signed-off-by: Pgowda <pgowda.cve@gmail.com>
-
----
- gcc/c-family/c-lex.c                          |   6 +-
- gcc/common.opt                                |  13 +
- gcc/diagnostic-format-json.cc                 |   3 +
- gcc/diagnostic-show-locus.c                   | 580 +++++++++++++++---
- gcc/diagnostic.c                              |  10 +-
- gcc/diagnostic.h                              |  18 +
- gcc/doc/invoke.texi                           |  43 +-
- gcc/input.c                                   |  62 +-
- gcc/input.h                                   |   7 +-
- gcc/opts.c                                    |   4 +
- gcc/selftest.c                                |  15 +
- gcc/selftest.h                                |   2 +
- .../c-c++-common/diagnostic-format-json-1.c   |   1 +
- .../c-c++-common/diagnostic-format-json-2.c   |   1 +
- .../c-c++-common/diagnostic-format-json-3.c   |   1 +
- .../c-c++-common/diagnostic-format-json-4.c   |   2 +
- .../c-c++-common/diagnostic-format-json-5.c   |   1 +
- .../gcc.dg/cpp/warn-normalized-4-bytes.c      |  21 +
- .../gcc.dg/cpp/warn-normalized-4-unicode.c    |  19 +
- gcc/testsuite/gcc.dg/encoding-issues-bytes.c  | Bin 0 -> 595 bytes
- .../gcc.dg/encoding-issues-unicode.c          | Bin 0 -> 613 bytes
- .../gfortran.dg/diagnostic-format-json-1.F90  |   1 +
- .../gfortran.dg/diagnostic-format-json-2.F90  |   1 +
- .../gfortran.dg/diagnostic-format-json-3.F90  |   1 +
- libcpp/charset.c                              |  63 +-
- libcpp/errors.c                               |  82 ++-
- libcpp/include/cpplib.h                       |  76 ++-
- libcpp/include/line-map.h                     |  13 +
- libcpp/internal.h                             |  23 +
- libcpp/lex.c                                  |  38 +-
- libcpp/line-map.c                             |   3 +-
- 31 files changed, 942 insertions(+), 168 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c
- create mode 100644 gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c
- create mode 100644 gcc/testsuite/gcc.dg/encoding-issues-bytes.c
- create mode 100644 gcc/testsuite/gcc.dg/encoding-issues-unicode.c
-
-diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
---- a/gcc/c-family/c-lex.c	2021-07-27 23:55:06.980283060 -0700
-+++ b/gcc/c-family/c-lex.c	2021-12-14 01:16:01.541943272 -0800
-@@ -603,7 +603,11 @@ c_lex_with_flags (tree *value, location_
- 	else if (ISGRAPH (c))
- 	  error_at (*loc, "stray %qc in program", (int) c);
- 	else
--	  error_at (*loc, "stray %<\\%o%> in program", (int) c);
-+	  {
-+	    rich_location rich_loc (line_table, *loc);
-+	    rich_loc.set_escape_on_output (true);
-+	    error_at (&rich_loc, "stray %<\\%o%> in program", (int) c);
-+	  }
-       }
-       goto retry;
- 
-diff --git a/gcc/common.opt b/gcc/common.opt
---- a/gcc/common.opt	2021-12-13 22:08:44.939137107 -0800
-+++ b/gcc/common.opt	2021-12-14 01:16:01.541943272 -0800
-@@ -1348,6 +1348,10 @@ fdiagnostics-format=
- Common Joined RejectNegative Enum(diagnostics_output_format)
- -fdiagnostics-format=[text|json]	Select output format.
- 
-+fdiagnostics-escape-format=
-+Common Joined RejectNegative Enum(diagnostics_escape_format)
-+-fdiagnostics-escape-format=[unicode|bytes]	Select how to escape non-printable-ASCII bytes in the source for diagnostics that suggest it.
-+
- ; Required for these enum values.
- SourceInclude
- diagnostic.h
-@@ -1362,6 +1366,15 @@ EnumValue
- Enum(diagnostics_column_unit) String(byte) Value(DIAGNOSTICS_COLUMN_UNIT_BYTE)
- 
- Enum
-+Name(diagnostics_escape_format) Type(int)
-+
-+EnumValue
-+Enum(diagnostics_escape_format) String(unicode) Value(DIAGNOSTICS_ESCAPE_FORMAT_UNICODE)
-+
-+EnumValue
-+Enum(diagnostics_escape_format) String(bytes) Value(DIAGNOSTICS_ESCAPE_FORMAT_BYTES)
-+
-+Enum
- Name(diagnostics_output_format) Type(int)
- 
- EnumValue
-diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
---- a/gcc/diagnostic.c	2021-07-27 23:55:07.232286576 -0700
-+++ b/gcc/diagnostic.c	2021-12-14 01:16:01.545943202 -0800
-@@ -230,6 +230,7 @@ diagnostic_initialize (diagnostic_contex
-   context->column_unit = DIAGNOSTICS_COLUMN_UNIT_DISPLAY;
-   context->column_origin = 1;
-   context->tabstop = 8;
-+  context->escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
-   context->edit_context_ptr = NULL;
-   context->diagnostic_group_nesting_depth = 0;
-   context->diagnostic_group_emission_count = 0;
-@@ -382,7 +383,10 @@ convert_column_unit (enum diagnostics_co
-       gcc_unreachable ();
- 
-     case DIAGNOSTICS_COLUMN_UNIT_DISPLAY:
--      return location_compute_display_column (s, tabstop);
-+      {
-+	cpp_char_column_policy policy (tabstop, cpp_wcwidth);
-+	return location_compute_display_column (s, policy);
-+      }
- 
-     case DIAGNOSTICS_COLUMN_UNIT_BYTE:
-       return s.column;
-@@ -2275,8 +2279,8 @@ test_diagnostic_get_location_text ()
-     const char *const content = "smile \xf0\x9f\x98\x82\n";
-     const int line_bytes = strlen (content) - 1;
-     const int def_tabstop = 8;
--    const int display_width = cpp_display_width (content, line_bytes,
--						 def_tabstop);
-+    const cpp_char_column_policy policy (def_tabstop, cpp_wcwidth);
-+    const int display_width = cpp_display_width (content, line_bytes, policy);
-     ASSERT_EQ (line_bytes - 2, display_width);
-     temp_source_file tmp (SELFTEST_LOCATION, ".c", content);
-     const char *const fname = tmp.get_filename ();
-diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc
---- a/gcc/diagnostic-format-json.cc	2021-07-27 23:55:07.232286576 -0700
-+++ b/gcc/diagnostic-format-json.cc	2021-12-14 01:16:01.541943272 -0800
-@@ -264,6 +264,9 @@ json_end_diagnostic (diagnostic_context
-       json::value *path_value = context->make_json_for_path (context, path);
-       diag_obj->set ("path", path_value);
-     }
-+
-+  diag_obj->set ("escape-source",
-+		 new json::literal (richloc->escape_on_output_p ()));
- }
- 
- /* No-op implementation of "begin_group_cb" for JSON output.  */
-diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
---- a/gcc/diagnostic.h	2021-07-27 23:55:07.236286632 -0700
-+++ b/gcc/diagnostic.h	2021-12-14 01:16:01.545943202 -0800
-@@ -38,6 +38,20 @@ enum diagnostics_column_unit
-   DIAGNOSTICS_COLUMN_UNIT_BYTE
- };
- 
-+/* An enum for controlling how to print non-ASCII characters/bytes when
-+   a diagnostic suggests escaping the source code on output.  */
-+
-+enum diagnostics_escape_format
-+{
-+  /* Escape non-ASCII Unicode characters in the form <U+XXXX> and
-+     non-UTF-8 bytes in the form <XX>.  */
-+  DIAGNOSTICS_ESCAPE_FORMAT_UNICODE,
-+
-+  /* Escape non-ASCII bytes in the form <XX> (thus showing the underlying
-+     encoding of non-ASCII Unicode characters).  */
-+  DIAGNOSTICS_ESCAPE_FORMAT_BYTES
-+};
-+
- /* Enum for overriding the standard output format.  */
- 
- enum diagnostics_output_format
-@@ -320,6 +334,10 @@ struct diagnostic_context
-   /* The size of the tabstop for tab expansion.  */
-   int tabstop;
- 
-+  /* How should non-ASCII/non-printable bytes be escaped when
-+     a diagnostic suggests escaping the source code on output.  */
-+  enum diagnostics_escape_format escape_format;
-+
-   /* If non-NULL, an edit_context to which fix-it hints should be
-      applied, for generating patches.  */
-   edit_context *edit_context_ptr;
-diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
---- a/gcc/diagnostic-show-locus.c	2021-07-27 23:55:07.232286576 -0700
-+++ b/gcc/diagnostic-show-locus.c	2021-12-14 01:16:01.545943202 -0800
-@@ -175,10 +175,26 @@ enum column_unit {
- class exploc_with_display_col : public expanded_location
- {
-  public:
--  exploc_with_display_col (const expanded_location &exploc, int tabstop)
--    : expanded_location (exploc),
--      m_display_col (location_compute_display_column (exploc, tabstop))
--  {}
-+  exploc_with_display_col (const expanded_location &exploc,
-+			   const cpp_char_column_policy &policy,
-+			   enum location_aspect aspect)
-+  : expanded_location (exploc),
-+    m_display_col (location_compute_display_column (exploc, policy))
-+  {
-+    if (exploc.column > 0)
-+      {
-+	/* m_display_col is now the final column of the byte.
-+	   If escaping has happened, we may want the first column instead.  */
-+	if (aspect != LOCATION_ASPECT_FINISH)
-+	  {
-+	    expanded_location prev_exploc (exploc);
-+	    prev_exploc.column--;
-+	    int prev_display_col
-+	      = (location_compute_display_column (prev_exploc, policy));
-+	    m_display_col = prev_display_col + 1;
-+	  }
-+      }
-+  }
- 
-   int m_display_col;
- };
-@@ -313,6 +329,31 @@ test_line_span ()
- 
- #endif /* #if CHECKING_P */
- 
-+/* A bundle of information containing how to print unicode
-+   characters and bytes when quoting source code.
-+
-+   Provides a unified place to support escaping some subset
-+   of characters to some format.
-+
-+   Extends char_column_policy; printing is split out to avoid
-+   libcpp having to know about pretty_printer.  */
-+
-+struct char_display_policy : public cpp_char_column_policy
-+{
-+ public:
-+  char_display_policy (int tabstop,
-+		       int (*width_cb) (cppchar_t c),
-+		       void (*print_cb) (pretty_printer *pp,
-+					 const cpp_decoded_char &cp))
-+  : cpp_char_column_policy (tabstop, width_cb),
-+    m_print_cb (print_cb)
-+  {
-+  }
-+
-+  void (*m_print_cb) (pretty_printer *pp,
-+		      const cpp_decoded_char &cp);
-+};
-+
- /* A class to control the overall layout when printing a diagnostic.
- 
-    The layout is determined within the constructor.
-@@ -345,6 +386,8 @@ class layout
- 
-   void print_line (linenum_type row);
- 
-+  void on_bad_codepoint (const char *ptr, cppchar_t ch, size_t ch_sz);
-+
-  private:
-   bool will_show_line_p (linenum_type row) const;
-   void print_leading_fixits (linenum_type row);
-@@ -386,6 +429,7 @@ class layout
-  private:
-   diagnostic_context *m_context;
-   pretty_printer *m_pp;
-+  char_display_policy m_policy;
-   location_t m_primary_loc;
-   exploc_with_display_col m_exploc;
-   colorizer m_colorizer;
-@@ -398,6 +442,7 @@ class layout
-   auto_vec <line_span> m_line_spans;
-   int m_linenum_width;
-   int m_x_offset_display;
-+  bool m_escape_on_output;
- };
- 
- /* Implementation of "class colorizer".  */
-@@ -646,6 +691,11 @@ layout_range::intersects_line_p (linenum
- /* Default for when we don't care what the tab expansion is set to.  */
- static const int def_tabstop = 8;
- 
-+static cpp_char_column_policy def_policy ()
-+{
-+  return cpp_char_column_policy (8, cpp_wcwidth);
-+}
-+
- /* Create some expanded locations for testing layout_range.  The filename
-    member of the explocs is set to the empty string.  This member will only be
-    inspected by the calls to location_compute_display_column() made from the
-@@ -662,10 +712,13 @@ make_range (int start_line, int start_co
-     = {"", start_line, start_col, NULL, false};
-   const expanded_location finish_exploc
-     = {"", end_line, end_col, NULL, false};
--  return layout_range (exploc_with_display_col (start_exploc, def_tabstop),
--		       exploc_with_display_col (finish_exploc, def_tabstop),
-+  return layout_range (exploc_with_display_col (start_exploc, def_policy (),
-+						LOCATION_ASPECT_START),
-+		       exploc_with_display_col (finish_exploc, def_policy (),
-+						LOCATION_ASPECT_FINISH),
- 		       SHOW_RANGE_WITHOUT_CARET,
--		       exploc_with_display_col (start_exploc, def_tabstop),
-+		       exploc_with_display_col (start_exploc, def_policy (),
-+						LOCATION_ASPECT_CARET),
- 		       0, NULL);
- }
- 
-@@ -959,6 +1012,164 @@ fixit_cmp (const void *p_a, const void *
-   return hint_a->get_start_loc () - hint_b->get_start_loc ();
- }
- 
-+/* Callbacks for use when not escaping the source.  */
-+
-+/* The default callback for char_column_policy::m_width_cb is cpp_wcwidth.  */
-+
-+/* Callback for char_display_policy::m_print_cb for printing source chars
-+   when not escaping the source.  */
-+
-+static void
-+default_print_decoded_ch (pretty_printer *pp,
-+			  const cpp_decoded_char &decoded_ch)
-+{
-+  for (const char *ptr = decoded_ch.m_start_byte;
-+       ptr != decoded_ch.m_next_byte; ptr++)
-+    {
-+      if (*ptr == '\0' || *ptr == '\r')
-+	{
-+	  pp_space (pp);
-+	  continue;
-+	}
-+
-+      pp_character (pp, *ptr);
-+    }
-+}
-+
-+/* Callbacks for use with DIAGNOSTICS_ESCAPE_FORMAT_BYTES.  */
-+
-+static const int width_per_escaped_byte = 4;
-+
-+/* Callback for char_column_policy::m_width_cb for determining the
-+   display width when escaping with DIAGNOSTICS_ESCAPE_FORMAT_BYTES.  */
-+
-+static int
-+escape_as_bytes_width (cppchar_t ch)
-+{
-+  if (ch < 0x80 && ISPRINT (ch))
-+    return cpp_wcwidth (ch);
-+  else
-+    {
-+      if (ch <=   0x7F) return 1 * width_per_escaped_byte;
-+      if (ch <=  0x7FF) return 2 * width_per_escaped_byte;
-+      if (ch <= 0xFFFF) return 3 * width_per_escaped_byte;
-+      return 4 * width_per_escaped_byte;
-+    }
-+}
-+
-+/* Callback for char_display_policy::m_print_cb for printing source chars
-+   when escaping with DIAGNOSTICS_ESCAPE_FORMAT_BYTES.  */
-+
-+static void
-+escape_as_bytes_print (pretty_printer *pp,
-+		       const cpp_decoded_char &decoded_ch)
-+{
-+  if (!decoded_ch.m_valid_ch)
-+    {
-+      for (const char *iter = decoded_ch.m_start_byte;
-+	   iter != decoded_ch.m_next_byte; ++iter)
-+	{
-+	  char buf[16];
-+	  sprintf (buf, "<%02x>", (unsigned char)*iter);
-+	  pp_string (pp, buf);
-+	}
-+      return;
-+    }
-+
-+  cppchar_t ch = decoded_ch.m_ch;
-+  if (ch < 0x80 && ISPRINT (ch))
-+    pp_character (pp, ch);
-+  else
-+    {
-+      for (const char *iter = decoded_ch.m_start_byte;
-+	   iter < decoded_ch.m_next_byte; ++iter)
-+	{
-+	  char buf[16];
-+	  sprintf (buf, "<%02x>", (unsigned char)*iter);
-+	  pp_string (pp, buf);
-+	}
-+    }
-+}
-+
-+/* Callbacks for use with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE.  */
-+
-+/* Callback for char_column_policy::m_width_cb for determining the
-+   display width when escaping with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE.  */
-+
-+static int
-+escape_as_unicode_width (cppchar_t ch)
-+{
-+  if (ch < 0x80 && ISPRINT (ch))
-+    return cpp_wcwidth (ch);
-+  else
-+    {
-+      // Width of "<U+%04x>"
-+      if (ch > 0xfffff)
-+	return 10;
-+      else if (ch > 0xffff)
-+	return 9;
-+      else
-+	return 8;
-+    }
-+}
-+
-+/* Callback for char_display_policy::m_print_cb for printing source chars
-+   when escaping with DIAGNOSTICS_ESCAPE_FORMAT_UNICODE.  */
-+
-+static void
-+escape_as_unicode_print (pretty_printer *pp,
-+			 const cpp_decoded_char &decoded_ch)
-+{
-+  if (!decoded_ch.m_valid_ch)
-+    {
-+      escape_as_bytes_print (pp, decoded_ch);
-+      return;
-+    }
-+
-+  cppchar_t ch = decoded_ch.m_ch;
-+  if (ch < 0x80 && ISPRINT (ch))
-+    pp_character (pp, ch);
-+  else
-+    {
-+      char buf[16];
-+      sprintf (buf, "<U+%04X>", ch);
-+      pp_string (pp, buf);
-+    }
-+}
-+
-+/* Populate a char_display_policy based on DC and RICHLOC.  */
-+
-+static char_display_policy
-+make_policy (const diagnostic_context &dc,
-+	     const rich_location &richloc)
-+{
-+  /* The default is to not escape non-ASCII bytes.  */
-+  char_display_policy result
-+    (dc.tabstop, cpp_wcwidth, default_print_decoded_ch);
-+
-+  /* If the diagnostic suggests escaping non-ASCII bytes, then
-+     use policy from user-supplied options.  */
-+  if (richloc.escape_on_output_p ())
-+    {
-+      result.m_undecoded_byte_width = width_per_escaped_byte;
-+      switch (dc.escape_format)
-+	{
-+	default:
-+	  gcc_unreachable ();
-+	case DIAGNOSTICS_ESCAPE_FORMAT_UNICODE:
-+	  result.m_width_cb = escape_as_unicode_width;
-+	  result.m_print_cb = escape_as_unicode_print;
-+	  break;
-+	case DIAGNOSTICS_ESCAPE_FORMAT_BYTES:
-+	  result.m_width_cb = escape_as_bytes_width;
-+	  result.m_print_cb = escape_as_bytes_print;
-+	  break;
-+	}
-+    }
-+
-+  return result;
-+}
-+
- /* Implementation of class layout.  */
- 
- /* Constructor for class layout.
-@@ -975,8 +1186,10 @@ layout::layout (diagnostic_context * con
- 		diagnostic_t diagnostic_kind)
- : m_context (context),
-   m_pp (context->printer),
-+  m_policy (make_policy (*context, *richloc)),
-   m_primary_loc (richloc->get_range (0)->m_loc),
--  m_exploc (richloc->get_expanded_location (0), context->tabstop),
-+  m_exploc (richloc->get_expanded_location (0), m_policy,
-+	    LOCATION_ASPECT_CARET),
-   m_colorizer (context, diagnostic_kind),
-   m_colorize_source_p (context->colorize_source_p),
-   m_show_labels_p (context->show_labels_p),
-@@ -986,7 +1199,8 @@ layout::layout (diagnostic_context * con
-   m_fixit_hints (richloc->get_num_fixit_hints ()),
-   m_line_spans (1 + richloc->get_num_locations ()),
-   m_linenum_width (0),
--  m_x_offset_display (0)
-+  m_x_offset_display (0),
-+  m_escape_on_output (richloc->escape_on_output_p ())
- {
-   for (unsigned int idx = 0; idx < richloc->get_num_locations (); idx++)
-     {
-@@ -1072,10 +1286,13 @@ layout::maybe_add_location_range (const
- 
-   /* Everything is now known to be in the correct source file,
-      but it may require further sanitization.  */
--  layout_range ri (exploc_with_display_col (start, m_context->tabstop),
--		   exploc_with_display_col (finish, m_context->tabstop),
-+  layout_range ri (exploc_with_display_col (start, m_policy,
-+					    LOCATION_ASPECT_START),
-+		   exploc_with_display_col (finish, m_policy,
-+					    LOCATION_ASPECT_FINISH),
- 		   loc_range->m_range_display_kind,
--		   exploc_with_display_col (caret, m_context->tabstop),
-+		   exploc_with_display_col (caret, m_policy,
-+					    LOCATION_ASPECT_CARET),
- 		   original_idx, loc_range->m_label);
- 
-   /* If we have a range that finishes before it starts (perhaps
-@@ -1409,7 +1626,7 @@ layout::calculate_x_offset_display ()
-     = get_line_bytes_without_trailing_whitespace (line.get_buffer (),
- 						  line.length ());
-   int eol_display_column
--    = cpp_display_width (line.get_buffer (), line_bytes, m_context->tabstop);
-+    = cpp_display_width (line.get_buffer (), line_bytes, m_policy);
-   if (caret_display_column > eol_display_column
-       || !caret_display_column)
-     {
-@@ -1488,7 +1705,7 @@ layout::print_source_line (linenum_type
-   /* This object helps to keep track of which display column we are at, which is
-      necessary for computing the line bounds in display units, for doing
-      tab expansion, and for implementing m_x_offset_display.  */
--  cpp_display_width_computation dw (line, line_bytes, m_context->tabstop);
-+  cpp_display_width_computation dw (line, line_bytes, m_policy);
- 
-   /* Skip the first m_x_offset_display display columns.  In case the leading
-      portion that will be skipped ends with a character with wcwidth > 1, then
-@@ -1536,7 +1753,8 @@ layout::print_source_line (linenum_type
- 	 tabs and replacing some control bytes with spaces as necessary.  */
-       const char *c = dw.next_byte ();
-       const int start_disp_col = dw.display_cols_processed () + 1;
--      const int this_display_width = dw.process_next_codepoint ();
-+      cpp_decoded_char cp;
-+      const int this_display_width = dw.process_next_codepoint (&cp);
-       if (*c == '\t')
- 	{
- 	  /* The returned display width is the number of spaces into which the
-@@ -1545,15 +1763,6 @@ layout::print_source_line (linenum_type
- 	    pp_space (m_pp);
- 	  continue;
- 	}
--      if (*c == '\0' || *c == '\r')
--	{
--	  /* cpp_wcwidth() promises to return 1 for all control bytes, and we
--	     want to output these as a single space too, so this case is
--	     actually the same as the '\t' case.  */
--	  gcc_assert (this_display_width == 1);
--	  pp_space (m_pp);
--	  continue;
--	}
- 
-       /* We have a (possibly multibyte) character to output; update the line
- 	 bounds if it is not whitespace.  */
-@@ -1565,7 +1774,8 @@ layout::print_source_line (linenum_type
- 	}
- 
-       /* Output the character.  */
--      while (c != dw.next_byte ()) pp_character (m_pp, *c++);
-+      m_policy.m_print_cb (m_pp, cp);
-+      c = dw.next_byte ();
-     }
-   print_newline ();
-   return lbounds;
-@@ -1664,14 +1874,14 @@ layout::print_annotation_line (linenum_t
- class line_label
- {
- public:
--  line_label (diagnostic_context *context, int state_idx, int column,
-+  line_label (const cpp_char_column_policy &policy,
-+	      int state_idx, int column,
- 	      label_text text)
-   : m_state_idx (state_idx), m_column (column),
-     m_text (text), m_label_line (0), m_has_vbar (true)
-   {
-     const int bytes = strlen (text.m_buffer);
--    m_display_width
--      = cpp_display_width (text.m_buffer, bytes, context->tabstop);
-+    m_display_width = cpp_display_width (text.m_buffer, bytes, policy);
-   }
- 
-   /* Sorting is primarily by column, then by state index.  */
-@@ -1731,7 +1941,7 @@ layout::print_any_labels (linenum_type r
- 	if (text.m_buffer == NULL)
- 	  continue;
- 
--	labels.safe_push (line_label (m_context, i, disp_col, text));
-+	labels.safe_push (line_label (m_policy, i, disp_col, text));
-       }
-   }
- 
-@@ -2011,7 +2221,7 @@ public:
- 
- /* Get the range of bytes or display columns that HINT would affect.  */
- static column_range
--get_affected_range (diagnostic_context *context,
-+get_affected_range (const cpp_char_column_policy &policy,
- 		    const fixit_hint *hint, enum column_unit col_unit)
- {
-   expanded_location exploc_start = expand_location (hint->get_start_loc ());
-@@ -2022,13 +2232,11 @@ get_affected_range (diagnostic_context *
-   int finish_column;
-   if (col_unit == CU_DISPLAY_COLS)
-     {
--      start_column
--	= location_compute_display_column (exploc_start, context->tabstop);
-+      start_column = location_compute_display_column (exploc_start, policy);
-       if (hint->insertion_p ())
- 	finish_column = start_column - 1;
-       else
--	finish_column
--	  = location_compute_display_column (exploc_finish, context->tabstop);
-+	finish_column = location_compute_display_column (exploc_finish, policy);
-     }
-   else
-     {
-@@ -2041,12 +2249,13 @@ get_affected_range (diagnostic_context *
- /* Get the range of display columns that would be printed for HINT.  */
- 
- static column_range
--get_printed_columns (diagnostic_context *context, const fixit_hint *hint)
-+get_printed_columns (const cpp_char_column_policy &policy,
-+		     const fixit_hint *hint)
- {
-   expanded_location exploc = expand_location (hint->get_start_loc ());
--  int start_column = location_compute_display_column (exploc, context->tabstop);
-+  int start_column = location_compute_display_column (exploc, policy);
-   int hint_width = cpp_display_width (hint->get_string (), hint->get_length (),
--				      context->tabstop);
-+				      policy);
-   int final_hint_column = start_column + hint_width - 1;
-   if (hint->insertion_p ())
-     {
-@@ -2056,8 +2265,7 @@ get_printed_columns (diagnostic_context
-     {
-       exploc = expand_location (hint->get_next_loc ());
-       --exploc.column;
--      int finish_column
--	= location_compute_display_column (exploc, context->tabstop);
-+      int finish_column = location_compute_display_column (exploc, policy);
-       return column_range (start_column,
- 			   MAX (finish_column, final_hint_column));
-     }
-@@ -2075,13 +2283,13 @@ public:
- 	      column_range affected_columns,
- 	      column_range printed_columns,
- 	      const char *new_text, size_t new_text_len,
--	      int tabstop)
-+	      const cpp_char_column_policy &policy)
-   : m_affected_bytes (affected_bytes),
-     m_affected_columns (affected_columns),
-     m_printed_columns (printed_columns),
-     m_text (xstrdup (new_text)),
-     m_byte_length (new_text_len),
--    m_tabstop (tabstop),
-+    m_policy (policy),
-     m_alloc_sz (new_text_len + 1)
-   {
-     compute_display_cols ();
-@@ -2099,7 +2307,7 @@ public:
- 
-   void compute_display_cols ()
-   {
--    m_display_cols = cpp_display_width (m_text, m_byte_length, m_tabstop);
-+    m_display_cols = cpp_display_width (m_text, m_byte_length, m_policy);
-   }
- 
-   void overwrite (int dst_offset, const char_span &src_span)
-@@ -2127,7 +2335,7 @@ public:
-   char *m_text;
-   size_t m_byte_length; /* Not including null-terminator.  */
-   int m_display_cols;
--  int m_tabstop;
-+  const cpp_char_column_policy &m_policy;
-   size_t m_alloc_sz;
- };
- 
-@@ -2163,15 +2371,16 @@ correction::ensure_terminated ()
- class line_corrections
- {
- public:
--  line_corrections (diagnostic_context *context, const char *filename,
-+  line_corrections (const char_display_policy &policy,
-+		    const char *filename,
- 		    linenum_type row)
--    : m_context (context), m_filename (filename), m_row (row)
-+  : m_policy (policy), m_filename (filename), m_row (row)
-   {}
-   ~line_corrections ();
- 
-   void add_hint (const fixit_hint *hint);
- 
--  diagnostic_context *m_context;
-+  const char_display_policy &m_policy;
-   const char *m_filename;
-   linenum_type m_row;
-   auto_vec <correction *> m_corrections;
-@@ -2217,10 +2426,10 @@ source_line::source_line (const char *fi
- void
- line_corrections::add_hint (const fixit_hint *hint)
- {
--  column_range affected_bytes = get_affected_range (m_context, hint, CU_BYTES);
--  column_range affected_columns = get_affected_range (m_context, hint,
-+  column_range affected_bytes = get_affected_range (m_policy, hint, CU_BYTES);
-+  column_range affected_columns = get_affected_range (m_policy, hint,
- 						      CU_DISPLAY_COLS);
--  column_range printed_columns = get_printed_columns (m_context, hint);
-+  column_range printed_columns = get_printed_columns (m_policy, hint);
- 
-   /* Potentially consolidate.  */
-   if (!m_corrections.is_empty ())
-@@ -2289,7 +2498,7 @@ line_corrections::add_hint (const fixit_
- 					   printed_columns,
- 					   hint->get_string (),
- 					   hint->get_length (),
--					   m_context->tabstop));
-+					   m_policy));
- }
- 
- /* If there are any fixit hints on source line ROW, print them.
-@@ -2303,7 +2512,7 @@ layout::print_trailing_fixits (linenum_t
- {
-   /* Build a list of correction instances for the line,
-      potentially consolidating hints (for the sake of readability).  */
--  line_corrections corrections (m_context, m_exploc.file, row);
-+  line_corrections corrections (m_policy, m_exploc.file, row);
-   for (unsigned int i = 0; i < m_fixit_hints.length (); i++)
-     {
-       const fixit_hint *hint = m_fixit_hints[i];
-@@ -2646,6 +2855,59 @@ namespace selftest {
- 
- /* Selftests for diagnostic_show_locus.  */
- 
-+/* Verify that cpp_display_width correctly handles escaping.  */
-+
-+static void
-+test_display_widths ()
-+{
-+  gcc_rich_location richloc (UNKNOWN_LOCATION);
-+
-+  /* U+03C0 "GREEK SMALL LETTER PI".  */
-+  const char *pi = "\xCF\x80";
-+  /* U+1F642 "SLIGHTLY SMILING FACE".  */
-+  const char *emoji = "\xF0\x9F\x99\x82";
-+  /* Stray trailing byte of a UTF-8 character.  */
-+  const char *stray = "\xBF";
-+  /* U+10FFFF.  */
-+  const char *max_codepoint = "\xF4\x8F\xBF\xBF";
-+
-+  /* No escaping.  */
-+  {
-+    test_diagnostic_context dc;
-+    char_display_policy policy (make_policy (dc, richloc));
-+    ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 1);
-+    ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 2);
-+    ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 1);
-+    /* Don't check width of U+10FFFF; it's in a private use plane.  */
-+  }
-+
-+  richloc.set_escape_on_output (true);
-+
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
-+    char_display_policy policy (make_policy (dc, richloc));
-+    ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 8);
-+    ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 9);
-+    ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 4);
-+    ASSERT_EQ (cpp_display_width (max_codepoint, strlen (max_codepoint),
-+				  policy),
-+	       strlen ("<U+10FFFF>"));
-+  }
-+
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES;
-+    char_display_policy policy (make_policy (dc, richloc));
-+    ASSERT_EQ (cpp_display_width (pi, strlen (pi), policy), 8);
-+    ASSERT_EQ (cpp_display_width (emoji, strlen (emoji), policy), 16);
-+    ASSERT_EQ (cpp_display_width (stray, strlen (stray), policy), 4);
-+    ASSERT_EQ (cpp_display_width (max_codepoint, strlen (max_codepoint),
-+				  policy),
-+	       16);
-+  }
-+}
-+
- /* For precise tests of the layout, make clear where the source line will
-    start.  test_left_margin sets the total byte count from the left side of the
-    screen to the start of source lines, after the line number and the separator,
-@@ -2715,10 +2977,10 @@ test_layout_x_offset_display_utf8 (const
-   char_span lspan = location_get_source_line (tmp.get_filename (), 1);
-   ASSERT_EQ (line_display_cols,
- 	     cpp_display_width (lspan.get_buffer (), lspan.length (),
--				def_tabstop));
-+				def_policy ()));
-   ASSERT_EQ (line_display_cols,
- 	     location_compute_display_column (expand_location (line_end),
--					      def_tabstop));
-+					      def_policy ()));
-   ASSERT_EQ (0, memcmp (lspan.get_buffer () + (emoji_col - 1),
- 			"\xf0\x9f\x98\x82\xf0\x9f\x98\x82", 8));
- 
-@@ -2866,12 +3128,13 @@ test_layout_x_offset_display_tab (const
-   ASSERT_EQ ('\t', *(lspan.get_buffer () + (tab_col - 1)));
-   for (int tabstop = 1; tabstop != num_tabstops; ++tabstop)
-     {
-+      cpp_char_column_policy policy (tabstop, cpp_wcwidth);
-       ASSERT_EQ (line_bytes + extra_width[tabstop],
- 		 cpp_display_width (lspan.get_buffer (), lspan.length (),
--				    tabstop));
-+				    policy));
-       ASSERT_EQ (line_bytes + extra_width[tabstop],
- 		 location_compute_display_column (expand_location (line_end),
--						  tabstop));
-+						  policy));
-     }
- 
-   /* Check that the tab is expanded to the expected number of spaces.  */
-@@ -4003,6 +4266,43 @@ test_one_liner_labels_utf8 ()
- 			   " bb\xf0\x9f\x98\x82\xf0\x9f\x98\x82\n",
- 		  pp_formatted_text (dc.printer));
-   }
-+
-+  /* Example of escaping the source lines.  */
-+  {
-+    text_range_label label0 ("label 0\xf0\x9f\x98\x82");
-+    text_range_label label1 ("label 1\xcf\x80");
-+    text_range_label label2 ("label 2\xcf\x80");
-+    gcc_rich_location richloc (foo, &label0);
-+    richloc.add_range (bar, SHOW_RANGE_WITHOUT_CARET, &label1);
-+    richloc.add_range (field, SHOW_RANGE_WITHOUT_CARET, &label2);
-+    richloc.set_escape_on_output (true);
-+
-+    {
-+      test_diagnostic_context dc;
-+      dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
-+      diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+      ASSERT_STREQ (" <U+1F602>_foo = <U+03C0>_bar.<U+1F602>_field<U+03C0>;\n"
-+		    " ^~~~~~~~~~~~~   ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~\n"
-+		    " |               |            |\n"
-+		    " |               |            label 2\xcf\x80\n"
-+		    " |               label 1\xcf\x80\n"
-+		    " label 0\xf0\x9f\x98\x82\n",
-+		    pp_formatted_text (dc.printer));
-+    }
-+    {
-+      test_diagnostic_context dc;
-+      dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES;
-+      diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+      ASSERT_STREQ
-+	(" <f0><9f><98><82>_foo = <cf><80>_bar.<f0><9f><98><82>_field<cf><80>;\n"
-+	 " ^~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
-+	 " |                      |            |\n"
-+	 " |                      |            label 2\xcf\x80\n"
-+	 " |                      label 1\xcf\x80\n"
-+	 " label 0\xf0\x9f\x98\x82\n",
-+	 pp_formatted_text (dc.printer));
-+    }
-+  }
- }
- 
- /* Make sure that colorization codes don't interrupt a multibyte
-@@ -4057,9 +4357,9 @@ test_diagnostic_show_locus_one_liner_utf
- 
-   char_span lspan = location_get_source_line (tmp.get_filename (), 1);
-   ASSERT_EQ (25, cpp_display_width (lspan.get_buffer (), lspan.length (),
--				    def_tabstop));
-+				    def_policy ()));
-   ASSERT_EQ (25, location_compute_display_column (expand_location (line_end),
--						  def_tabstop));
-+						  def_policy ()));
- 
-   test_one_liner_simple_caret_utf8 ();
-   test_one_liner_caret_and_range_utf8 ();
-@@ -4445,30 +4745,31 @@ test_overlapped_fixit_printing (const li
- 		  pp_formatted_text (dc.printer));
- 
-     /* Unit-test the line_corrections machinery.  */
-+    char_display_policy policy (make_policy (dc, richloc));
-     ASSERT_EQ (3, richloc.get_num_fixit_hints ());
-     const fixit_hint *hint_0 = richloc.get_fixit_hint (0);
-     ASSERT_EQ (column_range (12, 12),
--	       get_affected_range (&dc, hint_0, CU_BYTES));
-+	       get_affected_range (policy, hint_0, CU_BYTES));
-     ASSERT_EQ (column_range (12, 12),
--	       get_affected_range (&dc, hint_0, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (12, 22), get_printed_columns (&dc, hint_0));
-+	       get_affected_range (policy, hint_0, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (12, 22), get_printed_columns (policy, hint_0));
-     const fixit_hint *hint_1 = richloc.get_fixit_hint (1);
-     ASSERT_EQ (column_range (18, 18),
--	       get_affected_range (&dc, hint_1, CU_BYTES));
-+	       get_affected_range (policy, hint_1, CU_BYTES));
-     ASSERT_EQ (column_range (18, 18),
--	       get_affected_range (&dc, hint_1, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (18, 20), get_printed_columns (&dc, hint_1));
-+	       get_affected_range (policy, hint_1, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (18, 20), get_printed_columns (policy, hint_1));
-     const fixit_hint *hint_2 = richloc.get_fixit_hint (2);
-     ASSERT_EQ (column_range (29, 28),
--	       get_affected_range (&dc, hint_2, CU_BYTES));
-+	       get_affected_range (policy, hint_2, CU_BYTES));
-     ASSERT_EQ (column_range (29, 28),
--	       get_affected_range (&dc, hint_2, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (29, 29), get_printed_columns (&dc, hint_2));
-+	       get_affected_range (policy, hint_2, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (29, 29), get_printed_columns (policy, hint_2));
- 
-     /* Add each hint in turn to a line_corrections instance,
-        and verify that they are consolidated into one correction instance
-        as expected.  */
--    line_corrections lc (&dc, tmp.get_filename (), 1);
-+    line_corrections lc (policy, tmp.get_filename (), 1);
- 
-     /* The first replace hint by itself.  */
-     lc.add_hint (hint_0);
-@@ -4660,30 +4961,31 @@ test_overlapped_fixit_printing_utf8 (con
- 		  pp_formatted_text (dc.printer));
- 
-     /* Unit-test the line_corrections machinery.  */
-+    char_display_policy policy (make_policy (dc, richloc));
-     ASSERT_EQ (3, richloc.get_num_fixit_hints ());
-     const fixit_hint *hint_0 = richloc.get_fixit_hint (0);
-     ASSERT_EQ (column_range (14, 14),
--	       get_affected_range (&dc, hint_0, CU_BYTES));
-+	       get_affected_range (policy, hint_0, CU_BYTES));
-     ASSERT_EQ (column_range (12, 12),
--	       get_affected_range (&dc, hint_0, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (12, 22), get_printed_columns (&dc, hint_0));
-+	       get_affected_range (policy, hint_0, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (12, 22), get_printed_columns (policy, hint_0));
-     const fixit_hint *hint_1 = richloc.get_fixit_hint (1);
-     ASSERT_EQ (column_range (22, 22),
--	       get_affected_range (&dc, hint_1, CU_BYTES));
-+	       get_affected_range (policy, hint_1, CU_BYTES));
-     ASSERT_EQ (column_range (18, 18),
--	       get_affected_range (&dc, hint_1, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (18, 20), get_printed_columns (&dc, hint_1));
-+	       get_affected_range (policy, hint_1, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (18, 20), get_printed_columns (policy, hint_1));
-     const fixit_hint *hint_2 = richloc.get_fixit_hint (2);
-     ASSERT_EQ (column_range (35, 34),
--	       get_affected_range (&dc, hint_2, CU_BYTES));
-+	       get_affected_range (policy, hint_2, CU_BYTES));
-     ASSERT_EQ (column_range (30, 29),
--	       get_affected_range (&dc, hint_2, CU_DISPLAY_COLS));
--    ASSERT_EQ (column_range (30, 30), get_printed_columns (&dc, hint_2));
-+	       get_affected_range (policy, hint_2, CU_DISPLAY_COLS));
-+    ASSERT_EQ (column_range (30, 30), get_printed_columns (policy, hint_2));
- 
-     /* Add each hint in turn to a line_corrections instance,
-        and verify that they are consolidated into one correction instance
-        as expected.  */
--    line_corrections lc (&dc, tmp.get_filename (), 1);
-+    line_corrections lc (policy, tmp.get_filename (), 1);
- 
-     /* The first replace hint by itself.  */
-     lc.add_hint (hint_0);
-@@ -4877,15 +5179,16 @@ test_overlapped_fixit_printing_2 (const
-     richloc.add_fixit_insert_before (col_21, "}");
- 
-     /* These fixits should be accepted; they can't be consolidated.  */
-+    char_display_policy policy (make_policy (dc, richloc));
-     ASSERT_EQ (2, richloc.get_num_fixit_hints ());
-     const fixit_hint *hint_0 = richloc.get_fixit_hint (0);
-     ASSERT_EQ (column_range (23, 22),
--	       get_affected_range (&dc, hint_0, CU_BYTES));
--    ASSERT_EQ (column_range (23, 23), get_printed_columns (&dc, hint_0));
-+	       get_affected_range (policy, hint_0, CU_BYTES));
-+    ASSERT_EQ (column_range (23, 23), get_printed_columns (policy, hint_0));
-     const fixit_hint *hint_1 = richloc.get_fixit_hint (1);
-     ASSERT_EQ (column_range (21, 20),
--	       get_affected_range (&dc, hint_1, CU_BYTES));
--    ASSERT_EQ (column_range (21, 21), get_printed_columns (&dc, hint_1));
-+	       get_affected_range (policy, hint_1, CU_BYTES));
-+    ASSERT_EQ (column_range (21, 21), get_printed_columns (policy, hint_1));
- 
-     /* Verify that they're printed correctly.  */
-     diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-@@ -5152,10 +5455,11 @@ test_tab_expansion (const line_table_cas
-      ....................123 45678901234 56789012345  columns  */
- 
-   const int tabstop = 8;
-+  cpp_char_column_policy policy (tabstop, cpp_wcwidth);
-   const int first_non_ws_byte_col = 7;
-   const int right_quote_byte_col = 15;
-   const int last_byte_col = 25;
--  ASSERT_EQ (35, cpp_display_width (content, last_byte_col, tabstop));
-+  ASSERT_EQ (35, cpp_display_width (content, last_byte_col, policy));
- 
-   temp_source_file tmp (SELFTEST_LOCATION, ".c", content);
-   line_table_test ltt (case_);
-@@ -5198,6 +5502,114 @@ test_tab_expansion (const line_table_cas
-   }
- }
- 
-+/* Verify that the escaping machinery can cope with a variety of different
-+   invalid bytes.  */
-+
-+static void
-+test_escaping_bytes_1 (const line_table_case &case_)
-+{
-+  const char content[] = "before\0\1\2\3\r\x80\xff""after\n";
-+  const size_t sz = sizeof (content);
-+  temp_source_file tmp (SELFTEST_LOCATION, ".c", content, sz);
-+  line_table_test ltt (case_);
-+  const line_map_ordinary *ord_map = linemap_check_ordinary
-+    (linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 0));
-+  linemap_line_start (line_table, 1, 100);
-+
-+  location_t finish
-+    = linemap_position_for_line_and_column (line_table, ord_map, 1,
-+					    strlen (content));
-+
-+  if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS)
-+    return;
-+
-+  /* Locations of the NUL and \r bytes.  */
-+  location_t nul_loc
-+    = linemap_position_for_line_and_column (line_table, ord_map, 1, 7);
-+  location_t r_loc
-+    = linemap_position_for_line_and_column (line_table, ord_map, 1, 11);
-+  gcc_rich_location richloc (nul_loc);
-+  richloc.add_range (r_loc);
-+
-+  {
-+    test_diagnostic_context dc;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ (" before \1\2\3 \x80\xff""after\n"
-+		  "       ^   ~\n",
-+		  pp_formatted_text (dc.printer));
-+  }
-+  richloc.set_escape_on_output (true);
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ
-+      (" before<U+0000><U+0001><U+0002><U+0003><U+000D><80><ff>after\n"
-+       "       ^~~~~~~~                        ~~~~~~~~\n",
-+       pp_formatted_text (dc.printer));
-+  }
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ (" before<00><01><02><03><0d><80><ff>after\n"
-+		  "       ^~~~            ~~~~\n",
-+		  pp_formatted_text (dc.printer));
-+  }
-+}
-+
-+/* As above, but verify that we handle the initial byte of a line
-+   correctly.  */
-+
-+static void
-+test_escaping_bytes_2 (const line_table_case &case_)
-+{
-+  const char content[]  = "\0after\n";
-+  const size_t sz = sizeof (content);
-+  temp_source_file tmp (SELFTEST_LOCATION, ".c", content, sz);
-+  line_table_test ltt (case_);
-+  const line_map_ordinary *ord_map = linemap_check_ordinary
-+    (linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 0));
-+  linemap_line_start (line_table, 1, 100);
-+
-+  location_t finish
-+    = linemap_position_for_line_and_column (line_table, ord_map, 1,
-+					    strlen (content));
-+
-+  if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS)
-+    return;
-+
-+  /* Location of the NUL byte.  */
-+  location_t nul_loc
-+    = linemap_position_for_line_and_column (line_table, ord_map, 1, 1);
-+  gcc_rich_location richloc (nul_loc);
-+
-+  {
-+    test_diagnostic_context dc;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ ("  after\n"
-+		  " ^\n",
-+		  pp_formatted_text (dc.printer));
-+  }
-+  richloc.set_escape_on_output (true);
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ (" <U+0000>after\n"
-+		  " ^~~~~~~~\n",
-+		  pp_formatted_text (dc.printer));
-+  }
-+  {
-+    test_diagnostic_context dc;
-+    dc.escape_format = DIAGNOSTICS_ESCAPE_FORMAT_BYTES;
-+    diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-+    ASSERT_STREQ (" <00>after\n"
-+		  " ^~~~\n",
-+		  pp_formatted_text (dc.printer));
-+  }
-+}
-+
- /* Verify that line numbers are correctly printed for the case of
-    a multiline range in which the width of the line numbers changes
-    (e.g. from "9" to "10").  */
-@@ -5254,6 +5666,8 @@ diagnostic_show_locus_c_tests ()
-   test_layout_range_for_single_line ();
-   test_layout_range_for_multiple_lines ();
- 
-+  test_display_widths ();
-+
-   for_each_line_table_case (test_layout_x_offset_display_utf8);
-   for_each_line_table_case (test_layout_x_offset_display_tab);
- 
-@@ -5274,6 +5688,8 @@ diagnostic_show_locus_c_tests ()
-   for_each_line_table_case (test_fixit_replace_containing_newline);
-   for_each_line_table_case (test_fixit_deletion_affecting_newline);
-   for_each_line_table_case (test_tab_expansion);
-+  for_each_line_table_case (test_escaping_bytes_1);
-+  for_each_line_table_case (test_escaping_bytes_2);
- 
-   test_line_numbers_multiline_range ();
- }
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
---- a/gcc/doc/invoke.texi	2021-12-13 23:23:05.764437151 -0800
-+++ b/gcc/doc/invoke.texi	2021-12-14 01:16:01.553943061 -0800
-@@ -312,7 +312,8 @@ Objective-C and Objective-C++ Dialects}.
- -fdiagnostics-show-path-depths @gol
- -fno-show-column @gol
- -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol
---fdiagnostics-column-origin=@var{origin}}
-+-fdiagnostics-column-origin=@var{origin} @gol
-+-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
- 
- @item Warning Options
- @xref{Warning Options,,Options to Request or Suppress Warnings}.
-@@ -5083,6 +5084,38 @@ first column.  The default value of 1 co
- behavior and to the GNU style guide.  Some utilities may perform better with an
- origin of 0; any non-negative value may be specified.
- 
-+@item -fdiagnostics-escape-format=@var{FORMAT}
-+@opindex fdiagnostics-escape-format
-+When GCC prints pertinent source lines for a diagnostic it normally attempts
-+to print the source bytes directly.  However, some diagnostics relate to encoding
-+issues in the source file, such as malformed UTF-8, or issues with Unicode
-+normalization.  These diagnostics are flagged so that GCC will escape bytes
-+that are not printable ASCII when printing their pertinent source lines.
-+
-+This option controls how such bytes should be escaped.
-+
-+The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
-+are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
-+correspond to a Unicode character validly-encoded in UTF-8-encoded will be
-+displayed as hexadecimal in the form @samp{<XX>}.
-+
-+For example, a source line containing the string @samp{before} followed by the
-+Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
-+0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
-+the string @samp{after} will be printed for such a diagnostic as:
-+
-+@smallexample
-+ before<U+03C0><BF>after
-+@end smallexample
-+
-+Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
-+in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
-+Unicode characters.  For the example above, the following will be printed:
-+
-+@smallexample
-+ before<CF><80><BF>after
-+@end smallexample
-+
- @item -fdiagnostics-format=@var{FORMAT}
- @opindex fdiagnostics-format
- Select a different format for printing diagnostics.
-@@ -5150,9 +5183,11 @@ might be printed in JSON form (after for
-                         @}
-                     @}
-                 ],
-+                "escape-source": false,
-                 "message": "...this statement, but the latter is @dots{}"
-             @}
-         ]
-+	"escape-source": false,
- 	"column-origin": 1,
-     @},
-     @dots{}
-@@ -5239,6 +5274,7 @@ of the expression, which have labels.  I
-                 "label": "T @{aka struct t@}"
-             @}
-         ],
-+        "escape-source": false,
-         "message": "invalid operands to binary + @dots{}"
-     @}
- @end smallexample
-@@ -5292,6 +5328,7 @@ might be printed in JSON form as:
-                 @}
-             @}
-         ],
-+        "escape-source": false,
-         "message": "\u2018struct s\u2019 has no member named @dots{}"
-     @}
- @end smallexample
-@@ -5349,6 +5386,10 @@ For example, the intraprocedural example
-     ]
- @end smallexample
- 
-+Diagnostics have a boolean attribute @code{escape-source}, hinting whether
-+non-ASCII bytes should be escaped when printing the pertinent lines of
-+source code (@code{true} for diagnostics involving source encoding issues).
-+
- @end table
- 
- @node Warning Options
-diff --git a/gcc/input.c b/gcc/input.c
---- a/gcc/input.c	2021-07-27 23:55:07.328287915 -0700
-+++ b/gcc/input.c	2021-12-14 01:16:01.553943061 -0800
-@@ -913,7 +913,8 @@ make_location (location_t caret, source_
-    source line in order to calculate the display width.  If that cannot be done
-    for any reason, then returns the byte column as a fallback.  */
- int
--location_compute_display_column (expanded_location exploc, int tabstop)
-+location_compute_display_column (expanded_location exploc,
-+				 const cpp_char_column_policy &policy)
- {
-   if (!(exploc.file && *exploc.file && exploc.line && exploc.column))
-     return exploc.column;
-@@ -921,7 +922,7 @@ location_compute_display_column (expande
-   /* If line is NULL, this function returns exploc.column which is the
-      desired fallback.  */
-   return cpp_byte_column_to_display_column (line.get_buffer (), line.length (),
--					    exploc.column, tabstop);
-+					    exploc.column, policy);
- }
- 
- /* Dump statistics to stderr about the memory usage of the line_table
-@@ -3611,43 +3612,50 @@ test_line_offset_overflow ()
- void test_cpp_utf8 ()
- {
-   const int def_tabstop = 8;
-+  cpp_char_column_policy policy (def_tabstop, cpp_wcwidth);
-+
-   /* Verify that wcwidth of invalid UTF-8 or control bytes is 1.  */
-   {
--    int w_bad = cpp_display_width ("\xf0!\x9f!\x98!\x82!", 8, def_tabstop);
-+    int w_bad = cpp_display_width ("\xf0!\x9f!\x98!\x82!", 8, policy);
-     ASSERT_EQ (8, w_bad);
--    int w_ctrl = cpp_display_width ("\r\n\v\0\1", 5, def_tabstop);
-+    int w_ctrl = cpp_display_width ("\r\n\v\0\1", 5, policy);
-     ASSERT_EQ (5, w_ctrl);
-   }
- 
-   /* Verify that wcwidth of valid UTF-8 is as expected.  */
-   {
--    const int w_pi = cpp_display_width ("\xcf\x80", 2, def_tabstop);
-+    const int w_pi = cpp_display_width ("\xcf\x80", 2, policy);
-     ASSERT_EQ (1, w_pi);
--    const int w_emoji = cpp_display_width ("\xf0\x9f\x98\x82", 4, def_tabstop);
-+    const int w_emoji = cpp_display_width ("\xf0\x9f\x98\x82", 4, policy);
-     ASSERT_EQ (2, w_emoji);
-     const int w_umlaut_precomposed = cpp_display_width ("\xc3\xbf", 2,
--							def_tabstop);
-+							policy);
-     ASSERT_EQ (1, w_umlaut_precomposed);
-     const int w_umlaut_combining = cpp_display_width ("y\xcc\x88", 3,
--						      def_tabstop);
-+						      policy);
-     ASSERT_EQ (1, w_umlaut_combining);
--    const int w_han = cpp_display_width ("\xe4\xb8\xba", 3, def_tabstop);
-+    const int w_han = cpp_display_width ("\xe4\xb8\xba", 3, policy);
-     ASSERT_EQ (2, w_han);
--    const int w_ascii = cpp_display_width ("GCC", 3, def_tabstop);
-+    const int w_ascii = cpp_display_width ("GCC", 3, policy);
-     ASSERT_EQ (3, w_ascii);
-     const int w_mixed = cpp_display_width ("\xcf\x80 = 3.14 \xf0\x9f\x98\x82"
- 					   "\x9f! \xe4\xb8\xba y\xcc\x88",
--					   24, def_tabstop);
-+					   24, policy);
-     ASSERT_EQ (18, w_mixed);
-   }
- 
-   /* Verify that display width properly expands tabs.  */
-   {
-     const char *tstr = "\tabc\td";
--    ASSERT_EQ (6, cpp_display_width (tstr, 6, 1));
--    ASSERT_EQ (10, cpp_display_width (tstr, 6, 3));
--    ASSERT_EQ (17, cpp_display_width (tstr, 6, 8));
--    ASSERT_EQ (1, cpp_display_column_to_byte_column (tstr, 6, 7, 8));
-+    ASSERT_EQ (6, cpp_display_width (tstr, 6,
-+				     cpp_char_column_policy (1, cpp_wcwidth)));
-+    ASSERT_EQ (10, cpp_display_width (tstr, 6,
-+				      cpp_char_column_policy (3, cpp_wcwidth)));
-+    ASSERT_EQ (17, cpp_display_width (tstr, 6,
-+				      cpp_char_column_policy (8, cpp_wcwidth)));
-+    ASSERT_EQ (1,
-+	       cpp_display_column_to_byte_column
-+		 (tstr, 6, 7, cpp_char_column_policy (8, cpp_wcwidth)));
-   }
- 
-   /* Verify that cpp_byte_column_to_display_column can go past the end,
-@@ -3660,13 +3668,13 @@ void test_cpp_utf8 ()
-       /* 111122223456
- 	 Byte columns.  */
- 
--    ASSERT_EQ (5, cpp_display_width (str, 6, def_tabstop));
-+    ASSERT_EQ (5, cpp_display_width (str, 6, policy));
-     ASSERT_EQ (105,
--	       cpp_byte_column_to_display_column (str, 6, 106, def_tabstop));
-+	       cpp_byte_column_to_display_column (str, 6, 106, policy));
-     ASSERT_EQ (10000,
--	       cpp_byte_column_to_display_column (NULL, 0, 10000, def_tabstop));
-+	       cpp_byte_column_to_display_column (NULL, 0, 10000, policy));
-     ASSERT_EQ (0,
--	       cpp_byte_column_to_display_column (NULL, 10000, 0, def_tabstop));
-+	       cpp_byte_column_to_display_column (NULL, 10000, 0, policy));
-   }
- 
-   /* Verify that cpp_display_column_to_byte_column can go past the end,
-@@ -3680,25 +3688,25 @@ void test_cpp_utf8 ()
-       /* 000000000000000000000000000000000111111
- 	 111122223333444456666777788889999012345
- 	 Byte columns.  */
--    ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 2, def_tabstop));
-+    ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 2, policy));
-     ASSERT_EQ (15,
--	       cpp_display_column_to_byte_column (str, 15, 11, def_tabstop));
-+	       cpp_display_column_to_byte_column (str, 15, 11, policy));
-     ASSERT_EQ (115,
--	       cpp_display_column_to_byte_column (str, 15, 111, def_tabstop));
-+	       cpp_display_column_to_byte_column (str, 15, 111, policy));
-     ASSERT_EQ (10000,
--	       cpp_display_column_to_byte_column (NULL, 0, 10000, def_tabstop));
-+	       cpp_display_column_to_byte_column (NULL, 0, 10000, policy));
-     ASSERT_EQ (0,
--	       cpp_display_column_to_byte_column (NULL, 10000, 0, def_tabstop));
-+	       cpp_display_column_to_byte_column (NULL, 10000, 0, policy));
- 
-     /* Verify that we do not interrupt a UTF-8 sequence.  */
--    ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 1, def_tabstop));
-+    ASSERT_EQ (4, cpp_display_column_to_byte_column (str, 15, 1, policy));
- 
-     for (int byte_col = 1; byte_col <= 15; ++byte_col)
-       {
- 	const int disp_col
--	  = cpp_byte_column_to_display_column (str, 15, byte_col, def_tabstop);
-+	  = cpp_byte_column_to_display_column (str, 15, byte_col, policy);
- 	const int byte_col2
--	  = cpp_display_column_to_byte_column (str, 15, disp_col, def_tabstop);
-+	  = cpp_display_column_to_byte_column (str, 15, disp_col, policy);
- 
- 	/* If we ask for the display column in the middle of a UTF-8
- 	   sequence, it will return the length of the partial sequence,
-diff --git a/gcc/input.h b/gcc/input.h
---- a/gcc/input.h	2021-07-27 23:55:07.328287915 -0700
-+++ b/gcc/input.h	2021-12-14 01:16:01.553943061 -0800
-@@ -39,8 +39,11 @@ STATIC_ASSERT (BUILTINS_LOCATION < RESER
- extern bool is_location_from_builtin_token (location_t);
- extern expanded_location expand_location (location_t);
- 
--extern int location_compute_display_column (expanded_location exploc,
--					    int tabstop);
-+class cpp_char_column_policy;
-+
-+extern int
-+location_compute_display_column (expanded_location exploc,
-+				 const cpp_char_column_policy &policy);
- 
- /* A class capturing the bounds of a buffer, to allow for run-time
-    bounds-checking in a checked build.  */
-diff --git a/gcc/opts.c b/gcc/opts.c
---- a/gcc/opts.c	2021-07-27 23:55:07.364288417 -0700
-+++ b/gcc/opts.c	2021-12-14 01:16:01.553943061 -0800
-@@ -2573,6 +2573,10 @@ common_handle_option (struct gcc_options
-       dc->column_origin = value;
-       break;
- 
-+    case OPT_fdiagnostics_escape_format_:
-+      dc->escape_format = (enum diagnostics_escape_format)value;
-+      break;
-+
-     case OPT_fdiagnostics_show_cwe:
-       dc->show_cwe = value;
-       break;
-diff --git a/gcc/selftest.c b/gcc/selftest.c
---- a/gcc/selftest.c	2021-07-27 23:55:07.500290315 -0700
-+++ b/gcc/selftest.c	2021-12-14 01:16:01.557942991 -0800
-@@ -193,6 +193,21 @@ temp_source_file::temp_source_file (cons
-   fclose (out);
- }
- 
-+/* As above, but with a size, to allow for NUL bytes in CONTENT.  */
-+
-+temp_source_file::temp_source_file (const location &loc,
-+				    const char *suffix,
-+				    const char *content,
-+				    size_t sz)
-+: named_temp_file (suffix)
-+{
-+  FILE *out = fopen (get_filename (), "w");
-+  if (!out)
-+    fail_formatted (loc, "unable to open tempfile: %s", get_filename ());
-+  fwrite (content, sz, 1, out);
-+  fclose (out);
-+}
-+
- /* Avoid introducing locale-specific differences in the results
-    by hardcoding open_quote and close_quote.  */
- 
-diff --git a/gcc/selftest.h b/gcc/selftest.h
---- a/gcc/selftest.h	2021-07-27 23:55:07.500290315 -0700
-+++ b/gcc/selftest.h	2021-12-14 01:16:01.557942991 -0800
-@@ -112,6 +112,8 @@ class temp_source_file : public named_te
-  public:
-   temp_source_file (const location &loc, const char *suffix,
- 		    const char *content);
-+  temp_source_file (const location &loc, const char *suffix,
-+		    const char *content, size_t sz);
- };
- 
- /* RAII-style class for avoiding introducing locale-specific differences
-diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
---- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c	2021-07-27 23:55:07.596291654 -0700
-+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- /* { dg-regexp "\"kind\": \"error\"" } */
- /* { dg-regexp "\"column-origin\": 1" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- /* { dg-regexp "\"message\": \"#error message\"" } */
- 
- /* { dg-regexp "\"caret\": \{" } */
-diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
---- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c	2021-07-27 23:55:07.596291654 -0700
-+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- /* { dg-regexp "\"kind\": \"warning\"" } */
- /* { dg-regexp "\"column-origin\": 1" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- /* { dg-regexp "\"message\": \"#warning message\"" } */
- /* { dg-regexp "\"option\": \"-Wcpp\"" } */
- /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */
-diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
---- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c	2021-07-27 23:55:07.596291654 -0700
-+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- /* { dg-regexp "\"kind\": \"error\"" } */
- /* { dg-regexp "\"column-origin\": 1" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- /* { dg-regexp "\"message\": \"#warning message\"" } */
- /* { dg-regexp "\"option\": \"-Werror=cpp\"" } */
- /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wcpp\"" } */
-diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
---- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c	2021-07-27 23:55:07.596291654 -0700
-+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c	2021-12-14 01:16:01.557942991 -0800
-@@ -19,6 +19,7 @@ int test (void)
- 
- /* { dg-regexp "\"kind\": \"note\"" } */
- /* { dg-regexp "\"message\": \"...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'\"" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- 
- /* { dg-regexp "\"caret\": \{" } */
- /* { dg-regexp "\"file\": \"\[^\n\r\"\]*diagnostic-format-json-4.c\"" } */
-@@ -39,6 +40,7 @@ int test (void)
- /* { dg-regexp "\"kind\": \"warning\"" } */
- /* { dg-regexp "\"column-origin\": 1" } */
- /* { dg-regexp "\"message\": \"this 'if' clause does not guard...\"" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- /* { dg-regexp "\"option\": \"-Wmisleading-indentation\"" } */
- /* { dg-regexp "\"option_url\": \"https:\[^\n\r\"\]*#index-Wmisleading-indentation\"" } */
- 
-diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
---- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c	2021-07-27 23:55:07.596291654 -0700
-+++ b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c	2021-12-14 01:16:01.557942991 -0800
-@@ -14,6 +14,7 @@ int test (struct s *ptr)
- 
- /* { dg-regexp "\"kind\": \"error\"" } */
- /* { dg-regexp "\"column-origin\": 1" } */
-+/* { dg-regexp "\"escape-source\": false" } */
- /* { dg-regexp "\"message\": \".*\"" } */
- 
- /* Verify fix-it hints.  */
-diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c
---- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c	1969-12-31 16:00:00.000000000 -0800
-+++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-bytes.c	2021-12-14 01:16:01.557942991 -0800
-@@ -0,0 +1,21 @@
-+// { dg-do preprocess }
-+// { dg-options "-std=gnu99 -Werror=normalized=nfc -fdiagnostics-show-caret -fdiagnostics-escape-format=bytes" }
-+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-+
-+/* འ= U+0F43 TIBETAN LETTER GHA, which has decomposition "0F42 0FB7" i.e.
-+   U+0F42 TIBETAN LETTER GA: à½
-+   U+0FB7 TIBETAN SUBJOINED LETTER HA: ྷ
-+
-+   The UTF-8 encoding of U+0F43 TIBETAN LETTER GHA is: E0 BD 83.  */
-+
-+foo before_\u0F43_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." }
-+/* { dg-begin-multiline-output "" }
-+ foo before_\u0F43_after bar
-+     ^~~~~~~~~~~~~~~~~~~
-+   { dg-end-multiline-output "" } */
-+
-+foo before_à½_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." }
-+/* { dg-begin-multiline-output "" }
-+ foo before_<e0><bd><83>_after bar
-+     ^~~~~~~~~~~~~~~~~~~~~~~~~
-+   { dg-end-multiline-output "" } */
-diff --git a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c
---- a/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c	1969-12-31 16:00:00.000000000 -0800
-+++ b/gcc/testsuite/gcc.dg/cpp/warn-normalized-4-unicode.c	2021-12-14 01:16:01.557942991 -0800
-@@ -0,0 +1,19 @@
-+// { dg-do preprocess }
-+// { dg-options "-std=gnu99 -Werror=normalized=nfc -fdiagnostics-show-caret -fdiagnostics-escape-format=unicode" }
-+/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
-+
-+/* འ= U+0F43 TIBETAN LETTER GHA, which has decomposition "0F42 0FB7" i.e.
-+   U+0F42 TIBETAN LETTER GA: à½
-+   U+0FB7 TIBETAN SUBJOINED LETTER HA: ྷ  */
-+
-+foo before_\u0F43_after bar  // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." }
-+/* { dg-begin-multiline-output "" }
-+ foo before_\u0F43_after bar
-+     ^~~~~~~~~~~~~~~~~~~
-+   { dg-end-multiline-output "" } */
-+
-+foo before_à½_after bar // { dg-error "`before_.U00000f43_after' is not in NFC .-Werror=normalized=." }
-+/* { dg-begin-multiline-output "" }
-+ foo before_<U+0F43>_after bar
-+     ^~~~~~~~~~~~~~~~~~~~~
-+   { dg-end-multiline-output "" } */
-diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90
---- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90	2021-07-27 23:55:08.472303878 -0700
-+++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- ! { dg-regexp "\"kind\": \"error\"" }
- ! { dg-regexp "\"column-origin\": 1" }
-+! { dg-regexp "\"escape-source\": false" }
- ! { dg-regexp "\"message\": \"#error message\"" }
- 
- ! { dg-regexp "\"caret\": \{" }
-diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90
---- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90	2021-07-27 23:55:08.472303878 -0700
-+++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- ! { dg-regexp "\"kind\": \"warning\"" }
- ! { dg-regexp "\"column-origin\": 1" }
-+! { dg-regexp "\"escape-source\": false" }
- ! { dg-regexp "\"message\": \"#warning message\"" }
- ! { dg-regexp "\"option\": \"-Wcpp\"" }
- ! { dg-regexp "\"option_url\": \"\[^\n\r\"\]*#index-Wcpp\"" }
-diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90
---- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90	2021-07-27 23:55:08.472303878 -0700
-+++ b/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90	2021-12-14 01:16:01.557942991 -0800
-@@ -9,6 +9,7 @@
- 
- ! { dg-regexp "\"kind\": \"error\"" }
- ! { dg-regexp "\"column-origin\": 1" }
-+! { dg-regexp "\"escape-source\": false" }
- ! { dg-regexp "\"message\": \"#warning message\"" }
- ! { dg-regexp "\"option\": \"-Werror=cpp\"" }
- ! { dg-regexp "\"option_url\": \"\[^\n\r\"\]*#index-Wcpp\"" }
-diff --git a/libcpp/charset.c b/libcpp/charset.c
---- a/libcpp/charset.c	2021-07-27 23:55:08.712307227 -0700
-+++ b/libcpp/charset.c	2021-12-14 01:16:01.557942991 -0800
-@@ -1552,12 +1552,14 @@ convert_escape (cpp_reader *pfile, const
- 		   "unknown escape sequence: '\\%c'", (int) c);
-       else
- 	{
-+	  encoding_rich_location rich_loc (pfile);
-+
- 	  /* diagnostic.c does not support "%03o".  When it does, this
- 	     code can use %03o directly in the diagnostic again.  */
- 	  char buf[32];
- 	  sprintf(buf, "%03o", (int) c);
--	  cpp_error (pfile, CPP_DL_PEDWARN,
--		     "unknown escape sequence: '\\%s'", buf);
-+	  cpp_error_at (pfile, CPP_DL_PEDWARN, &rich_loc,
-+			"unknown escape sequence: '\\%s'", buf);
- 	}
-     }
- 
-@@ -2280,14 +2282,16 @@ cpp_string_location_reader::get_next ()
- }
- 
- cpp_display_width_computation::
--cpp_display_width_computation (const char *data, int data_length, int tabstop) :
-+cpp_display_width_computation (const char *data, int data_length,
-+			       const cpp_char_column_policy &policy) :
-   m_begin (data),
-   m_next (m_begin),
-   m_bytes_left (data_length),
--  m_tabstop (tabstop),
-+  m_policy (policy),
-   m_display_cols (0)
- {
--  gcc_assert (m_tabstop > 0);
-+  gcc_assert (policy.m_tabstop > 0);
-+  gcc_assert (policy.m_width_cb);
- }
- 
- 
-@@ -2299,19 +2303,28 @@ cpp_display_width_computation (const cha
-    point to a valid UTF-8-encoded sequence, then it will be treated as a single
-    byte with display width 1.  m_cur_display_col is the current display column,
-    relative to which tab stops should be expanded.  Returns the display width of
--   the codepoint just processed.  */
-+   the codepoint just processed.
-+   If OUT is non-NULL, it is populated.  */
- 
- int
--cpp_display_width_computation::process_next_codepoint ()
-+cpp_display_width_computation::process_next_codepoint (cpp_decoded_char *out)
- {
-   cppchar_t c;
-   int next_width;
- 
-+  if (out)
-+    out->m_start_byte = m_next;
-+
-   if (*m_next == '\t')
-     {
-       ++m_next;
-       --m_bytes_left;
--      next_width = m_tabstop - (m_display_cols % m_tabstop);
-+      next_width = m_policy.m_tabstop - (m_display_cols % m_policy.m_tabstop);
-+      if (out)
-+	{
-+	  out->m_ch = '\t';
-+	  out->m_valid_ch = true;
-+	}
-     }
-   else if (one_utf8_to_cppchar ((const uchar **) &m_next, &m_bytes_left, &c)
- 	   != 0)
-@@ -2321,14 +2334,24 @@ cpp_display_width_computation::process_n
- 	 of one.  */
-       ++m_next;
-       --m_bytes_left;
--      next_width = 1;
-+      next_width = m_policy.m_undecoded_byte_width;
-+      if (out)
-+	out->m_valid_ch = false;
-     }
-   else
-     {
-       /*  one_utf8_to_cppchar() has updated m_next and m_bytes_left for us.  */
--      next_width = cpp_wcwidth (c);
-+      next_width = m_policy.m_width_cb (c);
-+      if (out)
-+	{
-+	  out->m_ch = c;
-+	  out->m_valid_ch = true;
-+	}
-     }
- 
-+  if (out)
-+    out->m_next_byte = m_next;
-+
-   m_display_cols += next_width;
-   return next_width;
- }
-@@ -2344,7 +2367,7 @@ cpp_display_width_computation::advance_d
-   const int start = m_display_cols;
-   const int target = start + n;
-   while (m_display_cols < target && !done ())
--    process_next_codepoint ();
-+    process_next_codepoint (NULL);
-   return m_display_cols - start;
- }
- 
-@@ -2352,29 +2375,33 @@ cpp_display_width_computation::advance_d
-     how many display columns are occupied by the first COLUMN bytes.  COLUMN
-     may exceed DATA_LENGTH, in which case the phantom bytes at the end are
-     treated as if they have display width 1.  Tabs are expanded to the next tab
--    stop, relative to the start of DATA.  */
-+    stop, relative to the start of DATA, and non-printable-ASCII characters
-+    will be escaped as per POLICY.  */
- 
- int
- cpp_byte_column_to_display_column (const char *data, int data_length,
--				   int column, int tabstop)
-+				   int column,
-+				   const cpp_char_column_policy &policy)
- {
-   const int offset = MAX (0, column - data_length);
--  cpp_display_width_computation dw (data, column - offset, tabstop);
-+  cpp_display_width_computation dw (data, column - offset, policy);
-   while (!dw.done ())
--    dw.process_next_codepoint ();
-+    dw.process_next_codepoint (NULL);
-   return dw.display_cols_processed () + offset;
- }
- 
- /*  For the string of length DATA_LENGTH bytes that begins at DATA, compute
-     the least number of bytes that will result in at least DISPLAY_COL display
-     columns.  The return value may exceed DATA_LENGTH if the entire string does
--    not occupy enough display columns.  */
-+    not occupy enough display columns.  Non-printable-ASCII characters
-+    will be escaped as per POLICY.  */
- 
- int
- cpp_display_column_to_byte_column (const char *data, int data_length,
--				   int display_col, int tabstop)
-+				   int display_col,
-+				   const cpp_char_column_policy &policy)
- {
--  cpp_display_width_computation dw (data, data_length, tabstop);
-+  cpp_display_width_computation dw (data, data_length, policy);
-   const int avail_display = dw.advance_display_cols (display_col);
-   return dw.bytes_processed () + MAX (0, display_col - avail_display);
- }
-diff --git a/libcpp/errors.c b/libcpp/errors.c
---- a/libcpp/errors.c	2021-07-27 23:55:08.712307227 -0700
-+++ b/libcpp/errors.c	2021-12-14 01:16:01.557942991 -0800
-@@ -27,6 +27,31 @@ along with this program; see the file CO
- #include "cpplib.h"
- #include "internal.h"
- 
-+/* Get a location_t for the current location in PFILE,
-+   generally that of the previously lexed token.  */
-+
-+location_t
-+cpp_diagnostic_get_current_location (cpp_reader *pfile)
-+{
-+  if (CPP_OPTION (pfile, traditional))
-+    {
-+      if (pfile->state.in_directive)
-+	return pfile->directive_line;
-+      else
-+	return pfile->line_table->highest_line;
-+    }
-+  /* We don't want to refer to a token before the beginning of the
-+     current run -- that is invalid.  */
-+  else if (pfile->cur_token == pfile->cur_run->base)
-+    {
-+      return 0;
-+    }
-+  else
-+    {
-+      return pfile->cur_token[-1].src_loc;
-+    }
-+}
-+
- /* Print a diagnostic at the given location.  */
- 
- ATTRIBUTE_FPTR_PRINTF(5,0)
-@@ -52,25 +77,7 @@ cpp_diagnostic (cpp_reader * pfile, enum
- 		enum cpp_warning_reason reason,
- 		const char *msgid, va_list *ap)
- {
--  location_t src_loc;
--
--  if (CPP_OPTION (pfile, traditional))
--    {
--      if (pfile->state.in_directive)
--	src_loc = pfile->directive_line;
--      else
--	src_loc = pfile->line_table->highest_line;
--    }
--  /* We don't want to refer to a token before the beginning of the
--     current run -- that is invalid.  */
--  else if (pfile->cur_token == pfile->cur_run->base)
--    {
--      src_loc = 0;
--    }
--  else
--    {
--      src_loc = pfile->cur_token[-1].src_loc;
--    }
-+  location_t src_loc = cpp_diagnostic_get_current_location (pfile);
-   rich_location richloc (pfile->line_table, src_loc);
-   return cpp_diagnostic_at (pfile, level, reason, &richloc, msgid, ap);
- }
-@@ -142,6 +149,43 @@ cpp_warning_syshdr (cpp_reader * pfile,
- 
-   va_end (ap);
-   return ret;
-+}
-+
-+/* As cpp_warning above, but use RICHLOC as the location of the diagnostic.  */
-+
-+bool cpp_warning_at (cpp_reader *pfile, enum cpp_warning_reason reason,
-+		     rich_location *richloc, const char *msgid, ...)
-+{
-+  va_list ap;
-+  bool ret;
-+
-+  va_start (ap, msgid);
-+
-+  ret = cpp_diagnostic_at (pfile, CPP_DL_WARNING, reason, richloc,
-+			   msgid, &ap);
-+
-+  va_end (ap);
-+  return ret;
-+
-+}
-+
-+/* As cpp_pedwarning above, but use RICHLOC as the location of the
-+   diagnostic.  */
-+
-+bool
-+cpp_pedwarning_at (cpp_reader * pfile, enum cpp_warning_reason reason,
-+		   rich_location *richloc, const char *msgid, ...)
-+{
-+  va_list ap;
-+  bool ret;
-+
-+  va_start (ap, msgid);
-+
-+  ret = cpp_diagnostic_at (pfile, CPP_DL_PEDWARN, reason, richloc,
-+			   msgid, &ap);
-+
-+  va_end (ap);
-+  return ret;
- }
- 
- /* Print a diagnostic at a specific location.  */
-diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
---- a/libcpp/include/cpplib.h	2021-12-13 23:23:05.768437079 -0800
-+++ b/libcpp/include/cpplib.h	2021-12-14 01:20:16.189507386 -0800
-@@ -1275,6 +1275,14 @@ extern bool cpp_warning_syshdr (cpp_read
- 				const char *msgid, ...)
-   ATTRIBUTE_PRINTF_3;
- 
-+/* As their counterparts above, but use RICHLOC.  */
-+extern bool cpp_warning_at (cpp_reader *, enum cpp_warning_reason,
-+			    rich_location *richloc, const char *msgid, ...)
-+  ATTRIBUTE_PRINTF_4;
-+extern bool cpp_pedwarning_at (cpp_reader *, enum cpp_warning_reason,
-+			       rich_location *richloc, const char *msgid, ...)
-+  ATTRIBUTE_PRINTF_4;
-+
- /* Output a diagnostic with "MSGID: " preceding the
-    error string of errno.  No location is printed.  */
- extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
-@@ -1435,42 +1443,95 @@ extern const char * cpp_get_userdef_suff
- 
- /* In charset.c */
- 
-+/* The result of attempting to decode a run of UTF-8 bytes.  */
-+
-+struct cpp_decoded_char
-+{
-+  const char *m_start_byte;
-+  const char *m_next_byte;
-+
-+  bool m_valid_ch;
-+  cppchar_t m_ch;
-+};
-+
-+/* Information for mapping between code points and display columns.
-+
-+   This is a tabstop value, along with a callback for getting the
-+   widths of characters.  Normally this callback is cpp_wcwidth, but we
-+   support other schemes for escaping non-ASCII unicode as a series of
-+   ASCII chars when printing the user's source code in diagnostic-show-locus.c
-+
-+   For example, consider:
-+   - the Unicode character U+03C0 "GREEK SMALL LETTER PI" (UTF-8: 0xCF 0x80)
-+   - the Unicode character U+1F642 "SLIGHTLY SMILING FACE"
-+     (UTF-8: 0xF0 0x9F 0x99 0x82)
-+   - the byte 0xBF (a stray trailing byte of a UTF-8 character)
-+   Normally U+03C0 would occupy one display column, U+1F642
-+   would occupy two display columns, and the stray byte would be
-+   printed verbatim as one display column.
-+
-+   However when escaping them as unicode code points as "<U+03C0>"
-+   and "<U+1F642>" they occupy 8 and 9 display columns respectively,
-+   and when escaping them as bytes as "<CF><80>" and "<F0><9F><99><82>"
-+   they occupy 8 and 16 display columns respectively.  In both cases
-+   the stray byte is escaped to <BF> as 4 display columns.  */
-+
-+struct cpp_char_column_policy
-+{
-+  cpp_char_column_policy (int tabstop,
-+			  int (*width_cb) (cppchar_t c))
-+  : m_tabstop (tabstop),
-+    m_undecoded_byte_width (1),
-+    m_width_cb (width_cb)
-+  {}
-+
-+  int m_tabstop;
-+  /* Width in display columns of a stray byte that isn't decodable
-+     as UTF-8.  */
-+  int m_undecoded_byte_width;
-+  int (*m_width_cb) (cppchar_t c);
-+};
-+
- /* A class to manage the state while converting a UTF-8 sequence to cppchar_t
-    and computing the display width one character at a time.  */
- class cpp_display_width_computation {
-  public:
-   cpp_display_width_computation (const char *data, int data_length,
--				 int tabstop);
-+				 const cpp_char_column_policy &policy);
-   const char *next_byte () const { return m_next; }
-   int bytes_processed () const { return m_next - m_begin; }
-   int bytes_left () const { return m_bytes_left; }
-   bool done () const { return !bytes_left (); }
-   int display_cols_processed () const { return m_display_cols; }
- 
--  int process_next_codepoint ();
-+  int process_next_codepoint (cpp_decoded_char *out);
-   int advance_display_cols (int n);
- 
-  private:
-   const char *const m_begin;
-   const char *m_next;
-   size_t m_bytes_left;
--  const int m_tabstop;
-+  const cpp_char_column_policy &m_policy;
-   int m_display_cols;
- };
- 
- /* Convenience functions that are simple use cases for class
-    cpp_display_width_computation.  Tab characters will be expanded to spaces
--   as determined by TABSTOP.  */
-+   as determined by POLICY.m_tabstop, and non-printable-ASCII characters
-+   will be escaped as per POLICY.  */
-+
- int cpp_byte_column_to_display_column (const char *data, int data_length,
--				       int column, int tabstop);
-+				       int column,
-+				       const cpp_char_column_policy &policy);
- inline int cpp_display_width (const char *data, int data_length,
--			      int tabstop)
-+			      const cpp_char_column_policy &policy)
- {
-   return cpp_byte_column_to_display_column (data, data_length, data_length,
--					    tabstop);
-+					    policy);
- }
- int cpp_display_column_to_byte_column (const char *data, int data_length,
--				       int display_col, int tabstop);
-+				       int display_col,
-+				       const cpp_char_column_policy &policy);
- int cpp_wcwidth (cppchar_t c);
- 
- #endif /* ! LIBCPP_CPPLIB_H */
-diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
---- a/libcpp/include/line-map.h	2021-07-27 23:55:08.716307283 -0700
-+++ b/libcpp/include/line-map.h	2021-12-14 01:16:01.557942991 -0800
-@@ -1781,6 +1781,18 @@ class rich_location
-   const diagnostic_path *get_path () const { return m_path; }
-   void set_path (const diagnostic_path *path) { m_path = path; }
- 
-+  /* A flag for hinting that the diagnostic involves character encoding
-+     issues, and thus that it will be helpful to the user if we show some
-+     representation of how the characters in the pertinent source lines
-+     are encoded.
-+     The default is false (i.e. do not escape).
-+     When set to true, non-ASCII bytes in the pertinent source lines will
-+     be escaped in a manner controlled by the user-supplied option
-+     -fdiagnostics-escape-format=, so that the user can better understand
-+     what's going on with the encoding in their source file.  */
-+  bool escape_on_output_p () const { return m_escape_on_output; }
-+  void set_escape_on_output (bool flag) { m_escape_on_output = flag; }
-+
- private:
-   bool reject_impossible_fixit (location_t where);
-   void stop_supporting_fixits ();
-@@ -1807,6 +1819,7 @@ protected:
-   bool m_fixits_cannot_be_auto_applied;
- 
-   const diagnostic_path *m_path;
-+  bool m_escape_on_output;
- };
- 
- /* A struct for the result of range_label::get_text: a NUL-terminated buffer
-diff --git a/libcpp/internal.h b/libcpp/internal.h
---- a/libcpp/internal.h	2021-12-13 23:23:05.768437079 -0800
-+++ b/libcpp/internal.h	2021-12-14 01:16:01.557942991 -0800
-@@ -776,6 +776,9 @@ extern void _cpp_do_file_change (cpp_rea
- extern void _cpp_pop_buffer (cpp_reader *);
- extern char *_cpp_bracket_include (cpp_reader *);
- 
-+/* In errors.c  */
-+extern location_t cpp_diagnostic_get_current_location (cpp_reader *);
-+
- /* In traditional.c.  */
- extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *, bool);
- extern bool _cpp_read_logical_line_trad (cpp_reader *);
-@@ -942,6 +945,26 @@ int linemap_get_expansion_line (class li
- const char* linemap_get_expansion_filename (class line_maps *,
- 					    location_t);
- 
-+/* A subclass of rich_location for emitting a diagnostic
-+   at the current location of the reader, but flagging
-+   it with set_escape_on_output (true).  */
-+class encoding_rich_location : public rich_location
-+{
-+ public:
-+  encoding_rich_location (cpp_reader *pfile)
-+  : rich_location (pfile->line_table,
-+		   cpp_diagnostic_get_current_location (pfile))
-+  {
-+    set_escape_on_output (true);
-+  }
-+
-+  encoding_rich_location (cpp_reader *pfile, location_t loc)
-+  : rich_location (pfile->line_table, loc)
-+  {
-+    set_escape_on_output (true);
-+  }
-+};
-+
- #ifdef __cplusplus
- }
- #endif
-diff --git a/libcpp/lex.c b/libcpp/lex.c
---- a/libcpp/lex.c	2021-12-14 01:14:48.435225968 -0800
-+++ b/libcpp/lex.c	2021-12-14 01:24:37.220995816 -0800
-@@ -1774,7 +1774,11 @@ skip_whitespace (cpp_reader *pfile, cppc
-   while (is_nvspace (c));
- 
-   if (saw_NUL)
--    cpp_error (pfile, CPP_DL_WARNING, "null character(s) ignored");
-+    {
-+      encoding_rich_location rich_loc (pfile);
-+      cpp_error_at (pfile, CPP_DL_WARNING, &rich_loc,
-+		    "null character(s) ignored");
-+    }
- 
-   buffer->cur--;
- }
-@@ -1803,6 +1807,28 @@ warn_about_normalization (cpp_reader *pf
-   if (CPP_OPTION (pfile, warn_normalize) < NORMALIZE_STATE_RESULT (s)
-       && !pfile->state.skipping)
-     {
-+      location_t loc = token->src_loc;
-+
-+      /* If possible, create a location range for the token.  */
-+      if (loc >= RESERVED_LOCATION_COUNT
-+	  && token->type != CPP_EOF
-+	  /* There must be no line notes to process.  */
-+	  && (!(pfile->buffer->cur
-+		>= pfile->buffer->notes[pfile->buffer->cur_note].pos
-+		&& !pfile->overlaid_buffer)))
-+	{
-+	  source_range tok_range;
-+	  tok_range.m_start = loc;
-+	  tok_range.m_finish
-+	    = linemap_position_for_column (pfile->line_table,
-+					   CPP_BUF_COLUMN (pfile->buffer,
-+							   pfile->buffer->cur));
-+	  loc = COMBINE_LOCATION_DATA (pfile->line_table,
-+				       loc, tok_range, NULL);
-+	}
-+
-+      encoding_rich_location rich_loc (pfile, loc);
-+
-       /* Make sure that the token is printed using UCNs, even
- 	 if we'd otherwise happily print UTF-8.  */
-       unsigned char *buf = XNEWVEC (unsigned char, cpp_token_len (token));
-@@ -1810,11 +1836,11 @@ warn_about_normalization (cpp_reader *pf
- 
-       sz = cpp_spell_token (pfile, token, buf, false) - buf;
-       if (NORMALIZE_STATE_RESULT (s) == normalized_C)
--	cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0,
--			       "`%.*s' is not in NFKC", (int) sz, buf);
-+	cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc,
-+			"`%.*s' is not in NFKC", (int) sz, buf);
-       else
--	cpp_warning_with_line (pfile, CPP_W_NORMALIZE, token->src_loc, 0,
--			       "`%.*s' is not in NFC", (int) sz, buf);
-+	cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc,
-+			"`%.*s' is not in NFC", (int) sz, buf);
-       free (buf);
-     }
- }
-diff --git a/libcpp/line-map.c b/libcpp/line-map.c
---- a/libcpp/line-map.c	2021-07-27 23:55:08.716307283 -0700
-+++ b/libcpp/line-map.c	2021-12-14 01:16:01.561942921 -0800
-@@ -2086,7 +2086,8 @@ rich_location::rich_location (line_maps
-   m_fixit_hints (),
-   m_seen_impossible_fixit (false),
-   m_fixits_cannot_be_auto_applied (false),
--  m_path (NULL)
-+  m_path (NULL),
-+  m_escape_on_output (false)
- {
-   add_range (loc, SHOW_RANGE_WITH_CARET, label);
- }
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-46195.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-46195.patch
deleted file mode 100644
index 7b3651c..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-CVE-2021-46195.patch
+++ /dev/null
@@ -1,128 +0,0 @@
-From f10bec5ffa487ad3033ed5f38cfd0fc7d696deab Mon Sep 17 00:00:00 2001
-From: Nick Clifton <nickc@redhat.com>
-Date: Mon, 31 Jan 2022 14:28:42 +0000
-Subject: [PATCH] libiberty: Fix infinite recursion in rust demangler.
-
-libiberty/
-	PR demangler/98886
-	PR demangler/99935
-	* rust-demangle.c (struct rust_demangler): Add a recursion
-	counter.
-	(demangle_path): Increment/decrement the recursion counter upon
-	entry and exit.  Fail if the counter exceeds a fixed limit.
-	(demangle_type): Likewise.
-	(rust_demangle_callback): Initialise the recursion counter,
-	disabling if requested by the option flags.
-
-CVE: CVE-2021-46195
-Upstream-Status: Backport
-[https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=f10bec5ffa487ad3033ed5f38cfd0fc7d696deab]
-Signed-off-by: Pgowda <pgowda.cve@gmail.com>
----
- libiberty/rust-demangle.c | 47 ++++++++++++++++++++++++++++++++++-----
- 1 file changed, 41 insertions(+), 6 deletions(-)
-
-diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
-index 18c760491bd..3b24d63892a 100644
---- a/libiberty/rust-demangle.c
-+++ b/libiberty/rust-demangle.c
-@@ -74,6 +74,12 @@ struct rust_demangler
-   /* Rust mangling version, with legacy mangling being -1. */
-   int version;
- 
-+  /* Recursion depth.  */
-+  unsigned int recursion;
-+  /* Maximum number of times demangle_path may be called recursively.  */
-+#define RUST_MAX_RECURSION_COUNT  1024
-+#define RUST_NO_RECURSION_LIMIT   ((unsigned int) -1)
-+
-   uint64_t bound_lifetime_depth;
- };
- 
-@@ -671,6 +677,15 @@ demangle_path (struct rust_demangler *rdm, int in_value)
-   if (rdm->errored)
-     return;
- 
-+  if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
-+    {
-+      ++ rdm->recursion;
-+      if (rdm->recursion > RUST_MAX_RECURSION_COUNT)
-+	/* FIXME: There ought to be a way to report
-+	   that the recursion limit has been reached.  */
-+	goto fail_return;
-+    }
-+
-   switch (tag = next (rdm))
-     {
-     case 'C':
-@@ -688,10 +703,7 @@ demangle_path (struct rust_demangler *rdm, int in_value)
-     case 'N':
-       ns = next (rdm);
-       if (!ISLOWER (ns) && !ISUPPER (ns))
--        {
--          rdm->errored = 1;
--          return;
--        }
-+	goto fail_return;
- 
-       demangle_path (rdm, in_value);
- 
-@@ -776,9 +788,15 @@ demangle_path (struct rust_demangler *rdm, int in_value)
-         }
-       break;
-     default:
--      rdm->errored = 1;
--      return;
-+      goto fail_return;
-     }
-+  goto pass_return;
-+
-+ fail_return:
-+  rdm->errored = 1;
-+ pass_return:
-+  if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
-+    -- rdm->recursion;
- }
- 
- static void
-@@ -870,6 +888,19 @@ demangle_type (struct rust_demangler *rdm)
-       return;
-     }
- 
-+   if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
-+    {
-+      ++ rdm->recursion;
-+      if (rdm->recursion > RUST_MAX_RECURSION_COUNT)
-+	/* FIXME: There ought to be a way to report
-+	   that the recursion limit has been reached.  */
-+	{
-+	  rdm->errored = 1;
-+	  -- rdm->recursion;
-+	  return;
-+	}
-+    }
-+
-   switch (tag)
-     {
-     case 'R':
-@@ -1030,6 +1061,9 @@ demangle_type (struct rust_demangler *rdm)
-       rdm->next--;
-       demangle_path (rdm, 0);
-     }
-+
-+  if (rdm->recursion != RUST_NO_RECURSION_LIMIT)
-+    -- rdm->recursion;
- }
- 
- /* A trait in a trait object may have some "existential projections"
-@@ -1320,6 +1354,7 @@ rust_demangle_callback (const char *mangled, int options,
-   rdm.skipping_printing = 0;
-   rdm.verbose = (options & DMGL_VERBOSE) != 0;
-   rdm.version = 0;
-+  rdm.recursion = (options & DMGL_NO_RECURSE_LIMIT) ? RUST_NO_RECURSION_LIMIT : 0;
-   rdm.bound_lifetime_depth = 0;
- 
-   /* Rust symbols always start with _R (v0) or _ZN (legacy). */
--- 
-2.27.0
-
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-CVE-2021-42574.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-CVE-2021-42574.patch
deleted file mode 100644
index 9bad81d..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-CVE-2021-42574.patch
+++ /dev/null
@@ -1,1765 +0,0 @@
-From 51c500269bf53749b107807d84271385fad35628 Mon Sep 17 00:00:00 2001
-From: Marek Polacek <polacek@redhat.com>
-Date: Wed, 6 Oct 2021 14:33:59 -0400
-Subject: [PATCH] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]
-
-From a link below:
-"An issue was discovered in the Bidirectional Algorithm in the Unicode
-Specification through 14.0. It permits the visual reordering of
-characters via control sequences, which can be used to craft source code
-that renders different logic than the logical ordering of tokens
-ingested by compilers and interpreters. Adversaries can leverage this to
-encode source code for compilers accepting Unicode such that targeted
-vulnerabilities are introduced invisibly to human reviewers."
-
-More info:
-https://nvd.nist.gov/vuln/detail/CVE-2021-42574
-https://trojansource.codes/
-
-This is not a compiler bug.  However, to mitigate the problem, this patch
-implements -Wbidi-chars=[none|unpaired|any] to warn about possibly
-misleading Unicode bidirectional control characters the preprocessor may
-encounter.
-
-The default is =unpaired, which warns about improperly terminated
-bidirectional control characters; e.g. a LRE without its corresponding PDF.
-The level =any warns about any use of bidirectional control characters.
-
-This patch handles both UCNs and UTF-8 characters.  UCNs designating
-bidi characters in identifiers are accepted since r204886.  Then r217144
-enabled -fextended-identifiers by default.  Extended characters in C/C++
-identifiers have been accepted since r275979.  However, this patch still
-warns about mixing UTF-8 and UCN bidi characters; there seems to be no
-good reason to allow mixing them.
-
-We warn in different contexts: comments (both C and C++-style), string
-literals, character constants, and identifiers.  Expectedly, UCNs are ignored
-in comments and raw string literals.  The bidirectional control characters
-can nest so this patch handles that as well.
-
-I have not included nor tested this at all with Fortran (which also has
-string literals and line comments).
-
-Dave M. posted patches improving diagnostic involving Unicode characters.
-This patch does not make use of this new infrastructure yet.
-
-	PR preprocessor/103026
-
-gcc/c-family/ChangeLog:
-
-	* c.opt (Wbidi-chars, Wbidi-chars=): New option.
-
-gcc/ChangeLog:
-
-	* doc/invoke.texi: Document -Wbidi-chars.
-
-libcpp/ChangeLog:
-
-	* include/cpplib.h (enum cpp_bidirectional_level): New.
-	(struct cpp_options): Add cpp_warn_bidirectional.
-	(enum cpp_warning_reason): Add CPP_W_BIDIRECTIONAL.
-	* internal.h (struct cpp_reader): Add warn_bidi_p member
-	function.
-	* init.c (cpp_create_reader): Set cpp_warn_bidirectional.
-	* lex.c (bidi): New namespace.
-	(get_bidi_utf8): New function.
-	(get_bidi_ucn): Likewise.
-	(maybe_warn_bidi_on_close): Likewise.
-	(maybe_warn_bidi_on_char): Likewise.
-	(_cpp_skip_block_comment): Implement warning about bidirectional
-	control characters.
-	(skip_line_comment): Likewise.
-	(forms_identifier_p): Likewise.
-	(lex_identifier): Likewise.
-	(lex_string): Likewise.
-	(lex_raw_string): Likewise.
-
-gcc/testsuite/ChangeLog:
-
-	* c-c++-common/Wbidi-chars-1.c: New test.
-	* c-c++-common/Wbidi-chars-2.c: New test.
-	* c-c++-common/Wbidi-chars-3.c: New test.
-	* c-c++-common/Wbidi-chars-4.c: New test.
-	* c-c++-common/Wbidi-chars-5.c: New test.
-	* c-c++-common/Wbidi-chars-6.c: New test.
-	* c-c++-common/Wbidi-chars-7.c: New test.
-	* c-c++-common/Wbidi-chars-8.c: New test.
-	* c-c++-common/Wbidi-chars-9.c: New test.
-	* c-c++-common/Wbidi-chars-10.c: New test.
-	* c-c++-common/Wbidi-chars-11.c: New test.
-	* c-c++-common/Wbidi-chars-12.c: New test.
-	* c-c++-common/Wbidi-chars-13.c: New test.
-	* c-c++-common/Wbidi-chars-14.c: New test.
-	* c-c++-common/Wbidi-chars-15.c: New test.
-	* c-c++-common/Wbidi-chars-16.c: New test.
-	* c-c++-common/Wbidi-chars-17.c: New test.
-
-CVE: CVE-2021-42574
-Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=51c500269bf53749b107807d84271385fad35628]
-Signed-off-by: Pgowda <pgowda.cve@gmail.com>
-
----
- gcc/c-family/c.opt                          |  24 ++
- gcc/doc/invoke.texi                         |  21 +-
- gcc/testsuite/c-c++-common/Wbidi-chars-1.c  |  12 +
- gcc/testsuite/c-c++-common/Wbidi-chars-10.c |  27 ++
- gcc/testsuite/c-c++-common/Wbidi-chars-11.c |  13 +
- gcc/testsuite/c-c++-common/Wbidi-chars-12.c |  19 +
- gcc/testsuite/c-c++-common/Wbidi-chars-13.c |  17 +
- gcc/testsuite/c-c++-common/Wbidi-chars-14.c |  38 ++
- gcc/testsuite/c-c++-common/Wbidi-chars-15.c |  59 +++
- gcc/testsuite/c-c++-common/Wbidi-chars-16.c |  26 ++
- gcc/testsuite/c-c++-common/Wbidi-chars-17.c |  30 ++
- gcc/testsuite/c-c++-common/Wbidi-chars-2.c  |   9 +
- gcc/testsuite/c-c++-common/Wbidi-chars-3.c  |  11 +
- gcc/testsuite/c-c++-common/Wbidi-chars-4.c  | 188 +++++++++
- gcc/testsuite/c-c++-common/Wbidi-chars-5.c  | 188 +++++++++
- gcc/testsuite/c-c++-common/Wbidi-chars-6.c  | 155 ++++++++
- gcc/testsuite/c-c++-common/Wbidi-chars-7.c  |   9 +
- gcc/testsuite/c-c++-common/Wbidi-chars-8.c  |  13 +
- gcc/testsuite/c-c++-common/Wbidi-chars-9.c  |  29 ++
- libcpp/include/cpplib.h                     |  18 +-
- libcpp/init.c                               |   1 +
- libcpp/internal.h                           |   7 +
- libcpp/lex.c                                | 408 +++++++++++++++++++-
- 23 files changed, 1315 insertions(+), 7 deletions(-)
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-1.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-10.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-11.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-12.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-13.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-14.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-15.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-16.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-17.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-2.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-3.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-4.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-5.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-6.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-7.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-8.c
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-9.c
-
-diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
-index 8a4cd634f77..3976fc368db 100644
---- a/gcc/c-family/c.opt
-+++ b/gcc/c-family/c.opt
-@@ -370,6 +370,30 @@ Wbad-function-cast
- C ObjC Var(warn_bad_function_cast) Warning
- Warn about casting functions to incompatible types.
- 
-+Wbidi-chars
-+C ObjC C++ ObjC++ Warning Alias(Wbidi-chars=,any,none)
-+;
-+
-+Wbidi-chars=
-+C ObjC C++ ObjC++ RejectNegative Joined Warning CPP(cpp_warn_bidirectional) CppReason(CPP_W_BIDIRECTIONAL) Var(warn_bidirectional) Init(bidirectional_unpaired) Enum(cpp_bidirectional_level)
-+-Wbidi-chars=[none|unpaired|any] Warn about UTF-8 bidirectional control characters.
-+
-+; Required for these enum values.
-+SourceInclude
-+cpplib.h
-+
-+Enum
-+Name(cpp_bidirectional_level) Type(int) UnknownError(argument %qs to %<-Wbidi-chars%> not recognized)
-+
-+EnumValue
-+Enum(cpp_bidirectional_level) String(none) Value(bidirectional_none)
-+
-+EnumValue
-+Enum(cpp_bidirectional_level) String(unpaired) Value(bidirectional_unpaired)
-+
-+EnumValue
-+Enum(cpp_bidirectional_level) String(any) Value(bidirectional_any)
-+
- Wbool-compare
- C ObjC C++ ObjC++ Var(warn_bool_compare) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
- Warn about boolean expression compared with an integer value different from true/false.
-diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index 6070288856c..a22758d18ee 100644
---- a/gcc/doc/invoke.texi
-+++ b/gcc/doc/invoke.texi
-@@ -326,7 +326,9 @@ Objective-C and Objective-C++ Dialects}.
- -Warith-conversion @gol
- -Warray-bounds  -Warray-bounds=@var{n} @gol
- -Wno-attributes  -Wattribute-alias=@var{n} -Wno-attribute-alias @gol
---Wno-attribute-warning  -Wbool-compare  -Wbool-operation @gol
-+-Wno-attribute-warning  @gol
-+-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]} @gol
-+-Wbool-compare  -Wbool-operation @gol
- -Wno-builtin-declaration-mismatch @gol
- -Wno-builtin-macro-redefined  -Wc90-c99-compat  -Wc99-c11-compat @gol
- -Wc11-c2x-compat @gol
-@@ -7559,6 +7561,23 @@ Attributes considered include @code{allo
- This is the default.  You can disable these warnings with either
- @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
- 
-+@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{]}
-+@opindex Wbidi-chars=
-+@opindex Wbidi-chars
-+@opindex Wno-bidi-chars
-+Warn about possibly misleading UTF-8 bidirectional control characters in
-+comments, string literals, character constants, and identifiers.  Such
-+characters can change left-to-right writing direction into right-to-left
-+(and vice versa), which can cause confusion between the logical order and
-+visual order.  This may be dangerous; for instance, it may seem that a piece
-+of code is not commented out, whereas it in fact is.
-+
-+There are three levels of warning supported by GCC@.  The default is
-+@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
-+bidi contexts.  @option{-Wbidi-chars=none} turns the warning off.
-+@option{-Wbidi-chars=any} warns about any use of bidirectional control
-+characters.
-+
- @item -Wbool-compare
- @opindex Wno-bool-compare
- @opindex Wbool-compare
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-10.c b/gcc/testsuite/c-c++-common/Wbidi-chars-10.c
-new file mode 100644
-index 00000000000..34f5ac19271
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-10.c
-@@ -0,0 +1,27 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* More nesting testing.  */
-+
-+/* RLEâ« LRI⦠PDF⬠PDIâ©*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int LRE_\u202a_PDF_\u202c;
-+int LRE_\u202a_PDF_\u202c_LRE_\u202a_PDF_\u202c;
-+int LRE_\u202a_LRI_\u2066_PDF_\u202c_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLE_\u202b_RLI_\u2067_PDF_\u202c_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLE_\u202b_RLI_\u2067_PDI_\u2069_PDF_\u202c;
-+int FSI_\u2068_LRO_\u202d_PDI_\u2069_PDF_\u202c;
-+int FSI_\u2068;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int FSI_\u2068_PDI_\u2069;
-+int FSI_\u2068_FSI_\u2068_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069;
-+int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDF_\u202c;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLI_\u2067_RLI_\u2067_RLI_\u2067_RLI_\u2067_FSI_\u2068_PDI_\u2069_PDI_\u2069_PDI_\u2069_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-11.c b/gcc/testsuite/c-c++-common/Wbidi-chars-11.c
-new file mode 100644
-index 00000000000..270ce2368a9
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-11.c
-@@ -0,0 +1,13 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test that we warn when mixing UCN and UTF-8.  */
-+
-+int LRE_âª_PDF_\u202c;
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-+int LRE_\u202a_PDF_â¬_;
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-+const char *s1 = "LRE_âª_PDF_\u202c";
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-+const char *s2 = "LRE_\u202a_PDF_â¬";
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-12.c b/gcc/testsuite/c-c++-common/Wbidi-chars-12.c
-new file mode 100644
-index 00000000000..b07eec1da91
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-12.c
-@@ -0,0 +1,19 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile { target { c || c++11 } } } */
-+/* { dg-options "-Wbidi-chars=any" } */
-+/* Test raw strings.  */
-+
-+const char *s1 = R"(a b c LRE⪠1 2 3 PDF⬠x y z)";
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+const char *s2 = R"(a b c RLE⫠1 2 3 PDF⬠x y z)";
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+const char *s3 = R"(a b c LRO⭠1 2 3 PDF⬠x y z)";
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+const char *s4 = R"(a b c RLO⮠1 2 3 PDF⬠x y z)";
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+const char *s7 = R"(a b c FSI⨠1 2 3 PDI⩠x y) z";
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+const char *s8 = R"(a b c PDIâ© x y )z";
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-+const char *s9 = R"(a b c PDF⬠x y z)";
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-diff -uprN '-x*.orig' '-x*.rej' del/gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c
---- del/gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c	1969-12-31 16:00:00.000000000 -0800
-+++ gcc-11.2.0/gcc/testsuite/c-c++-common/Wbidi-chars-13.c	2021-12-13 23:11:22.328439287 -0800
-@@ -0,0 +1,17 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile { target { c || c++11 } } } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test raw strings.  */
-+
-+const char *s1 = R"(a b c LRE⪠1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s2 = R"(a b c RLEâ« 1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s3 = R"(a b c LROâ­ 1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s4 = R"(a b c FSI⨠1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s5 = R"(a b c LRI⦠1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s6 = R"(a b c RLI⧠1 2 3)";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-14.c b/gcc/testsuite/c-c++-common/Wbidi-chars-14.c
-new file mode 100644
-index 00000000000..ba5f75d9553
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-14.c
-@@ -0,0 +1,38 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test PDI handling, which also pops any subsequent LREs, RLEs, LROs,
-+   or RLOs.  */
-+
-+/* LRI_â¦_LRI_â¦_RLE_â«_RLE_â«_RLE_â«_PDI_â©*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// LRI_â¦_RLE_â«_RLE_â«_RLE_â«_PDI_â©
-+// LRI_â¦_RLO_â®_RLE_â«_RLE_â«_PDI_â©
-+// LRI_â¦_RLO_â®_RLE_â«_PDI_â©
-+// FSI_â¨_RLO_â®_PDI_â©
-+// FSI_â¨_FSI_â¨_RLO_â®_PDI_â©
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+int LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069_PDI_\u2069;
-+int LRI_\u2066_LRI_\u2066_LRI_\u2066_LRE_\u202a_LRE_\u202a_LRE_\u202a_PDI_\u2069_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int PDI_\u2069;
-+int LRI_\u2066_PDI_\u2069;
-+int RLI_\u2067_PDI_\u2069;
-+int LRE_\u202a_LRI_\u2066_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int LRI_\u2066_LRE_\u202a_PDF_\u202c_PDI_\u2069;
-+int LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069;
-+int RLI_\u2067_LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int FSI_\u2068_LRI_\u2066_LRE_\u202a_LRE_\u202a_PDF_\u202c_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLO_\u202e_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int RLI_\u2067_PDI_\u2069_RLI_\u2067;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int FSI_\u2068_PDF_\u202c_PDI_\u2069;
-+int FSI_\u2068_FSI_\u2068_PDF_\u202c_PDI_\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-15.c b/gcc/testsuite/c-c++-common/Wbidi-chars-15.c
-new file mode 100644
-index 00000000000..a0ce8ff5e2c
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-15.c
-@@ -0,0 +1,59 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test unpaired bidi control chars in multiline comments.  */
-+
-+/*
-+ * LRE⪠end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * RLEâ« end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * LROâ­ end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * RLOâ® end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * LRI⦠end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * RLI⧠end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/*
-+ * FSI⨠end
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/* LREâª
-+   PDF⬠*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+/* FSIâ¨
-+   PDIâ© */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+
-+/* LRE<âª>
-+ *
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-3 } */
-+
-+/*
-+ * LRE<âª>
-+ */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+
-+/*
-+ *
-+ * LRE<âª> */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+/* RLI<â§> */ /* PDI<â©> */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* LRE<âª> */ /* PDF<â¬> */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-16.c b/gcc/testsuite/c-c++-common/Wbidi-chars-16.c
-new file mode 100644
-index 00000000000..baa0159861c
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-16.c
-@@ -0,0 +1,26 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=any" } */
-+/* Test LTR/RTL chars.  */
-+
-+/* LTR<â> */
-+/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */
-+// LTR<â>
-+/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */
-+/* RTL<â> */
-+/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */
-+// RTL<â>
-+/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */
-+
-+const char *s1 = "LTR<â>";
-+/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */
-+const char *s2 = "LTR\u200e";
-+/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */
-+const char *s3 = "LTR\u200E";
-+/* { dg-warning "U\\+200E" "" { target *-*-* } .-1 } */
-+const char *s4 = "RTL<â>";
-+/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */
-+const char *s5 = "RTL\u200f";
-+/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */
-+const char *s6 = "RTL\u200F";
-+/* { dg-warning "U\\+200F" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-17.c b/gcc/testsuite/c-c++-common/Wbidi-chars-17.c
-new file mode 100644
-index 00000000000..07cb4321f96
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-17.c
-@@ -0,0 +1,30 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test LTR/RTL chars.  */
-+
-+/* LTR<â> */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// LTR<â>
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* RTL<â> */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// RTL<â>
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int ltr_\u200e;
-+/* { dg-error "universal character " "" { target *-*-* } .-1 } */
-+int rtl_\u200f;
-+/* { dg-error "universal character " "" { target *-*-* } .-1 } */
-+
-+const char *s1 = "LTR<â>";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+const char *s2 = "LTR\u200e";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+const char *s3 = "LTR\u200E";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+const char *s4 = "RTL<â>";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+const char *s5 = "RTL\u200f";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+const char *s6 = "RTL\u200F";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-1.c b/gcc/testsuite/c-c++-common/Wbidi-chars-1.c
-new file mode 100644
-index 00000000000..2340374f276
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-1.c
-@@ -0,0 +1,12 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+
-+int main() {
-+    int isAdmin = 0;
-+    /*â® } â¦if (isAdmin)⩠⦠begin admins only */
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+        __builtin_printf("You are an admin.\n");
-+    /* end admins only â® { â¦*/
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+    return 0;
-+}
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-2.c b/gcc/testsuite/c-c++-common/Wbidi-chars-2.c
-new file mode 100644
-index 00000000000..2340374f276
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-2.c
-@@ -0,0 +1,9 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+
-+int main() {
-+    /* Say hello; newlineâ§/*/ return 0 ;
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+    __builtin_printf("Hello world.\n");
-+    return 0;
-+}
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-3.c b/gcc/testsuite/c-c++-common/Wbidi-chars-3.c
-new file mode 100644
-index 00000000000..9dc7edb6e64
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-3.c
-@@ -0,0 +1,11 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+
-+int main() {
-+    const char* access_level = "user";
-+    if (__builtin_strcmp(access_level, "userâ® â¦// Check if adminâ© â¦")) {
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+        __builtin_printf("You are an admin.\n");
-+    }
-+    return 0;
-+}
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-4.c b/gcc/testsuite/c-c++-common/Wbidi-chars-4.c
-new file mode 100644
-index 00000000000..639e5c62e88
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-4.c
-@@ -0,0 +1,188 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=any -Wno-multichar -Wno-overflow" } */
-+/* Test all bidi chars in various contexts (identifiers, comments,
-+   string literals, character constants), both UCN and UTF-8.  The bidi
-+   chars here are properly terminated, except for the character constants.  */
-+
-+/* a b c LRE⪠1 2 3 PDF⬠x y z */
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+/* a b c RLE⫠1 2 3 PDF⬠x y z */
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+/* a b c LRO⭠1 2 3 PDF⬠x y z */
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+/* a b c RLO⮠1 2 3 PDF⬠x y z */
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+/* a b c LRI⦠1 2 3 PDI⩠x y z */
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+/* a b c RLI⧠1 2 3 PDI⩠x y */
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+/* a b c FSI⨠1 2 3 PDI⩠x y z */
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+
-+/* Same but C++ comments instead.  */
-+// a b c LRE⪠1 2 3 PDF⬠x y z
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+// a b c RLE⫠1 2 3 PDF⬠x y z
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+// a b c LRO⭠1 2 3 PDF⬠x y z
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+// a b c RLO⮠1 2 3 PDF⬠x y z
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+// a b c LRI⦠1 2 3 PDI⩠x y z
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+// a b c RLI⧠1 2 3 PDI⩠x y
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+// a b c FSI⨠1 2 3 PDI⩠x y z
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+
-+/* Here we're closing an unopened context, warn when =any.  */
-+/* a b c PDIâ© x y z */
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-+/* a b c PDF⬠x y z */
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+// a b c PDIâ© x y z
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-+// a b c PDF⬠x y z
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+
-+/* Multiline comments.  */
-+/* a b c PDIâ© x y z
-+   */
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-2 } */
-+/* a b c PDF⬠x y z
-+   */
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDIâ© x y z
-+   */
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDF⬠x y z
-+   */
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDIâ© x y z */
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-+/* first
-+   a b c PDF⬠x y z */
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+
-+void
-+g1 ()
-+{
-+  const char *s1 = "a b c LRE⪠1 2 3 PDF⬠x y z";
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+  const char *s2 = "a b c RLE⫠1 2 3 PDF⬠x y z";
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+  const char *s3 = "a b c LRO⭠1 2 3 PDF⬠x y z";
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+  const char *s4 = "a b c RLO⮠1 2 3 PDF⬠x y z";
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+  const char *s5 = "a b c LRI⦠1 2 3 PDI⩠x y z";
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+  const char *s6 = "a b c RLI⧠1 2 3 PDI⩠x y z";
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+  const char *s7 = "a b c FSI⨠1 2 3 PDI⩠x y z";
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+  const char *s8 = "a b c PDIâ© x y z";
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-+  const char *s9 = "a b c PDF⬠x y z";
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+
-+  const char *s10 = "a b c LRE\u202a 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+  const char *s11 = "a b c LRE\u202A 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+  const char *s12 = "a b c RLE\u202b 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+  const char *s13 = "a b c RLE\u202B 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+  const char *s14 = "a b c LRO\u202d 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+  const char *s15 = "a b c LRO\u202D 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+  const char *s16 = "a b c RLO\u202e 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+  const char *s17 = "a b c RLO\u202E 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+  const char *s18 = "a b c LRI\u2066 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+  const char *s19 = "a b c RLI\u2067 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+  const char *s20 = "a b c FSI\u2068 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+}
-+
-+void
-+g2 ()
-+{
-+  const char c1 = '\u202a';
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+  const char c2 = '\u202A';
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+  const char c3 = '\u202b';
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+  const char c4 = '\u202B';
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+  const char c5 = '\u202d';
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+  const char c6 = '\u202D';
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+  const char c7 = '\u202e';
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+  const char c8 = '\u202E';
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+  const char c9 = '\u2066';
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+  const char c10 = '\u2067';
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+  const char c11 = '\u2068';
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+}
-+
-+int aâªbâ¬c;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int aâ«bâ¬c;
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+int aâ­bâ¬c;
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+int aâ®bâ¬c;
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+int aâ¦bâ©c;
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+int aâ§bâ©c;
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+int aâ¨bâ©c;
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+int Aâ¬X;
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+int A\u202cY;
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+int A\u202CY2;
-+/* { dg-warning "U\\+202C" "" { target *-*-* } .-1 } */
-+
-+int d\u202ae\u202cf;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int d\u202Ae\u202cf2;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int d\u202be\u202cf;
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+int d\u202Be\u202cf2;
-+/* { dg-warning "U\\+202B" "" { target *-*-* } .-1 } */
-+int d\u202de\u202cf;
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+int d\u202De\u202cf2;
-+/* { dg-warning "U\\+202D" "" { target *-*-* } .-1 } */
-+int d\u202ee\u202cf;
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+int d\u202Ee\u202cf2;
-+/* { dg-warning "U\\+202E" "" { target *-*-* } .-1 } */
-+int d\u2066e\u2069f;
-+/* { dg-warning "U\\+2066" "" { target *-*-* } .-1 } */
-+int d\u2067e\u2069f;
-+/* { dg-warning "U\\+2067" "" { target *-*-* } .-1 } */
-+int d\u2068e\u2069f;
-+/* { dg-warning "U\\+2068" "" { target *-*-* } .-1 } */
-+int X\u2069;
-+/* { dg-warning "U\\+2069" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-5.c b/gcc/testsuite/c-c++-common/Wbidi-chars-5.c
-new file mode 100644
-index 00000000000..68cb053144b
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-5.c
-@@ -0,0 +1,188 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired -Wno-multichar -Wno-overflow" } */
-+/* Test all bidi chars in various contexts (identifiers, comments,
-+   string literals, character constants), both UCN and UTF-8.  The bidi
-+   chars here are properly terminated, except for the character constants.  */
-+
-+/* a b c LRE⪠1 2 3 PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLE⫠1 2 3 PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c LRO⭠1 2 3 PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLO⮠1 2 3 PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c LRI⦠1 2 3 PDI⩠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLI⧠1 2 3 PDI⩠x y */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c FSI⨠1 2 3 PDI⩠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+/* Same but C++ comments instead.  */
-+// a b c LRE⪠1 2 3 PDF⬠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLE⫠1 2 3 PDF⬠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c LRO⭠1 2 3 PDF⬠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLO⮠1 2 3 PDF⬠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c LRI⦠1 2 3 PDI⩠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLI⧠1 2 3 PDI⩠x y
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c FSI⨠1 2 3 PDI⩠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+/* Here we're closing an unopened context, warn when =any.  */
-+/* a b c PDIâ© x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c PDIâ© x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+// a b c PDF⬠x y z
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+/* Multiline comments.  */
-+/* a b c PDIâ© x y z
-+   */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */
-+/* a b c PDF⬠x y z
-+   */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDIâ© x y z
-+   */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDF⬠x y z
-+   */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-2 } */
-+/* first
-+   a b c PDIâ© x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+/* first
-+   a b c PDF⬠x y z */
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+void
-+g1 ()
-+{
-+  const char *s1 = "a b c LRE⪠1 2 3 PDF⬠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s2 = "a b c RLE⫠1 2 3 PDF⬠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s3 = "a b c LRO⭠1 2 3 PDF⬠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s4 = "a b c RLO⮠1 2 3 PDF⬠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s5 = "a b c LRI⦠1 2 3 PDI⩠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s6 = "a b c RLI⧠1 2 3 PDI⩠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s7 = "a b c FSI⨠1 2 3 PDI⩠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s8 = "a b c PDIâ© x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s9 = "a b c PDF⬠x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+  const char *s10 = "a b c LRE\u202a 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s11 = "a b c LRE\u202A 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s12 = "a b c RLE\u202b 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s13 = "a b c RLE\u202B 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s14 = "a b c LRO\u202d 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s15 = "a b c LRO\u202D 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s16 = "a b c RLO\u202e 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s17 = "a b c RLO\u202E 1 2 3 PDF\u202c x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s18 = "a b c LRI\u2066 1 2 3 PDI\u2069 x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s19 = "a b c RLI\u2067 1 2 3 PDI\u2069 x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s20 = "a b c FSI\u2068 1 2 3 PDI\u2069 x y z";
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+}
-+
-+void
-+g2 ()
-+{
-+  const char c1 = '\u202a';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c2 = '\u202A';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c3 = '\u202b';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c4 = '\u202B';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c5 = '\u202d';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c6 = '\u202D';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c7 = '\u202e';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c8 = '\u202E';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c9 = '\u2066';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c10 = '\u2067';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char c11 = '\u2068';
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+}
-+
-+int aâªbâ¬c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ«bâ¬c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ­bâ¬c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ®bâ¬c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ¦bâ©c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ§bâ©c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int aâ¨bâ©c;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int Aâ¬X;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int A\u202cY;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int A\u202CY2;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+
-+int d\u202ae\u202cf;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202Ae\u202cf2;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202be\u202cf;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202Be\u202cf2;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202de\u202cf;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202De\u202cf2;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202ee\u202cf;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u202Ee\u202cf2;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u2066e\u2069f;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u2067e\u2069f;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int d\u2068e\u2069f;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-+int X\u2069;
-+/* { dg-bogus "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-6.c b/gcc/testsuite/c-c++-common/Wbidi-chars-6.c
-new file mode 100644
-index 00000000000..0ce6fff2dee
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-6.c
-@@ -0,0 +1,155 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test nesting of bidi chars in various contexts.  */
-+
-+/* Terminated by the wrong char:  */
-+/* a b c LRE⪠1 2 3 PDI⩠x y z */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLEâ« 1 2 3 PDIâ© x y  z*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c LROâ­ 1 2 3 PDIâ© x y z */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLOâ® 1 2 3 PDIâ© x y z */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c LRI⦠1 2 3 PDF⬠x y z */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c RLI⧠1 2 3 PDF⬠x y z */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* a b c FSI⨠1 2 3 PDF⬠x y  z*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+/* LRE⪠PDF⬠*/
-+/* LRE⪠LRE⪠PDF⬠PDF⬠*/
-+/* PDF⬠LRE⪠PDF⬠*/
-+/* LRE⪠PDF⬠LRE⪠PDF⬠*/
-+/* LRE⪠LRE⪠PDF⬠*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* PDF⬠LRE⪠*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+// a b c LRE⪠1 2 3 PDI⩠x y z
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLEâ« 1 2 3 PDIâ© x y  z*/
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c LROâ­ 1 2 3 PDIâ© x y z 
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLOâ® 1 2 3 PDIâ© x y z 
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c LRI⦠1 2 3 PDF⬠x y z 
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c RLI⧠1 2 3 PDF⬠x y z 
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// a b c FSI⨠1 2 3 PDF⬠x y  z
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+// LRE⪠PDF⬠
-+// LRE⪠LRE⪠PDF⬠PDFâ¬
-+// PDF⬠LRE⪠PDFâ¬
-+// LRE⪠PDF⬠LRE⪠PDFâ¬
-+// LRE⪠LRE⪠PDFâ¬
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+// PDF⬠LREâª
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+void
-+g1 ()
-+{
-+  const char *s1 = "a b c LRE⪠1 2 3 PDI⩠x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s2 = "a b c LRE\u202a 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s3 = "a b c RLEâ« 1 2 3 PDIâ© x y ";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s4 = "a b c RLE\u202b 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s5 = "a b c LROâ­ 1 2 3 PDIâ© x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s6 = "a b c LRO\u202d 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s7 = "a b c RLOâ® 1 2 3 PDIâ© x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s8 = "a b c RLO\u202e 1 2 3 PDI\u2069 x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s9 = "a b c LRI⦠1 2 3 PDF⬠x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s10 = "a b c LRI\u2066 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s11 = "a b c RLI⧠1 2 3 PDF⬠x y z\
-+    ";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+  const char *s12 = "a b c RLI\u2067 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s13 = "a b c FSI⨠1 2 3 PDF⬠x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s14 = "a b c FSI\u2068 1 2 3 PDF\u202c x y z";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s15 = "PDF⬠LREâª";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s16 = "PDF\u202c LRE\u202a";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s17 = "LRE⪠PDFâ¬";
-+  const char *s18 = "LRE\u202a PDF\u202c";
-+  const char *s19 = "LRE⪠LRE⪠PDF⬠PDFâ¬";
-+  const char *s20 = "LRE\u202a LRE\u202a PDF\u202c PDF\u202c";
-+  const char *s21 = "PDF⬠LRE⪠PDFâ¬";
-+  const char *s22 = "PDF\u202c LRE\u202a PDF\u202c";
-+  const char *s23 = "LRE⪠LRE⪠PDFâ¬";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s24 = "LRE\u202a LRE\u202a PDF\u202c";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s25 = "PDF⬠LREâª";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s26 = "PDF\u202c LRE\u202a";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s27 = "PDF⬠LRE\u202a";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+  const char *s28 = "PDF\u202c LREâª";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+}
-+
-+int aLREâªbPDIâ©;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int A\u202aB\u2069C;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aRLEâ«bPDIâ©;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a\u202bB\u2069c;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aLROâ­bPDIâ©;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a\u202db\u2069c2;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aRLOâ®bPDIâ©;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a\u202eb\u2069;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aLRIâ¦bPDFâ¬;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a\u2066b\u202c;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aRLIâ§bPDFâ¬c
-+;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-2 } */
-+int a\u2067b\u202c;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aFSIâ¨bPDFâ¬;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a\u2068b\u202c;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aFSIâ¨bPD\u202C;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aFSI\u2068bPDFâ¬_;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int aLREâªbPDFâ¬b; 
-+int A\u202aB\u202c;
-+int a_LREâª_LREâª_b_PDFâ¬_PDFâ¬;
-+int A\u202aA\u202aB\u202cB\u202c;
-+int aPDFâ¬bLREadPDFâ¬;
-+int a_\u202C_\u202a_\u202c;
-+int a_LREâª_b_PDFâ¬_c_LREâª_PDFâ¬;
-+int a_\u202a_\u202c_\u202a_\u202c_;
-+int a_LREâª_b_PDFâ¬_c_LREâª;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int a_\u202a_\u202c_\u202a_;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-7.c b/gcc/testsuite/c-c++-common/Wbidi-chars-7.c
-new file mode 100644
-index 00000000000..d012d420ec0
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-7.c
-@@ -0,0 +1,9 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=any" } */
-+/* Test we ignore UCNs in comments.  */
-+
-+// a b c \u202a 1 2 3
-+// a b c \u202A 1 2 3
-+/* a b c \u202a 1 2 3 */
-+/* a b c \u202A 1 2 3 */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-8.c b/gcc/testsuite/c-c++-common/Wbidi-chars-8.c
-new file mode 100644
-index 00000000000..4f54c5092ec
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-8.c
-@@ -0,0 +1,13 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=any" } */
-+/* Test \u vs \U.  */
-+
-+int a_\u202A;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int a_\u202a_2;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int a_\U0000202A_3;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-+int a_\U0000202a_4;
-+/* { dg-warning "U\\+202A" "" { target *-*-* } .-1 } */
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-9.c b/gcc/testsuite/c-c++-common/Wbidi-chars-9.c
-new file mode 100644
-index 00000000000..e2af1b1ca97
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-9.c
-@@ -0,0 +1,29 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired" } */
-+/* Test that we properly separate bidi contexts (comment/identifier/character
-+   constant/string literal).  */
-+
-+/* LRE ->âª<- */ int pdf_\u202c_1;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* RLE ->â«<- */ int pdf_\u202c_2;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* LRO ->â­<- */ int pdf_\u202c_3;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* RLO ->â®<- */ int pdf_\u202c_4;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* LRI ->â¦<-*/ int pdi_\u2069_1;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* RLI ->â§<- */ int pdi_\u2069_12;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* FSI ->â¨<- */ int pdi_\u2069_3;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+
-+const char *s1 = "LRE\u202a"; /* PDF ->â¬<- */
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+/* LRE ->âª<- */ const char *s2 = "PDF\u202c";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+const char *s3 = "LRE\u202a"; int pdf_\u202c_5;
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-+int lre_\u202a; const char *s4 = "PDF\u202c";
-+/* { dg-warning "unpaired" "" { target *-*-* } .-1 } */
-diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
-index 176f8c5bbce..112b9c24751 100644
---- a/libcpp/include/cpplib.h
-+++ b/libcpp/include/cpplib.h
-@@ -318,6 +318,17 @@ enum cpp_main_search
-   CMS_system,  /* Search the system INCLUDE path.  */
- };
- 
-+/* The possible bidirectional control characters checking levels, from least
-+   restrictive to most.  */
-+enum cpp_bidirectional_level {
-+  /* No checking.  */
-+  bidirectional_none,
-+  /* Only detect unpaired uses of bidirectional control characters.  */
-+  bidirectional_unpaired,
-+  /* Detect any use of bidirectional control characters.  */
-+  bidirectional_any
-+};
-+
- /* This structure is nested inside struct cpp_reader, and
-    carries all the options visible to the command line.  */
- struct cpp_options
-@@ -531,6 +542,10 @@ struct cpp_options
-   /* True if warn about differences between C++98 and C++11.  */
-   bool cpp_warn_cxx11_compat;
- 
-+  /* Nonzero if bidirectional control characters checking is on.  See enum
-+     cpp_bidirectional_level.  */
-+  unsigned char cpp_warn_bidirectional;
-+
-   /* Dependency generation.  */
-   struct
-   {
-@@ -635,7 +650,8 @@ enum cpp_warning_reason {
-   CPP_W_C90_C99_COMPAT,
-   CPP_W_C11_C2X_COMPAT,
-   CPP_W_CXX11_COMPAT,
--  CPP_W_EXPANSION_TO_DEFINED
-+  CPP_W_EXPANSION_TO_DEFINED,
-+  CPP_W_BIDIRECTIONAL
- };
- 
- /* Callback for header lookup for HEADER, which is the name of a
-diff --git a/libcpp/init.c b/libcpp/init.c
-index 5a424e23553..f9a8f5f088f 100644
---- a/libcpp/init.c
-+++ b/libcpp/init.c
-@@ -219,6 +219,7 @@ cpp_create_reader (enum c_lang lang, cpp
-       = ENABLE_CANONICAL_SYSTEM_HEADERS;
-   CPP_OPTION (pfile, ext_numeric_literals) = 1;
-   CPP_OPTION (pfile, warn_date_time) = 0;
-+  CPP_OPTION (pfile, cpp_warn_bidirectional) = bidirectional_unpaired;
- 
-   /* Default CPP arithmetic to something sensible for the host for the
-      benefit of dumb users like fix-header.  */
-diff --git a/libcpp/internal.h b/libcpp/internal.h
-index 8577cab6c83..0ce0246c5a2 100644
---- a/libcpp/internal.h
-+++ b/libcpp/internal.h
-@@ -597,6 +597,13 @@ struct cpp_reader
-   /* Location identifying the main source file -- intended to be line
-      zero of said file.  */
-   location_t main_loc;
-+
-+  /* Returns true iff we should warn about UTF-8 bidirectional control
-+     characters.  */
-+  bool warn_bidi_p () const
-+  {
-+    return CPP_OPTION (this, cpp_warn_bidirectional) != bidirectional_none;
-+  }
- };
- 
- /* Character classes.  Based on the more primitive macros in safe-ctype.h.
-diff --git a/libcpp/lex.c b/libcpp/lex.c
-index fa2253d41c3..6a4fbce6030 100644
---- a/libcpp/lex.c
-+++ b/libcpp/lex.c
-@@ -1164,6 +1164,324 @@ _cpp_process_line_notes (cpp_reader *pfi
-     }
- }
- 
-+namespace bidi {
-+  enum class kind {
-+    NONE, LRE, RLE, LRO, RLO, LRI, RLI, FSI, PDF, PDI, LTR, RTL
-+  };
-+
-+  /* All the UTF-8 encodings of bidi characters start with E2.  */
-+  constexpr uchar utf8_start = 0xe2;
-+
-+  /* A vector holding currently open bidi contexts.  We use a char for
-+     each context, its LSB is 1 if it represents a PDF context, 0 if it
-+     represents a PDI context.  The next bit is 1 if this context was open
-+     by a bidi character written as a UCN, and 0 when it was UTF-8.  */
-+  semi_embedded_vec <unsigned char, 16> vec;
-+
-+  /* Close the whole comment/identifier/string literal/character constant
-+     context.  */
-+  void on_close ()
-+  {
-+    vec.truncate (0);
-+  }
-+
-+  /* Pop the last element in the vector.  */
-+  void pop ()
-+  {
-+    unsigned int len = vec.count ();
-+    gcc_checking_assert (len > 0);
-+    vec.truncate (len - 1);
-+  }
-+
-+  /* Return the context of the Ith element.  */
-+  kind ctx_at (unsigned int i)
-+  {
-+    return (vec[i] & 1) ? kind::PDF : kind::PDI;
-+  }
-+
-+  /* Return which context is currently opened.  */
-+  kind current_ctx ()
-+  {
-+    unsigned int len = vec.count ();
-+    if (len == 0)
-+      return kind::NONE;
-+    return ctx_at (len - 1);
-+  }
-+
-+  /* Return true if the current context comes from a UCN origin, that is,
-+     the bidi char which started this bidi context was written as a UCN.  */
-+  bool current_ctx_ucn_p ()
-+  {
-+    unsigned int len = vec.count ();
-+    gcc_checking_assert (len > 0);
-+    return (vec[len - 1] >> 1) & 1;
-+  }
-+
-+  /* We've read a bidi char, update the current vector as necessary.  */
-+  void on_char (kind k, bool ucn_p)
-+  {
-+    switch (k)
-+      {
-+      case kind::LRE:
-+      case kind::RLE:
-+      case kind::LRO:
-+      case kind::RLO:
-+	vec.push (ucn_p ? 3u : 1u);
-+	break;
-+      case kind::LRI:
-+      case kind::RLI:
-+      case kind::FSI:
-+	vec.push (ucn_p ? 2u : 0u);
-+	break;
-+      /* PDF terminates the scope of the last LRE, RLE, LRO, or RLO
-+	 whose scope has not yet been terminated.  */
-+      case kind::PDF:
-+	if (current_ctx () == kind::PDF)
-+	  pop ();
-+	break;
-+      /* PDI terminates the scope of the last LRI, RLI, or FSI whose
-+	 scope has not yet been terminated, as well as the scopes of
-+	 any subsequent LREs, RLEs, LROs, or RLOs whose scopes have not
-+	 yet been terminated.  */
-+      case kind::PDI:
-+	for (int i = vec.count () - 1; i >= 0; --i)
-+	  if (ctx_at (i) == kind::PDI)
-+	    {
-+	      vec.truncate (i);
-+	      break;
-+	    }
-+	break;
-+      case kind::LTR:
-+      case kind::RTL:
-+	/* These aren't popped by a PDF/PDI.  */
-+	break;
-+      [[likely]] case kind::NONE:
-+	break;
-+      default:
-+	abort ();
-+      }
-+  }
-+
-+  /* Return a descriptive string for K.  */
-+  const char *to_str (kind k)
-+  {
-+    switch (k)
-+      {
-+      case kind::LRE:
-+	return "U+202A (LEFT-TO-RIGHT EMBEDDING)";
-+      case kind::RLE:
-+	return "U+202B (RIGHT-TO-LEFT EMBEDDING)";
-+      case kind::LRO:
-+	return "U+202D (LEFT-TO-RIGHT OVERRIDE)";
-+      case kind::RLO:
-+	return "U+202E (RIGHT-TO-LEFT OVERRIDE)";
-+      case kind::LRI:
-+	return "U+2066 (LEFT-TO-RIGHT ISOLATE)";
-+      case kind::RLI:
-+	return "U+2067 (RIGHT-TO-LEFT ISOLATE)";
-+      case kind::FSI:
-+	return "U+2068 (FIRST STRONG ISOLATE)";
-+      case kind::PDF:
-+	return "U+202C (POP DIRECTIONAL FORMATTING)";
-+      case kind::PDI:
-+	return "U+2069 (POP DIRECTIONAL ISOLATE)";
-+      case kind::LTR:
-+	return "U+200E (LEFT-TO-RIGHT MARK)";
-+      case kind::RTL:
-+	return "U+200F (RIGHT-TO-LEFT MARK)";
-+      default:
-+	abort ();
-+      }
-+  }
-+}
-+
-+/* Parse a sequence of 3 bytes starting with P and return its bidi code.  */
-+
-+static bidi::kind
-+get_bidi_utf8 (const unsigned char *const p)
-+{
-+  gcc_checking_assert (p[0] == bidi::utf8_start);
-+
-+  if (p[1] == 0x80)
-+    switch (p[2])
-+      {
-+      case 0xaa:
-+	return bidi::kind::LRE;
-+      case 0xab:
-+	return bidi::kind::RLE;
-+      case 0xac:
-+	return bidi::kind::PDF;
-+      case 0xad:
-+	return bidi::kind::LRO;
-+      case 0xae:
-+	return bidi::kind::RLO;
-+      case 0x8e:
-+	return bidi::kind::LTR;
-+      case 0x8f:
-+	return bidi::kind::RTL;
-+      default:
-+	break;
-+      }
-+  else if (p[1] == 0x81)
-+    switch (p[2])
-+      {
-+      case 0xa6:
-+	return bidi::kind::LRI;
-+      case 0xa7:
-+	return bidi::kind::RLI;
-+      case 0xa8:
-+	return bidi::kind::FSI;
-+      case 0xa9:
-+	return bidi::kind::PDI;
-+      default:
-+	break;
-+      }
-+
-+  return bidi::kind::NONE;
-+}
-+
-+/* Parse a UCN where P points just past \u or \U and return its bidi code.  */
-+
-+static bidi::kind
-+get_bidi_ucn (const unsigned char *p, bool is_U)
-+{
-+  /* 6.4.3 Universal Character Names
-+      \u hex-quad
-+      \U hex-quad hex-quad
-+     where \unnnn means \U0000nnnn.  */
-+
-+  if (is_U)
-+    {
-+      if (p[0] != '0' || p[1] != '0' || p[2] != '0' || p[3] != '0')
-+	return bidi::kind::NONE;
-+      /* Skip 4B so we can treat \u and \U the same below.  */
-+      p += 4;
-+    }
-+
-+  /* All code points we are looking for start with 20xx.  */
-+  if (p[0] != '2' || p[1] != '0')
-+    return bidi::kind::NONE;
-+  else if (p[2] == '2')
-+    switch (p[3])
-+      {
-+      case 'a':
-+      case 'A':
-+	return bidi::kind::LRE;
-+      case 'b':
-+      case 'B':
-+	return bidi::kind::RLE;
-+      case 'c':
-+      case 'C':
-+	return bidi::kind::PDF;
-+      case 'd':
-+      case 'D':
-+	return bidi::kind::LRO;
-+      case 'e':
-+      case 'E':
-+	return bidi::kind::RLO;
-+      default:
-+	break;
-+      }
-+  else if (p[2] == '6')
-+    switch (p[3])
-+      {
-+      case '6':
-+	return bidi::kind::LRI;
-+      case '7':
-+	return bidi::kind::RLI;
-+      case '8':
-+	return bidi::kind::FSI;
-+      case '9':
-+	return bidi::kind::PDI;
-+      default:
-+	break;
-+      }
-+  else if (p[2] == '0')
-+    switch (p[3])
-+      {
-+      case 'e':
-+      case 'E':
-+	return bidi::kind::LTR;
-+      case 'f':
-+      case 'F':
-+	return bidi::kind::RTL;
-+      default:
-+	break;
-+      }
-+
-+  return bidi::kind::NONE;
-+}
-+
-+/* We're closing a bidi context, that is, we've encountered a newline,
-+   are closing a C-style comment, or are at the end of a string literal,
-+   character constant, or identifier.  Warn if this context was not
-+   properly terminated by a PDI or PDF.  P points to the last character
-+   in this context.  */
-+
-+static void
-+maybe_warn_bidi_on_close (cpp_reader *pfile, const uchar *p)
-+{
-+  if (CPP_OPTION (pfile, cpp_warn_bidirectional) == bidirectional_unpaired
-+      && bidi::vec.count () > 0)
-+    {
-+      const location_t loc
-+	= linemap_position_for_column (pfile->line_table,
-+				       CPP_BUF_COLUMN (pfile->buffer, p));
-+      cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
-+			     "unpaired UTF-8 bidirectional control character "
-+			     "detected");
-+    }
-+  /* We're done with this context.  */
-+  bidi::on_close ();
-+}
-+
-+/* We're at the beginning or in the middle of an identifier/comment/string
-+   literal/character constant.  Warn if we've encountered a bidi character.
-+   KIND says which bidi character it was; P points to it in the character
-+   stream.  UCN_P is true iff this bidi character was written as a UCN.  */
-+
-+static void
-+maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind,
-+			 bool ucn_p)
-+{
-+  if (__builtin_expect (kind == bidi::kind::NONE, 1))
-+    return;
-+
-+  const auto warn_bidi = CPP_OPTION (pfile, cpp_warn_bidirectional);
-+
-+  if (warn_bidi != bidirectional_none)
-+    {
-+      const location_t loc
-+	= linemap_position_for_column (pfile->line_table,
-+				       CPP_BUF_COLUMN (pfile->buffer, p));
-+      /* It seems excessive to warn about a PDI/PDF that is closing
-+	 an opened context because we've already warned about the
-+	 opening character.  Except warn when we have a UCN x UTF-8
-+	 mismatch.  */
-+      if (kind == bidi::current_ctx ())
-+	{
-+	  if (warn_bidi == bidirectional_unpaired
-+	      && bidi::current_ctx_ucn_p () != ucn_p)
-+	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
-+				   "UTF-8 vs UCN mismatch when closing "
-+				   "a context by \"%s\"", bidi::to_str (kind));
-+	}
-+      else if (warn_bidi == bidirectional_any)
-+	{
-+	  if (kind == bidi::kind::PDF || kind == bidi::kind::PDI)
-+	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
-+				   "\"%s\" is closing an unopened context",
-+				   bidi::to_str (kind));
-+	  else
-+	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
-+				   "found problematic Unicode character \"%s\"",
-+				   bidi::to_str (kind));
-+	}
-+    }
-+  /* We're done with this context.  */
-+  bidi::on_char (kind, ucn_p);
-+}
-+
- /* Skip a C-style block comment.  We find the end of the comment by
-    seeing if an asterisk is before every '/' we encounter.  Returns
-    nonzero if comment terminated by EOF, zero otherwise.
-@@ -1175,6 +1493,7 @@ _cpp_skip_block_comment (cpp_reader *pfi
-   cpp_buffer *buffer = pfile->buffer;
-   const uchar *cur = buffer->cur;
-   uchar c;
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
- 
-   cur++;
-   if (*cur == '/')
-@@ -1189,7 +1508,11 @@ _cpp_skip_block_comment (cpp_reader *pfi
-       if (c == '/')
- 	{
- 	  if (cur[-2] == '*')
--	    break;
-+	    {
-+	      if (warn_bidi_p)
-+		maybe_warn_bidi_on_close (pfile, cur);
-+	      break;
-+	    }
- 
- 	  /* Warn about potential nested comments, but not if the '/'
- 	     comes immediately before the true comment delimiter.
-@@ -1208,6 +1531,8 @@ _cpp_skip_block_comment (cpp_reader *pfi
- 	{
- 	  unsigned int cols;
- 	  buffer->cur = cur - 1;
-+	  if (warn_bidi_p)
-+	    maybe_warn_bidi_on_close (pfile, cur);
- 	  _cpp_process_line_notes (pfile, true);
- 	  if (buffer->next_line >= buffer->rlimit)
- 	    return true;
-@@ -1218,6 +1543,13 @@ _cpp_skip_block_comment (cpp_reader *pfi
- 
- 	  cur = buffer->cur;
- 	}
-+      /* If this is a beginning of a UTF-8 encoding, it might be
-+	 a bidirectional control character.  */
-+      else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p)
-+	{
-+	  bidi::kind kind = get_bidi_utf8 (cur - 1);
-+	  maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/false);
-+	}
-     }
- 
-   buffer->cur = cur;
-@@ -1233,9 +1565,31 @@ skip_line_comment (cpp_reader *pfile)
- {
-   cpp_buffer *buffer = pfile->buffer;
-   location_t orig_line = pfile->line_table->highest_line;
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
- 
--  while (*buffer->cur != '\n')
--    buffer->cur++;
-+  if (!warn_bidi_p)
-+    while (*buffer->cur != '\n')
-+      buffer->cur++;
-+  else
-+    {
-+      while (*buffer->cur != '\n'
-+	     && *buffer->cur != bidi::utf8_start)
-+	buffer->cur++;
-+      if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0))
-+	{
-+	  while (*buffer->cur != '\n')
-+	    {
-+	      if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0))
-+		{
-+		  bidi::kind kind = get_bidi_utf8 (buffer->cur);
-+		  maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
-+					   /*ucn_p=*/false);
-+		}
-+	      buffer->cur++;
-+	    }
-+	  maybe_warn_bidi_on_close (pfile, buffer->cur);
-+	}
-+    }
- 
-   _cpp_process_line_notes (pfile, true);
-   return orig_line != pfile->line_table->highest_line;
-@@ -1317,11 +1671,13 @@ static const cppchar_t utf8_signifier =
- 
- /* Returns TRUE if the sequence starting at buffer->cur is valid in
-    an identifier.  FIRST is TRUE if this starts an identifier.  */
-+
- static bool
- forms_identifier_p (cpp_reader *pfile, int first,
- 		    struct normalize_state *state)
- {
-   cpp_buffer *buffer = pfile->buffer;
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
- 
-   if (*buffer->cur == '$')
-     {
-@@ -1344,6 +1700,13 @@ forms_identifier_p (cpp_reader *pfile, i
-       cppchar_t s;
-       if (*buffer->cur >= utf8_signifier)
- 	{
-+	  if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0)
-+	      && warn_bidi_p)
-+	    {
-+	      bidi::kind kind = get_bidi_utf8 (buffer->cur);
-+	      maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
-+				       /*ucn_p=*/false);
-+	    }
- 	  if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
- 			       state, &s))
- 	    return true;
-@@ -1352,6 +1715,13 @@ forms_identifier_p (cpp_reader *pfile, i
- 	       && (buffer->cur[1] == 'u' || buffer->cur[1] == 'U'))
- 	{
- 	  buffer->cur += 2;
-+	  if (warn_bidi_p)
-+	    {
-+	      bidi::kind kind = get_bidi_ucn (buffer->cur,
-+					      buffer->cur[-1] == 'U');
-+	      maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
-+				       /*ucn_p=*/true);
-+	    }
- 	  if (_cpp_valid_ucn (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
- 			      state, &s, NULL, NULL))
- 	    return true;
-@@ -1460,6 +1830,7 @@ lex_identifier (cpp_reader *pfile, const
-   const uchar *cur;
-   unsigned int len;
-   unsigned int hash = HT_HASHSTEP (0, *base);
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
- 
-   cur = pfile->buffer->cur;
-   if (! starts_ucn)
-@@ -1483,6 +1854,8 @@ lex_identifier (cpp_reader *pfile, const
- 	    pfile->buffer->cur++;
- 	  }
-       } while (forms_identifier_p (pfile, false, nst));
-+      if (warn_bidi_p)
-+	maybe_warn_bidi_on_close (pfile, pfile->buffer->cur);
-       result = _cpp_interpret_identifier (pfile, base,
- 					  pfile->buffer->cur - base);
-       *spelling = cpp_lookup (pfile, base, pfile->buffer->cur - base);
-@@ -1719,6 +2092,7 @@ static void
- lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
- {
-   const uchar *pos = base;
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
- 
-   /* 'tis a pity this information isn't passed down from the lexer's
-      initial categorization of the token.  */
-@@ -1955,8 +2329,15 @@ lex_raw_string (cpp_reader *pfile, cpp_t
- 	  pos = base = pfile->buffer->cur;
- 	  note = &pfile->buffer->notes[pfile->buffer->cur_note];
- 	}
-+      else if (__builtin_expect ((unsigned char) c == bidi::utf8_start, 0)
-+	       && warn_bidi_p)
-+	maybe_warn_bidi_on_char (pfile, pos - 1, get_bidi_utf8 (pos - 1),
-+				 /*ucn_p=*/false);
-     }
- 
-+  if (warn_bidi_p)
-+    maybe_warn_bidi_on_close (pfile, pos);
-+
-   if (CPP_OPTION (pfile, user_literals))
-     {
-       /* If a string format macro, say from inttypes.h, is placed touching
-@@ -2051,15 +2432,27 @@ lex_string (cpp_reader *pfile, cpp_token
-   else
-     terminator = '>', type = CPP_HEADER_NAME;
- 
-+  const bool warn_bidi_p = pfile->warn_bidi_p ();
-   for (;;)
-     {
-       cppchar_t c = *cur++;
- 
-       /* In #include-style directives, terminators are not escapable.  */
-       if (c == '\\' && !pfile->state.angled_headers && *cur != '\n')
--	cur++;
-+	{
-+	  if ((cur[0] == 'u' || cur[0] == 'U') && warn_bidi_p)
-+	    {
-+	      bidi::kind kind = get_bidi_ucn (cur + 1, cur[0] == 'U');
-+	      maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/true);
-+	    }
-+	  cur++;
-+	}
-       else if (c == terminator)
--	break;
-+	{
-+	  if (warn_bidi_p)
-+	    maybe_warn_bidi_on_close (pfile, cur - 1);
-+	  break;
-+	}
-       else if (c == '\n')
- 	{
- 	  cur--;
-@@ -2076,6 +2469,11 @@ lex_string (cpp_reader *pfile, cpp_token
- 	}
-       else if (c == '\0')
- 	saw_NUL = true;
-+      else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p)
-+	{
-+	  bidi::kind kind = get_bidi_utf8 (cur - 1);
-+	  maybe_warn_bidi_on_char (pfile, cur - 1, kind, /*ucn_p=*/false);
-+	}
-     }
- 
-   if (saw_NUL && !pfile->state.skipping)
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-CVE-2021-42574.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-CVE-2021-42574.patch
deleted file mode 100644
index 2995a6f..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-CVE-2021-42574.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From 1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3 Mon Sep 17 00:00:00 2001
-From: David Malcolm <dmalcolm@redhat.com>
-Date: Tue, 2 Nov 2021 09:54:32 -0400
-Subject: [PATCH] libcpp: escape non-ASCII source bytes in -Wbidi-chars=
- [PR103026]
-MIME-Version: 1.0
-Content-Type: text/plain; charset=utf8
-Content-Transfer-Encoding: 8bit
-
-This flags rich_locations associated with -Wbidi-chars= so that
-non-ASCII bytes will be escaped when printing the source lines
-(using the diagnostics support I added in
-r12-4825-gbd5e882cf6e0def3dd1bc106075d59a303fe0d1e).
-
-In particular, this ensures that the printed source lines will
-be pure ASCII, and thus the visual ordering of the characters
-will be the same as the logical ordering.
-
-Before:
-
-  Wbidi-chars-1.c: In function âmainâ:
-  Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      6 |     /*â® } â¦if (isAdmin)⩠⦠begin admins only */
-        |                                           ^
-  Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      9 |     /* end admins only â® { â¦*/
-        |                            ^
-
-  Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-      6 | int LRE_âª_PDF_\u202c;
-        |               ^
-  Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-      8 | int LRE_\u202a_PDF_â¬_;
-        |                   ^
-  Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-     10 | const char *s1 = "LRE_âª_PDF_\u202c";
-        |                            ^
-  Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-     12 | const char *s2 = "LRE_\u202a_PDF_â¬";
-        |                                 ^
-
-After:
-
-  Wbidi-chars-1.c: In function âmainâ:
-  Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      6 |     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */
-        |                                                                           ^
-  Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      9 |     /* end admins only <U+202E> { <U+2066>*/
-        |                                            ^
-
-  Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-      6 | int LRE_<U+202A>_PDF_\u202c;
-        |                       ^
-  Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-      8 | int LRE_\u202a_PDF_<U+202C>_;
-        |                   ^
-  Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-     10 | const char *s1 = "LRE_<U+202A>_PDF_\u202c";
-        |                                    ^
-  Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
-     12 | const char *s2 = "LRE_\u202a_PDF_<U+202C>";
-        |                                 ^
-
-libcpp/ChangeLog:
-	PR preprocessor/103026
-	* lex.c (maybe_warn_bidi_on_close): Use a rich_location
-	and call set_escape_on_output (true) on it.
-	(maybe_warn_bidi_on_char): Likewise.
-
-Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-
-CVE: CVE-2021-42574
-Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3]
-Signed-off-by: Pgowda <pgowda.cve@gmail.com>
-
----
- libcpp/lex.c | 29 +++++++++++++++++------------
- 1 file changed, 17 insertions(+), 12 deletions(-)
-
-diff --git a/libcpp/lex.c b/libcpp/lex.c
-index 8188e33b07d..2421d6c0f40 100644
---- a/libcpp/lex.c
-+++ b/libcpp/lex.c
-@@ -1427,9 +1427,11 @@ maybe_warn_bidi_on_close (cpp_reader *pfile, const uchar *p)
-       const location_t loc
- 	= linemap_position_for_column (pfile->line_table,
- 				       CPP_BUF_COLUMN (pfile->buffer, p));
--      cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
--			     "unpaired UTF-8 bidirectional control character "
--			     "detected");
-+      rich_location rich_loc (pfile->line_table, loc);
-+      rich_loc.set_escape_on_output (true);
-+      cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+		      "unpaired UTF-8 bidirectional control character "
-+		      "detected");
-     }
-   /* We're done with this context.  */
-   bidi::on_close ();
-@@ -1454,6 +1456,9 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind,
-       const location_t loc
- 	= linemap_position_for_column (pfile->line_table,
- 				       CPP_BUF_COLUMN (pfile->buffer, p));
-+      rich_location rich_loc (pfile->line_table, loc);
-+      rich_loc.set_escape_on_output (true);
-+
-       /* It seems excessive to warn about a PDI/PDF that is closing
- 	 an opened context because we've already warned about the
- 	 opening character.  Except warn when we have a UCN x UTF-8
-@@ -1462,20 +1467,20 @@ maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind,
- 	{
- 	  if (warn_bidi == bidirectional_unpaired
- 	      && bidi::current_ctx_ucn_p () != ucn_p)
--	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
--				   "UTF-8 vs UCN mismatch when closing "
--				   "a context by \"%s\"", bidi::to_str (kind));
-+	    cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			    "UTF-8 vs UCN mismatch when closing "
-+			    "a context by \"%s\"", bidi::to_str (kind));
- 	}
-       else if (warn_bidi == bidirectional_any)
- 	{
- 	  if (kind == bidi::kind::PDF || kind == bidi::kind::PDI)
--	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
--				   "\"%s\" is closing an unopened context",
--				   bidi::to_str (kind));
-+	    cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			    "\"%s\" is closing an unopened context",
-+			    bidi::to_str (kind));
- 	  else
--	    cpp_warning_with_line (pfile, CPP_W_BIDIRECTIONAL, loc, 0,
--				   "found problematic Unicode character \"%s\"",
--				   bidi::to_str (kind));
-+	    cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			    "found problematic Unicode character \"%s\"",
-+			    bidi::to_str (kind));
- 	}
-     }
-   /* We're done with this context.  */
--- 
-2.27.0
-
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-CVE-2021-42574.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-CVE-2021-42574.patch
deleted file mode 100644
index 4999c71..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-CVE-2021-42574.patch
+++ /dev/null
@@ -1,573 +0,0 @@
-From bef32d4a28595e933f24fef378cf052a30b674a7 Mon Sep 17 00:00:00 2001
-From: David Malcolm <dmalcolm@redhat.com>
-Date: Tue, 2 Nov 2021 15:45:22 -0400
-Subject: [PATCH] libcpp: capture and underline ranges in -Wbidi-chars=
- [PR103026]
-MIME-Version: 1.0
-Content-Type: text/plain; charset=utf8
-Content-Transfer-Encoding: 8bit
-
-This patch converts the bidi::vec to use a struct so that we can
-capture location_t values for the bidirectional control characters.
-
-Before:
-
-  Wbidi-chars-1.c: In function âmainâ:
-  Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      6 |     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */
-        |                                                                           ^
-  Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control character detected [-Wbidi-chars=]
-      9 |     /* end admins only <U+202E> { <U+2066>*/
-        |                                            ^
-
-After:
-
-  Wbidi-chars-1.c: In function âmainâ:
-  Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control characters detected [-Wbidi-chars=]
-      6 |     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */
-        |       ~~~~~~~~                                ~~~~~~~~                    ^
-        |       |                                       |                           |
-        |       |                                       |                           end of bidirectional context
-        |       U+202E (RIGHT-TO-LEFT OVERRIDE)         U+2066 (LEFT-TO-RIGHT ISOLATE)
-  Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control characters detected [-Wbidi-chars=]
-      9 |     /* end admins only <U+202E> { <U+2066>*/
-        |                        ~~~~~~~~   ~~~~~~~~ ^
-        |                        |          |        |
-        |                        |          |        end of bidirectional context
-        |                        |          U+2066 (LEFT-TO-RIGHT ISOLATE)
-        |                        U+202E (RIGHT-TO-LEFT OVERRIDE)
-
-Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-
-gcc/testsuite/ChangeLog:
-	PR preprocessor/103026
-	* c-c++-common/Wbidi-chars-ranges.c: New test.
-
-libcpp/ChangeLog:
-	PR preprocessor/103026
-	* lex.c (struct bidi::context): New.
-	(bidi::vec): Convert to a vec of context rather than unsigned
-	char.
-	(bidi::ctx_at): Rename to...
-	(bidi::pop_kind_at): ...this and reimplement for above change.
-	(bidi::current_ctx): Update for change to vec.
-	(bidi::current_ctx_ucn_p): Likewise.
-	(bidi::current_ctx_loc): New.
-	(bidi::on_char): Update for usage of context struct.  Add "loc"
-	param and pass it when pushing contexts.
-	(get_location_for_byte_range_in_cur_line): New.
-	(get_bidi_utf8): Rename to...
-	(get_bidi_utf8_1): ...this, reintroducing...
-	(get_bidi_utf8): ...as a wrapper, setting *OUT when the result is
-	not NONE.
-	(get_bidi_ucn): Rename to...
-	(get_bidi_ucn_1): ...this, reintroducing...
-	(get_bidi_ucn): ...as a wrapper, setting *OUT when the result is
-	not NONE.
-	(class unpaired_bidi_rich_location): New.
-	(maybe_warn_bidi_on_close): Use unpaired_bidi_rich_location when
-	reporting on unpaired bidi chars.  Split into singular vs plural
-	spellings.
-	(maybe_warn_bidi_on_char): Pass in a location_t rather than a
-	const uchar * and use it when emitting warnings, and when calling
-	bidi::on_char.
-	(_cpp_skip_block_comment): Capture location when kind is not NONE
-	and pass it to maybe_warn_bidi_on_char.
-	(skip_line_comment): Likewise.
-	(forms_identifier_p): Likewise.
-	(lex_raw_string): Likewise.
-	(lex_string): Likewise.
-
-Signed-off-by: David Malcolm <dmalcolm@redhat.com>
-
-CVE: CVE-2021-42574
-Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=bef32d4a28595e933f24fef378cf052a30b674a7]
-Signed-off-by: Pgowda <pgowda.cve@gmail.com>
-
----
- .../c-c++-common/Wbidi-chars-ranges.c         |  54 ++++
- libcpp/lex.c                                  | 251 ++++++++++++++----
- 2 files changed, 257 insertions(+), 48 deletions(-)
- create mode 100644 gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c
-
-diff --git a/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c b/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c
-new file mode 100644
-index 00000000000..298750a2a64
---- /dev/null
-+++ b/gcc/testsuite/c-c++-common/Wbidi-chars-ranges.c
-@@ -0,0 +1,54 @@
-+/* PR preprocessor/103026 */
-+/* { dg-do compile } */
-+/* { dg-options "-Wbidi-chars=unpaired -fdiagnostics-show-caret" } */
-+/* Verify that we escape and underline pertinent bidirectional
-+   control characters when quoting the source.  */
-+
-+int test_unpaired_bidi () {
-+    int isAdmin = 0;
-+    /*â® } â¦if (isAdmin)⩠⦠begin admins only */
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+#if 0
-+   { dg-begin-multiline-output "" }
-+     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */
-+       ~~~~~~~~                                ~~~~~~~~                    ^
-+       |                                       |                           |
-+       |                                       |                           end of bidirectional context
-+       U+202E (RIGHT-TO-LEFT OVERRIDE)         U+2066 (LEFT-TO-RIGHT ISOLATE)
-+   { dg-end-multiline-output "" }
-+#endif
-+
-+        __builtin_printf("You are an admin.\n");
-+    /* end admins only â® { â¦*/
-+/* { dg-warning "bidirectional" "" { target *-*-* } .-1 } */
-+#if 0
-+   { dg-begin-multiline-output "" }
-+     /* end admins only <U+202E> { <U+2066>*/
-+                        ~~~~~~~~   ~~~~~~~~ ^
-+                        |          |        |
-+                        |          |        end of bidirectional context
-+                        |          U+2066 (LEFT-TO-RIGHT ISOLATE)
-+                        U+202E (RIGHT-TO-LEFT OVERRIDE)
-+   { dg-end-multiline-output "" }
-+#endif
-+
-+    return 0;
-+}
-+
-+int LRE_âª_PDF_\u202c;
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-+#if 0
-+   { dg-begin-multiline-output "" }
-+ int LRE_<U+202A>_PDF_\u202c;
-+         ~~~~~~~~     ^~~~~~
-+   { dg-end-multiline-output "" }
-+#endif
-+
-+const char *s1 = "LRE_âª_PDF_\u202c";
-+/* { dg-warning "mismatch" "" { target *-*-* } .-1 } */
-+#if 0
-+   { dg-begin-multiline-output "" }
-+ const char *s1 = "LRE_<U+202A>_PDF_\u202c";
-+                       ~~~~~~~~     ^~~~~~
-+   { dg-end-multiline-output "" }
-+#endif
-diff --git a/libcpp/lex.c b/libcpp/lex.c
-index 2421d6c0f40..94c36f0d014 100644
---- a/libcpp/lex.c
-+++ b/libcpp/lex.c
-@@ -1172,11 +1172,34 @@ namespace bidi {
-   /* All the UTF-8 encodings of bidi characters start with E2.  */
-   constexpr uchar utf8_start = 0xe2;
- 
-+  struct context
-+  {
-+    context () {}
-+    context (location_t loc, kind k, bool pdf, bool ucn)
-+    : m_loc (loc), m_kind (k), m_pdf (pdf), m_ucn (ucn)
-+    {
-+    }
-+
-+    kind get_pop_kind () const
-+    {
-+      return m_pdf ? kind::PDF : kind::PDI;
-+    }
-+    bool ucn_p () const
-+    {
-+      return m_ucn;
-+    }
-+
-+    location_t m_loc;
-+    kind m_kind;
-+    unsigned m_pdf : 1;
-+    unsigned m_ucn : 1;
-+  };
-+
-   /* A vector holding currently open bidi contexts.  We use a char for
-      each context, its LSB is 1 if it represents a PDF context, 0 if it
-      represents a PDI context.  The next bit is 1 if this context was open
-      by a bidi character written as a UCN, and 0 when it was UTF-8.  */
--  semi_embedded_vec <unsigned char, 16> vec;
-+  semi_embedded_vec <context, 16> vec;
- 
-   /* Close the whole comment/identifier/string literal/character constant
-      context.  */
-@@ -1193,19 +1216,19 @@ namespace bidi {
-     vec.truncate (len - 1);
-   }
- 
--  /* Return the context of the Ith element.  */
--  kind ctx_at (unsigned int i)
-+  /* Return the pop kind of the context of the Ith element.  */
-+  kind pop_kind_at (unsigned int i)
-   {
--    return (vec[i] & 1) ? kind::PDF : kind::PDI;
-+    return vec[i].get_pop_kind ();
-   }
- 
--  /* Return which context is currently opened.  */
-+  /* Return the pop kind of the context that is currently opened.  */
-   kind current_ctx ()
-   {
-     unsigned int len = vec.count ();
-     if (len == 0)
-       return kind::NONE;
--    return ctx_at (len - 1);
-+    return vec[len - 1].get_pop_kind ();
-   }
- 
-   /* Return true if the current context comes from a UCN origin, that is,
-@@ -1214,11 +1237,19 @@ namespace bidi {
-   {
-     unsigned int len = vec.count ();
-     gcc_checking_assert (len > 0);
--    return (vec[len - 1] >> 1) & 1;
-+    return vec[len - 1].m_ucn;
-   }
- 
--  /* We've read a bidi char, update the current vector as necessary.  */
--  void on_char (kind k, bool ucn_p)
-+  location_t current_ctx_loc ()
-+  {
-+    unsigned int len = vec.count ();
-+    gcc_checking_assert (len > 0);
-+    return vec[len - 1].m_loc;
-+  }
-+
-+  /* We've read a bidi char, update the current vector as necessary.
-+     LOC is only valid when K is not kind::NONE.  */
-+  void on_char (kind k, bool ucn_p, location_t loc)
-   {
-     switch (k)
-       {
-@@ -1226,12 +1257,12 @@ namespace bidi {
-       case kind::RLE:
-       case kind::LRO:
-       case kind::RLO:
--	vec.push (ucn_p ? 3u : 1u);
-+	vec.push (context (loc, k, true, ucn_p));
- 	break;
-       case kind::LRI:
-       case kind::RLI:
-       case kind::FSI:
--	vec.push (ucn_p ? 2u : 0u);
-+	vec.push (context (loc, k, false, ucn_p));
- 	break;
-       /* PDF terminates the scope of the last LRE, RLE, LRO, or RLO
- 	 whose scope has not yet been terminated.  */
-@@ -1245,7 +1276,7 @@ namespace bidi {
- 	 yet been terminated.  */
-       case kind::PDI:
- 	for (int i = vec.count () - 1; i >= 0; --i)
--	  if (ctx_at (i) == kind::PDI)
-+	  if (pop_kind_at (i) == kind::PDI)
- 	    {
- 	      vec.truncate (i);
- 	      break;
-@@ -1295,10 +1326,47 @@ namespace bidi {
-   }
- }
- 
-+/* Get location_t for the range of bytes [START, START + NUM_BYTES)
-+   within the current line in FILE, with the caret at START.  */
-+
-+static location_t
-+get_location_for_byte_range_in_cur_line (cpp_reader *pfile,
-+					 const unsigned char *const start,
-+					 size_t num_bytes)
-+{
-+  gcc_checking_assert (num_bytes > 0);
-+
-+  /* CPP_BUF_COLUMN and linemap_position_for_column both refer
-+     to offsets in bytes, but CPP_BUF_COLUMN is 0-based,
-+     whereas linemap_position_for_column is 1-based.  */
-+
-+  /* Get 0-based offsets within the line.  */
-+  size_t start_offset = CPP_BUF_COLUMN (pfile->buffer, start);
-+  size_t end_offset = start_offset + num_bytes - 1;
-+
-+  /* Now convert to location_t, where "columns" are 1-based byte offsets.  */
-+  location_t start_loc = linemap_position_for_column (pfile->line_table,
-+						      start_offset + 1);
-+  location_t end_loc = linemap_position_for_column (pfile->line_table,
-+						     end_offset + 1);
-+
-+  if (start_loc == end_loc)
-+    return start_loc;
-+
-+  source_range src_range;
-+  src_range.m_start = start_loc;
-+  src_range.m_finish = end_loc;
-+  location_t combined_loc = COMBINE_LOCATION_DATA (pfile->line_table,
-+						   start_loc,
-+						   src_range,
-+						   NULL);
-+  return combined_loc;
-+}
-+
- /* Parse a sequence of 3 bytes starting with P and return its bidi code.  */
- 
- static bidi::kind
--get_bidi_utf8 (const unsigned char *const p)
-+get_bidi_utf8_1 (const unsigned char *const p)
- {
-   gcc_checking_assert (p[0] == bidi::utf8_start);
- 
-@@ -1340,10 +1408,25 @@ get_bidi_utf8 (const unsigned char *cons
-   return bidi::kind::NONE;
- }
- 
-+/* Parse a sequence of 3 bytes starting with P and return its bidi code.
-+   If the kind is not NONE, write the location to *OUT.*/
-+
-+static bidi::kind
-+get_bidi_utf8 (cpp_reader *pfile, const unsigned char *const p, location_t *out)
-+{
-+  bidi::kind result = get_bidi_utf8_1 (p);
-+  if (result != bidi::kind::NONE)
-+    {
-+      /* We have a sequence of 3 bytes starting at P.  */
-+      *out = get_location_for_byte_range_in_cur_line (pfile, p, 3);
-+    }
-+  return result;
-+}
-+
- /* Parse a UCN where P points just past \u or \U and return its bidi code.  */
- 
- static bidi::kind
--get_bidi_ucn (const unsigned char *p, bool is_U)
-+get_bidi_ucn_1 (const unsigned char *p, bool is_U)
- {
-   /* 6.4.3 Universal Character Names
-       \u hex-quad
-@@ -1412,6 +1495,62 @@ get_bidi_ucn (const unsigned char *p, bo
-   return bidi::kind::NONE;
- }
- 
-+/* Parse a UCN where P points just past \u or \U and return its bidi code.
-+   If the kind is not NONE, write the location to *OUT.*/
-+
-+static bidi::kind
-+get_bidi_ucn (cpp_reader *pfile,  const unsigned char *p, bool is_U,
-+	      location_t *out)
-+{
-+  bidi::kind result = get_bidi_ucn_1 (p, is_U);
-+  if (result != bidi::kind::NONE)
-+    {
-+      const unsigned char *start = p - 2;
-+      size_t num_bytes = 2 + (is_U ? 8 : 4);
-+      *out = get_location_for_byte_range_in_cur_line (pfile, start, num_bytes);
-+    }
-+  return result;
-+}
-+
-+/* Subclass of rich_location for reporting on unpaired UTF-8
-+   bidirectional control character(s).
-+   Escape the source lines on output, and show all unclosed
-+   bidi context, labelling everything.  */
-+
-+class unpaired_bidi_rich_location : public rich_location
-+{
-+ public:
-+  class custom_range_label : public range_label
-+  {
-+   public:
-+     label_text get_text (unsigned range_idx) const FINAL OVERRIDE
-+     {
-+       /* range 0 is the primary location; each subsequent range i + 1
-+	  is for bidi::vec[i].  */
-+       if (range_idx > 0)
-+	 {
-+	   const bidi::context &ctxt (bidi::vec[range_idx - 1]);
-+	   return label_text::borrow (bidi::to_str (ctxt.m_kind));
-+	 }
-+       else
-+	 return label_text::borrow (_("end of bidirectional context"));
-+     }
-+  };
-+
-+  unpaired_bidi_rich_location (cpp_reader *pfile, location_t loc)
-+  : rich_location (pfile->line_table, loc, &m_custom_label)
-+  {
-+    set_escape_on_output (true);
-+    for (unsigned i = 0; i < bidi::vec.count (); i++)
-+      add_range (bidi::vec[i].m_loc,
-+		 SHOW_RANGE_WITHOUT_CARET,
-+		 &m_custom_label);
-+  }
-+
-+ private:
-+   custom_range_label m_custom_label;
-+};
-+
- /* We're closing a bidi context, that is, we've encountered a newline,
-    are closing a C-style comment, or are at the end of a string literal,
-    character constant, or identifier.  Warn if this context was not
-@@ -1427,11 +1566,17 @@ maybe_warn_bidi_on_close (cpp_reader *pf
-       const location_t loc
- 	= linemap_position_for_column (pfile->line_table,
- 				       CPP_BUF_COLUMN (pfile->buffer, p));
--      rich_location rich_loc (pfile->line_table, loc);
--      rich_loc.set_escape_on_output (true);
--      cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
--		      "unpaired UTF-8 bidirectional control character "
--		      "detected");
-+      unpaired_bidi_rich_location rich_loc (pfile, loc);
-+      /* cpp_callbacks doesn't yet have a way to handle singular vs plural
-+	 forms of a diagnostic, so fake it for now.  */
-+      if (bidi::vec.count () > 1)
-+	cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			"unpaired UTF-8 bidirectional control characters "
-+			"detected");
-+      else
-+	cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			"unpaired UTF-8 bidirectional control character "
-+			"detected");
-     }
-   /* We're done with this context.  */
-   bidi::on_close ();
-@@ -1439,12 +1584,13 @@ maybe_warn_bidi_on_close (cpp_reader *pf
- 
- /* We're at the beginning or in the middle of an identifier/comment/string
-    literal/character constant.  Warn if we've encountered a bidi character.
--   KIND says which bidi character it was; P points to it in the character
--   stream.  UCN_P is true iff this bidi character was written as a UCN.  */
-+   KIND says which bidi control character it was; UCN_P is true iff this bidi
-+   control character was written as a UCN.  LOC is the location of the
-+   character, but is only valid if KIND != bidi::kind::NONE.  */
- 
- static void
--maybe_warn_bidi_on_char (cpp_reader *pfile, const uchar *p, bidi::kind kind,
--			 bool ucn_p)
-+maybe_warn_bidi_on_char (cpp_reader *pfile, bidi::kind kind,
-+			 bool ucn_p, location_t loc)
- {
-   if (__builtin_expect (kind == bidi::kind::NONE, 1))
-     return;
-@@ -1453,9 +1599,6 @@ maybe_warn_bidi_on_char (cpp_reader *pfi
- 
-   if (warn_bidi != bidirectional_none)
-     {
--      const location_t loc
--	= linemap_position_for_column (pfile->line_table,
--				       CPP_BUF_COLUMN (pfile->buffer, p));
-       rich_location rich_loc (pfile->line_table, loc);
-       rich_loc.set_escape_on_output (true);
- 
-@@ -1467,9 +1610,12 @@ maybe_warn_bidi_on_char (cpp_reader *pfi
- 	{
- 	  if (warn_bidi == bidirectional_unpaired
- 	      && bidi::current_ctx_ucn_p () != ucn_p)
--	    cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
--			    "UTF-8 vs UCN mismatch when closing "
--			    "a context by \"%s\"", bidi::to_str (kind));
-+	    {
-+	      rich_loc.add_range (bidi::current_ctx_loc ());
-+	      cpp_warning_at (pfile, CPP_W_BIDIRECTIONAL, &rich_loc,
-+			      "UTF-8 vs UCN mismatch when closing "
-+			      "a context by \"%s\"", bidi::to_str (kind));
-+	    }
- 	}
-       else if (warn_bidi == bidirectional_any)
- 	{
-@@ -1484,7 +1630,7 @@ maybe_warn_bidi_on_char (cpp_reader *pfi
- 	}
-     }
-   /* We're done with this context.  */
--  bidi::on_char (kind, ucn_p);
-+  bidi::on_char (kind, ucn_p, loc);
- }
- 
- /* Skip a C-style block comment.  We find the end of the comment by
-@@ -1552,8 +1698,9 @@ _cpp_skip_block_comment (cpp_reader *pfi
- 	 a bidirectional control character.  */
-       else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p)
- 	{
--	  bidi::kind kind = get_bidi_utf8 (cur - 1);
--	  maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/false);
-+	  location_t loc;
-+	  bidi::kind kind = get_bidi_utf8 (pfile, cur - 1, &loc);
-+	  maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc);
- 	}
-     }
- 
-@@ -1586,9 +1733,9 @@ skip_line_comment (cpp_reader *pfile)
- 	    {
- 	      if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0))
- 		{
--		  bidi::kind kind = get_bidi_utf8 (buffer->cur);
--		  maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
--					   /*ucn_p=*/false);
-+		  location_t loc;
-+		  bidi::kind kind = get_bidi_utf8 (pfile, buffer->cur, &loc);
-+		  maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc);
- 		}
- 	      buffer->cur++;
- 	    }
-@@ -1708,9 +1855,9 @@ forms_identifier_p (cpp_reader *pfile, i
- 	  if (__builtin_expect (*buffer->cur == bidi::utf8_start, 0)
- 	      && warn_bidi_p)
- 	    {
--	      bidi::kind kind = get_bidi_utf8 (buffer->cur);
--	      maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
--				       /*ucn_p=*/false);
-+	      location_t loc;
-+	      bidi::kind kind = get_bidi_utf8 (pfile, buffer->cur, &loc);
-+	      maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc);
- 	    }
- 	  if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
- 			       state, &s))
-@@ -1722,10 +1869,12 @@ forms_identifier_p (cpp_reader *pfile, i
- 	  buffer->cur += 2;
- 	  if (warn_bidi_p)
- 	    {
--	      bidi::kind kind = get_bidi_ucn (buffer->cur,
--					      buffer->cur[-1] == 'U');
--	      maybe_warn_bidi_on_char (pfile, buffer->cur, kind,
--				       /*ucn_p=*/true);
-+	      location_t loc;
-+	      bidi::kind kind = get_bidi_ucn (pfile,
-+					      buffer->cur,
-+					      buffer->cur[-1] == 'U',
-+					      &loc);
-+	      maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/true, loc);
- 	    }
- 	  if (_cpp_valid_ucn (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
- 			      state, &s, NULL, NULL))
-@@ -2336,8 +2485,11 @@ lex_raw_string (cpp_reader *pfile, cpp_t
- 	}
-       else if (__builtin_expect ((unsigned char) c == bidi::utf8_start, 0)
- 	       && warn_bidi_p)
--	maybe_warn_bidi_on_char (pfile, pos - 1, get_bidi_utf8 (pos - 1),
--				 /*ucn_p=*/false);
-+	{
-+	  location_t loc;
-+	  bidi::kind kind = get_bidi_utf8 (pfile, pos - 1, &loc);
-+	  maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc);
-+	}
-     }
- 
-   if (warn_bidi_p)
-@@ -2447,8 +2599,10 @@ lex_string (cpp_reader *pfile, cpp_token
- 	{
- 	  if ((cur[0] == 'u' || cur[0] == 'U') && warn_bidi_p)
- 	    {
--	      bidi::kind kind = get_bidi_ucn (cur + 1, cur[0] == 'U');
--	      maybe_warn_bidi_on_char (pfile, cur, kind, /*ucn_p=*/true);
-+	      location_t loc;
-+	      bidi::kind kind = get_bidi_ucn (pfile, cur + 1, cur[0] == 'U',
-+					      &loc);
-+	      maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/true, loc);
- 	    }
- 	  cur++;
- 	}
-@@ -2476,8 +2630,9 @@ lex_string (cpp_reader *pfile, cpp_token
- 	saw_NUL = true;
-       else if (__builtin_expect (c == bidi::utf8_start, 0) && warn_bidi_p)
- 	{
--	  bidi::kind kind = get_bidi_utf8 (cur - 1);
--	  maybe_warn_bidi_on_char (pfile, cur - 1, kind, /*ucn_p=*/false);
-+	  location_t loc;
-+	  bidi::kind kind = get_bidi_utf8 (pfile, cur - 1, &loc);
-+	  maybe_warn_bidi_on_char (pfile, kind, /*ucn_p=*/false, loc);
- 	}
-     }
- 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
deleted file mode 100644
index ef19eef..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
+++ /dev/null
@@ -1,260 +0,0 @@
-From 84dd8ea4c982fc2c82af642293d29e9c1880de5b Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 29 Mar 2013 09:24:50 +0400
-Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
- relative to SYSTEMLIBS_DIR
-
-This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
-relative to SYSTEMLIBS_DIR which can be set in generated headers
-This breaks the assumption of hardcoded multilib in gcc
-Change is only for the supported architectures in OE including
-SH, sparc, alpha for possible future support (if any)
-
-Removes the do_headerfix task in metadata
-
-Upstream-Status: Inappropriate [OE configuration]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- gcc/config/aarch64/aarch64-linux.h |  4 ++--
- gcc/config/alpha/linux-elf.h       |  4 ++--
- gcc/config/arm/linux-eabi.h        |  4 ++--
- gcc/config/arm/linux-elf.h         |  2 +-
- gcc/config/i386/linux.h            |  2 +-
- gcc/config/i386/linux64.h          |  6 +++---
- gcc/config/linux.h                 |  8 ++++----
- gcc/config/mips/linux.h            | 12 ++++++------
- gcc/config/riscv/linux.h           |  2 +-
- gcc/config/rs6000/linux64.h        | 15 +++++----------
- gcc/config/sh/linux.h              |  2 +-
- gcc/config/sparc/linux.h           |  2 +-
- gcc/config/sparc/linux64.h         |  4 ++--
- 13 files changed, 31 insertions(+), 36 deletions(-)
-
-diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
-index 7f2529a2a1d..4bcae7f3110 100644
---- a/gcc/config/aarch64/aarch64-linux.h
-+++ b/gcc/config/aarch64/aarch64-linux.h
-@@ -21,10 +21,10 @@
- #ifndef GCC_AARCH64_LINUX_H
- #define GCC_AARCH64_LINUX_H
- 
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
-+#define GLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
- 
- #undef MUSL_DYNAMIC_LINKER
--#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
-+#define MUSL_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
- 
- #undef  ASAN_CC1_SPEC
- #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
-diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
-index c1dae8ca2cf..3ce2b76c1a4 100644
---- a/gcc/config/alpha/linux-elf.h
-+++ b/gcc/config/alpha/linux-elf.h
-@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3.  If not see
- #define EXTRA_SPECS \
- { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
- 
--#define GLIBC_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
--#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
-+#define GLIBC_DYNAMIC_LINKER	SYSTEMLIBS_DIR "ld-linux.so.2"
-+#define UCLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-uClibc.so.0"
- #if DEFAULT_LIBC == LIBC_UCLIBC
- #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
- #elif DEFAULT_LIBC == LIBC_GLIBC
-diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
-index 85d0136e76e..6bd95855827 100644
---- a/gcc/config/arm/linux-eabi.h
-+++ b/gcc/config/arm/linux-eabi.h
-@@ -65,8 +65,8 @@
-    GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI.  */
- 
- #undef  GLIBC_DYNAMIC_LINKER
--#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
--#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
-+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT SYSTEMLIBS_DIR "ld-linux.so.3"
-+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT SYSTEMLIBS_DIR "ld-linux-armhf.so.3"
- #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
- 
- #define GLIBC_DYNAMIC_LINKER \
-diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
-index 0c1c4e70b6b..6bd643ade11 100644
---- a/gcc/config/arm/linux-elf.h
-+++ b/gcc/config/arm/linux-elf.h
-@@ -60,7 +60,7 @@
- 
- #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
- 
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
- 
- #define LINUX_TARGET_LINK_SPEC  "%{h*} \
-    %{static:-Bstatic} \
-diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
-index 04b274f1654..7aafcf3ac2d 100644
---- a/gcc/config/i386/linux.h
-+++ b/gcc/config/i386/linux.h
-@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
- <http://www.gnu.org/licenses/>.  */
- 
- #define GNU_USER_LINK_EMULATION "elf_i386"
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
- 
- #undef MUSL_DYNAMIC_LINKER
- #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
-diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
-index b3822ced528..92d303e80d6 100644
---- a/gcc/config/i386/linux64.h
-+++ b/gcc/config/i386/linux64.h
-@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
- #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
- #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
- 
--#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
--#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
--#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
-+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
-+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
- 
- #undef MUSL_DYNAMIC_LINKER32
- #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
-diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index 4e1db60fced..87efc5f69fe 100644
---- a/gcc/config/linux.h
-+++ b/gcc/config/linux.h
-@@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
-    GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
-    supporting both 32-bit and 64-bit compilation.  */
--#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
--#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
--#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
--#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
-+#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0"
-+#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
-+#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
-+#define UCLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ldx32-uClibc.so.0"
- #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
- #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
- #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
-diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
-index 44a85e410d9..8d41b5574f6 100644
---- a/gcc/config/mips/linux.h
-+++ b/gcc/config/mips/linux.h
-@@ -22,20 +22,20 @@ along with GCC; see the file COPYING3.  If not see
- #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
- 
- #define GLIBC_DYNAMIC_LINKER32 \
--  "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
- #define GLIBC_DYNAMIC_LINKER64 \
--  "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
- #define GLIBC_DYNAMIC_LINKERN32 \
--  "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
- 
- #undef UCLIBC_DYNAMIC_LINKER32
- #define UCLIBC_DYNAMIC_LINKER32 \
--  "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
- #undef UCLIBC_DYNAMIC_LINKER64
- #define UCLIBC_DYNAMIC_LINKER64 \
--  "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld64-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld64-uClibc.so.0}"
- #define UCLIBC_DYNAMIC_LINKERN32 \
--  "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
-+  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
- 
- #undef MUSL_DYNAMIC_LINKER32
- #define MUSL_DYNAMIC_LINKER32 \
-diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
-index fce5b896e6e..03aa55cb5ab 100644
---- a/gcc/config/riscv/linux.h
-+++ b/gcc/config/riscv/linux.h
-@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
-     GNU_USER_TARGET_OS_CPP_BUILTINS();				\
-   } while (0)
- 
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
-+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
- 
- #define MUSL_ABI_SUFFIX \
-   "%{mabi=ilp32:-sf}" \
-diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
-index e3f2cd254f6..a11e01faa3d 100644
---- a/gcc/config/rs6000/linux64.h
-+++ b/gcc/config/rs6000/linux64.h
-@@ -336,24 +336,19 @@ extern int dot_symbols;
- #undef	LINK_OS_DEFAULT_SPEC
- #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
- 
--#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
--
-+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
- #ifdef LINUX64_DEFAULT_ABI_ELFv2
--#define GLIBC_DYNAMIC_LINKER64 \
--"%{mabi=elfv1:%(dynamic_linker_prefix)/lib64/ld64.so.1;" \
--":%(dynamic_linker_prefix)/lib64/ld64.so.2}"
-+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:" SYSTEMLIBS_DIR "ld64.so.1;:" SYSTEMLIBS_DIR "ld64.so.2}"
- #else
--#define GLIBC_DYNAMIC_LINKER64 \
--"%{mabi=elfv2:%(dynamic_linker_prefix)/lib64/ld64.so.2;" \
--":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
-+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}"
- #endif
- 
- #undef MUSL_DYNAMIC_LINKER32
- #define MUSL_DYNAMIC_LINKER32 \
--  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
-+  SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
- #undef MUSL_DYNAMIC_LINKER64
- #define MUSL_DYNAMIC_LINKER64 \
--  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
-+  SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
- 
- #undef  DEFAULT_ASM_ENDIAN
- #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
-diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
-index 7558d2f7195..3aaa6c3a078 100644
---- a/gcc/config/sh/linux.h
-+++ b/gcc/config/sh/linux.h
-@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3.  If not see
-   "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
-   "%{mfdpic:-fdpic}.so.1"
- 
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
- 
- #undef SUBTARGET_LINK_EMUL_SUFFIX
- #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
-diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
-index 2550d7ee8f0..a94f4cd8ba2 100644
---- a/gcc/config/sparc/linux.h
-+++ b/gcc/config/sparc/linux.h
-@@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
-    When the -shared link option is used a final link is not being
-    done.  */
- 
--#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
- 
- #undef  LINK_SPEC
- #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
-diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
-index 95af8afa9b5..63127afb074 100644
---- a/gcc/config/sparc/linux64.h
-+++ b/gcc/config/sparc/linux64.h
-@@ -78,8 +78,8 @@ along with GCC; see the file COPYING3.  If not see
-    When the -shared link option is used a final link is not being
-    done.  */
- 
--#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
--#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
-+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux.so.2"
- 
- #ifdef SPARC_BI_ARCH
- 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0007-gcc-Fix-argument-list-too-long-error.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0007-gcc-Fix-argument-list-too-long-error.patch
deleted file mode 100644
index 9f9f8cc..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0007-gcc-Fix-argument-list-too-long-error.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 768e9075e88d811b00207d991123438bb996e4ea Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 29 Mar 2013 09:26:37 +0400
-Subject: [PATCH] gcc: Fix argument list too long error.
-
-There would be an "Argument list too long" error when the
-build directory is longer than 200, this is caused by:
-
-headers=`echo $(PLUGIN_HEADERS) | tr ' ' '\012' | sort -u`
-
-The PLUGIN_HEADERS is too long before sort, so the "echo" can't handle
-it, use the $(sort list) of GNU make which can handle the too long list
-would fix the problem, the header would be short enough after sorted.
-The "tr ' ' '\012'" was used for translating the space to "\n", the
-$(sort list) doesn't need this.
-
-Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
-
-RP: gcc then added *.h and *.def additions to this list, breaking the original
-fix. Add the sort to the original gcc code, leaving the tr+sort to fix the original
-issue but include the new files too as reported by Zhuang <qiuguang.zqg@alibaba-inc.com>
-
-Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=66e157188bd2f789809e17e85f917534c9381599]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- gcc/Makefile.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/gcc/Makefile.in b/gcc/Makefile.in
-index 95962ae37b6..d1d4512bba3 100644
---- a/gcc/Makefile.in
-+++ b/gcc/Makefile.in
-@@ -3671,7 +3671,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
- # We keep the directory structure for files in config, common/config or
- # c-family and .def files. All other files are flattened to a single directory.
- 	$(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
--	headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
-+	headers=`echo $(sort $(PLUGIN_HEADERS)) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
- 	srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \
- 	for file in $$headers; do \
- 	  if [ -f $$file ] ; then \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch
deleted file mode 100644
index 45953f8..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch
+++ /dev/null
@@ -1,204 +0,0 @@
-From 667b302f637be0a4b6ef714b5eb0026c54425386 Mon Sep 17 00:00:00 2001
-From: Richard Purdie <richard.purdie@linuxfoundation.org>
-Date: Sun, 31 Oct 2021 17:40:12 -0700
-Subject: [PATCH] Makefile.in: Ensure build CPP/CPPFLAGS is used for build
- targets
-
-During cross compiling, CPP is being set to the target compiler even for
-build targets. As an example, when building a cross compiler targetting
-mingw, the config.log for libiberty in
-build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log
-shows:
-
-configure:3786: checking how to run the C preprocessor
-configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32
-configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c
-configure:3876: $? = 0
-
-This is libiberty being built for the build environment, not the target one
-(i.e. in build-x86_64-linux). As such it should be using the build environment's
-gcc and not the target one. In the mingw case the system headers are quite
-different leading to build failures related to not being able to include a
-process.h file for pem-unix.c.
-
-Further analysis shows the same issue occuring for CPPFLAGS too.
-
-Fix this by adding support for CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD which
-for example, avoids mixing the mingw headers for host binaries on linux
-systems.
-
-2021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org>
-
-ChangeLog:
-
-    * Makefile.tpl: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
-    * Makefile.in: Regenerate.
-    * configure: Regenerate.
-    * configure.ac: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
-
-gcc/ChangeLog:
-
-    * configure: Regenerate.
-    * configure.ac: Use CPPFLAGS_FOR_BUILD for GMPINC
-
-Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-
-Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582727.html]
-Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=84401ce5fb4ecab55decb472b168100e7593e01f]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- Makefile.in      | 6 ++++++
- Makefile.tpl     | 6 ++++++
- configure        | 4 ++++
- configure.ac     | 4 ++++
- gcc/configure    | 2 +-
- gcc/configure.ac | 2 +-
- 6 files changed, 22 insertions(+), 2 deletions(-)
-
-diff --git a/Makefile.in b/Makefile.in
-index 20cbbe2906d..33476d53327 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -154,6 +154,8 @@ BUILD_EXPORTS = \
- 	CC="$(CC_FOR_BUILD)"; export CC; \
- 	CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
- 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
-+	CPP="$(CPP_FOR_BUILD)"; export CPP; \
-+	CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
- 	CXX="$(CXX_FOR_BUILD)"; export CXX; \
- 	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
- 	GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
-@@ -202,6 +204,8 @@ HOST_EXPORTS = \
- 	AR="$(AR)"; export AR; \
- 	AS="$(AS)"; export AS; \
- 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
-+	CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
-+	CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
- 	CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
- 	DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
- 	DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
-@@ -360,6 +364,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
- AS_FOR_BUILD = @AS_FOR_BUILD@
- CC_FOR_BUILD = @CC_FOR_BUILD@
- CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
-+CPP_FOR_BUILD = @CPP_FOR_BUILD@
-+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
- CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
- CXX_FOR_BUILD = @CXX_FOR_BUILD@
- DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
-diff --git a/Makefile.tpl b/Makefile.tpl
-index 9adf4f94728..e39d85d1109 100644
---- a/Makefile.tpl
-+++ b/Makefile.tpl
-@@ -157,6 +157,8 @@ BUILD_EXPORTS = \
- 	CC="$(CC_FOR_BUILD)"; export CC; \
- 	CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
- 	CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
-+	CPP="$(CPP_FOR_BUILD)"; export CPP; \
-+	CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
- 	CXX="$(CXX_FOR_BUILD)"; export CXX; \
- 	CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
- 	GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
-@@ -205,6 +207,8 @@ HOST_EXPORTS = \
- 	AR="$(AR)"; export AR; \
- 	AS="$(AS)"; export AS; \
- 	CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
-+	CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
-+	CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
- 	CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
- 	DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
- 	DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
-@@ -363,6 +367,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
- AS_FOR_BUILD = @AS_FOR_BUILD@
- CC_FOR_BUILD = @CC_FOR_BUILD@
- CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
-+CPP_FOR_BUILD = @CPP_FOR_BUILD@
-+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
- CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
- CXX_FOR_BUILD = @CXX_FOR_BUILD@
- DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
-diff --git a/configure b/configure
-index 45744e6e471..ff0de8a68b4 100755
---- a/configure
-+++ b/configure
-@@ -655,6 +655,8 @@ DSYMUTIL_FOR_BUILD
- DLLTOOL_FOR_BUILD
- CXX_FOR_BUILD
- CXXFLAGS_FOR_BUILD
-+CPPFLAGS_FOR_BUILD
-+CPP_FOR_BUILD
- CFLAGS_FOR_BUILD
- CC_FOR_BUILD
- AS_FOR_BUILD
-@@ -4100,6 +4102,7 @@ if test "${build}" != "${host}" ; then
-   AR_FOR_BUILD=${AR_FOR_BUILD-ar}
-   AS_FOR_BUILD=${AS_FOR_BUILD-as}
-   CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
-+  CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}"
-   CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
-   DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
-   GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
-@@ -9831,6 +9834,7 @@ esac
- # our build compiler if desired.
- if test x"${build}" = x"${host}" ; then
-   CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
-+  CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
-   CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
-   LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
- fi
-diff --git a/configure.ac b/configure.ac
-index bf66b51373c..09fa3896dc7 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1347,6 +1347,7 @@ if test "${build}" != "${host}" ; then
-   AR_FOR_BUILD=${AR_FOR_BUILD-ar}
-   AS_FOR_BUILD=${AS_FOR_BUILD-as}
-   CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
-+  CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}"
-   CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
-   DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
-   GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
-@@ -3336,6 +3337,7 @@ esac
- # our build compiler if desired.
- if test x"${build}" = x"${host}" ; then
-   CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
-+  CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
-   CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
-   LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
- fi
-@@ -3402,6 +3404,8 @@ AC_SUBST(AR_FOR_BUILD)
- AC_SUBST(AS_FOR_BUILD)
- AC_SUBST(CC_FOR_BUILD)
- AC_SUBST(CFLAGS_FOR_BUILD)
-+AC_SUBST(CPP_FOR_BUILD)
-+AC_SUBST(CPPFLAGS_FOR_BUILD)
- AC_SUBST(CXXFLAGS_FOR_BUILD)
- AC_SUBST(CXX_FOR_BUILD)
- AC_SUBST(DLLTOOL_FOR_BUILD)
-diff --git a/gcc/configure b/gcc/configure
-index ec3c24482df..31a460dc9d0 100755
---- a/gcc/configure
-+++ b/gcc/configure
-@@ -12740,7 +12740,7 @@ else
- 	CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
- 	CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
- 	LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
--	GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
-+	GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
- 	${realsrcdir}/configure \
- 		--enable-languages=${enable_languages-all} \
- 		${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
-diff --git a/gcc/configure.ac b/gcc/configure.ac
-index ea794cd1763..b965eb036bc 100644
---- a/gcc/configure.ac
-+++ b/gcc/configure.ac
-@@ -2054,7 +2054,7 @@ else
- 	CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
- 	CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
- 	LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
--	GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
-+	GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
- 	${realsrcdir}/configure \
- 		--enable-languages=${enable_languages-all} \
- 		${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch
deleted file mode 100644
index 76ebfd7..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 9ec4db8e910d9a51ae43f6b20d4bf1dac2d8cca8 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Tue, 2 Feb 2016 10:26:10 -0800
-Subject: [PATCH] nios2: Define MUSL_DYNAMIC_LINKER
-
-Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e5ddbbf992b909d8e38851bd3179d29389e6ac97]
-
-Signed-off-by: Marek Vasut <marex@denx.de>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- gcc/config/nios2/linux.h | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
-index 08edf1521f6..15696d86241 100644
---- a/gcc/config/nios2/linux.h
-+++ b/gcc/config/nios2/linux.h
-@@ -30,6 +30,7 @@
- #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
- 
- #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
-+#define MUSL_DYNAMIC_LINKER  "/lib/ld-musl-nios2.so.1"
- 
- #undef LINK_SPEC
- #define LINK_SPEC LINK_SPEC_ENDIAN \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
deleted file mode 100644
index 9b7c5c5..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 79a568dec47baa264eb6290fed3df3244450a92e Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Wed, 4 May 2016 21:11:34 -0700
-Subject: [PATCH] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS
-
-Upstream-Status: Pending
-
-Signed-off-by: Christopher Larson <chris_larson@mentor.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- libgcc/config/t-slibgcc | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc
-index c59b43b7b69..ca4c141f526 100644
---- a/libgcc/config/t-slibgcc
-+++ b/libgcc/config/t-slibgcc
-@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
- 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
- 
- SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
--	$(SHLIB_LDFLAGS) \
-+	$(LDFLAGS) $(SHLIB_LDFLAGS) \
- 	-o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
- 	$(SHLIB_OBJS) $(SHLIB_LC) && \
- 	rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0022-sync-gcc-stddef.h-with-musl.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0022-sync-gcc-stddef.h-with-musl.patch
deleted file mode 100644
index 86fb22f..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0022-sync-gcc-stddef.h-with-musl.patch
+++ /dev/null
@@ -1,88 +0,0 @@
-From 07a06aa8e8285c1bb06d0bebeaa9ad04eb76f2e2 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Fri, 3 Feb 2017 12:56:00 -0800
-Subject: [PATCH] sync gcc stddef.h with musl
-
-musl defines ptrdiff_t size_t and wchar_t
-so dont define them here if musl is definining them
-
-Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=85a438fc78dd12249ca854a3e5c577fefeb1a5cd]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- gcc/ginclude/stddef.h | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
-index 66619fe43b1..3f843d6f365 100644
---- a/gcc/ginclude/stddef.h
-+++ b/gcc/ginclude/stddef.h
-@@ -128,6 +128,7 @@ _TYPE_wchar_t;
- #ifndef ___int_ptrdiff_t_h
- #ifndef _GCC_PTRDIFF_T
- #ifndef _PTRDIFF_T_DECLARED /* DragonFly */
-+#ifndef __DEFINED_ptrdiff_t /* musl */
- #define _PTRDIFF_T
- #define _T_PTRDIFF_
- #define _T_PTRDIFF
-@@ -137,10 +138,12 @@ _TYPE_wchar_t;
- #define ___int_ptrdiff_t_h
- #define _GCC_PTRDIFF_T
- #define _PTRDIFF_T_DECLARED
-+#define __DEFINED_ptrdiff_t /* musl */
- #ifndef __PTRDIFF_TYPE__
- #define __PTRDIFF_TYPE__ long int
- #endif
- typedef __PTRDIFF_TYPE__ ptrdiff_t;
-+#endif /* __DEFINED_ptrdiff_t */
- #endif /* _PTRDIFF_T_DECLARED */
- #endif /* _GCC_PTRDIFF_T */
- #endif /* ___int_ptrdiff_t_h */
-@@ -178,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
- #ifndef _GCC_SIZE_T
- #ifndef _SIZET_
- #ifndef __size_t
-+#ifndef __DEFINED_size_t /* musl */
- #define __size_t__	/* BeOS */
- #define __SIZE_T__	/* Cray Unicos/Mk */
- #define _SIZE_T
-@@ -194,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
- #define ___int_size_t_h
- #define _GCC_SIZE_T
- #define _SIZET_
-+#define __DEFINED_size_t /* musl */
- #if defined (__FreeBSD__) \
-   || defined(__DragonFly__) \
-   || defined(__FreeBSD_kernel__) \
-@@ -228,6 +233,7 @@ typedef long ssize_t;
- #endif /* _SIZE_T */
- #endif /* __SIZE_T__ */
- #endif /* __size_t__ */
-+#endif /* __DEFINED_size_t */
- #undef	__need_size_t
- #endif /* _STDDEF_H or __need_size_t.  */
- 
-@@ -257,6 +263,7 @@ typedef long ssize_t;
- #ifndef ___int_wchar_t_h
- #ifndef __INT_WCHAR_T_H
- #ifndef _GCC_WCHAR_T
-+#ifndef __DEFINED_wchar_t /* musl */
- #define __wchar_t__	/* BeOS */
- #define __WCHAR_T__	/* Cray Unicos/Mk */
- #define _WCHAR_T
-@@ -272,6 +279,7 @@ typedef long ssize_t;
- #define __INT_WCHAR_T_H
- #define _GCC_WCHAR_T
- #define _WCHAR_T_DECLARED
-+#define __DEFINED_wchar_t /* musl */
- 
- /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
-    instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
-@@ -337,6 +345,7 @@ typedef __WCHAR_TYPE__ wchar_t;
- #endif
- #endif /* __WCHAR_T__ */
- #endif /* __wchar_t__ */
-+#endif /* __DEFINED_wchar_t musl */
- #undef	__need_wchar_t
- #endif /* _STDDEF_H or __need_wchar_t.  */
- 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0026-mingw32-Enable-operation_not_supported.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0026-mingw32-Enable-operation_not_supported.patch
deleted file mode 100644
index b46bde1..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0026-mingw32-Enable-operation_not_supported.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 7bc34769f0b055e25286576e4ba6d211e8159834 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Tue, 12 May 2020 10:39:09 -0700
-Subject: [PATCH] mingw32: Enable operation_not_supported
-
-Fixes nativesdk build errors on mingw32 gcc-runtime
-
-Upstream-Status: Pending
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- libstdc++-v3/config/os/mingw32/error_constants.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h
-index eca06a97014..933cfab49cf 100644
---- a/libstdc++-v3/config/os/mingw32/error_constants.h
-+++ b/libstdc++-v3/config/os/mingw32/error_constants.h
-@@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
- #ifdef EPERM
-       operation_not_permitted = 		EPERM,
- #endif
--//    operation_not_supported = 		EOPNOTSUPP,
-+      operation_not_supported = 		EOPNOTSUPP,
- #ifdef EWOULDBLOCK
-       operation_would_block = 			EWOULDBLOCK,
- #endif
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch
deleted file mode 100644
index de06793..0000000
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch
+++ /dev/null
@@ -1,101 +0,0 @@
-From 49008eeedc97014f44e12afe179d3785e4438372 Mon Sep 17 00:00:00 2001
-From: Richard Biener <rguenther@suse.de>
-Date: Tue, 20 Jul 2021 11:00:33 +0200
-Subject: [PATCH] debug/101473 - apply debug prefix maps before checksumming
- DIEs
-
-The following makes sure to apply the debug prefix maps to filenames
-before checksumming DIEs to create the global symbol for the CU DIE
-used by LTO to link the late debug to the early debug.  This avoids
-binary differences (in said symbol) when compiling with toolchains
-installed under a different path and that compensated with appropriate
--fdebug-prefix-map options.
-
-The easiest and most scalable way is to record both the unmapped
-and the remapped filename in the dwarf_file_data so the remapping
-process takes place at a single point and only once (otherwise it
-creates GC garbage at each point doing that).
-
-2021-07-20  Richard Biener  <rguenther@suse.de>
-
-	PR debug/101473
-	* dwarf2out.h (dwarf_file_data): Add key member.
-	* dwarf2out.c (dwarf_file_hasher::equal): Compare key.
-	(dwarf_file_hasher::hash): Hash key.
-	(lookup_filename): Remap the filename and store it in the
-	filename member of dwarf_file_data when creating a new
-	dwarf_file_data.
-	(file_name_acquire): Do not remap the filename again.
-	(maybe_emit_file): Likewise.
-
-[YOCTO #14481]
-
-Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7cc2df084b7977653a9b59cbc34a9ad500ae619c]
-
-The upstream patch was modified to compensate for the definition of
-"struct dwarf_file_data" being in dwarf2out.c rather than dwarf2out.h in
-this version of gcc.
-
-Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- gcc/dwarf2out.c | 13 +++++++------
- 1 file changed, 7 insertions(+), 6 deletions(-)
-
-diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
-index e5d3ce4966d..41ac3008507 100644
---- a/gcc/dwarf2out.c
-+++ b/gcc/dwarf2out.c
-@@ -1283,6 +1283,7 @@ dwarf2out_switch_text_section (void)
- 
- /* Data about a single source file.  */
- struct GTY((for_user)) dwarf_file_data {
-+  const char * key;
-   const char * filename;
-   int emitted_number;
- };
-@@ -12335,7 +12336,7 @@ file_name_acquire (dwarf_file_data **slot, file_name_acquire_data *fnad)
- 
-   fi = fnad->files + fnad->used_files++;
- 
--  f = remap_debug_filename (d->filename);
-+  f = d->filename;
- 
-   /* Skip all leading "./".  */
-   while (f[0] == '.' && IS_DIR_SEPARATOR (f[1]))
-@@ -27259,13 +27260,13 @@ dwarf2out_ignore_block (const_tree block)
- bool
- dwarf_file_hasher::equal (dwarf_file_data *p1, const char *p2)
- {
--  return filename_cmp (p1->filename, p2) == 0;
-+  return filename_cmp (p1->key, p2) == 0;
- }
- 
- hashval_t
- dwarf_file_hasher::hash (dwarf_file_data *p)
- {
--  return htab_hash_string (p->filename);
-+  return htab_hash_string (p->key);
- }
- 
- /* Lookup FILE_NAME (in the list of filenames that we know about here in
-@@ -27295,7 +27296,8 @@ lookup_filename (const char *file_name)
-     return *slot;
- 
-   created = ggc_alloc<dwarf_file_data> ();
--  created->filename = file_name;
-+  created->key = file_name;
-+  created->filename = remap_debug_filename (file_name);
-   created->emitted_number = 0;
-   *slot = created;
-   return created;
-@@ -27321,8 +27323,7 @@ maybe_emit_file (struct dwarf_file_data * fd)
-       if (output_asm_line_debug_info ())
- 	{
- 	  fprintf (asm_out_file, "\t.file %u ", fd->emitted_number);
--	  output_quoted_string (asm_out_file,
--				remap_debug_filename (fd->filename));
-+	  output_quoted_string (asm_out_file, fd->filename);
- 	  fputc ('\n', asm_out_file);
- 	}
-     }
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3.inc b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2.inc
similarity index 61%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3.inc
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2.inc
index 8eba959..06bd8fa 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3.inc
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2.inc
@@ -1,16 +1,16 @@
 require recipes-devtools/gcc/gcc-common.inc
 
 # Third digit in PV should be incremented after a minor release
-ARM_GCC_VERSION = "11.3"
+ARM_GCC_VERSION = "12.2"
 ARM_GCC_SUB_VERSION = "rel1"
 PV = "arm-${ARM_GCC_VERSION}"
-CVE_VERSION = "11.3"
+CVE_VERSION = "12.2"
 
 # BINV should be incremented to a revision after a minor gcc release
 
-BINV = "11.3.1"
+BINV = "12.2.1"
 
-MMYY = "22.08"
+MMYY = "22.12"
 RELEASE = "20${MMYY}"
 PR = "r${RELEASE}"
 
@@ -30,45 +30,34 @@
 "
 
 BASEURI ?= "https://developer.arm.com/-/media/Files/downloads/gnu/${ARM_GCC_VERSION}.${ARM_GCC_SUB_VERSION}/srcrel/arm-gnu-toolchain-src-snapshot-${ARM_GCC_VERSION}.${ARM_GCC_SUB_VERSION}.tar.xz"
-SRC_URI = "\
-           ${BASEURI} \
+SRC_URI = "${BASEURI} \
            file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \
            file://0002-gcc-poison-system-directories.patch \
            file://0003-64-bit-multilib-hack.patch \
-           file://0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
-           file://0005-cpp-honor-sysroot.patch \
-           file://0006-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
-           file://0007-gcc-Fix-argument-list-too-long-error.patch \
+           file://0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch \
+           file://0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
+           file://0006-cpp-honor-sysroot.patch \
+           file://0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
            file://0008-libtool.patch \
            file://0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \
            file://0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch \
            file://0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \
-           file://0012-Ensure-target-gcc-headers-can-be-included.patch \
-           file://0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch \
-           file://0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
-           file://0015-Makefile.in-Ensure-build-CPP-CPPFLAGS-is-used-for-bu.patch \
-           file://0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch \
-           file://0017-handle-sysroot-support-for-nativesdk-gcc.patch \
-           file://0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
-           file://0019-nios2-Define-MUSL_DYNAMIC_LINKER.patch \
-           file://0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
-           file://0021-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \
-           file://0022-sync-gcc-stddef.h-with-musl.patch \
-           file://0023-Re-introduce-spe-commandline-options.patch \
-           file://0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \
-           file://0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
-           file://0026-mingw32-Enable-operation_not_supported.patch \
-           file://0027-libatomic-Do-not-enforce-march-on-aarch64.patch \
-           file://0028-debug-101473-apply-debug-prefix-maps-before-checksum.patch \
-           file://0029-Fix-install-path-of-linux64.h.patch \
-           file://0030-rust-recursion-limit.patch \
-           file://0001-CVE-2021-42574.patch \
-           file://0002-CVE-2021-42574.patch \
-           file://0003-CVE-2021-42574.patch \
-           file://0004-CVE-2021-42574.patch \
-           file://0001-CVE-2021-46195.patch \
+           file://0013-Ensure-target-gcc-headers-can-be-included.patch \
+           file://0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch \
+           file://0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
+           file://0016-handle-sysroot-support-for-nativesdk-gcc.patch \
+           file://0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
+           file://0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
+           file://0019-Re-introduce-spe-commandline-options.patch \
+           file://0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \
+           file://0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
+           file://0023-libatomic-Do-not-enforce-march-on-aarch64.patch \
+           file://0024-Fix-install-path-of-linux64.h.patch \
+           file://0026-rust-recursion-limit.patch \
+           file://prefix-map-realpath.patch \
+           file://hardcoded-paths.patch \
 "
-SRC_URI[sha256sum] = "4fb9a3c58c94deb91bd75bc503962fae347f05d4d47a0e079141350f08919fb5"
+SRC_URI[sha256sum] = "108b5e0786b988c7ce24b82187d8cf643fefbd8e3db24fa5f67e530e727d0c70"
 
 S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/arm-gnu-toolchain-src-snapshot-${ARM_GCC_VERSION}.${ARM_GCC_SUB_VERSION}"
 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
similarity index 84%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
index 0bf8834..66e582c 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
@@ -1,4 +1,4 @@
-From 6badb97389cae4ff9a533d38dc7cceefe21b97a8 Mon Sep 17 00:00:00 2001
+From 31f94ef5b43a984a98f0eebd2dcf1b53aa1d7bce Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 08:37:11 +0400
 Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET
@@ -12,10 +12,10 @@
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/configure b/configure
-index e218a19e333..45744e6e471 100755
+index 5dcaab14ae9..f76310a36bb 100755
 --- a/configure
 +++ b/configure
-@@ -9750,7 +9750,7 @@ fi
+@@ -10165,7 +10165,7 @@ fi
  # for target_alias and gcc doesn't manage it consistently.
  target_configargs="--cache-file=./config.cache ${target_configargs}"
  
@@ -25,10 +25,10 @@
   *" newlib "*)
    case " $target_configargs " in
 diff --git a/configure.ac b/configure.ac
-index 7e8e628b325..bf66b51373c 100644
+index 85977482aee..8b9097c7a45 100644
 --- a/configure.ac
 +++ b/configure.ac
-@@ -3255,7 +3255,7 @@ fi
+@@ -3346,7 +3346,7 @@ fi
  # for target_alias and gcc doesn't manage it consistently.
  target_configargs="--cache-file=./config.cache ${target_configargs}"
  
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-gcc-poison-system-directories.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0002-gcc-poison-system-directories.patch
similarity index 80%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-gcc-poison-system-directories.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0002-gcc-poison-system-directories.patch
index d19cefb..5aa635b 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0002-gcc-poison-system-directories.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0002-gcc-poison-system-directories.patch
@@ -1,4 +1,4 @@
-From 863f1f9dc78839ecd021b2cb01d501e8c9e00ef7 Mon Sep 17 00:00:00 2001
+From 99f1e61b2957226254a116fde7fd73bf07034012 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 8 Mar 2021 16:04:20 -0800
 Subject: [PATCH] gcc: poison-system-directories
@@ -20,15 +20,15 @@
  gcc/configure       | 19 +++++++++++++++++++
  gcc/configure.ac    | 16 ++++++++++++++++
  gcc/doc/invoke.texi |  9 +++++++++
- gcc/gcc.c           |  9 +++++++--
- gcc/incpath.c       | 21 +++++++++++++++++++++
- 7 files changed, 86 insertions(+), 2 deletions(-)
+ gcc/gcc.cc          | 15 ++++++++++++---
+ gcc/incpath.cc      | 21 +++++++++++++++++++++
+ 7 files changed, 91 insertions(+), 3 deletions(-)
 
 diff --git a/gcc/common.opt b/gcc/common.opt
-index a75b44ee47e..d15105a73f3 100644
+index 8a0dafc52..0357868e2 100644
 --- a/gcc/common.opt
 +++ b/gcc/common.opt
-@@ -683,6 +683,10 @@ Wreturn-local-addr
+@@ -710,6 +710,10 @@ Wreturn-local-addr
  Common Var(warn_return_local_addr) Init(1) Warning
  Warn about returning a pointer/reference to a local or temporary variable.
  
@@ -40,7 +40,7 @@
  Common Var(warn_shadow) Warning
  Warn when one variable shadows another.  Same as -Wshadow=global.
 diff --git a/gcc/config.in b/gcc/config.in
-index 048bf52e8c2..4f973f7906a 100644
+index 64c27c9cf..a693cb8a8 100644
 --- a/gcc/config.in
 +++ b/gcc/config.in
 @@ -230,6 +230,16 @@
@@ -61,10 +61,10 @@
     optimizer and back end) to be checked for dynamic type safety at runtime.
     This is quite expensive. */
 diff --git a/gcc/configure b/gcc/configure
-index 7218b0c331a..d7445339f9a 100755
+index 2b83acfb0..8bb97578c 100755
 --- a/gcc/configure
 +++ b/gcc/configure
-@@ -1019,6 +1019,7 @@ enable_maintainer_mode
+@@ -1023,6 +1023,7 @@ enable_maintainer_mode
  enable_link_mutex
  enable_link_serialization
  enable_version_specific_runtime_libs
@@ -72,7 +72,7 @@
  enable_plugin
  enable_host_shared
  enable_libquadmath_support
-@@ -1781,6 +1782,8 @@ Optional Features:
+@@ -1785,6 +1786,8 @@ Optional Features:
    --enable-version-specific-runtime-libs
                            specify that runtime libraries should be installed
                            in a compiler-specific directory
@@ -81,7 +81,7 @@
    --enable-plugin         enable plugin support
    --enable-host-shared    build host code as shared libraries
    --disable-libquadmath-support
-@@ -31932,6 +31935,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
+@@ -31996,6 +31999,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
  fi
  
  
@@ -105,10 +105,10 @@
  
  
 diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 49f043ed29b..fe488f2232b 100644
+index daf2a708c..6155b83a7 100644
 --- a/gcc/configure.ac
 +++ b/gcc/configure.ac
-@@ -7393,6 +7393,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
+@@ -7435,6 +7435,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
                  [specify that runtime libraries should be
                   installed in a compiler-specific directory])])
  
@@ -132,10 +132,10 @@
  AC_SUBST(subdirs)
  AC_SUBST(srcdir)
 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
-index 35508efb4ef..40f798eac78 100644
+index ff6c338be..a8ebfa59a 100644
 --- a/gcc/doc/invoke.texi
 +++ b/gcc/doc/invoke.texi
-@@ -369,6 +369,7 @@ Objective-C and Objective-C++ Dialects}.
+@@ -379,6 +379,7 @@ Objective-C and Objective-C++ Dialects}.
  -Wpacked  -Wno-packed-bitfield-compat  -Wpacked-not-aligned  -Wpadded @gol
  -Wparentheses  -Wno-pedantic-ms-format @gol
  -Wpointer-arith  -Wno-pointer-compare  -Wno-pointer-to-int-cast @gol
@@ -143,7 +143,7 @@
  -Wno-pragmas  -Wno-prio-ctor-dtor  -Wredundant-decls @gol
  -Wrestrict  -Wno-return-local-addr  -Wreturn-type @gol
  -Wno-scalar-storage-order  -Wsequence-point @gol
-@@ -7728,6 +7729,14 @@ made up of data only and thus requires no special treatment.  But, for
+@@ -8029,6 +8030,14 @@ made up of data only and thus requires no special treatment.  But, for
  most targets, it is made up of code and thus requires the stack to be
  made executable in order for the program to work properly.
  
@@ -158,11 +158,11 @@
  @item -Wfloat-equal
  @opindex Wfloat-equal
  @opindex Wno-float-equal
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index 0af888c7d78..b047fc31c2f 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -1152,6 +1152,8 @@ proper position among the other output files.  */
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index beefde7f6..4e6557b3c 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1162,6 +1162,8 @@ proper position among the other output files.  */
     "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
     "%X %{o*} %{e*} %{N} %{n} %{r}\
      %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
@@ -171,7 +171,7 @@
      %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
      VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
      %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
-@@ -1247,8 +1249,11 @@ static const char *cpp_unique_options =
+@@ -1257,8 +1259,11 @@ static const char *cpp_unique_options =
  static const char *cpp_options =
  "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
   %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
@@ -179,16 +179,29 @@
 - %{undef} %{save-temps*:-fpch-preprocess}";
 + %{!fno-working-directory:-fworking-directory}}} %{O*}"
 +#ifdef POISON_BY_DEFAULT
-+ " -Werror=poison-system-directories"
++ " %{!Wno-error=poison-system-directories:-Werror=poison-system-directories}"
 +#endif
 + " %{undef} %{save-temps*:-fpch-preprocess}";
  
  /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
  
-diff --git a/gcc/incpath.c b/gcc/incpath.c
-index 446d280321d..fbfc0ce03b8 100644
---- a/gcc/incpath.c
-+++ b/gcc/incpath.c
+@@ -1287,7 +1292,11 @@ static const char *cc1_options =
+  %{coverage:-fprofile-arcs -ftest-coverage}\
+  %{fprofile-arcs|fprofile-generate*|coverage:\
+    %{!fprofile-update=single:\
+-     %{pthread:-fprofile-update=prefer-atomic}}}";
++     %{pthread:-fprofile-update=prefer-atomic}}}"
++#ifdef POISON_BY_DEFAULT
++ " %{!Wno-error=poison-system-directories:-Werror=poison-system-directories}"
++#endif
++  ;
+ 
+ static const char *asm_options =
+ "%{-target-help:%:print-asm-header()} "
+diff --git a/gcc/incpath.cc b/gcc/incpath.cc
+index 622204a38..5ac03c086 100644
+--- a/gcc/incpath.cc
++++ b/gcc/incpath.cc
 @@ -26,6 +26,7 @@
  #include "intl.h"
  #include "incpath.h"
@@ -197,7 +210,7 @@
  
  /* Microsoft Windows does not natively support inodes.
     VMS has non-numeric inodes.  */
-@@ -395,6 +396,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
+@@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
  	}
        fprintf (stderr, _("End of search list.\n"));
      }
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-64-bit-multilib-hack.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0003-64-bit-multilib-hack.patch
similarity index 94%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-64-bit-multilib-hack.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0003-64-bit-multilib-hack.patch
index c0e8cbd..e83f05b 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0003-64-bit-multilib-hack.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0003-64-bit-multilib-hack.patch
@@ -1,4 +1,4 @@
-From b87a3ac51df372128be2fda992238c5aab4a719a Mon Sep 17 00:00:00 2001
+From 34b861e7a4cfd7b1f0d2c0f8cf9bb0b0b81eb61a Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:10:06 +0400
 Subject: [PATCH] 64-bit multilib hack.
@@ -28,6 +28,7 @@
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
 Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
  gcc/config/aarch64/t-aarch64-linux |  8 ++++----
  gcc/config/arc/t-multilib-linux    |  4 ++--
@@ -38,7 +39,7 @@
  6 files changed, 17 insertions(+), 22 deletions(-)
 
 diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux
-index 241b0ef20b6..a7dadb2d64f 100644
+index d0cd546002a..f4056d68372 100644
 --- a/gcc/config/aarch64/t-aarch64-linux
 +++ b/gcc/config/aarch64/t-aarch64-linux
 @@ -21,8 +21,8 @@
@@ -55,7 +56,7 @@
 -MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
 +#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
 diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux
-index fc3fff640a2..d58e28f6df8 100644
+index ecb9ae6859f..12a164028d4 100644
 --- a/gcc/config/arc/t-multilib-linux
 +++ b/gcc/config/arc/t-multilib-linux
 @@ -16,9 +16,9 @@
@@ -71,7 +72,7 @@
  # Aliases:
  MULTILIB_MATCHES += mcpu?arc700=mA7
 diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
-index d288b093522..7b5980a9d21 100644
+index 5526ad0e6cc..fa51c88912b 100644
 --- a/gcc/config/i386/t-linux64
 +++ b/gcc/config/i386/t-linux64
 @@ -32,7 +32,5 @@
@@ -85,7 +86,7 @@
 +MULTILIB_DIRNAMES = . .
 +MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
 diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64
-index 130e1f04707..3b7eb6b2a2f 100644
+index 2fdd8e00407..04f2099250f 100644
 --- a/gcc/config/mips/t-linux64
 +++ b/gcc/config/mips/t-linux64
 @@ -17,10 +17,6 @@
@@ -115,7 +116,7 @@
 +#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
 +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
 diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64
-index e11a118cb5f..4eaffb416fe 100644
+index 47e0efd5764..05f5a3f188e 100644
 --- a/gcc/config/rs6000/t-linux64
 +++ b/gcc/config/rs6000/t-linux64
 @@ -26,10 +26,9 @@
@@ -129,5 +130,5 @@
 -MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
 +MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
  
- rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
  	$(COMPILE) $<
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch
similarity index 84%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch
index 7f807a9..e8f2163 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0016-If-CXXFLAGS-contains-something-unsupported-by-the-bu.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch
@@ -1,10 +1,10 @@
-From 2c2a92573598ddbc33c023fe5d499191491fb523 Mon Sep 17 00:00:00 2001
+From 7f40f8321fb999e9b34d948724517d3fb0d26820 Mon Sep 17 00:00:00 2001
 From: Richard Purdie <richard.purdie@linuxfoundation.org>
 Date: Thu, 28 Oct 2021 11:33:40 +0100
-Subject: [PATCH] If CXXFLAGS contains something unsupported by the build CXX,
- we see build failures (e.g. using -fmacro-prefix-map for the target).
+Subject: [PATCH] Pass CXXFLAGS_FOR_BUILD in a couple of places to avoid these
+ errors.
 
-Pass CXXFLAGS_FOR_BUILD in a couple of places to avoid these errors.
+If CXXFLAGS contains something unsupported by the build CXX, we see build failures (e.g. using -fmacro-prefix-map for the target).
 
 2021-10-28 Richard Purdie <richard.purdie@linuxfoundation.org>
 
@@ -23,7 +23,7 @@
  2 files changed, 4 insertions(+)
 
 diff --git a/Makefile.in b/Makefile.in
-index 33476d53327..b949dffee0e 100644
+index 593495e1650..1d9c83cc566 100644
 --- a/Makefile.in
 +++ b/Makefile.in
 @@ -176,6 +176,7 @@ BUILD_EXPORTS = \
@@ -43,7 +43,7 @@
  	DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
  	LD="$(LD)"; export LD; \
 diff --git a/Makefile.tpl b/Makefile.tpl
-index e39d85d1109..d8520cbb164 100644
+index ef58fac2b9a..bab04f335c2 100644
 --- a/Makefile.tpl
 +++ b/Makefile.tpl
 @@ -179,6 +179,7 @@ BUILD_EXPORTS = \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
similarity index 88%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
index 55a5885..e34eb2c 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0004-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
@@ -1,4 +1,4 @@
-From 1766cf28fd7d917df510b1c262c47211b9ea70fa Mon Sep 17 00:00:00 2001
+From 5455fc1de74897a27c1199dc5611ec02243e24af Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:17:25 +0400
 Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}
@@ -26,10 +26,10 @@
  4 files changed, 7 insertions(+), 7 deletions(-)
 
 diff --git a/gcc/Makefile.in b/gcc/Makefile.in
-index 7bfd6ce653f..95962ae37b6 100644
+index 31ff95500c9..a8277254696 100644
 --- a/gcc/Makefile.in
 +++ b/gcc/Makefile.in
-@@ -552,7 +552,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
+@@ -553,7 +553,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
  TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
  
  xmake_file=@xmake_file@
@@ -39,10 +39,10 @@
  TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@
  TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@
 diff --git a/gcc/configure b/gcc/configure
-index d7445339f9a..f5b99d1cf7d 100755
+index dc2d59701ad..3fc0e2f5813 100755
 --- a/gcc/configure
 +++ b/gcc/configure
-@@ -13131,8 +13131,8 @@ for f in $tm_file; do
+@@ -13381,8 +13381,8 @@ for f in $tm_file; do
         tm_include_list="${tm_include_list} $f"
         ;;
      defaults.h )
@@ -54,10 +54,10 @@
      * )
         tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
 diff --git a/gcc/configure.ac b/gcc/configure.ac
-index fe488f2232b..29005f6d18f 100644
+index 36ce78924de..46de496b256 100644
 --- a/gcc/configure.ac
 +++ b/gcc/configure.ac
-@@ -2294,8 +2294,8 @@ for f in $tm_file; do
+@@ -2332,8 +2332,8 @@ for f in $tm_file; do
         tm_include_list="${tm_include_list} $f"
         ;;
      defaults.h )
@@ -69,7 +69,7 @@
      * )
         tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
 diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh
-index c49acd8f7e4..a0a657bdbb9 100644
+index 91cc43f69ff..8de33713cd8 100644
 --- a/gcc/mkconfig.sh
 +++ b/gcc/mkconfig.sh
 @@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0005-cpp-honor-sysroot.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0006-cpp-honor-sysroot.patch
similarity index 82%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0005-cpp-honor-sysroot.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0006-cpp-honor-sysroot.patch
index f2883fe..b08aecc 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0005-cpp-honor-sysroot.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0006-cpp-honor-sysroot.patch
@@ -1,4 +1,4 @@
-From e6a820a19c4cd115d8af7c235c5f9700c7a24730 Mon Sep 17 00:00:00 2001
+From abc3b82ab24169277f2090e9df1ceac3573142be Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:22:00 +0400
 Subject: [PATCH] cpp: honor sysroot.
@@ -19,14 +19,14 @@
 
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 
-Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582725.html]
+Upstream-Status: Pending
 ---
  gcc/cp/lang-specs.h | 2 +-
- gcc/gcc.c           | 2 +-
+ gcc/gcc.cc          | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h
-index 8902ae1d2ed..e99e2fcd6ad 100644
+index f35c9fab76b..19ddc98ce7f 100644
 --- a/gcc/cp/lang-specs.h
 +++ b/gcc/cp/lang-specs.h
 @@ -116,7 +116,7 @@ along with GCC; see the file COPYING3.  If not see
@@ -38,11 +38,11 @@
        "  %{!fsyntax-only:"
        "    %{fmodule-only:%{!S:-o %g.s%V}}"
        "    %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}"
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index b047fc31c2f..bdee2671532 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -1469,7 +1469,7 @@ static const struct compiler default_compilers[] =
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index ce161d3c853..aa4cf92fb78 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -1476,7 +1476,7 @@ static const struct compiler default_compilers[] =
  					   %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0},
    {".i", "@cpp-output", 0, 0, 0},
    {"@cpp-output",
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
new file mode 100644
index 0000000..b59eed5
--- /dev/null
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
@@ -0,0 +1,403 @@
+From 4de00af67b57b5440bdf61ab364ad959ad0aeee7 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 29 Mar 2013 09:24:50 +0400
+Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
+ relative to SYSTEMLIBS_DIR
+
+This patch defines GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
+relative to SYSTEMLIBS_DIR which can be set in generated headers
+This breaks the assumption of hardcoded multilib in gcc
+Change is only for the supported architectures in OE including
+SH, sparc, alpha for possible future support (if any)
+
+Removes the do_headerfix task in metadata
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Upstream-Status: Inappropriate [OE configuration]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ gcc/config/aarch64/aarch64-linux.h |  4 ++--
+ gcc/config/alpha/linux-elf.h       |  4 ++--
+ gcc/config/arm/linux-eabi.h        |  6 +++---
+ gcc/config/arm/linux-elf.h         |  2 +-
+ gcc/config/i386/linux.h            |  4 ++--
+ gcc/config/i386/linux64.h          | 12 ++++++------
+ gcc/config/linux.h                 |  8 ++++----
+ gcc/config/loongarch/gnu-user.h    |  4 ++--
+ gcc/config/microblaze/linux.h      |  4 ++--
+ gcc/config/mips/linux.h            | 18 +++++++++---------
+ gcc/config/nios2/linux.h           |  4 ++--
+ gcc/config/riscv/linux.h           |  4 ++--
+ gcc/config/rs6000/linux64.h        | 15 +++++----------
+ gcc/config/rs6000/sysv4.h          |  4 ++--
+ gcc/config/s390/linux.h            |  8 ++++----
+ gcc/config/sh/linux.h              |  4 ++--
+ gcc/config/sparc/linux.h           |  2 +-
+ gcc/config/sparc/linux64.h         |  4 ++--
+ 18 files changed, 53 insertions(+), 58 deletions(-)
+
+diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
+index 5e4553d79f5..877e8841eb2 100644
+--- a/gcc/config/aarch64/aarch64-linux.h
++++ b/gcc/config/aarch64/aarch64-linux.h
+@@ -21,10 +21,10 @@
+ #ifndef GCC_AARCH64_LINUX_H
+ #define GCC_AARCH64_LINUX_H
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++#define GLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+ 
+ #undef MUSL_DYNAMIC_LINKER
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
++#define MUSL_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+ 
+ #undef  ASAN_CC1_SPEC
+ #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
+diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
+index 17f16a55910..0a7be38fa63 100644
+--- a/gcc/config/alpha/linux-elf.h
++++ b/gcc/config/alpha/linux-elf.h
+@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3.  If not see
+ #define EXTRA_SPECS \
+ { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
+ 
+-#define GLIBC_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
+-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
++#define GLIBC_DYNAMIC_LINKER	SYSTEMLIBS_DIR "ld-linux.so.2"
++#define UCLIBC_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-uClibc.so.0"
+ #if DEFAULT_LIBC == LIBC_UCLIBC
+ #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+ #elif DEFAULT_LIBC == LIBC_GLIBC
+diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
+index 50cc0bc6d08..17c18b27145 100644
+--- a/gcc/config/arm/linux-eabi.h
++++ b/gcc/config/arm/linux-eabi.h
+@@ -65,8 +65,8 @@
+    GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI.  */
+ 
+ #undef  GLIBC_DYNAMIC_LINKER
+-#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
+-#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
++#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT SYSTEMLIBS_DIR "ld-linux.so.3"
++#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT SYSTEMLIBS_DIR "ld-linux-armhf.so.3"
+ #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
+ 
+ #define GLIBC_DYNAMIC_LINKER \
+@@ -89,7 +89,7 @@
+ #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
+ #endif
+ #define MUSL_DYNAMIC_LINKER \
+-  "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
+ 
+ /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
+    use the GNU/Linux version, not the generic BPABI version.  */
+diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
+index df3da67c4f0..37456e9d5a4 100644
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -60,7 +60,7 @@
+ 
+ #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
+ 
+ #define LINUX_TARGET_LINK_SPEC  "%{h*} \
+    %{static:-Bstatic} \
+diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
+index 5d99ee56d5b..a76022c9ccc 100644
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3.  If not see
+ <http://www.gnu.org/licenses/>.  */
+ 
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
+ 
+ #undef MUSL_DYNAMIC_LINKER
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1"
+diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
+index 8681e36f10d..ddce49b6b60 100644
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -27,13 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+ #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
+ #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
+ 
+-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+-#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
++#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
+ 
+ #undef MUSL_DYNAMIC_LINKER32
+-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
+ #undef MUSL_DYNAMIC_LINKER64
+-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
+ #undef MUSL_DYNAMIC_LINKERX32
+-#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
++#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
+diff --git a/gcc/config/linux.h b/gcc/config/linux.h
+index 74f70793d90..4ce173384ef 100644
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -99,10 +99,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
+    GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
+    supporting both 32-bit and 64-bit compilation.  */
+-#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+-#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
+-#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
+-#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
++#define UCLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-uClibc.so.0"
++#define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
++#define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
++#define UCLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ldx32-uClibc.so.0"
+ #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
+index 664dc9206ad..082bd7cfc6f 100644
+--- a/gcc/config/loongarch/gnu-user.h
++++ b/gcc/config/loongarch/gnu-user.h
+@@ -31,11 +31,11 @@ along with GCC; see the file COPYING3.  If not see
+ 
+ #undef GLIBC_DYNAMIC_LINKER
+ #define GLIBC_DYNAMIC_LINKER \
+-  "/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1"
++  SYSTEMLIBS_DIR "ld-linux-loongarch-" ABI_SPEC ".so.1"
+ 
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER \
+-  "/lib" ABI_GRLEN_SPEC "/ld-musl-loongarch-" ABI_SPEC ".so.1"
++  SYSTEMLIBS_DIR "ld-musl-loongarch-" ABI_SPEC ".so.1"
+ 
+ #undef GNU_USER_TARGET_LINK_SPEC
+ #define GNU_USER_TARGET_LINK_SPEC \
+diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
+index 5b1a365eda4..2e63df1ae9c 100644
+--- a/gcc/config/microblaze/linux.h
++++ b/gcc/config/microblaze/linux.h
+@@ -28,7 +28,7 @@
+ #undef TLS_NEEDS_GOT
+ #define TLS_NEEDS_GOT 1
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "/ld.so.1"
+ #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+ 
+ #if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
+@@ -38,7 +38,7 @@
+ #endif
+ 
+ #undef MUSL_DYNAMIC_LINKER
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
++#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
+ 
+ #undef  SUBTARGET_EXTRA_SPECS
+ #define SUBTARGET_EXTRA_SPECS \
+diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
+index 230b7789bb8..d96d134bfcf 100644
+--- a/gcc/config/mips/linux.h
++++ b/gcc/config/mips/linux.h
+@@ -22,29 +22,29 @@ along with GCC; see the file COPYING3.  If not see
+ #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
+ 
+ #define GLIBC_DYNAMIC_LINKER32 \
+-  "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
+ #define GLIBC_DYNAMIC_LINKER64 \
+-  "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
+ #define GLIBC_DYNAMIC_LINKERN32 \
+-  "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
+ 
+ #undef UCLIBC_DYNAMIC_LINKER32
+ #define UCLIBC_DYNAMIC_LINKER32 \
+-  "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
+ #undef UCLIBC_DYNAMIC_LINKER64
+ #define UCLIBC_DYNAMIC_LINKER64 \
+-  "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld64-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld64-uClibc.so.0}"
+ #define UCLIBC_DYNAMIC_LINKERN32 \
+-  "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
++  "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
+ 
+ #undef MUSL_DYNAMIC_LINKER32
+ #define MUSL_DYNAMIC_LINKER32 \
+-  "/lib/ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
+ #undef MUSL_DYNAMIC_LINKER64
+ #define MUSL_DYNAMIC_LINKER64 \
+-  "/lib/ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
+ #define MUSL_DYNAMIC_LINKERN32 \
+-  "/lib/ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
+ 
+ #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
+ #define GNU_USER_DYNAMIC_LINKERN32 \
+diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
+index f5dd813acad..7a13e1c9799 100644
+--- a/gcc/config/nios2/linux.h
++++ b/gcc/config/nios2/linux.h
+@@ -29,8 +29,8 @@
+ #undef CPP_SPEC
+ #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
+-#define MUSL_DYNAMIC_LINKER  "/lib/ld-musl-nios2.so.1"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-nios2.so.1"
++#define MUSL_DYNAMIC_LINKER  SYSTEMLIBS_DIR "ld-musl-nios2.so.1"
+ 
+ #undef LINK_SPEC
+ #define LINK_SPEC LINK_SPEC_ENDIAN \
+diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
+index 38803723ba9..d5ef8a96a19 100644
+--- a/gcc/config/riscv/linux.h
++++ b/gcc/config/riscv/linux.h
+@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3.  If not see
+     GNU_USER_TARGET_OS_CPP_BUILTINS();				\
+   } while (0)
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-riscv" XLEN_SPEC "-" ABI_SPEC ".so.1"
+ 
+ #define MUSL_ABI_SUFFIX \
+   "%{mabi=ilp32:-sf}" \
+@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3.  If not see
+   "%{mabi=lp64d:}"
+ 
+ #undef MUSL_DYNAMIC_LINKER
+-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
++#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
+ 
+ /* Because RISC-V only has word-sized atomics, it requries libatomic where
+    others do not.  So link libatomic by default, as needed.  */
+diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
+index b2a7afabc73..364c1a5b155 100644
+--- a/gcc/config/rs6000/linux64.h
++++ b/gcc/config/rs6000/linux64.h
+@@ -339,24 +339,19 @@ extern int dot_symbols;
+ #undef	LINK_OS_DEFAULT_SPEC
+ #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
+ 
+-#define GLIBC_DYNAMIC_LINKER32 "%(dynamic_linker_prefix)/lib/ld.so.1"
+-
++#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
+ #ifdef LINUX64_DEFAULT_ABI_ELFv2
+-#define GLIBC_DYNAMIC_LINKER64 \
+-"%{mabi=elfv1:%(dynamic_linker_prefix)/lib64/ld64.so.1;" \
+-":%(dynamic_linker_prefix)/lib64/ld64.so.2}"
++#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:" SYSTEMLIBS_DIR "ld64.so.1;:" SYSTEMLIBS_DIR "ld64.so.2}"
+ #else
+-#define GLIBC_DYNAMIC_LINKER64 \
+-"%{mabi=elfv2:%(dynamic_linker_prefix)/lib64/ld64.so.2;" \
+-":%(dynamic_linker_prefix)/lib64/ld64.so.1}"
++#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:" SYSTEMLIBS_DIR "ld64.so.2;:" SYSTEMLIBS_DIR "ld64.so.1}"
+ #endif
+ 
+ #undef MUSL_DYNAMIC_LINKER32
+ #define MUSL_DYNAMIC_LINKER32 \
+-  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ #undef MUSL_DYNAMIC_LINKER64
+ #define MUSL_DYNAMIC_LINKER64 \
+-  "/lib/ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-powerpc64" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ 
+ #undef  DEFAULT_ASM_ENDIAN
+ #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
+diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
+index 7e2519de5d4..a73954d9de5 100644
+--- a/gcc/config/rs6000/sysv4.h
++++ b/gcc/config/rs6000/sysv4.h
+@@ -779,10 +779,10 @@ GNU_USER_TARGET_CC1_SPEC
+ 
+ #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1"
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER \
+-  "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
++  SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
+ 
+ #ifndef GNU_USER_DYNAMIC_LINKER
+ #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
+diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
+index d7b7e7a7b02..0139b4d06ca 100644
+--- a/gcc/config/s390/linux.h
++++ b/gcc/config/s390/linux.h
+@@ -72,13 +72,13 @@ along with GCC; see the file COPYING3.  If not see
+ #define MULTILIB_DEFAULTS { "m31" }
+ #endif
+ 
+-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
+-#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
++#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
++#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64.so.1"
+ 
+ #undef MUSL_DYNAMIC_LINKER32
+-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1"
++#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-s390.so.1"
+ #undef MUSL_DYNAMIC_LINKER64
+-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1"
++#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-s390x.so.1"
+ 
+ #undef  LINK_SPEC
+ #define LINK_SPEC \
+diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
+index d96d077c99e..7d27f9893ee 100644
+--- a/gcc/config/sh/linux.h
++++ b/gcc/config/sh/linux.h
+@@ -61,10 +61,10 @@ along with GCC; see the file COPYING3.  If not see
+ 
+ #undef MUSL_DYNAMIC_LINKER
+ #define MUSL_DYNAMIC_LINKER \
+-  "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
++  SYSTEMLIBS_DIR "ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
+   "%{mfdpic:-fdpic}.so.1"
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
+ 
+ #undef SUBTARGET_LINK_EMUL_SUFFIX
+ #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
+diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
+index 6a809e9092d..60603765ad6 100644
+--- a/gcc/config/sparc/linux.h
++++ b/gcc/config/sparc/linux.h
+@@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
+    When the -shared link option is used a final link is not being
+    done.  */
+ 
+-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
+ 
+ #undef  LINK_SPEC
+ #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
+diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
+index d08a2ef96fe..e6955da0a5b 100644
+--- a/gcc/config/sparc/linux64.h
++++ b/gcc/config/sparc/linux64.h
+@@ -78,8 +78,8 @@ along with GCC; see the file COPYING3.  If not see
+    When the -shared link option is used a final link is not being
+    done.  */
+ 
+-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
++#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux.so.2"
+ 
+ #ifdef SPARC_BI_ARCH
+ 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0008-libtool.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0008-libtool.patch
similarity index 94%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0008-libtool.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0008-libtool.patch
index 358e1d7..c9bc38c 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0008-libtool.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0008-libtool.patch
@@ -1,4 +1,4 @@
-From b19700ef0103f9414416b9a779a64d6138c58b1f Mon Sep 17 00:00:00 2001
+From 5117519c1897a49b09fe7fff213b9c2ea15d37f5 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:29:11 +0400
 Subject: [PATCH] libtool
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
similarity index 87%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
index ac13954..dd67b11 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
@@ -1,4 +1,4 @@
-From 10d23d93697167396e223711bf6210e1642ee926 Mon Sep 17 00:00:00 2001
+From 32129f9682d0d27fc67af10f077ad2768935cbe6 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:30:32 +0400
 Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI.
@@ -19,12 +19,12 @@
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
-index 6bd95855827..77befab5da8 100644
+index 17c18b27145..8eacb099317 100644
 --- a/gcc/config/arm/linux-eabi.h
 +++ b/gcc/config/arm/linux-eabi.h
 @@ -91,10 +91,14 @@
  #define MUSL_DYNAMIC_LINKER \
-   "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
+   SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
  
 +/* For armv4 we pass --fix-v4bx to linker to support EABI */
 +#undef TARGET_FIX_V4BX_SPEC
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
similarity index 89%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
index 4912fa9..45edc62 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
@@ -1,4 +1,4 @@
-From 5970fb3fadccd8c43f7f7030e6ff51e0295731ef Mon Sep 17 00:00:00 2001
+From bf85b8bbcb4b77725d4c22c1bb25a29f6ff21038 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 29 Mar 2013 09:33:04 +0400
 Subject: [PATCH] Use the multilib config files from ${B} instead of using the
@@ -18,10 +18,10 @@
  2 files changed, 36 insertions(+), 8 deletions(-)
 
 diff --git a/gcc/configure b/gcc/configure
-index f5b99d1cf7d..ec3c24482df 100755
+index 3fc0e2f5813..2f0f0e057a9 100755
 --- a/gcc/configure
 +++ b/gcc/configure
-@@ -13111,10 +13111,20 @@ done
+@@ -13361,10 +13361,20 @@ done
  tmake_file_=
  for f in ${tmake_file}
  do
@@ -46,7 +46,7 @@
  done
  tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
  
-@@ -13125,6 +13135,10 @@ tm_file_list="options.h"
+@@ -13375,6 +13385,10 @@ tm_file_list="options.h"
  tm_include_list="options.h insn-constants.h"
  for f in $tm_file; do
    case $f in
@@ -58,10 +58,10 @@
         f=`echo $f | sed 's/^..//'`
         tm_file_list="${tm_file_list} $f"
 diff --git a/gcc/configure.ac b/gcc/configure.ac
-index 29005f6d18f..ea794cd1763 100644
+index 46de496b256..6155b83a732 100644
 --- a/gcc/configure.ac
 +++ b/gcc/configure.ac
-@@ -2274,10 +2274,20 @@ done
+@@ -2312,10 +2312,20 @@ done
  tmake_file_=
  for f in ${tmake_file}
  do
@@ -86,7 +86,7 @@
  done
  tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
  
-@@ -2288,6 +2298,10 @@ tm_file_list="options.h"
+@@ -2326,6 +2336,10 @@ tm_file_list="options.h"
  tm_include_list="options.h insn-constants.h"
  for f in $tm_file; do
    case $f in
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
similarity index 92%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
index e3e3594..352c6ee 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0011-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
@@ -1,4 +1,4 @@
-From 2af537b9ff0018945a27a7f89efad736a0f647d4 Mon Sep 17 00:00:00 2001
+From e5463727ff028cee5e452da38f5b4c44d52e412e Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 20 Feb 2015 09:39:38 +0000
 Subject: [PATCH] Avoid using libdir from .la which usually points to a host
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0012-Ensure-target-gcc-headers-can-be-included.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0013-Ensure-target-gcc-headers-can-be-included.patch
similarity index 85%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0012-Ensure-target-gcc-headers-can-be-included.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0013-Ensure-target-gcc-headers-can-be-included.patch
index d33925e..61e61ec 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0012-Ensure-target-gcc-headers-can-be-included.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0013-Ensure-target-gcc-headers-can-be-included.patch
@@ -1,4 +1,4 @@
-From 9427c6cedf88e15f747c48cb4fcf9eda6f5c4555 Mon Sep 17 00:00:00 2001
+From 612801d426e75ff997cfabda380dbe52c2cbc532 Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Fri, 20 Feb 2015 10:25:11 +0000
 Subject: [PATCH] Ensure target gcc headers can be included
@@ -21,14 +21,14 @@
  gcc/Makefile.in           | 2 ++
  gcc/config/linux.h        | 8 ++++++++
  gcc/config/rs6000/sysv4.h | 8 ++++++++
- gcc/cppdefault.c          | 4 ++++
+ gcc/cppdefault.cc         | 4 ++++
  4 files changed, 22 insertions(+)
 
 diff --git a/gcc/Makefile.in b/gcc/Makefile.in
-index d1d4512bba3..06eb0d27a28 100644
+index a8277254696..07fa63b6640 100644
 --- a/gcc/Makefile.in
 +++ b/gcc/Makefile.in
-@@ -630,6 +630,7 @@ libexecdir = @libexecdir@
+@@ -632,6 +632,7 @@ libexecdir = @libexecdir@
  
  # Directory in which the compiler finds libraries etc.
  libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
@@ -36,7 +36,7 @@
  # Directory in which the compiler finds executables
  libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
  # Directory in which all plugin resources are installed
-@@ -3009,6 +3010,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\"
+@@ -3024,6 +3025,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\"
  
  PREPROCESSOR_DEFINES = \
    -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
@@ -45,10 +45,10 @@
    -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
    -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
 diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index 87efc5f69fe..b525bcd56b3 100644
+index 4ce173384ef..8a3cd4f2d34 100644
 --- a/gcc/config/linux.h
 +++ b/gcc/config/linux.h
-@@ -165,6 +165,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+@@ -170,6 +170,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  #define INCLUDE_DEFAULTS_MUSL_TOOL
  #endif
  
@@ -62,7 +62,7 @@
  #ifdef NATIVE_SYSTEM_HEADER_DIR
  #define INCLUDE_DEFAULTS_MUSL_NATIVE			\
      { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 },	\
-@@ -191,6 +198,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+@@ -196,6 +203,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      INCLUDE_DEFAULTS_MUSL_PREFIX			\
      INCLUDE_DEFAULTS_MUSL_CROSS				\
      INCLUDE_DEFAULTS_MUSL_TOOL				\
@@ -71,10 +71,10 @@
      { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 },		\
      { 0, 0, 0, 0, 0, 0 }				\
 diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
-index 510abe169c5..0c2bba5ea32 100644
+index a73954d9de5..e5dd6538358 100644
 --- a/gcc/config/rs6000/sysv4.h
 +++ b/gcc/config/rs6000/sysv4.h
-@@ -995,6 +995,13 @@ ncrtn.o%s"
+@@ -994,6 +994,13 @@ ncrtn.o%s"
  #define INCLUDE_DEFAULTS_MUSL_TOOL
  #endif
  
@@ -88,7 +88,7 @@
  #ifdef NATIVE_SYSTEM_HEADER_DIR
  #define INCLUDE_DEFAULTS_MUSL_NATIVE			\
      { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 },	\
-@@ -1021,6 +1028,7 @@ ncrtn.o%s"
+@@ -1020,6 +1027,7 @@ ncrtn.o%s"
      INCLUDE_DEFAULTS_MUSL_PREFIX			\
      INCLUDE_DEFAULTS_MUSL_CROSS				\
      INCLUDE_DEFAULTS_MUSL_TOOL				\
@@ -96,10 +96,10 @@
      INCLUDE_DEFAULTS_MUSL_NATIVE			\
      { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 },		\
      { 0, 0, 0, 0, 0, 0 }				\
-diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
-index c503d14fc3f..d54d6ce0076 100644
---- a/gcc/cppdefault.c
-+++ b/gcc/cppdefault.c
+diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc
+index 7888300f277..52cf14e92f8 100644
+--- a/gcc/cppdefault.cc
++++ b/gcc/cppdefault.cc
 @@ -64,6 +64,10 @@ const struct default_include cpp_include_defaults[]
      /* This is the dir for gcc's private headers.  */
      { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch
similarity index 93%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch
index 5b5d229..94308b2 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0013-Don-t-search-host-directory-during-relink-if-inst_pr.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch
@@ -1,4 +1,4 @@
-From ab6e6af5deca6f4b35b089a6b197776df38780e6 Mon Sep 17 00:00:00 2001
+From 9ae49e7b88c208ab79ec9c2fc4a2fa8a3f1e85bb Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Tue, 3 Mar 2015 08:21:19 +0000
 Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch
similarity index 87%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch
index b82277c..ce9635c 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0014-libcc1-fix-libcc1-s-install-path-and-rpath.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch
@@ -1,4 +1,4 @@
-From fd862c8c112067d8613d921ae89c99056aca54a1 Mon Sep 17 00:00:00 2001
+From bf918db7117f41d3c04162095641165ca241707d Mon Sep 17 00:00:00 2001
 From: Robert Yang <liezhi.yang@windriver.com>
 Date: Sun, 5 Jul 2015 20:25:18 -0700
 Subject: [PATCH] libcc1: fix libcc1's install path and rpath
@@ -20,10 +20,10 @@
  2 files changed, 4 insertions(+), 4 deletions(-)
 
 diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am
-index 3b75e7d9290..d3a4c4f9ddf 100644
+index 6e3a34ff7e2..3f3f6391aba 100644
 --- a/libcc1/Makefile.am
 +++ b/libcc1/Makefile.am
-@@ -41,8 +41,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
+@@ -40,8 +40,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
  	    $(Wc)$(libiberty_normal)))
  libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
  
@@ -35,10 +35,10 @@
  if ENABLE_PLUGIN
  plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la
 diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in
-index 07fa9d94c83..a9f737d78f2 100644
+index f8f590d71e9..56462492045 100644
 --- a/libcc1/Makefile.in
 +++ b/libcc1/Makefile.in
-@@ -398,8 +398,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
+@@ -396,8 +396,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
  	    $(Wc)$(libiberty_normal)))
  
  libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0017-handle-sysroot-support-for-nativesdk-gcc.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0016-handle-sysroot-support-for-nativesdk-gcc.patch
similarity index 90%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0017-handle-sysroot-support-for-nativesdk-gcc.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0016-handle-sysroot-support-for-nativesdk-gcc.patch
index 5d86e4c..3b54719 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0017-handle-sysroot-support-for-nativesdk-gcc.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0016-handle-sysroot-support-for-nativesdk-gcc.patch
@@ -1,4 +1,4 @@
-From 68802ca536b01ab21cfa58e11ef332e30d9a3c5e Mon Sep 17 00:00:00 2001
+From 4fbbd40d7db89cdbeaf93df1e1da692b1f80a5bc Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 7 Dec 2015 23:39:54 +0000
 Subject: [PATCH] handle sysroot support for nativesdk-gcc
@@ -35,21 +35,21 @@
 
 Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
 ---
- gcc/c-family/c-opts.c     |  4 +--
+ gcc/c-family/c-opts.cc    |  4 +--
  gcc/config/linux.h        | 24 +++++++--------
  gcc/config/rs6000/sysv4.h | 24 +++++++--------
- gcc/cppdefault.c          | 63 ++++++++++++++++++++++++---------------
+ gcc/cppdefault.cc         | 63 ++++++++++++++++++++++++---------------
  gcc/cppdefault.h          | 13 ++++----
- gcc/gcc.c                 | 20 +++++++++----
- gcc/incpath.c             | 12 ++++----
- gcc/prefix.c              |  6 ++--
+ gcc/gcc.cc                | 20 +++++++++----
+ gcc/incpath.cc            | 12 ++++----
+ gcc/prefix.cc             |  6 ++--
  8 files changed, 94 insertions(+), 72 deletions(-)
 
-diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
-index 6f001e0bb6c..55ab07c278f 100644
---- a/gcc/c-family/c-opts.c
-+++ b/gcc/c-family/c-opts.c
-@@ -1438,8 +1438,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain)
+diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
+index a341a061758..83b0bef4dbb 100644
+--- a/gcc/c-family/c-opts.cc
++++ b/gcc/c-family/c-opts.cc
+@@ -1458,8 +1458,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain)
    size_t prefix_len, suffix_len;
  
    suffix_len = strlen (suffix);
@@ -61,11 +61,11 @@
    path = (char *) xmalloc (prefix_len + suffix_len + 1);
    memcpy (path, prefix, prefix_len);
 diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index b525bcd56b3..ba02c013e30 100644
+index 8a3cd4f2d34..58143dff731 100644
 --- a/gcc/config/linux.h
 +++ b/gcc/config/linux.h
-@@ -129,53 +129,53 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-  * Unfortunately, this is mostly duplicated from cppdefault.c */
+@@ -134,53 +134,53 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+  * Unfortunately, this is mostly duplicated from cppdefault.cc */
  #if DEFAULT_LIBC == LIBC_MUSL
  #define INCLUDE_DEFAULTS_MUSL_GPP			\
 -    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,		\
@@ -129,7 +129,7 @@
  #else
  #define INCLUDE_DEFAULTS_MUSL_NATIVE
  #endif
-@@ -200,7 +200,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+@@ -205,7 +205,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      INCLUDE_DEFAULTS_MUSL_TOOL				\
      INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET			\
      INCLUDE_DEFAULTS_MUSL_NATIVE			\
@@ -139,10 +139,10 @@
    }
  #endif
 diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
-index 0c2bba5ea32..313a8de4417 100644
+index e5dd6538358..b496849b792 100644
 --- a/gcc/config/rs6000/sysv4.h
 +++ b/gcc/config/rs6000/sysv4.h
-@@ -959,53 +959,53 @@ ncrtn.o%s"
+@@ -958,53 +958,53 @@ ncrtn.o%s"
  /* Include order changes for musl, same as in generic linux.h.  */
  #if DEFAULT_LIBC == LIBC_MUSL
  #define INCLUDE_DEFAULTS_MUSL_GPP			\
@@ -207,7 +207,7 @@
  #else
  #define INCLUDE_DEFAULTS_MUSL_NATIVE
  #endif
-@@ -1030,7 +1030,7 @@ ncrtn.o%s"
+@@ -1029,7 +1029,7 @@ ncrtn.o%s"
      INCLUDE_DEFAULTS_MUSL_TOOL				\
      INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET			\
      INCLUDE_DEFAULTS_MUSL_NATIVE			\
@@ -216,10 +216,10 @@
      { 0, 0, 0, 0, 0, 0 }				\
    }
  #endif
-diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
-index d54d6ce0076..784a92a0c24 100644
---- a/gcc/cppdefault.c
-+++ b/gcc/cppdefault.c
+diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc
+index 52cf14e92f8..d8977afc05e 100644
+--- a/gcc/cppdefault.cc
++++ b/gcc/cppdefault.cc
 @@ -35,6 +35,30 @@
  # undef CROSS_INCLUDE_DIR
  #endif
@@ -343,7 +343,7 @@
  /* This value is set by cpp_relocated at runtime */
  const char *gcc_exec_prefix;
 diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h
-index fd3c655db1c..20669ac427d 100644
+index fb97c0b5814..6267150facc 100644
 --- a/gcc/cppdefault.h
 +++ b/gcc/cppdefault.h
 @@ -33,7 +33,8 @@
@@ -354,7 +354,7 @@
 +  const char *fname;     /* The name of the directory.  */
 +
    const char *const component;	/* The component containing the directory
- 				   (see update_path in prefix.c) */
+ 				   (see update_path in prefix.cc) */
    const char cplusplus;		/* When this is non-zero, we should only
 @@ -55,17 +56,13 @@ struct default_include
  };
@@ -377,10 +377,10 @@
  /* The run-time execution prefix.  This is typically the lib/gcc
     subdirectory of the actual installation.  */
  extern const char *gcc_exec_prefix;
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index bdee2671532..36e8af38630 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index aa4cf92fb78..5569a39a14a 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
 @@ -252,6 +252,8 @@ FILE *report_times_to_file = NULL;
  #endif
  static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
@@ -390,7 +390,7 @@
  /* Nonzero means pass the updated target_system_root to the compiler.  */
  
  static int target_system_root_changed;
-@@ -568,6 +570,7 @@ or with constant text in a single argument.
+@@ -575,6 +577,7 @@ or with constant text in a single argument.
   %G     process LIBGCC_SPEC as a spec.
   %R     Output the concatenation of target_system_root and
          target_sysroot_suffix.
@@ -398,7 +398,7 @@
   %S     process STARTFILE_SPEC as a spec.  A capital S is actually used here.
   %E     process ENDFILE_SPEC as a spec.  A capital E is actually used here.
   %C     process CPP_SPEC as a spec.
-@@ -1620,10 +1623,10 @@ static const char *gcc_libexec_prefix;
+@@ -1627,10 +1630,10 @@ static const char *gcc_libexec_prefix;
     gcc_exec_prefix is set because, in that case, we know where the
     compiler has been installed, and use paths relative to that
     location instead.  */
@@ -413,7 +413,7 @@
  
  /* For native compilers, these are well-known paths containing
     components that may be provided by the system.  For cross
-@@ -1631,9 +1634,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
+@@ -1638,9 +1641,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
  static const char *md_exec_prefix = MD_EXEC_PREFIX;
  static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
  static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
@@ -425,7 +425,7 @@
    = STANDARD_STARTFILE_PREFIX_2;
  
  /* A relative path to be used in finding the location of tools
-@@ -6570,6 +6573,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
+@@ -6676,6 +6679,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
  	      }
  	    break;
  
@@ -437,11 +437,11 @@
  	  case 'S':
  	    value = do_spec_1 (startfile_spec, 0, NULL);
  	    if (value != 0)
-diff --git a/gcc/incpath.c b/gcc/incpath.c
-index fbfc0ce03b8..a82e543428b 100644
---- a/gcc/incpath.c
-+++ b/gcc/incpath.c
-@@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
+diff --git a/gcc/incpath.cc b/gcc/incpath.cc
+index c80f100f476..5ac03c08693 100644
+--- a/gcc/incpath.cc
++++ b/gcc/incpath.cc
+@@ -135,7 +135,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
    int relocated = cpp_relocated ();
    size_t len;
  
@@ -450,7 +450,7 @@
      {
        /* Look for directories that start with the standard prefix.
  	 "Translate" them, i.e. replace /usr/local/lib/gcc... with
-@@ -146,7 +146,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
+@@ -150,7 +150,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
  		 now.  */
  	      if (sysroot && p->add_sysroot)
  		continue;
@@ -459,7 +459,7 @@
  		{
  		  char *str = concat (iprefix, p->fname + len, NULL);
  		  if (p->multilib == 1 && imultilib)
-@@ -187,7 +187,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
+@@ -191,7 +191,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
  	      free (sysroot_no_trailing_dir_separator);
  	    }
  	  else if (!p->add_sysroot && relocated
@@ -468,7 +468,7 @@
  	    {
   	      static const char *relocated_prefix;
  	      char *ostr;
-@@ -204,12 +204,12 @@ add_standard_paths (const char *sysroot, const char *iprefix,
+@@ -208,12 +208,12 @@ add_standard_paths (const char *sysroot, const char *iprefix,
  		  dummy = concat (gcc_exec_prefix, "dummy", NULL);
  		  relocated_prefix
  		    = make_relative_prefix (dummy,
@@ -484,10 +484,10 @@
  			     NULL);
  	      str = update_path (ostr, p->component);
  	      free (ostr);
-diff --git a/gcc/prefix.c b/gcc/prefix.c
-index 747c09de638..f728638dc65 100644
---- a/gcc/prefix.c
-+++ b/gcc/prefix.c
+diff --git a/gcc/prefix.cc b/gcc/prefix.cc
+index 096ed5afa3d..2526f0ecc39 100644
+--- a/gcc/prefix.cc
++++ b/gcc/prefix.cc
 @@ -72,7 +72,9 @@ License along with GCC; see the file COPYING3.  If not see
  #include "prefix.h"
  #include "common/common-target.h"
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch
similarity index 89%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch
index 0f43e98..9b05da6 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0018-Search-target-sysroot-gcc-version-specific-dirs-with.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch
@@ -1,4 +1,4 @@
-From 14291076874b133e7fb67ef1714b768a2c48ea44 Mon Sep 17 00:00:00 2001
+From 33a1f07a4417247dc24819d4e583ca09f56d5a7b Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Mon, 7 Dec 2015 23:41:45 +0000
 Subject: [PATCH] Search target sysroot gcc version specific dirs with
@@ -47,14 +47,14 @@
 
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- gcc/gcc.c | 29 ++++++++++++++++++++++++++++-
+ gcc/gcc.cc | 29 ++++++++++++++++++++++++++++-
  1 file changed, 28 insertions(+), 1 deletion(-)
 
-diff --git a/gcc/gcc.c b/gcc/gcc.c
-index 36e8af38630..d1faa788d60 100644
---- a/gcc/gcc.c
-+++ b/gcc/gcc.c
-@@ -2810,7 +2810,7 @@ for_each_path (const struct path_prefix *paths,
+diff --git a/gcc/gcc.cc b/gcc/gcc.cc
+index 5569a39a14a..4598f6cd7c9 100644
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -2817,7 +2817,7 @@ for_each_path (const struct path_prefix *paths,
        if (path == NULL)
  	{
  	  len = paths->max_len + extra_space + 1;
@@ -63,7 +63,7 @@
  	  path = XNEWVEC (char, len);
  	}
  
-@@ -2822,6 +2822,33 @@ for_each_path (const struct path_prefix *paths,
+@@ -2829,6 +2829,33 @@ for_each_path (const struct path_prefix *paths,
  	  /* Look first in MACHINE/VERSION subdirectory.  */
  	  if (!skip_multi_dir)
  	    {
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
similarity index 89%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
index b82fa44..56793e0 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0020-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
@@ -1,4 +1,4 @@
-From af72a47a677ce98c08cb73444bdd741ca8e28422 Mon Sep 17 00:00:00 2001
+From d7dc2861840e88a4592817a398a054a886c3f3ee Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Tue, 27 Jun 2017 18:10:54 -0700
 Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets
@@ -23,10 +23,10 @@
  3 files changed, 27 insertions(+)
 
 diff --git a/gcc/config/linux.h b/gcc/config/linux.h
-index ba02c013e30..8fcaa0c9faf 100644
+index 58143dff731..d2409ccac26 100644
 --- a/gcc/config/linux.h
 +++ b/gcc/config/linux.h
-@@ -203,6 +203,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+@@ -208,6 +208,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 },		\
      { 0, 0, 0, 0, 0, 0 }				\
    }
@@ -41,10 +41,10 @@
  
  #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
 diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
-index 47c9d9ac0b6..d065f88b377 100644
+index 8c9039ac1e5..259cd485973 100644
 --- a/gcc/config/rs6000/linux.h
 +++ b/gcc/config/rs6000/linux.h
-@@ -94,6 +94,16 @@
+@@ -99,6 +99,16 @@
  					 " -m elf32ppclinux")
  #endif
  
@@ -62,10 +62,10 @@
  #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
    %{!static-pie: \
 diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
-index a11e01faa3d..ce464f3626b 100644
+index 364c1a5b155..e33d9ae98e0 100644
 --- a/gcc/config/rs6000/linux64.h
 +++ b/gcc/config/rs6000/linux64.h
-@@ -369,6 +369,16 @@ extern int dot_symbols;
+@@ -372,6 +372,16 @@ extern int dot_symbols;
  					   " -m elf64ppc")
  #endif
  
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0023-Re-introduce-spe-commandline-options.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0019-Re-introduce-spe-commandline-options.patch
similarity index 87%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0023-Re-introduce-spe-commandline-options.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0019-Re-introduce-spe-commandline-options.patch
index 23cf02a..bb1699b 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0023-Re-introduce-spe-commandline-options.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0019-Re-introduce-spe-commandline-options.patch
@@ -1,4 +1,4 @@
-From ca73043041c3c7aa86af9a3d4f316abc87eb3254 Mon Sep 17 00:00:00 2001
+From bf0d7c463e1fab62804556099b56319fe94be1eb Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 6 Jun 2018 12:10:22 -0700
 Subject: [PATCH] Re-introduce spe commandline options
@@ -14,10 +14,10 @@
  1 file changed, 13 insertions(+)
 
 diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
-index 6b0a3e27529..1bd2e356ac9 100644
+index 4931d781c4e..3fb87b6f7d5 100644
 --- a/gcc/config/rs6000/rs6000.opt
 +++ b/gcc/config/rs6000/rs6000.opt
-@@ -352,6 +352,19 @@ mdebug=
+@@ -348,6 +348,19 @@ mdebug=
  Target RejectNegative Joined
  -mdebug=	Enable debug output.
  
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
similarity index 76%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
index f915f28..f370920 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0024-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
@@ -1,4 +1,4 @@
-From b3957bc1fd52ec427a1b71b10055905cab4bbc7c Mon Sep 17 00:00:00 2001
+From a32c75b37209d6836eaaa943dc6b1207acba5d27 Mon Sep 17 00:00:00 2001
 From: Szabolcs Nagy <nsz@port70.net>
 Date: Sat, 24 Oct 2015 20:09:53 +0000
 Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of
@@ -33,30 +33,30 @@
 
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- gcc/config/i386/i386-expand.c | 4 ++--
- libgcc/config/i386/cpuinfo.c  | 6 +++---
- libgcc/config/i386/t-linux    | 2 +-
+ gcc/config/i386/i386-expand.cc | 4 ++--
+ libgcc/config/i386/cpuinfo.c   | 6 +++---
+ libgcc/config/i386/t-linux     | 2 +-
  3 files changed, 6 insertions(+), 6 deletions(-)
 
-diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
-index 31eae75d277..ec7e858ec83 100644
---- a/gcc/config/i386/i386-expand.c
-+++ b/gcc/config/i386/i386-expand.c
-@@ -11066,10 +11066,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
+diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
+index 68978ef8dc2..0c71f36b572 100644
+--- a/gcc/config/i386/i386-expand.cc
++++ b/gcc/config/i386/i386-expand.cc
+@@ -12321,10 +12321,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
      {
      case IX86_BUILTIN_CPU_INIT:
        {
--	/* Make it call __cpu_indicator_init in libgcc. */
-+	/* Make it call __cpu_indicator_init_local in libgcc.a. */
+-	/* Make it call __cpu_indicator_init in libgcc.  */
++	/* Make it call __cpu_indicator_init_local in libgcc.a.  */
  	tree call_expr, fndecl, type;
-         type = build_function_type_list (integer_type_node, NULL_TREE); 
+ 	type = build_function_type_list (integer_type_node, NULL_TREE);
 -	fndecl = build_fn_decl ("__cpu_indicator_init", type);
 +	fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
- 	call_expr = build_call_expr (fndecl, 0); 
+ 	call_expr = build_call_expr (fndecl, 0);
  	return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
        }
 diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
-index ef463848f9d..1a3de052c80 100644
+index dab1d98060f..cf824b4114a 100644
 --- a/libgcc/config/i386/cpuinfo.c
 +++ b/libgcc/config/i386/cpuinfo.c
 @@ -63,7 +63,7 @@ __cpu_indicator_init (void)
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
similarity index 75%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
index f33193e..f5f04ae 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0025-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
@@ -1,4 +1,4 @@
-From 5fd90d243ae14034a4699443110070dafc0d4d30 Mon Sep 17 00:00:00 2001
+From 4efc42b99c96b026f560b0918de7e237ac3dc8d1 Mon Sep 17 00:00:00 2001
 From: Richard Purdie <richard.purdie@linuxfoundation.org>
 Date: Tue, 10 Mar 2020 08:26:53 -0700
 Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining
@@ -12,15 +12,15 @@
 Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
 ---
- gcc/gengtype.c |  6 +++---
- gcc/genmodes.c | 32 ++++++++++++++++----------------
+ gcc/gengtype.cc |  6 +++---
+ gcc/genmodes.cc | 32 ++++++++++++++++----------------
  2 files changed, 19 insertions(+), 19 deletions(-)
 
-diff --git a/gcc/gengtype.c b/gcc/gengtype.c
-index 98d4626f87e..f602da8b501 100644
---- a/gcc/gengtype.c
-+++ b/gcc/gengtype.c
-@@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt,
+diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc
+index 386ae1b0506..9762e914296 100644
+--- a/gcc/gengtype.cc
++++ b/gcc/gengtype.cc
+@@ -1006,7 +1006,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt,
  /* Create a fake field with the given type and name.  NEXT is the next
     field in the chain.  */
  #define create_field(next,type,name) \
@@ -29,7 +29,7 @@
  
  /* Like create_field, but the field is only valid when condition COND
     is true.  */
-@@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name,
+@@ -1039,7 +1039,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name,
  }
  
  #define create_optional_field(next,type,name,cond)	\
@@ -38,7 +38,7 @@
  
  /* Reverse a linked list of 'struct pair's in place.  */
  pair_p
-@@ -5189,7 +5189,7 @@ main (int argc, char **argv)
+@@ -5238,7 +5238,7 @@ main (int argc, char **argv)
        /* These types are set up with #define or else outside of where
           we can see them.  We should initialize them before calling
           read_input_list.  */
@@ -47,11 +47,11 @@
  	Call;} while (0)
        POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
        POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
-diff --git a/gcc/genmodes.c b/gcc/genmodes.c
-index c268ebc4c6e..4361f3f1563 100644
---- a/gcc/genmodes.c
-+++ b/gcc/genmodes.c
-@@ -438,7 +438,7 @@ complete_all_modes (void)
+diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc
+index 59850bb070a..e187f8542a1 100644
+--- a/gcc/genmodes.cc
++++ b/gcc/genmodes.cc
+@@ -440,7 +440,7 @@ complete_all_modes (void)
  }
  
  /* For each mode in class CLASS, construct a corresponding complex mode.  */
@@ -60,7 +60,7 @@
  static void
  make_complex_modes (enum mode_class cl,
  		    const char *file, unsigned int line)
-@@ -497,7 +497,7 @@ make_complex_modes (enum mode_class cl,
+@@ -499,7 +499,7 @@ make_complex_modes (enum mode_class cl,
     having as many components as necessary.  ORDER is the sorting order
     of the mode, with smaller numbers indicating a higher priority.  */
  #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \
@@ -69,16 +69,16 @@
  #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0)
  static void ATTRIBUTE_UNUSED
  make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
-@@ -549,7 +549,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
- /* Create a vector of booleans called NAME with COUNT elements and
+@@ -552,7 +552,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
     BYTESIZE bytes in total.  */
- #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \
--  make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__)
-+  make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0)
+ #define VECTOR_BOOL_MODE(NAME, COUNT, COMPONENT, BYTESIZE)		\
+   make_vector_bool_mode (#NAME, COUNT, #COMPONENT, BYTESIZE,		\
+-			 __FILE__, __LINE__)
++			 __FILE__, 0)
  static void ATTRIBUTE_UNUSED
  make_vector_bool_mode (const char *name, unsigned int count,
- 		       unsigned int bytesize, const char *file,
-@@ -571,7 +571,7 @@ make_vector_bool_mode (const char *name, unsigned int count,
+ 		       const char *component, unsigned int bytesize,
+@@ -574,7 +574,7 @@ make_vector_bool_mode (const char *name, unsigned int count,
  /* Input.  */
  
  #define _SPECIAL_MODE(C, N) \
@@ -87,7 +87,7 @@
  #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
  #define CC_MODE(N) _SPECIAL_MODE (CC, N)
  
-@@ -584,7 +584,7 @@ make_special_mode (enum mode_class cl, const char *name,
+@@ -587,7 +587,7 @@ make_special_mode (enum mode_class cl, const char *name,
  
  #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
  #define FRACTIONAL_INT_MODE(N, B, Y) \
@@ -96,7 +96,7 @@
  
  static void
  make_int_mode (const char *name,
-@@ -611,16 +611,16 @@ make_opaque_mode (const char *name,
+@@ -628,16 +628,16 @@ make_opaque_mode (const char *name,
  }
  
  #define FRACT_MODE(N, Y, F) \
@@ -117,7 +117,7 @@
  
  /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
     FILE, and LINE.  */
-@@ -641,7 +641,7 @@ make_fixed_point_mode (enum mode_class cl,
+@@ -658,7 +658,7 @@ make_fixed_point_mode (enum mode_class cl,
  
  #define FLOAT_MODE(N, Y, F)             FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
  #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
@@ -126,7 +126,7 @@
  
  static void
  make_float_mode (const char *name,
-@@ -658,7 +658,7 @@ make_float_mode (const char *name,
+@@ -675,7 +675,7 @@ make_float_mode (const char *name,
  #define DECIMAL_FLOAT_MODE(N, Y, F)	\
  	FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
  #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F)	\
@@ -135,7 +135,7 @@
  
  static void
  make_decimal_float_mode (const char *name,
-@@ -673,7 +673,7 @@ make_decimal_float_mode (const char *name,
+@@ -690,7 +690,7 @@ make_decimal_float_mode (const char *name,
  }
  
  #define RESET_FLOAT_FORMAT(N, F) \
@@ -144,7 +144,7 @@
  static void ATTRIBUTE_UNUSED
  reset_float_format (const char *name, const char *format,
  		    const char *file, unsigned int line)
-@@ -694,7 +694,7 @@ reset_float_format (const char *name, const char *format,
+@@ -711,7 +711,7 @@ reset_float_format (const char *name, const char *format,
  
  /* __intN support.  */
  #define INT_N(M,PREC)				\
@@ -153,7 +153,7 @@
  static void ATTRIBUTE_UNUSED
  make_int_n (const char *m, int bitsize,
              const char *file, unsigned int line)
-@@ -723,7 +723,7 @@ make_int_n (const char *m, int bitsize,
+@@ -740,7 +740,7 @@ make_int_n (const char *m, int bitsize,
  /* Partial integer modes are specified by relation to a full integer
     mode.  */
  #define PARTIAL_INT_MODE(M,PREC,NAME)				\
@@ -162,16 +162,16 @@
  static void ATTRIBUTE_UNUSED
  make_partial_integer_mode (const char *base, const char *name,
  			   unsigned int precision,
-@@ -750,7 +750,7 @@ make_partial_integer_mode (const char *base, const char *name,
+@@ -767,7 +767,7 @@ make_partial_integer_mode (const char *base, const char *name,
  /* A single vector mode can be specified by naming its component
     mode and the number of components.  */
- #define VECTOR_MODE(C, M, N) \
--  make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__);
-+  make_vector_mode (MODE_##C, #M, N, __FILE__, 0);
+ #define VECTOR_MODE_WITH_PREFIX(PREFIX, C, M, N, ORDER) \
+-  make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, __LINE__);
++  make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, 0);
+ #define VECTOR_MODE(C, M, N) VECTOR_MODE_WITH_PREFIX(V, C, M, N, 0);
  static void ATTRIBUTE_UNUSED
  make_vector_mode (enum mode_class bclass,
- 		  const char *base,
-@@ -793,7 +793,7 @@ make_vector_mode (enum mode_class bclass,
+@@ -814,7 +814,7 @@ make_vector_mode (enum mode_class bclass,
  
  /* Adjustability.  */
  #define _ADD_ADJUST(A, M, X, C1, C2) \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0027-libatomic-Do-not-enforce-march-on-aarch64.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0023-libatomic-Do-not-enforce-march-on-aarch64.patch
similarity index 94%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0027-libatomic-Do-not-enforce-march-on-aarch64.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0023-libatomic-Do-not-enforce-march-on-aarch64.patch
index 85b1251..2f01659 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0027-libatomic-Do-not-enforce-march-on-aarch64.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0023-libatomic-Do-not-enforce-march-on-aarch64.patch
@@ -1,4 +1,4 @@
-From df1c63bbd7a520e8c6d0d0692b4d8bff56952394 Mon Sep 17 00:00:00 2001
+From 52931ec7a708b58d68e69ce9eb99001ae9f099dd Mon Sep 17 00:00:00 2001
 From: Khem Raj <raj.khem@gmail.com>
 Date: Wed, 13 May 2020 15:10:38 -0700
 Subject: [PATCH] libatomic: Do not enforce march on aarch64
@@ -17,7 +17,7 @@
  2 files changed, 2 deletions(-)
 
 diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
-index ab8c2da24a1..f614a46b34d 100644
+index d88515e4a03..e0e2f8b442a 100644
 --- a/libatomic/Makefile.am
 +++ b/libatomic/Makefile.am
 @@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0029-Fix-install-path-of-linux64.h.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0024-Fix-install-path-of-linux64.h.patch
similarity index 85%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0029-Fix-install-path-of-linux64.h.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0024-Fix-install-path-of-linux64.h.patch
index d7e156e..555be62 100644
--- a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0029-Fix-install-path-of-linux64.h.patch
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0024-Fix-install-path-of-linux64.h.patch
@@ -1,4 +1,4 @@
-From 8a62cc0a64670e39f462c1dbbf82e04d2f03b89e Mon Sep 17 00:00:00 2001
+From 3e67c9c77e46132c252911bf1e5e4222dfd3aa34 Mon Sep 17 00:00:00 2001
 From: Andrei Gherzan <andrei.gherzan@huawei.com>
 Date: Wed, 22 Dec 2021 12:49:25 +0100
 Subject: [PATCH] Fix install path of linux64.h
@@ -17,10 +17,10 @@
  1 file changed, 2 insertions(+)
 
 diff --git a/gcc/Makefile.in b/gcc/Makefile.in
-index 06eb0d27a28..a8678ca24ed 100644
+index 07fa63b6640..0def7394454 100644
 --- a/gcc/Makefile.in
 +++ b/gcc/Makefile.in
-@@ -3686,6 +3686,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
+@@ -3706,6 +3706,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
  	  "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \
  	  | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \
  	    base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0030-rust-recursion-limit.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0026-rust-recursion-limit.patch
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-11.3/0030-rust-recursion-limit.patch
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/0026-rust-recursion-limit.patch
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/hardcoded-paths.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/hardcoded-paths.patch
new file mode 100644
index 0000000..f348585
--- /dev/null
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/hardcoded-paths.patch
@@ -0,0 +1,19 @@
+Avoid encoding build paths into sources used for floating point on powerpc.
+(MACHINE=qemuppc bitbake libgcc).
+
+Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599882.html]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+Index: gcc-12.1.0/libgcc/config/rs6000/t-float128
+===================================================================
+--- gcc-12.1.0.orig/libgcc/config/rs6000/t-float128
++++ gcc-12.1.0/libgcc/config/rs6000/t-float128
+@@ -103,7 +103,7 @@ $(ibm128_dec_objs)	: INTERNAL_CFLAGS +=
+ $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep)
+ 	@src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \
+ 	echo "Create $@"; \
+-	(echo "/* file created from $$src */"; \
++	(echo "/* file created from `basename $$src` */"; \
+ 	 echo; \
+ 	 sed -f $(fp128_sed) < $$src) > $@
+ 
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/prefix-map-realpath.patch b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/prefix-map-realpath.patch
new file mode 100644
index 0000000..7f1a2de
--- /dev/null
+++ b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-arm-12.2/prefix-map-realpath.patch
@@ -0,0 +1,63 @@
+Relative paths don't work with -fdebug-prefix-map and friends. This
+can lead to paths which the user wanted to be remapped being missed.
+Setting -fdebug-prefix-map to work with a relative path isn't practical
+either.
+
+Instead, call gcc's realpath function on the incomming path name before
+comparing it with the remapping. This means other issues like symlinks
+are also accounted for and leads to a more consistent remapping experience.
+
+Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599885.html]
+[Also https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599884.html]
+Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
+
+
+Index: gcc-12.1.0/gcc/file-prefix-map.cc
+===================================================================
+--- gcc-12.1.0.orig/gcc/file-prefix-map.cc
++++ gcc-12.1.0/gcc/file-prefix-map.cc
+@@ -70,19 +70,28 @@ remap_filename (file_prefix_map *maps, c
+   file_prefix_map *map;
+   char *s;
+   const char *name;
++  char *realname;
+   size_t name_len;
+ 
++  if (lbasename (filename) == filename)
++    return filename;
++
++  realname = lrealpath (filename);
++
+   for (map = maps; map; map = map->next)
+-    if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
++    if (filename_ncmp (realname, map->old_prefix, map->old_len) == 0)
+       break;
+-  if (!map)
++  if (!map) {
++    free (realname);
+     return filename;
+-  name = filename + map->old_len;
++  }
++  name = realname + map->old_len;
+   name_len = strlen (name) + 1;
+ 
+   s = (char *) ggc_alloc_atomic (name_len + map->new_len);
+   memcpy (s, map->new_prefix, map->new_len);
+   memcpy (s + map->new_len, name, name_len);
++  free (realname);
+   return s;
+ }
+ 
+Index: gcc-12.1.0/libcpp/macro.cc
+===================================================================
+--- gcc-12.1.0.orig/libcpp/macro.cc
++++ gcc-12.1.0/libcpp/macro.cc
+@@ -563,7 +563,7 @@ _cpp_builtin_macro_text (cpp_reader *pfi
+ 	    if (!name)
+ 	      abort ();
+ 	  }
+-	if (pfile->cb.remap_filename)
++	if (pfile->cb.remap_filename && !pfile->state.in_directive)
+ 	  name = pfile->cb.remap_filename (name);
+ 	len = strlen (name);
+ 	buf = _cpp_unaligned_alloc (pfile, len * 2 + 3);
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross-canadian_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-cross_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-crosssdk_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-runtime_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-sanitizers_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc-source_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/gcc_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc-initial_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgcc_arm-12.2.bb
diff --git a/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-11.3.bb b/meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-12.2.bb
similarity index 100%
rename from meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-11.3.bb
rename to meta-arm/meta-arm-toolchain/recipes-devtools/gcc/libgfortran_arm-12.2.bb
diff --git a/meta-arm/meta-arm/classes/fvpboot.bbclass b/meta-arm/meta-arm/classes/fvpboot.bbclass
index 508deb2..3159cd4 100644
--- a/meta-arm/meta-arm/classes/fvpboot.bbclass
+++ b/meta-arm/meta-arm/classes/fvpboot.bbclass
@@ -24,7 +24,8 @@
 # Arbitrary extra arguments
 FVP_EXTRA_ARGS ?= ""
 # Bitbake variables to pass to the FVP environment
-FVP_ENV_PASSTHROUGH ?= "FASTSIM_DISABLE_TA"
+FVP_ENV_PASSTHROUGH ?= "FASTSIM_DISABLE_TA ARMLMD_LICENSE_FILE"
+FVP_ENV_PASSTHROUGH[vardeps] = "${FVP_ENV_PASSTHROUGH}"
 # Disable timing annotation by default
 FASTSIM_DISABLE_TA ?= "1"
 
@@ -72,7 +73,8 @@
 
     data["env"] = {}
     for var in d.getVar("FVP_ENV_PASSTHROUGH").split():
-        data["env"][var] = d.getVar(var)
+        if d.getVar(var) is not None:
+            data["env"][var] = d.getVar(var)
 
     os.makedirs(os.path.dirname(conffile), exist_ok=True)
     with open(conffile, "wt") as f:
diff --git a/meta-arm/meta-arm/conf/layer.conf b/meta-arm/meta-arm/conf/layer.conf
index 68d8c56..2b35437 100644
--- a/meta-arm/meta-arm/conf/layer.conf
+++ b/meta-arm/meta-arm/conf/layer.conf
@@ -13,7 +13,9 @@
     core \
     arm-toolchain \
 "
-LAYERSERIES_COMPAT_meta-arm = "langdale mickledore"
+LAYERSERIES_COMPAT_meta-arm = "mickledore"
 
 # runfvp --console needs telnet, so pull this in for testimage.
 HOSTTOOLS_NONFATAL += "telnet"
+
+addpylib ${LAYERDIR}/lib oeqa
diff --git a/meta-arm/meta-arm/conf/machine/qemuarm-secureboot.conf b/meta-arm/meta-arm/conf/machine/qemuarm-secureboot.conf
index db02dc6..cb54fe9 100644
--- a/meta-arm/meta-arm/conf/machine/qemuarm-secureboot.conf
+++ b/meta-arm/meta-arm/conf/machine/qemuarm-secureboot.conf
@@ -23,4 +23,4 @@
 MACHINE_FEATURES += "optee-ftpm"
 
 PREFERRED_VERSION_optee-os ?= "3.18.%"
-
+PREFERRED_VERSION_u-boot ?= "2022.10"
diff --git a/meta-arm/meta-arm/lib/fvp/runner.py b/meta-arm/meta-arm/lib/fvp/runner.py
index 4fd624b..c52cdc1 100644
--- a/meta-arm/meta-arm/lib/fvp/runner.py
+++ b/meta-arm/meta-arm/lib/fvp/runner.py
@@ -91,7 +91,7 @@
         # Pass through environment variables needed for GUI applications, such
         # as xterm, to work.
         env = config['env']
-        for name in ('DISPLAY', 'WAYLAND_DISPLAY'):
+        for name in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
             if name in os.environ:
                 env[name] = os.environ[name]
 
diff --git a/meta-arm/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.10.0.bb b/meta-arm/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.10.0.bb
index 4828fb5..b25b9a4 100644
--- a/meta-arm/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.10.0.bb
+++ b/meta-arm/meta-arm/recipes-bsp/scp-firmware/scp-firmware_2.10.0.bb
@@ -6,7 +6,9 @@
 LIC_FILES_CHKSUM = "file://license.md;beginline=5;md5=9db9e3d2fb8d9300a6c3d15101b19731 \
                     file://contrib/cmsis/git/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e"
 
-SRC_URI = "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https;branch=master"
+SRC_URI_SCP_FIRMWARE ?= "gitsm://github.com/ARM-software/SCP-firmware.git;protocol=https"
+SRC_URI = "${SRC_URI_SCP_FIRMWARE};branch=${SRCBRANCH}"
+SRCBRANCH = "master"
 
 SRCREV  = "673d014f3861ad81cc5ab06d2884a314a610799b"
 
@@ -27,7 +29,7 @@
 # For now we only build with GCC, so stop meta-clang trying to get involved
 TOOLCHAIN = "gcc"
 
-SCP_BUILD_STR = "${@bb.utils.contains('SCP_BUILD_RELEASE', '1', 'release', 'debug', d)}"
+SCP_BUILD_STR = "${@bb.utils.contains('SCP_BUILD_RELEASE', '1', 'Release', 'Debug', d)}"
 
 inherit deploy
 
@@ -46,6 +48,7 @@
 EXTRA_OECMAKE = "-D CMAKE_BUILD_TYPE=${SCP_BUILD_STR} \
                  -D SCP_LOG_LEVEL=${SCP_LOG_LEVEL} \
                  -D SCP_PLATFORM_FEATURE_SET=${SCP_PLATFORM_FEATURE_SET} \
+                 -D DISABLE_CPPCHECK=1 \
                 "
 
 do_configure() {
diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/tf-a-tests_2.7.0.bb b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/tf-a-tests_2.7.0.bb
index 645b245..8ded64d 100644
--- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/tf-a-tests_2.7.0.bb
+++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/tf-a-tests_2.7.0.bb
@@ -7,9 +7,11 @@
 
 COMPATIBLE_MACHINE ?= "invalid"
 
-SRC_URI = "git://git.trustedfirmware.org/TF-A/tf-a-tests.git;protocol=https;branch=master \
+SRC_URI_TRUSTED_FIRMWARE_A_TESTS ?= "git://git.trustedfirmware.org/TF-A/tf-a-tests.git;protocol=https"
+SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_A_TESTS};branch=${SRCBRANCH} \
           file://tf-a-tests-no-warn-rwx-segments.patch"
-SRCREV ?= "5f591f67738a1bbe6b262c53d9dad46ed8bbcd67"
+SRCBRANCH = "master"
+SRCREV = "5f591f67738a1bbe6b262c53d9dad46ed8bbcd67"
 
 DEPENDS += "optee-os"
 
diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
index c5b695e..b0533a1 100644
--- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
+++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-a/trusted-firmware-a.inc
@@ -5,7 +5,9 @@
 
 inherit deploy
 
-SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https;name=tfa;branch=master"
+SRC_URI_TRUSTED_FIRMWARE_A ?= "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https"
+SRCBRANCH = "master"
+SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_A};name=tfa;branch=${SRCBRANCH}"
 
 UPSTREAM_CHECK_GITTAGREGEX = "^v(?P<pver>\d+(\.\d+)+)$"
 
diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch
new file mode 100644
index 0000000..b279cfe
--- /dev/null
+++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/files/rwx.patch
@@ -0,0 +1,24 @@
+From 1d548c77d07fc9a83e3e9aa28a23aa19a0177e3b Mon Sep 17 00:00:00 2001
+From: Jon Mason <jon.mason@arm.com>
+Date: Wed, 18 Jan 2023 15:13:37 -0500
+Subject: [PATCH] arm/trusted-firmware-m: disable fatal warnings
+
+Signed-off-by: Jon Mason <jon.mason@arm.com>
+Upstream-Status: Inappropriate
+
+---
+ toolchain_GNUARM.cmake | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake
+index 7978eaca68..88395f922a 100644
+--- a/toolchain_GNUARM.cmake
++++ b/toolchain_GNUARM.cmake
+@@ -66,7 +66,6 @@ macro(tfm_toolchain_reset_linker_flags)
+         --entry=Reset_Handler
+         --specs=nano.specs
+         LINKER:-check-sections
+-        LINKER:-fatal-warnings
+         LINKER:--gc-sections
+         LINKER:--no-wchar-size-warning
+         ${MEMORY_USAGE_FLAG}
diff --git a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb
index 3b4469d..b4a4c41 100644
--- a/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb
+++ b/meta-arm/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.7.0.bb
@@ -15,11 +15,17 @@
                     file://../mbedtls/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57 \
                     file://../mcuboot/LICENSE;md5=b6ee33f1d12a5e6ee3de1e82fb51eeb8"
 
-SRC_URI  = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https;branch=${SRCBRANCH_tfm};name=tfm;destsuffix=git/tfm \
-            git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https;branch=${SRCBRANCH_tfm-tests};name=tfm-tests;destsuffix=git/tf-m-tests \
-            git://github.com/ARMmbed/mbedtls.git;protocol=https;branch=${SRCBRANCH_mbedtls};name=mbedtls;destsuffix=git/mbedtls \
-            git://github.com/mcu-tools/mcuboot.git;protocol=https;branch=${SRCBRANCH_mcuboot};name=mcuboot;destsuffix=git/mcuboot \
-            git://github.com/laurencelundblade/QCBOR.git;protocol=https;branch=${SRCBRANCH_qcbor};name=qcbor;destsuffix=git/qcbor \
+SRC_URI_TRUSTED_FIRMWARE_M ?= "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https"
+SRC_URI_TRUSTED_FIRMWARE_M_TESTS ?= "git://git.trustedfirmware.org/TF-M/tf-m-tests.git;protocol=https"
+SRC_URI_TRUSTED_FIRMWARE_M_MBEDTLS ?= "git://github.com/ARMmbed/mbedtls.git;protocol=https"
+SRC_URI_TRUSTED_FIRMWARE_M_MCUBOOT ?= "git://github.com/mcu-tools/mcuboot.git;protocol=https"
+SRC_URI_TRUSTED_FIRMWARE_M_QCBOR ?= "git://github.com/laurencelundblade/QCBOR.git;protocol=https"
+SRC_URI  = "${SRC_URI_TRUSTED_FIRMWARE_M};branch=${SRCBRANCH_tfm};name=tfm;destsuffix=git/tfm \
+            ${SRC_URI_TRUSTED_FIRMWARE_M_TESTS};branch=${SRCBRANCH_tfm-tests};name=tfm-tests;destsuffix=git/tf-m-tests \
+            ${SRC_URI_TRUSTED_FIRMWARE_M_MBEDTLS};branch=${SRCBRANCH_mbedtls};name=mbedtls;destsuffix=git/mbedtls \
+            ${SRC_URI_TRUSTED_FIRMWARE_M_MCUBOOT};branch=${SRCBRANCH_mcuboot};name=mcuboot;destsuffix=git/mcuboot \
+            ${SRC_URI_TRUSTED_FIRMWARE_M_QCBOR};branch=${SRCBRANCH_qcbor};name=qcbor;destsuffix=git/qcbor \
+            file://rwx.patch \
             "
 
 # The required dependencies are documented in tf-m/config/config_default.cmake
diff --git a/meta-arm/meta-arm/recipes-bsp/u-boot/u-boot_2022.10.bb b/meta-arm/meta-arm/recipes-bsp/u-boot/u-boot_2022.10.bb
new file mode 100644
index 0000000..905ae55
--- /dev/null
+++ b/meta-arm/meta-arm/recipes-bsp/u-boot/u-boot_2022.10.bb
@@ -0,0 +1,26 @@
+HOMEPAGE = "http://www.denx.de/wiki/U-Boot/WebHome"
+DESCRIPTION = "U-Boot, a boot loader for Embedded boards based on PowerPC, \
+ARM, MIPS and several other processors, which can be installed in a boot \
+ROM and used to initialize and test the hardware or to download and run \
+application code."
+SECTION = "bootloaders"
+DEPENDS += "flex-native bison-native"
+
+LICENSE = "GPL-2.0-or-later"
+LIC_FILES_CHKSUM = "file://Licenses/README;md5=2ca5f2c35c8cc335f0a19756634782f1"
+PE = "1"
+
+# We use the revision in order to avoid having to fetch it from the
+# repo during parse
+SRCREV = "4debc57a3da6c3f4d3f89a637e99206f4cea0a96"
+
+SRC_URI = "git://git.denx.de/u-boot.git;branch=master \
+          "
+
+S = "${WORKDIR}/git"
+B = "${WORKDIR}/build"
+do_configure[cleandirs] = "${B}"
+
+require recipes-bsp/u-boot/u-boot.inc
+
+DEPENDS += "bc-native dtc-native gnutls-native"
diff --git a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
index c9f1f1d..bc47747 100644
--- a/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
+++ b/meta-arm/meta-arm/recipes-bsp/uefi/edk2-firmware.inc
@@ -11,12 +11,13 @@
 LIC_FILES_CHKSUM += "file://edk2-platforms/License.txt;md5=2b415520383f7964e96700ae12b4570a"
 
 # These can be overridden as needed
-EDK2_SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https"
-EDK2_PLATFORMS_SRC_URI = "git://github.com/tianocore/edk2-platforms.git;branch=master;protocol=https"
-
+SRC_URI_EDK2 ?= "gitsm://github.com/tianocore/edk2.git;protocol=https"
+SRC_URI_EDK2_PLATFORMS ?= "git://github.com/tianocore/edk2-platforms.git;protocol=https"
+SRCBRANCH_edk2 = "master"
+SRCBRANCH_edk2_platforms = "master"
 SRC_URI = "\
-    ${EDK2_SRC_URI};name=edk2;destsuffix=edk2;nobranch=1 \
-    ${EDK2_PLATFORMS_SRC_URI};name=edk2-platforms;destsuffix=edk2/edk2-platforms;nobranch=1 \
+    ${SRC_URI_EDK2};branch=${SRCBRANCH_edk2_platforms};name=edk2;destsuffix=edk2 \
+    ${SRC_URI_EDK2_PLATFORMS};branch=${SRCBRANCH_edk2};name=edk2-platforms;destsuffix=edk2/edk2-platforms \
     file://unaligned.patch \
     file://default.patch;patchdir=edk2-platforms \
 "
diff --git a/meta-arm/meta-arm/recipes-devtools/fiptool/fiptool-native_2.7.bb b/meta-arm/meta-arm/recipes-devtools/fiptool/fiptool-native_2.7.bb
index ec531e4..66cf2ce 100644
--- a/meta-arm/meta-arm/recipes-devtools/fiptool/fiptool-native_2.7.bb
+++ b/meta-arm/meta-arm/recipes-devtools/fiptool/fiptool-native_2.7.bb
@@ -5,7 +5,9 @@
 DESCRIPTION = "fiptool - Trusted Firmware tool for packaging"
 LICENSE = "BSD-3-Clause"
 
-SRC_URI = "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;destsuffix=fiptool-${PV};protocol=https;branch=master"
+SRC_URI_TRUSTED_FIRMWARE_A ?= "git://git.trustedfirmware.org/TF-A/trusted-firmware-a.git;protocol=https"
+SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_A};destsuffix=fiptool-${PV};branch=${SRCBRANCH}"
+SRCBRANCH = "master"
 LIC_FILES_CHKSUM = "file://docs/license.rst;md5=b2c740efedc159745b9b31f88ff03dde"
 
 # Use fiptool from TF-A v2.7
diff --git a/meta-arm/meta-arm/recipes-devtools/trusted-firmware-m-scripts/trusted-firmware-m-scripts-native_1.6.0.bb b/meta-arm/meta-arm/recipes-devtools/trusted-firmware-m-scripts/trusted-firmware-m-scripts-native_1.6.0.bb
index 453d456..217f08a 100644
--- a/meta-arm/meta-arm/recipes-devtools/trusted-firmware-m-scripts/trusted-firmware-m-scripts-native_1.6.0.bb
+++ b/meta-arm/meta-arm/recipes-devtools/trusted-firmware-m-scripts/trusted-firmware-m-scripts-native_1.6.0.bb
@@ -1,5 +1,6 @@
 
-SRC_URI = "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https;branch=${SRCBRANCH}"
+SRC_URI_TRUSTED_FIRMWARE_M ?= "git://git.trustedfirmware.org/TF-M/trusted-firmware-m.git;protocol=https"
+SRC_URI = "${SRC_URI_TRUSTED_FIRMWARE_M};branch=${SRCBRANCH}"
 # Use the wrapper script from TF-Mv1.6.0
 SRCBRANCH ?= "release/1.6.x"
 SRCREV = "7387d88158701a3c51ad51c90a05326ee12847a8"
diff --git a/meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.1.bb b/meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.2.bb
similarity index 89%
rename from meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.1.bb
rename to meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.2.bb
index 9e997de..5790d00 100644
--- a/meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.1.bb
+++ b/meta-arm/meta-arm/recipes-kernel/arm-ffa-tee/arm-ffa-tee_1.1.2.bb
@@ -10,8 +10,8 @@
           "
 S = "${WORKDIR}/git"
 
-# Tag tee-v1.1
-SRCREV = "3b543b7591505b715f332c972248a3ea41604d83"
+# Tag tee-v1.1.2
+SRCREV = "8a81f5d2406f146b15a705d49b256efaa5fa3ba9"
 
 COMPATIBLE_HOST = "(arm|aarch64).*-linux"
 KERNEL_MODULE_AUTOLOAD += "arm-ffa-tee"
diff --git a/meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.0.bb b/meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.1.bb
similarity index 92%
rename from meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.0.bb
rename to meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.1.bb
index 8d86197..1261fa4 100644
--- a/meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.0.bb
+++ b/meta-arm/meta-arm/recipes-kernel/arm-ffa-user/arm-ffa-user_5.0.1.bb
@@ -11,8 +11,8 @@
           "
 S = "${WORKDIR}/git"
 
-# Tag 5.0.0.
-SRCREV = "6ec4196a59db8204ed670ef3b78f24a8234b85a6"
+# Tag debugfs-v5.0.1
+SRCREV = "18e3be71f65a405dfb5d97603ae71b3c11759861"
 
 COMPATIBLE_HOST = "(arm|aarch64).*-linux"
 KERNEL_MODULE_AUTOLOAD += "arm-ffa-user"
diff --git a/meta-arm/meta-arm/recipes-security/optee/optee-os-3_19.inc b/meta-arm/meta-arm/recipes-security/optee/optee-os-3_19.inc
index 8adb699..61475dc 100644
--- a/meta-arm/meta-arm/recipes-security/optee/optee-os-3_19.inc
+++ b/meta-arm/meta-arm/recipes-security/optee/optee-os-3_19.inc
@@ -8,7 +8,7 @@
 inherit deploy python3native
 require optee.inc
 
-FILESEXTRAPATHS:prepend := "${THISDIR}/optee-os-3_19:"
+FILESEXTRAPATHS:prepend := "${THISDIR}/optee-os-3.19.0:"
 
 CVE_PRODUCT = "linaro:op-tee op-tee:op-tee_os"
 
diff --git a/meta-raspberrypi/recipes-connectivity/pi-bluetooth/pi-bluetooth/0001-bthelper-correct-path-for-hciconfig-under-Yocto.patch b/meta-raspberrypi/recipes-connectivity/pi-bluetooth/pi-bluetooth/0001-bthelper-correct-path-for-hciconfig-under-Yocto.patch
index 079377e..8766a77 100644
--- a/meta-raspberrypi/recipes-connectivity/pi-bluetooth/pi-bluetooth/0001-bthelper-correct-path-for-hciconfig-under-Yocto.patch
+++ b/meta-raspberrypi/recipes-connectivity/pi-bluetooth/pi-bluetooth/0001-bthelper-correct-path-for-hciconfig-under-Yocto.patch
@@ -3,7 +3,7 @@
 Date: Wed, 14 Nov 2018 09:19:51 -0600
 Subject: [PATCH] bthelper: correct path for hciconfig under Yocto
 
-Upstream-Status: Inapproprate [OE-specific]
+Upstream-Status: Inappropriate [OE-specific]
 Signed-off-by: Peter A. Bigot <pab@pabigot.com>
 Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
 
diff --git a/meta-raspberrypi/recipes-multimedia/gstreamer/gstreamer1.0-omx/0005-Don-t-abort-gst_omx_video_dec_set_format-if-there-s-.patch b/meta-raspberrypi/recipes-multimedia/gstreamer/gstreamer1.0-omx/0005-Don-t-abort-gst_omx_video_dec_set_format-if-there-s-.patch
index 3245294..9914bb8 100644
--- a/meta-raspberrypi/recipes-multimedia/gstreamer/gstreamer1.0-omx/0005-Don-t-abort-gst_omx_video_dec_set_format-if-there-s-.patch
+++ b/meta-raspberrypi/recipes-multimedia/gstreamer/gstreamer1.0-omx/0005-Don-t-abort-gst_omx_video_dec_set_format-if-there-s-.patch
@@ -11,7 +11,7 @@
 Subject: [PATCH] Don't abort gst_omx_video_dec_set_format() if there's a
 timeout releasing the buffers taken by the egl_render out port
 
-Upstream-status: Pending
+Upstream-Status: Pending
 Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
 ---
  omx/gstomxvideodec.c | 2 ++
diff --git a/meta-security/conf/layer.conf b/meta-security/conf/layer.conf
index 84346a1..b5a74f1 100644
--- a/meta-security/conf/layer.conf
+++ b/meta-security/conf/layer.conf
@@ -9,7 +9,7 @@
 BBFILE_PATTERN_security = "^${LAYERDIR}/"
 BBFILE_PRIORITY_security = "8"
 
-LAYERSERIES_COMPAT_security = "langdale mickledore"
+LAYERSERIES_COMPAT_security = "mickledore"
 
 LAYERDEPENDS_security = "core openembedded-layer"
 
diff --git a/meta-security/meta-hardening/conf/layer.conf b/meta-security/meta-hardening/conf/layer.conf
index a150085..add3cbc 100644
--- a/meta-security/meta-hardening/conf/layer.conf
+++ b/meta-security/meta-hardening/conf/layer.conf
@@ -8,6 +8,6 @@
 BBFILE_PATTERN_harden-layer = "^${LAYERDIR}/"
 BBFILE_PRIORITY_harden-layer = "10"
 
-LAYERSERIES_COMPAT_harden-layer = "langdale mickledore"
+LAYERSERIES_COMPAT_harden-layer = "mickledore"
 
 LAYERDEPENDS_harden-layer = "core openembedded-layer"
diff --git a/meta-security/meta-integrity/conf/layer.conf b/meta-security/meta-integrity/conf/layer.conf
index 237306d..b273b5b 100644
--- a/meta-security/meta-integrity/conf/layer.conf
+++ b/meta-security/meta-integrity/conf/layer.conf
@@ -20,7 +20,7 @@
 # interactive shell is enough.
 OE_TERMINAL_EXPORTS += "INTEGRITY_BASE"
 
-LAYERSERIES_COMPAT_integrity = "langdale mickledore"
+LAYERSERIES_COMPAT_integrity = "mickledore"
 # ima-evm-utils depends on keyutils from meta-oe
 LAYERDEPENDS_integrity = "core openembedded-layer"
 
diff --git a/meta-security/meta-parsec/conf/layer.conf b/meta-security/meta-parsec/conf/layer.conf
index 3495235..0a71694 100644
--- a/meta-security/meta-parsec/conf/layer.conf
+++ b/meta-security/meta-parsec/conf/layer.conf
@@ -8,7 +8,7 @@
 BBFILE_PATTERN_parsec-layer = "^${LAYERDIR}/"
 BBFILE_PRIORITY_parsec-layer = "5"
 
-LAYERSERIES_COMPAT_parsec-layer = "langdale mickledore"
+LAYERSERIES_COMPAT_parsec-layer = "mickledore"
 
 LAYERDEPENDS_parsec-layer = "core clang-layer"
 BBLAYERS_LAYERINDEX_NAME_parsec-layer = "meta-parsec"
diff --git a/meta-security/meta-security-compliance/conf/layer.conf b/meta-security/meta-security-compliance/conf/layer.conf
index a250f5c..f07532c 100644
--- a/meta-security/meta-security-compliance/conf/layer.conf
+++ b/meta-security/meta-security-compliance/conf/layer.conf
@@ -8,7 +8,7 @@
 BBFILE_PATTERN_scanners-layer = "^${LAYERDIR}/"
 BBFILE_PRIORITY_scanners-layer = "10"
 
-LAYERSERIES_COMPAT_scanners-layer = "langdale mickledore"
+LAYERSERIES_COMPAT_scanners-layer = "mickledore"
 
 LAYERDEPENDS_scanners-layer = "core openembedded-layer meta-python"
 
diff --git a/meta-security/meta-security-compliance/recipes-openscap/openscap/openscap.inc b/meta-security/meta-security-compliance/recipes-openscap/openscap/openscap.inc
index 4babcf9..e875227 100644
--- a/meta-security/meta-security-compliance/recipes-openscap/openscap/openscap.inc
+++ b/meta-security/meta-security-compliance/recipes-openscap/openscap/openscap.inc
@@ -6,8 +6,8 @@
 LIC_FILES_CHKSUM = "file://COPYING;md5=fbc093901857fcd118f065f900982c24"
 LICENSE = "LGPL-2.1-only"
 
-DEPENDS = "dbus acl bzip2 pkgconfig gconf procps curl libxml2 libxslt libcap swig"
-DEPENDS:class-native = "pkgconfig-native swig-native curl-native libxml2-native libxslt-native libcap-native"
+DEPENDS = "dbus acl bzip2 pkgconfig gconf procps curl libxml2 libxslt libcap swig libpcre"
+DEPENDS:class-native = "pkgconfig-native swig-native curl-native libxml2-native libxslt-native libcap-native libpcre-native"
 
 S = "${WORKDIR}/git"
 
diff --git a/meta-security/meta-security-isafw/conf/layer.conf b/meta-security/meta-security-isafw/conf/layer.conf
index bc88530..550cced 100644
--- a/meta-security/meta-security-isafw/conf/layer.conf
+++ b/meta-security/meta-security-isafw/conf/layer.conf
@@ -14,4 +14,4 @@
 
 LAYERDEPENDS_security-isafw = "core"
 
-LAYERSERIES_COMPAT_security-isafw = "langdale mickledore"
+LAYERSERIES_COMPAT_security-isafw = "mickledore"
diff --git a/meta-security/meta-tpm/conf/layer.conf b/meta-security/meta-tpm/conf/layer.conf
index 0dd19b6..81690ca 100644
--- a/meta-security/meta-tpm/conf/layer.conf
+++ b/meta-security/meta-tpm/conf/layer.conf
@@ -8,7 +8,7 @@
 BBFILE_PATTERN_tpm-layer = "^${LAYERDIR}/"
 BBFILE_PRIORITY_tpm-layer = "10"
 
-LAYERSERIES_COMPAT_tpm-layer = "langdale mickledore"
+LAYERSERIES_COMPAT_tpm-layer = "mickledore"
 
 LAYERDEPENDS_tpm-layer = " \
     core \
diff --git a/meta-security/recipes-security/bubblewrap/bubblewrap_0.7.0.bb b/meta-security/recipes-security/bubblewrap/bubblewrap_0.7.0.bb
deleted file mode 100644
index a48b012..0000000
--- a/meta-security/recipes-security/bubblewrap/bubblewrap_0.7.0.bb
+++ /dev/null
@@ -1,22 +0,0 @@
-DESCRIPTION = "Unprivileged sandboxing tool"
-HOMEPAGE = "https://github.com/containers/bubblewrap"
-LICENSE = "LGPL-2.0-or-later"
-LIC_FILES_CHKSUM = "file://COPYING;md5=5f30f0716dfdd0d91eb439ebec522ec2"
-
-DEPENDS = "libcap"
-
-SRC_URI = "https://github.com/containers/${BPN}/releases/download/v${PV}/${BP}.tar.xz"
-SRC_URI[sha256sum] = "764ab7100bd037ea53d440d362e099d7a425966bc62d1f00ab26b8fbb882a9dc"
-
-inherit autotools bash-completion github-releases manpages pkgconfig
-
-GITHUB_BASE_URI = "https://github.com/containers/${BPN}/releases/"
-
-PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}"
-PACKAGECONFIG[manpages] = "--enable-man,--disable-man,libxslt-native docbook-xsl-stylesheets-native xmlto-native"
-PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux"
-PACKAGECONFIG[setuid] = "--with-priv-mode=setuid,--with-priv-mode=none"
-
-PACKAGES += "${PN}-zsh-completion"
-
-FILES:${PN}-zsh-completion = "${datadir}/zsh/site-functions"