mbox series

[v5,00/39] Qualcomm generic board support

Message ID 20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org
Headers show
Series Qualcomm generic board support | expand

Message

Caleb Connolly Feb. 26, 2024, 5:26 p.m. UTC
Historically, Qualcomm boards in U-Boot have all had their own
board/qualcomm/xyz directory, their own CONFIG_TARGET_XYZ option, their
own hardcoded sysmap-xyz.c file, and their own U-Boot specific
devicetree with little/no compatibility with upstream DT.

This series makes a few final prepatory changes, and then replaces
almost all of the board specific code with generic alternatives. The end
result is that all Qualcomm boards both current and future (with the
exception of the db410c and db820c) can be supported by a single U-Boot
binary by just providing the correct DT. New boards can be added without
introducing any addition mach/ or board/ code or config options.

Due to the nature of this change, the patch ("mach-snapdragon:
generalise board support") has become pretty big, I tried a few
different ways to represent this in git history, but the other methods
(e.g. adding a stub "generic" target and removing it again) were more
confusing and made for much messier git history. The current patch is
mostly atomic, but requires regenerating the config.

The QCS404 EVB board had some code to enable the USB VBUS regulator,
this is dropped in favour of a adding a new vbus-supply property to the
dwc3-generic driver. This will also be used by the dragonboard845c in a
future patch. This handles the common case of a board requiring some
regulator be enabled for USB host mode.

A more detailed description of the changes is below.

== Memory map ==

The memory map was historically hardcoded into U-Boot, this meant that
U-Boot had to be built for a specific variant of a device. This is
changed to instead read the memory map from the DT /memory node.

Additionally, most boards mapped addresss 0x0 as valid, as a result if a
null pointer access happens then it will cause a bus stall (and board
hang). This is fixed so that null pointer accesses will now correctly
throw an exception.

== DT loading ==

Previously, boards used the FDT blob embedded into U-Boot (via
OF_SEPARATE). However, most Qualcomm boards run U-Boot as a secondary
bootloader, so we can instead rely on the first-stage bootloader to
populate some useful FDT properties for us (notably the /memory node and
KASLR seed) and fetch the DTB that it provides. Combined with the memory
map changes above, this let's us entirely avoid configuring the memory
map explicitly.

== defconfig ==

Most of the board defconfigs and config headers were quite similar, to
simplify maintenance going forward, all the fully generic boards (sdm845
and qcs404-evb so far) are adapted to use the new qcom_defconfig. Going
forward, all new Qualcomm boards should be supported by this defconfig.
A notable exception is for specific usecases (like U-Boot as the primary
bootloader).

== The older dragonboards ==

The db410c and db820c both have some custom board init code, as a result
they aren't yet binary compatible. mach-snapdragon is adjusted so
that all the necessary config options (e.g. CONFIG_SYS_BOARD) can be set
from their defconfigs, this makes it possible to enable support for new
boards without introducing additional config options.

The db410c can run U-Boot either chainloaded like the other boards, or
as a first-stage bootloader replacing aboot. However it was hardcoded to
only build for the latter option. This series introduces a new
"chainloaded" defconfig to enable easier testing via fastboot.

== dynamic environment variables ==

This series also introduces runtime-allocated load addresses via the lmb
allocator. This allows for booting on boards with vastly different
memory layouts without any pre-calculation or macro magic in the config
header. This feature is based on similar code in mach-apple.

The soc, board, and fdtfile environment variables are also generated
automatically. Many Qualcomm boards follow a similar scheme for DTB
naming such that the name can often be derived from the root compatible
properties. This is intended to cover the most common cases and be a
simple solution for booting generic distro images without having to
explicitly choose the right DTB. The U-Boot DTS can be tweaked if
necessary to produce the correct name, the variable can be overwritten,
or a bootloader like GRUB can load the devicetree instead.

== Upstream DT ==

All Qualcomm boards have had their devicetree files replaced with the
upstream versions. Previous patch series made the necessary driver
adjustments to fully support the upstream DT format. All future
Qualcomm boards should use upstream DTS by default.

Once Sumit's work to import dt-rebasing has been merged, we will drop
the imported DT and bindings again.

---
I have tested this series on the Dragonboard410c, Dragonboard820c, and
Dragonboard845c. Sumit has tested this on the db410c and QCS404 EVB
board.

---
Changes in v5:
- Adjust msm_sdhci clock handling patch to have clearer error handling based on feedback from Dan.
- Adjust dwc3 vbus-supply patch to be more readable and handle error
  paths better based on feedback from Jonas.
- Add a helper function for determining if a pin is "special" in the
  pinctrl/gpio drivers, set special_pins_start for all SoCs and avoid
  modifying const driver data at runtime.
- Add a comment to clarify that the pmic gpio readonly quirk is a
  workaround and not expected behaviour for the platforms where it's
  necessary.
- Link to v4: https://lore.kernel.org/r/20240215-b4-qcom-common-target-v4-0-ed06355c634a@linaro.org

Changes in v4:
- Drop unreachable return in ehci_usb_of_bind()
- Adjust error reporting in msm_sdc_clk_init() to not print ret which
  will always be 0.
- Simplify qcom_pmic_gpio and associated pinctrrl driver.
- Fix the bit clock divider on QCS404 (thanks Sumit).
- Make QCS404 pinctrl driver compatible with upstream DT.
- Fix qcs404_clk_set_rate() return values + move some things that should
  be in enable.
- Optimise reserved memory carveout algorithm and fix the last regions
  always getting skipped.
- Adjust APQ8016 to probe the pinctrl driver pre-relocation so that UART
  can be initialised.
- Stub in support for special pins in the Qualcomm pinctrl driver - we
  don't support them yet but in most cases they're already configured
  correctly and can be safely skipped.
- Improve readability of sdhci msm_sdc_clk_init() and use log_warning()
  instead of printf().
- Add missing CONFIG_SAVE_PREV_BL options to qcom_defconfig
- Document known issue only affecting qcs404 where in the msm_sdhci driver
  the xo_board clock somehow becomes associated with the qcom_clock device
  resulting in qcs404_clk_set_rate() being called for clock id 0. This
  doesn't seem to cause any issues but has proven somewhat elusive to debug.
- Add a link to the APQ8016 TRM in doc/board/qualcomm/dragonboard410c.rst
- Link to v3: https://lore.kernel.org/r/20240130-b4-qcom-common-target-v3-0-e523cbf9e556@linaro.org

Changes in v3:
- Remove dragonboard410c.dts file
- Introduce generic board_usb_init() function.
- Remove db410c specific dead code (smem RAM layout)
- Fix pinctrl DT compatibility for msm8916/msm8996
- Reference git tag where DT and headers were taken from Linux.
- Adjust ramdisk allocation size to 128M
- Improve documentation wording, reference buildman
- Fix mapping for reserved regions to avoid speculative pre-fetching
- Apply quicksort to memory banks read from DT to ensure ordering
- Link to v2: https://lore.kernel.org/r/20231219-b4-qcom-common-target-v2-0-b6dd9704219e@linaro.org

Changes in v2:
- Split DTS changes to reduce patch size.
- Import full board DTS files from Linux too, and introduce -u-boot.dtsi
  files where necessary to make any U-Boot specific changes.
- Add a pinctrl driver for qcom PMIC GPIOs
- Always enable LINUX_KERNEL_IMAGE_HEADER
- Link to v1: https://lore.kernel.org/r/20231121-b4-qcom-common-target-v1-0-9492198e0c15@linaro.org

To: Neil Armstrong <neil.armstrong@linaro.org>
To: Sumit Garg <sumit.garg@linaro.org>
To: Ramon Fried <rfried.dev@gmail.com>
Cc: Marek Vasut <marex@denx.de>
To: Dzmitry Sankouski <dsankouski@gmail.com>
To: Caleb Connolly <caleb.connolly@linaro.org>
To: Peng Fan <peng.fan@nxp.com>
To: Jaehoon Chung <jh80.chung@samsung.com>
To: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
To: Lukasz Majewski <lukma@denx.de>
To: Sean Anderson <seanga2@gmail.com>
To: Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
To: Stephan Gerhold <stephan@gerhold.net>
Cc:  <u-boot@lists.denx.de>

---
Caleb Connolly (39):
      arm: init: export prev_bl_fdt_addr
      usb: dwc3-generic: support external vbus regulator
      mmc: msm_sdhci: use modern clock handling
      dt-bindings: drop msm_sdhci binding
      clk/qcom: use upstream compatible properties
      clock/qcom: qcs404: fix clk_set_rate
      serial: msm: add debug UART
      serial: msm: fix clock handling and pinctrl
      gpio: qcom_pmic: 1-based GPIOs
      gpio: qcom_pmic: add a quirk to skip GPIO configuration
      gpio: qcom_pmic: add pinctrl driver
      sandbox: dts: fix qcom pmic gpio
      pinctrl: qcom: stub support for special GPIOs
      pinctrl: qcom: fix DT compatibility
      pinctrl: qcom: apq8016: init pre-reloaction
      board: dragonboard410c: add chainloaded config fragment
      board: dragonboard410c: upstream DT compat
      board: dragonboard410c: import board code from mach-snapdragon
      board: dragonboard820c: use LINUX_KERNEL_IMAGE_HEADER
      mach-snapdragon: generalise board support
      mach-snapdragon: dynamic load addresses
      mach-snapdragon: generate fdtfile automatically
      mach-snapdragon: carve out no-map regions
      board: qcs404-evb: drop board code
      doc: board/qualcomm: document generic targets
      doc: board/qualcomm: link to APQ8016 TRM
      dt-bindings: import headers for SDM845
      dts: sdm845: import supporting dtsi files
      dts: sdm845: replace with upstream DTS
      dt-bindings: import headers for MSM8916
      dts: msm8916: import PMIC dtsi files
      dts: msm8916: replace with upstream DTS
      dt-bindings: import headers for MSM8996
      dts: msm8996: import PMIC dtsi files
      dts: dragonboard820c: use correct bindings for clocks
      dts: msm8996: replace with upstream DTS
      dt-bindings: import headers for qcs404
      dts: qcs404-evb: replace with upstream DT
      MAINTAINERS: Qualcomm: add some missing paths

 MAINTAINERS                                        |   12 +-
 arch/arm/Kconfig                                   |    4 +
 arch/arm/dts/Makefile                              |    9 +-
 arch/arm/dts/apq8016-sbc-u-boot.dtsi               |   20 +
 arch/arm/dts/apq8016-sbc.dts                       |  729 +++
 arch/arm/dts/apq8096-db820c-u-boot.dtsi            |   14 +
 arch/arm/dts/apq8096-db820c.dts                    | 1137 ++++
 arch/arm/dts/dragonboard410c-uboot.dtsi            |   44 -
 arch/arm/dts/dragonboard410c.dts                   |  209 -
 arch/arm/dts/dragonboard820c-uboot.dtsi            |   32 -
 arch/arm/dts/dragonboard820c.dts                   |  151 -
 arch/arm/dts/dragonboard845c-uboot.dtsi            |   26 -
 arch/arm/dts/dragonboard845c.dts                   |   48 -
 arch/arm/dts/msm8916-pm8916.dtsi                   |  157 +
 arch/arm/dts/msm8916.dtsi                          | 2702 +++++++++
 arch/arm/dts/msm8996.dtsi                          | 3884 +++++++++++++
 arch/arm/dts/pm8916.dtsi                           |  178 +
 arch/arm/dts/pm8994.dtsi                           |  152 +
 arch/arm/dts/pm8998.dtsi                           |  130 +
 arch/arm/dts/pmi8994.dtsi                          |   65 +
 arch/arm/dts/pmi8998.dtsi                          |   98 +
 arch/arm/dts/pms405.dtsi                           |  149 +
 arch/arm/dts/qcs404-evb-4000-u-boot.dtsi           |   48 +
 arch/arm/dts/qcs404-evb-4000.dts                   |   96 +
 arch/arm/dts/qcs404-evb-uboot.dtsi                 |   30 -
 arch/arm/dts/qcs404-evb.dts                        |  390 --
 arch/arm/dts/qcs404-evb.dtsi                       |  389 ++
 arch/arm/dts/qcs404.dtsi                           | 1829 ++++++
 arch/arm/dts/sdm845-db845c.dts                     | 1190 ++++
 .../arm/dts/sdm845-samsung-starqltechn-u-boot.dtsi |   16 +
 arch/arm/dts/sdm845-samsung-starqltechn.dts        |  460 ++
 arch/arm/dts/sdm845-wcd9340.dtsi                   |   86 +
 arch/arm/dts/sdm845.dtsi                           | 5801 +++++++++++++++++++-
 arch/arm/dts/starqltechn-uboot.dtsi                |   27 -
 arch/arm/dts/starqltechn.dts                       |   68 -
 arch/arm/lib/save_prev_bl_data.c                   |    5 +
 arch/arm/mach-snapdragon/Kconfig                   |   95 +-
 arch/arm/mach-snapdragon/Makefile                  |    8 +-
 arch/arm/mach-snapdragon/board.c                   |  468 ++
 arch/arm/mach-snapdragon/dram.c                    |   99 -
 arch/arm/mach-snapdragon/include/mach/dram.h       |   12 -
 arch/arm/mach-snapdragon/include/mach/gpio.h       |    7 +
 arch/arm/mach-snapdragon/include/mach/misc.h       |   13 -
 arch/arm/mach-snapdragon/init_sdm845.c             |   73 -
 arch/arm/mach-snapdragon/misc.c                    |   55 -
 arch/arm/mach-snapdragon/sysmap-apq8016.c          |   31 -
 arch/arm/mach-snapdragon/sysmap-apq8096.c          |   31 -
 arch/arm/mach-snapdragon/sysmap-qcs404.c           |   43 -
 arch/arm/mach-snapdragon/sysmap-sdm845.c           |   31 -
 arch/sandbox/dts/sandbox.dtsi                      |    9 +-
 board/qualcomm/dragonboard410c/Kconfig             |   15 -
 board/qualcomm/dragonboard410c/Makefile            |    2 +-
 .../dragonboard410c/configs/chainloaded.config     |    7 +
 board/qualcomm/dragonboard410c/dragonboard410c.c   |  130 +-
 board/qualcomm/dragonboard820c/Kconfig             |   15 -
 board/qualcomm/dragonboard820c/Makefile            |    1 -
 board/qualcomm/dragonboard820c/dragonboard820c.c   |   39 +-
 board/qualcomm/dragonboard820c/head.S              |   33 -
 board/qualcomm/dragonboard820c/u-boot.lds          |  111 -
 board/qualcomm/dragonboard845c/Kconfig             |   12 -
 board/qualcomm/qcs404-evb/Kconfig                  |   15 -
 board/qualcomm/qcs404-evb/Makefile                 |    6 -
 board/qualcomm/qcs404-evb/qcs404-evb.c             |   62 -
 configs/dragonboard410c_defconfig                  |    8 +-
 configs/dragonboard820c_defconfig                  |    8 +-
 configs/dragonboard845c_defconfig                  |   29 -
 configs/qcom_defconfig                             |   67 +
 configs/qcs404evb_defconfig                        |   55 -
 configs/starqltechn_defconfig                      |   41 -
 doc/board/qualcomm/board.rst                       |  125 +
 doc/board/qualcomm/debugging.rst                   |   61 +
 doc/board/qualcomm/dragonboard410c.rst             |    2 +
 doc/board/qualcomm/index.rst                       |    4 +-
 doc/board/qualcomm/qcs404.rst                      |   79 -
 doc/board/qualcomm/sdm845.rst                      |  167 -
 doc/device-tree-bindings/mmc/msm_sdhci.txt         |   25 -
 doc/device-tree-bindings/usb/ehci-msm.txt          |   10 -
 drivers/clk/qcom/clock-apq8016.c                   |    9 +-
 drivers/clk/qcom/clock-apq8096.c                   |    7 +-
 drivers/clk/qcom/clock-qcs404.c                    |   25 +-
 drivers/gpio/msm_gpio.c                            |   20 +
 drivers/gpio/qcom_pmic_gpio.c                      |  277 +-
 drivers/mmc/msm_sdhci.c                            |   69 +-
 drivers/phy/qcom/msm8916-usbh-phy.c                |    4 +-
 drivers/pinctrl/qcom/pinctrl-apq8016.c             |   34 +-
 drivers/pinctrl/qcom/pinctrl-apq8096.c             |   21 +-
 drivers/pinctrl/qcom/pinctrl-ipq4019.c             |    5 +-
 drivers/pinctrl/qcom/pinctrl-qcom.c                |   12 +
 drivers/pinctrl/qcom/pinctrl-qcs404.c              |   64 +-
 drivers/pinctrl/qcom/pinctrl-sdm845.c              |    5 +-
 drivers/serial/Kconfig                             |    8 +
 drivers/serial/serial_msm.c                        |   62 +-
 drivers/usb/dwc3/dwc3-generic.c                    |   24 +-
 drivers/usb/host/ehci-msm.c                        |   22 +-
 include/configs/dragonboard845c.h                  |   20 -
 include/configs/qcom.h                             |   21 +
 include/configs/qcs404-evb.h                       |   20 -
 include/configs/sdm845.h                           |   26 -
 include/dt-bindings/arm/coresight-cti-dt.h         |   37 +
 include/dt-bindings/clock/qcom,camcc-sdm845.h      |  116 +
 include/dt-bindings/clock/qcom,dispcc-sdm845.h     |   56 +
 include/dt-bindings/clock/qcom,gcc-msm8916.h       |  179 +
 include/dt-bindings/clock/qcom,gcc-msm8996.h       |  362 ++
 include/dt-bindings/clock/qcom,gpucc-sdm845.h      |   24 +
 include/dt-bindings/clock/qcom,lpass-sdm845.h      |   15 +
 include/dt-bindings/clock/qcom,mmcc-msm8996.h      |  295 +
 include/dt-bindings/clock/qcom,rpmcc.h             |  174 +
 include/dt-bindings/clock/qcom,rpmh.h              |   37 +
 include/dt-bindings/clock/qcom,turingcc-qcs404.h   |   15 +
 include/dt-bindings/clock/qcom,videocc-sdm845.h    |   35 +
 include/dt-bindings/dma/qcom-gpi.h                 |   11 +
 include/dt-bindings/firmware/qcom,scm.h            |   39 +
 include/dt-bindings/iio/qcom,spmi-vadc.h           |  300 +
 include/dt-bindings/interconnect/qcom,msm8916.h    |  100 +
 .../dt-bindings/interconnect/qcom,msm8996-cbf.h    |   12 +
 include/dt-bindings/interconnect/qcom,msm8996.h    |  163 +
 include/dt-bindings/interconnect/qcom,osm-l3.h     |   15 +
 include/dt-bindings/interconnect/qcom,sdm845.h     |  150 +
 include/dt-bindings/phy/phy-qcom-qmp.h             |   20 +
 include/dt-bindings/phy/phy-qcom-qusb2.h           |   37 +
 include/dt-bindings/pinctrl/qcom,pmic-gpio.h       |  164 +
 include/dt-bindings/pinctrl/qcom,pmic-mpp.h        |  106 +
 include/dt-bindings/power/qcom-rpmpd.h             |  412 ++
 .../dt-bindings/regulator/qcom,rpmh-regulator.h    |   36 +
 include/dt-bindings/reset/qcom,gcc-msm8916.h       |  100 +
 include/dt-bindings/reset/qcom,sdm845-aoss.h       |   17 +
 include/dt-bindings/reset/qcom,sdm845-pdc.h        |   22 +
 include/dt-bindings/soc/qcom,apr.h                 |   28 +
 include/dt-bindings/soc/qcom,rpmh-rsc.h            |   14 +
 include/dt-bindings/sound/apq8016-lpass.h          |    9 +
 include/dt-bindings/sound/qcom,lpass.h             |   46 +
 include/dt-bindings/sound/qcom,q6afe.h             |    9 +
 include/dt-bindings/sound/qcom,q6asm.h             |   26 +
 include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h |  234 +
 include/dt-bindings/sound/qcom,wcd9335.h           |   15 +
 include/init.h                                     |   11 +
 136 files changed, 24033 insertions(+), 2652 deletions(-)
---
base-commit: 1a66a7768af7e8106c2cd93a19f4013877fb85ae

// Caleb (they/them)

Comments

Sumit Garg March 1, 2024, 2:51 p.m. UTC | #1
Hi Caleb,

On Mon, 26 Feb 2024 at 22:56, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> Historically, Qualcomm boards in U-Boot have all had their own
> board/qualcomm/xyz directory, their own CONFIG_TARGET_XYZ option, their
> own hardcoded sysmap-xyz.c file, and their own U-Boot specific
> devicetree with little/no compatibility with upstream DT.
>
> This series makes a few final prepatory changes, and then replaces
> almost all of the board specific code with generic alternatives. The end
> result is that all Qualcomm boards both current and future (with the
> exception of the db410c and db820c) can be supported by a single U-Boot
> binary by just providing the correct DT. New boards can be added without
> introducing any addition mach/ or board/ code or config options.
>
> Due to the nature of this change, the patch ("mach-snapdragon:
> generalise board support") has become pretty big, I tried a few
> different ways to represent this in git history, but the other methods
> (e.g. adding a stub "generic" target and removing it again) were more
> confusing and made for much messier git history. The current patch is
> mostly atomic, but requires regenerating the config.
>
> The QCS404 EVB board had some code to enable the USB VBUS regulator,
> this is dropped in favour of a adding a new vbus-supply property to the
> dwc3-generic driver. This will also be used by the dragonboard845c in a
> future patch. This handles the common case of a board requiring some
> regulator be enabled for USB host mode.
>
> A more detailed description of the changes is below.
>
> == Memory map ==
>
> The memory map was historically hardcoded into U-Boot, this meant that
> U-Boot had to be built for a specific variant of a device. This is
> changed to instead read the memory map from the DT /memory node.
>
> Additionally, most boards mapped addresss 0x0 as valid, as a result if a
> null pointer access happens then it will cause a bus stall (and board
> hang). This is fixed so that null pointer accesses will now correctly
> throw an exception.
>
> == DT loading ==
>
> Previously, boards used the FDT blob embedded into U-Boot (via
> OF_SEPARATE). However, most Qualcomm boards run U-Boot as a secondary
> bootloader, so we can instead rely on the first-stage bootloader to
> populate some useful FDT properties for us (notably the /memory node and
> KASLR seed) and fetch the DTB that it provides. Combined with the memory
> map changes above, this let's us entirely avoid configuring the memory
> map explicitly.
>
> == defconfig ==
>
> Most of the board defconfigs and config headers were quite similar, to
> simplify maintenance going forward, all the fully generic boards (sdm845
> and qcs404-evb so far) are adapted to use the new qcom_defconfig. Going
> forward, all new Qualcomm boards should be supported by this defconfig.
> A notable exception is for specific usecases (like U-Boot as the primary
> bootloader).
>
> == The older dragonboards ==
>
> The db410c and db820c both have some custom board init code, as a result
> they aren't yet binary compatible. mach-snapdragon is adjusted so
> that all the necessary config options (e.g. CONFIG_SYS_BOARD) can be set
> from their defconfigs, this makes it possible to enable support for new
> boards without introducing additional config options.
>
> The db410c can run U-Boot either chainloaded like the other boards, or
> as a first-stage bootloader replacing aboot. However it was hardcoded to
> only build for the latter option. This series introduces a new
> "chainloaded" defconfig to enable easier testing via fastboot.
>
> == dynamic environment variables ==
>
> This series also introduces runtime-allocated load addresses via the lmb
> allocator. This allows for booting on boards with vastly different
> memory layouts without any pre-calculation or macro magic in the config
> header. This feature is based on similar code in mach-apple.
>
> The soc, board, and fdtfile environment variables are also generated
> automatically. Many Qualcomm boards follow a similar scheme for DTB
> naming such that the name can often be derived from the root compatible
> properties. This is intended to cover the most common cases and be a
> simple solution for booting generic distro images without having to
> explicitly choose the right DTB. The U-Boot DTS can be tweaked if
> necessary to produce the correct name, the variable can be overwritten,
> or a bootloader like GRUB can load the devicetree instead.
>
> == Upstream DT ==
>
> All Qualcomm boards have had their devicetree files replaced with the
> upstream versions. Previous patch series made the necessary driver
> adjustments to fully support the upstream DT format. All future
> Qualcomm boards should use upstream DTS by default.
>
> Once Sumit's work to import dt-rebasing has been merged, we will drop
> the imported DT and bindings again.

I suppose we are just in time for this as the OF_UPSTREAM work has
been merged into U-Boot next branch [1]. Can you rebase this patch-set
on top of that? I suppose many of the DT import patches won't be
needed at all.

[1] https://source.denx.de/u-boot/u-boot/-/commits/next/?ref_type=heads

-Sumit

>
> ---
> I have tested this series on the Dragonboard410c, Dragonboard820c, and
> Dragonboard845c. Sumit has tested this on the db410c and QCS404 EVB
> board.
>
> ---
> Changes in v5:
> - Adjust msm_sdhci clock handling patch to have clearer error handling based on feedback from Dan.
> - Adjust dwc3 vbus-supply patch to be more readable and handle error
>   paths better based on feedback from Jonas.
> - Add a helper function for determining if a pin is "special" in the
>   pinctrl/gpio drivers, set special_pins_start for all SoCs and avoid
>   modifying const driver data at runtime.
> - Add a comment to clarify that the pmic gpio readonly quirk is a
>   workaround and not expected behaviour for the platforms where it's
>   necessary.
> - Link to v4: https://lore.kernel.org/r/20240215-b4-qcom-common-target-v4-0-ed06355c634a@linaro.org
>
> Changes in v4:
> - Drop unreachable return in ehci_usb_of_bind()
> - Adjust error reporting in msm_sdc_clk_init() to not print ret which
>   will always be 0.
> - Simplify qcom_pmic_gpio and associated pinctrrl driver.
> - Fix the bit clock divider on QCS404 (thanks Sumit).
> - Make QCS404 pinctrl driver compatible with upstream DT.
> - Fix qcs404_clk_set_rate() return values + move some things that should
>   be in enable.
> - Optimise reserved memory carveout algorithm and fix the last regions
>   always getting skipped.
> - Adjust APQ8016 to probe the pinctrl driver pre-relocation so that UART
>   can be initialised.
> - Stub in support for special pins in the Qualcomm pinctrl driver - we
>   don't support them yet but in most cases they're already configured
>   correctly and can be safely skipped.
> - Improve readability of sdhci msm_sdc_clk_init() and use log_warning()
>   instead of printf().
> - Add missing CONFIG_SAVE_PREV_BL options to qcom_defconfig
> - Document known issue only affecting qcs404 where in the msm_sdhci driver
>   the xo_board clock somehow becomes associated with the qcom_clock device
>   resulting in qcs404_clk_set_rate() being called for clock id 0. This
>   doesn't seem to cause any issues but has proven somewhat elusive to debug.
> - Add a link to the APQ8016 TRM in doc/board/qualcomm/dragonboard410c.rst
> - Link to v3: https://lore.kernel.org/r/20240130-b4-qcom-common-target-v3-0-e523cbf9e556@linaro.org
>
> Changes in v3:
> - Remove dragonboard410c.dts file
> - Introduce generic board_usb_init() function.
> - Remove db410c specific dead code (smem RAM layout)
> - Fix pinctrl DT compatibility for msm8916/msm8996
> - Reference git tag where DT and headers were taken from Linux.
> - Adjust ramdisk allocation size to 128M
> - Improve documentation wording, reference buildman
> - Fix mapping for reserved regions to avoid speculative pre-fetching
> - Apply quicksort to memory banks read from DT to ensure ordering
> - Link to v2: https://lore.kernel.org/r/20231219-b4-qcom-common-target-v2-0-b6dd9704219e@linaro.org
>
> Changes in v2:
> - Split DTS changes to reduce patch size.
> - Import full board DTS files from Linux too, and introduce -u-boot.dtsi
>   files where necessary to make any U-Boot specific changes.
> - Add a pinctrl driver for qcom PMIC GPIOs
> - Always enable LINUX_KERNEL_IMAGE_HEADER
> - Link to v1: https://lore.kernel.org/r/20231121-b4-qcom-common-target-v1-0-9492198e0c15@linaro.org
>
> To: Neil Armstrong <neil.armstrong@linaro.org>
> To: Sumit Garg <sumit.garg@linaro.org>
> To: Ramon Fried <rfried.dev@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> To: Dzmitry Sankouski <dsankouski@gmail.com>
> To: Caleb Connolly <caleb.connolly@linaro.org>
> To: Peng Fan <peng.fan@nxp.com>
> To: Jaehoon Chung <jh80.chung@samsung.com>
> To: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> To: Lukasz Majewski <lukma@denx.de>
> To: Sean Anderson <seanga2@gmail.com>
> To: Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
> To: Stephan Gerhold <stephan@gerhold.net>
> Cc:  <u-boot@lists.denx.de>
>
> ---
> Caleb Connolly (39):
>       arm: init: export prev_bl_fdt_addr
>       usb: dwc3-generic: support external vbus regulator
>       mmc: msm_sdhci: use modern clock handling
>       dt-bindings: drop msm_sdhci binding
>       clk/qcom: use upstream compatible properties
>       clock/qcom: qcs404: fix clk_set_rate
>       serial: msm: add debug UART
>       serial: msm: fix clock handling and pinctrl
>       gpio: qcom_pmic: 1-based GPIOs
>       gpio: qcom_pmic: add a quirk to skip GPIO configuration
>       gpio: qcom_pmic: add pinctrl driver
>       sandbox: dts: fix qcom pmic gpio
>       pinctrl: qcom: stub support for special GPIOs
>       pinctrl: qcom: fix DT compatibility
>       pinctrl: qcom: apq8016: init pre-reloaction
>       board: dragonboard410c: add chainloaded config fragment
>       board: dragonboard410c: upstream DT compat
>       board: dragonboard410c: import board code from mach-snapdragon
>       board: dragonboard820c: use LINUX_KERNEL_IMAGE_HEADER
>       mach-snapdragon: generalise board support
>       mach-snapdragon: dynamic load addresses
>       mach-snapdragon: generate fdtfile automatically
>       mach-snapdragon: carve out no-map regions
>       board: qcs404-evb: drop board code
>       doc: board/qualcomm: document generic targets
>       doc: board/qualcomm: link to APQ8016 TRM
>       dt-bindings: import headers for SDM845
>       dts: sdm845: import supporting dtsi files
>       dts: sdm845: replace with upstream DTS
>       dt-bindings: import headers for MSM8916
>       dts: msm8916: import PMIC dtsi files
>       dts: msm8916: replace with upstream DTS
>       dt-bindings: import headers for MSM8996
>       dts: msm8996: import PMIC dtsi files
>       dts: dragonboard820c: use correct bindings for clocks
>       dts: msm8996: replace with upstream DTS
>       dt-bindings: import headers for qcs404
>       dts: qcs404-evb: replace with upstream DT
>       MAINTAINERS: Qualcomm: add some missing paths
>
>  MAINTAINERS                                        |   12 +-
>  arch/arm/Kconfig                                   |    4 +
>  arch/arm/dts/Makefile                              |    9 +-
>  arch/arm/dts/apq8016-sbc-u-boot.dtsi               |   20 +
>  arch/arm/dts/apq8016-sbc.dts                       |  729 +++
>  arch/arm/dts/apq8096-db820c-u-boot.dtsi            |   14 +
>  arch/arm/dts/apq8096-db820c.dts                    | 1137 ++++
>  arch/arm/dts/dragonboard410c-uboot.dtsi            |   44 -
>  arch/arm/dts/dragonboard410c.dts                   |  209 -
>  arch/arm/dts/dragonboard820c-uboot.dtsi            |   32 -
>  arch/arm/dts/dragonboard820c.dts                   |  151 -
>  arch/arm/dts/dragonboard845c-uboot.dtsi            |   26 -
>  arch/arm/dts/dragonboard845c.dts                   |   48 -
>  arch/arm/dts/msm8916-pm8916.dtsi                   |  157 +
>  arch/arm/dts/msm8916.dtsi                          | 2702 +++++++++
>  arch/arm/dts/msm8996.dtsi                          | 3884 +++++++++++++
>  arch/arm/dts/pm8916.dtsi                           |  178 +
>  arch/arm/dts/pm8994.dtsi                           |  152 +
>  arch/arm/dts/pm8998.dtsi                           |  130 +
>  arch/arm/dts/pmi8994.dtsi                          |   65 +
>  arch/arm/dts/pmi8998.dtsi                          |   98 +
>  arch/arm/dts/pms405.dtsi                           |  149 +
>  arch/arm/dts/qcs404-evb-4000-u-boot.dtsi           |   48 +
>  arch/arm/dts/qcs404-evb-4000.dts                   |   96 +
>  arch/arm/dts/qcs404-evb-uboot.dtsi                 |   30 -
>  arch/arm/dts/qcs404-evb.dts                        |  390 --
>  arch/arm/dts/qcs404-evb.dtsi                       |  389 ++
>  arch/arm/dts/qcs404.dtsi                           | 1829 ++++++
>  arch/arm/dts/sdm845-db845c.dts                     | 1190 ++++
>  .../arm/dts/sdm845-samsung-starqltechn-u-boot.dtsi |   16 +
>  arch/arm/dts/sdm845-samsung-starqltechn.dts        |  460 ++
>  arch/arm/dts/sdm845-wcd9340.dtsi                   |   86 +
>  arch/arm/dts/sdm845.dtsi                           | 5801 +++++++++++++++++++-
>  arch/arm/dts/starqltechn-uboot.dtsi                |   27 -
>  arch/arm/dts/starqltechn.dts                       |   68 -
>  arch/arm/lib/save_prev_bl_data.c                   |    5 +
>  arch/arm/mach-snapdragon/Kconfig                   |   95 +-
>  arch/arm/mach-snapdragon/Makefile                  |    8 +-
>  arch/arm/mach-snapdragon/board.c                   |  468 ++
>  arch/arm/mach-snapdragon/dram.c                    |   99 -
>  arch/arm/mach-snapdragon/include/mach/dram.h       |   12 -
>  arch/arm/mach-snapdragon/include/mach/gpio.h       |    7 +
>  arch/arm/mach-snapdragon/include/mach/misc.h       |   13 -
>  arch/arm/mach-snapdragon/init_sdm845.c             |   73 -
>  arch/arm/mach-snapdragon/misc.c                    |   55 -
>  arch/arm/mach-snapdragon/sysmap-apq8016.c          |   31 -
>  arch/arm/mach-snapdragon/sysmap-apq8096.c          |   31 -
>  arch/arm/mach-snapdragon/sysmap-qcs404.c           |   43 -
>  arch/arm/mach-snapdragon/sysmap-sdm845.c           |   31 -
>  arch/sandbox/dts/sandbox.dtsi                      |    9 +-
>  board/qualcomm/dragonboard410c/Kconfig             |   15 -
>  board/qualcomm/dragonboard410c/Makefile            |    2 +-
>  .../dragonboard410c/configs/chainloaded.config     |    7 +
>  board/qualcomm/dragonboard410c/dragonboard410c.c   |  130 +-
>  board/qualcomm/dragonboard820c/Kconfig             |   15 -
>  board/qualcomm/dragonboard820c/Makefile            |    1 -
>  board/qualcomm/dragonboard820c/dragonboard820c.c   |   39 +-
>  board/qualcomm/dragonboard820c/head.S              |   33 -
>  board/qualcomm/dragonboard820c/u-boot.lds          |  111 -
>  board/qualcomm/dragonboard845c/Kconfig             |   12 -
>  board/qualcomm/qcs404-evb/Kconfig                  |   15 -
>  board/qualcomm/qcs404-evb/Makefile                 |    6 -
>  board/qualcomm/qcs404-evb/qcs404-evb.c             |   62 -
>  configs/dragonboard410c_defconfig                  |    8 +-
>  configs/dragonboard820c_defconfig                  |    8 +-
>  configs/dragonboard845c_defconfig                  |   29 -
>  configs/qcom_defconfig                             |   67 +
>  configs/qcs404evb_defconfig                        |   55 -
>  configs/starqltechn_defconfig                      |   41 -
>  doc/board/qualcomm/board.rst                       |  125 +
>  doc/board/qualcomm/debugging.rst                   |   61 +
>  doc/board/qualcomm/dragonboard410c.rst             |    2 +
>  doc/board/qualcomm/index.rst                       |    4 +-
>  doc/board/qualcomm/qcs404.rst                      |   79 -
>  doc/board/qualcomm/sdm845.rst                      |  167 -
>  doc/device-tree-bindings/mmc/msm_sdhci.txt         |   25 -
>  doc/device-tree-bindings/usb/ehci-msm.txt          |   10 -
>  drivers/clk/qcom/clock-apq8016.c                   |    9 +-
>  drivers/clk/qcom/clock-apq8096.c                   |    7 +-
>  drivers/clk/qcom/clock-qcs404.c                    |   25 +-
>  drivers/gpio/msm_gpio.c                            |   20 +
>  drivers/gpio/qcom_pmic_gpio.c                      |  277 +-
>  drivers/mmc/msm_sdhci.c                            |   69 +-
>  drivers/phy/qcom/msm8916-usbh-phy.c                |    4 +-
>  drivers/pinctrl/qcom/pinctrl-apq8016.c             |   34 +-
>  drivers/pinctrl/qcom/pinctrl-apq8096.c             |   21 +-
>  drivers/pinctrl/qcom/pinctrl-ipq4019.c             |    5 +-
>  drivers/pinctrl/qcom/pinctrl-qcom.c                |   12 +
>  drivers/pinctrl/qcom/pinctrl-qcs404.c              |   64 +-
>  drivers/pinctrl/qcom/pinctrl-sdm845.c              |    5 +-
>  drivers/serial/Kconfig                             |    8 +
>  drivers/serial/serial_msm.c                        |   62 +-
>  drivers/usb/dwc3/dwc3-generic.c                    |   24 +-
>  drivers/usb/host/ehci-msm.c                        |   22 +-
>  include/configs/dragonboard845c.h                  |   20 -
>  include/configs/qcom.h                             |   21 +
>  include/configs/qcs404-evb.h                       |   20 -
>  include/configs/sdm845.h                           |   26 -
>  include/dt-bindings/arm/coresight-cti-dt.h         |   37 +
>  include/dt-bindings/clock/qcom,camcc-sdm845.h      |  116 +
>  include/dt-bindings/clock/qcom,dispcc-sdm845.h     |   56 +
>  include/dt-bindings/clock/qcom,gcc-msm8916.h       |  179 +
>  include/dt-bindings/clock/qcom,gcc-msm8996.h       |  362 ++
>  include/dt-bindings/clock/qcom,gpucc-sdm845.h      |   24 +
>  include/dt-bindings/clock/qcom,lpass-sdm845.h      |   15 +
>  include/dt-bindings/clock/qcom,mmcc-msm8996.h      |  295 +
>  include/dt-bindings/clock/qcom,rpmcc.h             |  174 +
>  include/dt-bindings/clock/qcom,rpmh.h              |   37 +
>  include/dt-bindings/clock/qcom,turingcc-qcs404.h   |   15 +
>  include/dt-bindings/clock/qcom,videocc-sdm845.h    |   35 +
>  include/dt-bindings/dma/qcom-gpi.h                 |   11 +
>  include/dt-bindings/firmware/qcom,scm.h            |   39 +
>  include/dt-bindings/iio/qcom,spmi-vadc.h           |  300 +
>  include/dt-bindings/interconnect/qcom,msm8916.h    |  100 +
>  .../dt-bindings/interconnect/qcom,msm8996-cbf.h    |   12 +
>  include/dt-bindings/interconnect/qcom,msm8996.h    |  163 +
>  include/dt-bindings/interconnect/qcom,osm-l3.h     |   15 +
>  include/dt-bindings/interconnect/qcom,sdm845.h     |  150 +
>  include/dt-bindings/phy/phy-qcom-qmp.h             |   20 +
>  include/dt-bindings/phy/phy-qcom-qusb2.h           |   37 +
>  include/dt-bindings/pinctrl/qcom,pmic-gpio.h       |  164 +
>  include/dt-bindings/pinctrl/qcom,pmic-mpp.h        |  106 +
>  include/dt-bindings/power/qcom-rpmpd.h             |  412 ++
>  .../dt-bindings/regulator/qcom,rpmh-regulator.h    |   36 +
>  include/dt-bindings/reset/qcom,gcc-msm8916.h       |  100 +
>  include/dt-bindings/reset/qcom,sdm845-aoss.h       |   17 +
>  include/dt-bindings/reset/qcom,sdm845-pdc.h        |   22 +
>  include/dt-bindings/soc/qcom,apr.h                 |   28 +
>  include/dt-bindings/soc/qcom,rpmh-rsc.h            |   14 +
>  include/dt-bindings/sound/apq8016-lpass.h          |    9 +
>  include/dt-bindings/sound/qcom,lpass.h             |   46 +
>  include/dt-bindings/sound/qcom,q6afe.h             |    9 +
>  include/dt-bindings/sound/qcom,q6asm.h             |   26 +
>  include/dt-bindings/sound/qcom,q6dsp-lpass-ports.h |  234 +
>  include/dt-bindings/sound/qcom,wcd9335.h           |   15 +
>  include/init.h                                     |   11 +
>  136 files changed, 24033 insertions(+), 2652 deletions(-)
> ---
> base-commit: 1a66a7768af7e8106c2cd93a19f4013877fb85ae
>
> // Caleb (they/them)
>
Caleb Connolly March 1, 2024, 3:10 p.m. UTC | #2
On Mon, 26 Feb 2024 17:26:04 +0000, Caleb Connolly wrote:
> Historically, Qualcomm boards in U-Boot have all had their own
> board/qualcomm/xyz directory, their own CONFIG_TARGET_XYZ option, their
> own hardcoded sysmap-xyz.c file, and their own U-Boot specific
> devicetree with little/no compatibility with upstream DT.
> 
> This series makes a few final prepatory changes, and then replaces
> almost all of the board specific code with generic alternatives. The end
> result is that all Qualcomm boards both current and future (with the
> exception of the db410c and db820c) can be supported by a single U-Boot
> binary by just providing the correct DT. New boards can be added without
> introducing any addition mach/ or board/ code or config options.
> 
> [...]

Applied, thanks!

[01/39] arm: init: export prev_bl_fdt_addr
        commit: ca84ba63858a607fe2dabf56ed593d7808d2689d
[02/39] usb: dwc3-generic: support external vbus regulator
        commit: de451d5d5b6f1913b7a7c270e7e5ff606342f126
[03/39] mmc: msm_sdhci: use modern clock handling
        commit: 5f3c4cca362b29fa60fd4fb5efeec60fe8f35af1
[04/39] dt-bindings: drop msm_sdhci binding
        commit: dae9614e1eb8fa5d4ae8051497a582940430e134
[05/39] clk/qcom: use upstream compatible properties
        commit: 7d96cca9e1d83ef307d7907e15d7a504ffc1ae69
[06/39] clock/qcom: qcs404: fix clk_set_rate
        commit: 641237bf99f701ffdf3748f5fe1e118eb2d7b781
[07/39] serial: msm: add debug UART
        commit: 90023bdfe979a5ea3806b73e73fabfc3e1a94a04
[08/39] serial: msm: fix clock handling and pinctrl
        commit: 92781cff6e7115b5a8957e6a9ded6cd7516d4fc7
[09/39] gpio: qcom_pmic: 1-based GPIOs
        commit: a2ce3aac46121e7ffa244540b62b439ddeed7a9c
[10/39] gpio: qcom_pmic: add a quirk to skip GPIO configuration
        commit: 19f000b72b2fa7e4540f7cdb91287aff594239bd
[11/39] gpio: qcom_pmic: add pinctrl driver
        commit: eb2393d7d5443750b8ab61912ead78eb54b42fb9
[12/39] sandbox: dts: fix qcom pmic gpio
        commit: cc18d5486b2cb520d50d2154fc2e9fe2566f480c
[13/39] pinctrl: qcom: stub support for special GPIOs
        commit: a245aece2acfbbaf01f41c595f9bfb02a9aedb70
[14/39] pinctrl: qcom: fix DT compatibility
        commit: 97487ac76de85d22653b12c7561e6c007a3b4eb5
[15/39] pinctrl: qcom: apq8016: init pre-reloaction
        commit: 8048976e9c9943b28aec8b7e4d998e128b39fe70
[16/39] board: dragonboard410c: add chainloaded config fragment
        commit: e9302ba6cc6bfdf8a3dc4e9f232767b9bc0b217d
[17/39] board: dragonboard410c: upstream DT compat
        commit: c744e6308951d47f597e5dac450cab5555698246
[18/39] board: dragonboard410c: import board code from mach-snapdragon
        commit: 14868845db54b4f64701977385dc9a6e951e4139
[19/39] board: dragonboard820c: use LINUX_KERNEL_IMAGE_HEADER
        commit: 9d5e434eb24d1bc73c8eb881bee95949a798f150
[20/39] mach-snapdragon: generalise board support
        commit: 059d526af3123935c1fb525d12953d570d392f7c
[21/39] mach-snapdragon: dynamic load addresses
        commit: a2364d97ffaef6b708b0e7098c5cb5de98f5b6e1
[22/39] mach-snapdragon: generate fdtfile automatically
        commit: 2bdc48f7fdcf412d9a67c07673bf7e7202628186
[23/39] mach-snapdragon: carve out no-map regions
        commit: c6f4985a04f50dead54fee43745fca87107bace7
[24/39] board: qcs404-evb: drop board code
        commit: 90744c1a14c54d08c9981869dec9262289da2d6b
[25/39] doc: board/qualcomm: document generic targets
        commit: d9252fcde1218902ed4805acd951da0405ba7d1b
[26/39] doc: board/qualcomm: link to APQ8016 TRM
        commit: d795efef8361e6406c08fd1551e1f1d98b1751ff
[27/39] dt-bindings: import headers for SDM845
        commit: c0297b30f1b576180c95dbc44b7647f20f3a4bd1
[28/39] dts: sdm845: import supporting dtsi files
        commit: e59755b0d688d0b5ff63b5034a1722d6c4c8ece7
[29/39] dts: sdm845: replace with upstream DTS
        commit: 99870a4c412b41893014eeb2d7ce8ba74d7b7d1a
[30/39] dt-bindings: import headers for MSM8916
        commit: 8a09bdceae5f1d295ced5feb19db3b883ed2dfd7
[31/39] dts: msm8916: import PMIC dtsi files
        commit: 89a013dbe8b5eca8f29c029bd60e7ca0c5f14da3
[32/39] dts: msm8916: replace with upstream DTS
        commit: ed8fbd2889fc072b12fe2437ac92e83676c93728
[33/39] dt-bindings: import headers for MSM8996
        commit: 7d5e9976f25149cace7fd9d6ebaf8b7b87dbf66f
[34/39] dts: msm8996: import PMIC dtsi files
        commit: 0d80f44c644aed766cc26fbb201e1c1a38bca924
[35/39] dts: dragonboard820c: use correct bindings for clocks
        commit: 5566bb447647bc155d06fad852db4ba3006d9329
[36/39] dts: msm8996: replace with upstream DTS
        commit: 93441fc3b527a3e5c60d687dc4cb01df03221759
[37/39] dt-bindings: import headers for qcs404
        commit: 4745c4d76cd463129d5f4a82ea4e4bbcc32dfd21
[38/39] dts: qcs404-evb: replace with upstream DT
        commit: 890207c6517d0d6dbd63d503c1fa8180c6022b98
[39/39] MAINTAINERS: Qualcomm: add some missing paths
        commit: f70ab46df3c2768002fdfc0fca9652af732cd619

Best regards,