mach-snapdragon: generalise board support

Historically, Qualcomm boards have relied on heavy hardcoding in U-Boot,
in many cases to the specific SoC but also to the board itself (e.g.
memory map). This has been largely resolved by modernising the Qualcomm
drivers in U-Boot, however the board code still largely follows this
model.

This patch removes the board specific memory maps and duplicated board
init code, replacing it with generic init code.

The memory map is now built at runtime based on data read from DT, this
allows for the memory map to be provided without having to recompile
U-Boot. Support is also added for booting with appended DTBs, so that
the first-stage bootloader can populate the memory map for us.

The sdm845 specific init code is dropped entirely, it set an environment
variable depending on if a button was pressed, but this variable wasn't
used in U-Boot, and could be written to use the button command instead.

The KASLR detection is also dropped as with appended dtb, the kaslr seed
can be read directly from the DTB passed to U-Boot.

A new qcom_defconfig is added, with the aim of providing a generic
U-Boot configuration that will work on as many Qualcomm boards as
possible. It replaces the defconfig files for the Dragonboard 845c,
Galaxy S9, and QCS404 EVB. For now the db410c and 820c are excluded as
they still have some board code left.

Similarly, the config headers for db845c, starqltechn, and qcs404-evb
are replaced by a single qcom header.

The previously db410c-specific board_usb_init() function is made to be
generic and is added to mach-snapdragon. While we lack proper modelling
for USB configuration, using a well-known named pinctrl state is a
reasonably generic middleground, and works using upstream DT. This
function will do nothing unless the USB node has a pinctrl state named
"device", in which case it will be set when entering USB peripheral
mode.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Tested-by: Sumit Garg <sumit.garg@linaro.org> #qcs404
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
diff --git a/arch/arm/mach-snapdragon/Kconfig b/arch/arm/mach-snapdragon/Kconfig
index f897c39..96e44e2 100644
--- a/arch/arm/mach-snapdragon/Kconfig
+++ b/arch/arm/mach-snapdragon/Kconfig
@@ -3,6 +3,9 @@
 config SYS_SOC
 	default "snapdragon"
 
+config SYS_VENDOR
+	default "qualcomm"
+
 config SYS_MALLOC_F_LEN
 	default 0x2000
 
@@ -12,91 +15,24 @@
 config SPL_SYS_MALLOC_F_LEN
 	default 0x2000
 
-config SDM845
-	bool "Qualcomm Snapdragon 845 SoC"
-	select LINUX_KERNEL_IMAGE_HEADER
-	imply CLK_QCOM_SDM845
-	imply PINCTRL_QCOM_SDM845
-	imply BUTTON_QCOM_PMIC
-
 config LNX_KRNL_IMG_TEXT_OFFSET_BASE
 	default 0x80000000
 
-choice
-	prompt "Snapdragon board select"
-
-config TARGET_DRAGONBOARD410C
-	bool "96Boards Dragonboard 410C"
-	select BOARD_LATE_INIT
-	select ENABLE_ARM_SOC_BOOT0_HOOK
-	imply CLK_QCOM_APQ8016
-	imply PINCTRL_QCOM_APQ8016
-	imply BUTTON_QCOM_PMIC
+config SYS_BOARD
+	string "Qualcomm custom board"
 	help
-	  Support for 96Boards Dragonboard 410C. This board complies with
-	  96Board Open Platform Specifications. Features:
-	  - Qualcomm Snapdragon 410C SoC - APQ8016 (4xCortex A53, Adreno 306)
-	  - 1GiB RAM
-	  - 8GiB eMMC, uSD slot
-	  - WiFi, Bluetooth and GPS module
-	  - 2x Host, 1x Device USB port
-	  - HDMI
-	  - 20-pin low speed and 40-pin high speed expanders, 4 LED, 3 buttons
+	  The Dragonboard 410c and 820c have additional board init
+	  code that isn't shared with other Qualcomm boards.
+	  Based on this option board/qualcomm/<CONFIG_SYS_BOARD> will
+	  be used.
 
-config TARGET_DRAGONBOARD820C
-	bool "96Boards Dragonboard 820C"
-	select LINUX_KERNEL_IMAGE_HEADER
-	imply CLK_QCOM_APQ8096
-	imply PINCTRL_QCOM_APQ8096
-	imply BUTTON_QCOM_PMIC
+config SYS_CONFIG_NAME
+	string "Board configuration name"
+	default SYS_BOARD if SYS_BOARD != ""
+	default "qcom"
 	help
-	  Support for 96Boards Dragonboard 820C. This board complies with
-	  96Board Open Platform Specifications. Features:
-	  - Qualcomm Snapdragon 820C SoC - APQ8096 (4xKyro CPU)
-	  - 3GiB RAM
-	  - 32GiB UFS drive
-
-config TARGET_DRAGONBOARD845C
-	bool "96Boards Dragonboard 845C"
-	help
-	  Support for 96Boards Dragonboard 845C aka Robotics RB3 Development
-	  Platform. This board complies with 96Boards Open Platform
-	  Specifications. Features:
-	  - Qualcomm Snapdragon SDA845 SoC
-	  - 4GiB RAM
-	  - 64GiB UFS drive
-	select MISC_INIT_R
-	select SDM845
-
-config TARGET_STARQLTECHN
-	bool "Samsung S9 SM-G9600(starqltechn)"
-	help
-	  Support for Samsung S9 SM-G9600(starqltechn) board.
-	  Features:
-	  - Qualcomm Snapdragon SDM845 SoC
-	  - 4GiB RAM
-	  - 64GiB UFS drive
-	select MISC_INIT_R
-	select SDM845
-
-config TARGET_QCS404EVB
-	bool "Qualcomm Technologies, Inc. QCS404 EVB"
-	select LINUX_KERNEL_IMAGE_HEADER
-	imply CLK_QCOM_QCS404
-	imply PINCTRL_QCOM_QCS404
-	help
-	  Support for Qualcomm Technologies, Inc. QCS404 evaluation board.
-	  Features:
-	  - Qualcomm Snapdragon QCS404 SoC
-	  - 1GiB RAM
-	  - 8GiB eMMC, uSD slot
-
-endchoice
-
-source "board/qualcomm/dragonboard410c/Kconfig"
-source "board/qualcomm/dragonboard820c/Kconfig"
-source "board/qualcomm/dragonboard845c/Kconfig"
-source "board/samsung/starqltechn/Kconfig"
-source "board/qualcomm/qcs404-evb/Kconfig"
+	  This option contains information about board configuration name.
+	  Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header
+	  will be used for board configuration.
 
 endif