Skip to contentSkip to conversation

Add support for SDM845 based boards, and SM-G9600

PATCH In review Dzmitry Sankouski 2 participants 13 messages Oct 17, 2021 – Oct 31, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add support for SDM845 based boards, and SM-G9600

Snapdragon 845 - hi-end qualcomm chip, introduced in late 2017. Mostly used in flagship phones and tablets of 2018. Features:
- arm64 arch
- total of 8 Kryo 385 Gold / Silver cores
- Hexagon 685 DSP
- Adreno 630 GPU

Tested only as second-stage bootloader.

Samsung S9 SM-G9600 - Snapdragon SDM845 version of the phone, for China \ Hong Kong markets.
Has unlockable bootloader, unlike SM-G960U (American market version), which allows running u-boot as a chain-loaded bootloader.

Dzmitry Sankouski (6):
serial: qcom: add support for GENI serial driver
spmi: msm: add arbiter version 5 support
pinctrl: qcom: add pinctrl and gpio drivers for SDM845 SoC
clocks: qcom: add clocks for SDM845 debug uart
SoC: qcom: add support for SDM845
board: samsung: add Samsung Galaxy S9/S9+(SM-G96x0) board

 MAINTAINERS                                   |   2 +
 arch/arm/dts/Makefile                         |   1 +
 arch/arm/dts/sdm845.dtsi                      | 118 ++++
 arch/arm/dts/starqltechn-uboot.dtsi           |  39 ++
 arch/arm/dts/starqltechn.dts                  |  53 ++
 arch/arm/mach-snapdragon/Kconfig              |  17 +
 arch/arm/mach-snapdragon/Makefile             |   4 +
 arch/arm/mach-snapdragon/clock-sdm845.c       |  92 +++
 arch/arm/mach-snapdragon/clock-snapdragon.c   |   1 +
 arch/arm/mach-snapdragon/clock-snapdragon.h   |   3 +-
 .../include/mach/sysmap-sdm845.h              |  42 ++
 arch/arm/mach-snapdragon/init_sdm845.c        |  82 +++
 arch/arm/mach-snapdragon/pinctrl-sdm845.c     |  44 ++
 arch/arm/mach-snapdragon/pinctrl-snapdragon.c |   1 +
 arch/arm/mach-snapdragon/pinctrl-snapdragon.h |   1 +
 arch/arm/mach-snapdragon/sysmap-sdm845.c      |  31 +
 board/samsung/starqltechn/Kconfig             |  14 +
 board/samsung/starqltechn/MAINTAINERS         |   6 +
 board/samsung/starqltechn/Makefile            |   9 +
 board/samsung/starqltechn/starqltechn.c       |  10 +
 configs/starqltechn_defconfig                 |  33 +
 doc/board/qualcomm/index.rst                  |   1 +
 doc/board/qualcomm/sdm845.rst                 |  38 ++
 .../serial/msm-geni-serial.txt                |   6 +
 drivers/gpio/msm_gpio.c                       |   1 +
 drivers/gpio/pm8916_gpio.c                    |   8 +-
 drivers/serial/Kconfig                        |  17 +
 drivers/serial/Makefile                       |   1 +
 drivers/serial/serial_msm_geni.c              | 602 ++++++++++++++++++
 drivers/spmi/spmi-msm.c                       | 156 +++--
 include/configs/sdm845.h                      |  33 +
 include/configs/starqltechn.h                 |  16 +
 32 files changed, 1428 insertions(+), 54 deletions(-)
 create mode 100644 arch/arm/dts/sdm845.dtsi
 create mode 100644 arch/arm/dts/starqltechn-uboot.dtsi
 create mode 100644 arch/arm/dts/starqltechn.dts
 create mode 100644 arch/arm/mach-snapdragon/clock-sdm845.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-sdm845.h
 create mode 100644 arch/arm/mach-snapdragon/init_sdm845.c
 create mode 100644 arch/arm/mach-snapdragon/pinctrl-sdm845.c
 create mode 100644 arch/arm/mach-snapdragon/sysmap-sdm845.c
 create mode 100644 board/samsung/starqltechn/Kconfig
 create mode 100644 board/samsung/starqltechn/MAINTAINERS
 create mode 100644 board/samsung/starqltechn/Makefile
 create mode 100644 board/samsung/starqltechn/starqltechn.c
 create mode 100644 configs/starqltechn_defconfig
 create mode 100644 doc/board/qualcomm/sdm845.rst
 create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
 create mode 100644 drivers/serial/serial_msm_geni.c
 create mode 100644 include/configs/sdm845.h
 create mode 100644 include/configs/starqltechn.h
Signature · 1 line
2.20.1
#1 lore raw

PATCH v5 1/6 serial: qcom: add support for GENI serial driver

Generic Interface (GENI) Serial Engine (SE) based uart can be found on newer qualcomm SOCs, starting from SDM845. Tested on Samsung SM-G9600(starqltechn)
by chain-loading u-boot with stock bootloader.

---
Changes for v2:
- change functions return type to void, where possible
- remove '.' from summary line
Changes for v3:
- move function open brace on new line
- use tab between define name and value
- define: wrap expression with braces, remove braces from constants Changes for v4:
- add linux/delay.h header
Changes for v5:
- Kconfig: break long lines
- rearrange definitions
- add docs to functions
- add docs on cfg0 variable (packing configuration info)
- get_clk_div_rate, get_clk_cfg: use mainline linux function instead of starqltechn downstream version
- use setbits_le32
- extract qcom_geni_serial_abort_rx function
- remove explicit pinctrl setup
- make an unconditional cancel at serial init
- calculate CLK_DIV on host machine with #define, when debug enabled. throw error, if we cannot get target baudrate with CONFIG_DEBUG_UART_CLOCK value. This is because we cannot adjust clocks at early debug.

 MAINTAINERS                                   |   1 +
 .../serial/msm-geni-serial.txt                |   6 +
 drivers/serial/Kconfig                        |  18 +
 drivers/serial/Makefile                       |   1 +
 drivers/serial/serial_msm_geni.c              | 613 ++++++++++++++++++
 5 files changed, 639 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
 create mode 100644 drivers/serial/serial_msm_geni.c
MAINTAINERS +1 -0
index 776ff703b9..52ddc99cda 100644
@@ -390,6 +390,7 @@ F:	drivers/gpio/msm_gpio.c
 F:	drivers/mmc/msm_sdhci.c
 F:	drivers/phy/msm8916-usbh-phy.c
 F:	drivers/serial/serial_msm.c
+F:	drivers/serial/serial_msm_geni.c
 F:	drivers/smem/msm_smem.c
 F:	drivers/usb/host/ehci-msm.c
 
doc/device-tree-bindings/serial/msm-geni-serial.txt new file +6 -0
new file mode 100644
index 0000000000..9eadc2561b
@@ -0,0 +1,6 @@
+Qualcomm GENI UART
+
+Required properties:
+- compatible: must be "qcom,msm-geni-uart"
+- reg: start address and size of the registers
+- clock: interface clock (must accept baudrate as a frequency)
drivers/serial/Kconfig +18 -0
index 93348c0929..5d9d4b46f2 100644
@@ -278,6 +278,14 @@ config DEBUG_UART_S5P
 	  will need to provide parameters to make this work. The driver will
 	  be available until the real driver-model serial is running.
 
+config DEBUG_UART_MSM_GENI
+	bool "Qualcomm snapdragon"
+	depends on ARCH_SNAPDRAGON
+	help
+	  Select this to enable a debug UART using the serial_msm driver. You
+	  will need to provide parameters to make this work. The driver will
+	  be available until the real driver-model serial is running.
+
 config DEBUG_UART_MESON
 	bool "Amlogic Meson"
 	depends on MESON_SERIAL
@@ -783,6 +791,16 @@ config MSM_SERIAL
 	  for example APQ8016 and MSM8916.
 	  Single baudrate is supported in current implementation (115200).
 
+config MSM_GENI_SERIAL
+	bool "Qualcomm on-chip GENI UART"
+	help
+	  Support UART based on Generic Interface (GENI) Serial Engine (SE),
+	  used on Qualcomm Snapdragon SoCs. Should support all qualcomm SOCs
+	  with Qualcomm Universal Peripheral (QUP) Wrapper cores,
+	  i.e. newer ones, starting from SDM845.
+	  Driver works in FIFO mode.
+	  Multiple baudrates supported.
+
 config OCTEON_SERIAL_BOOTCMD
 	bool "MIPS Octeon PCI remote bootcmd input"
 	depends on ARCH_OCTEON
drivers/serial/Makefile +1 -0
index 3cbea8156f..d44caf4ea2 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_PIC32_SERIAL) += serial_pic32.o
 obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
 obj-$(CONFIG_BCM283X_PL011_SERIAL) += serial_bcm283x_pl011.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
+obj-$(CONFIG_MSM_GENI_SERIAL) += serial_msm_geni.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
 obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
drivers/serial/serial_msm_geni.c new file +613 -0

613 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw

PATCH 4/6 clocks: qcom: add clocks for SDM845 debug uart

In reply to Dzmitry Sankouski

Allows to change clock frequency of debug uart,
thus supporting wide range of baudrates.
Enable / disable functionality is not implemented yet. In most use cases of SDM845 (i.e. mobile phones and tablets) it's not needed, because qualcomm first stage bootloader leaves it initialized, and on the other hand there's no possibility to replace signed first stage bootloader with u-boot.

---
 arch/arm/mach-snapdragon/clock-sdm845.c     | 92 +++++++++++++++++++++
 arch/arm/mach-snapdragon/clock-snapdragon.c |  1 +
 arch/arm/mach-snapdragon/clock-snapdragon.h |  3 +-
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-snapdragon/clock-sdm845.c
arch/arm/mach-snapdragon/clock-sdm845.c new file +92 -0
new file mode 100644
index 0000000000..9572639238
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Clock drivers for Qualcomm SDM845
+ *
+ * (C) Copyright 2017 Jorge Ramirez Ortiz <[email protected]>
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ *
+ * Based on Little Kernel driver, simplified
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+#include "clock-snapdragon.h"
+
+#define F(f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
+
+struct freq_tbl {
+	uint freq;
+	uint src;
+	u8 pre_div;
+	u16 m;
+	u16 n;
+};
+
+static const struct freq_tbl ftbl_gcc_qupv3_wrap0_s0_clk_src[] = {
+	F(7372800, CFG_CLK_SRC_GPLL0_EVEN, 1, 384, 15625),
+	F(14745600, CFG_CLK_SRC_GPLL0_EVEN, 1, 768, 15625),
+	F(19200000, CFG_CLK_SRC_CXO, 1, 0, 0),
+	F(29491200, CFG_CLK_SRC_GPLL0_EVEN, 1, 1536, 15625),
+	F(32000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 75),
+	F(48000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 25),
+	F(64000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 16, 75),
+	F(80000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 4, 15),
+	F(96000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 8, 25),
+	F(100000000, CFG_CLK_SRC_GPLL0_EVEN, 3, 0, 0),
+	F(102400000, CFG_CLK_SRC_GPLL0_EVEN, 1, 128, 375),
+	F(112000000, CFG_CLK_SRC_GPLL0_EVEN, 1, 28, 75),
+	F(117964800, CFG_CLK_SRC_GPLL0_EVEN, 1, 6144, 15625),
+	F(120000000, CFG_CLK_SRC_GPLL0_EVEN, 2.5, 0, 0),
+	F(128000000, CFG_CLK_SRC_GPLL0, 1, 16, 75),
+	{ }
+};
+
+static const struct bcr_regs uart2_regs = {
+	.cfg_rcgr = SE9_UART_APPS_CFG_RCGR,
+	.cmd_rcgr = SE9_UART_APPS_CMD_RCGR,
+	.M = SE9_UART_APPS_M,
+	.N = SE9_UART_APPS_N,
+	.D = SE9_UART_APPS_D,
+};
+
+const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, uint rate)
+{
+	if (!f)
+		return NULL;
+
+	if (!f->freq)
+		return f;
+
+	for (; f->freq; f++)
+		if (rate <= f->freq)
+			return f;
+
+	/* Default to our fastest rate */
+	return f - 1;
+}
+
+static int clk_init_uart(struct msm_clk_priv *priv, uint rate)
+{
+	const struct freq_tbl *freq = qcom_find_freq(ftbl_gcc_qupv3_wrap0_s0_clk_src, rate);
+
+	clk_rcg_set_rate_mnd(priv->base, &uart2_regs,
+						freq->pre_div, freq->m, freq->n, freq->src);
+
+	return 0;
+}
+
+ulong msm_set_rate(struct clk *clk, ulong rate)
+{
+	struct msm_clk_priv *priv = dev_get_priv(clk->dev);
+
+	switch (clk->id) {
+	case 0x58: /*UART2*/
+		return clk_init_uart(priv, rate);
+	default:
+		return 0;
+	}
+}
arch/arm/mach-snapdragon/clock-snapdragon.c +1 -0
index 2b76371718..3deb08ac4a 100644
@@ -135,6 +135,7 @@ static const struct udevice_id msm_clk_ids[] = {
 	{ .compatible = "qcom,gcc-apq8016" },
 	{ .compatible = "qcom,gcc-msm8996" },
 	{ .compatible = "qcom,gcc-apq8096" },
+	{ .compatible = "qcom,gcc-sdm845" },
 	{ }
 };
 
arch/arm/mach-snapdragon/clock-snapdragon.h +2 -1
index 58fab40a2e..2ac53b538d 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Qualcomm APQ8016, APQ8096
+ * Qualcomm APQ8016, APQ8096, SDM845
  *
  * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  */
@@ -9,6 +9,7 @@
 
 #define CFG_CLK_SRC_CXO   (0 << 8)
 #define CFG_CLK_SRC_GPLL0 (1 << 8)
+#define CFG_CLK_SRC_GPLL0_EVEN (6 << 8)
 #define CFG_CLK_SRC_MASK  (7 << 8)
 
 struct pll_vote_clk {
Signature · 1 line
2.20.1
#5 lore raw

PATCH v4 2/6 spmi: msm: add arbiter version 5 support

In reply to Dzmitry Sankouski

Currently driver supports only version 1 and 2. Version 5 has slightly different registers structure

---
Changes for v2:
- change string formats in debug statements Changes for v3:
- remove if else braces where possible Changes for v4:
- change variable type to fix pointer cast warning

 MAINTAINERS             |   1 +
 drivers/spmi/spmi-msm.c | 154 +++++++++++++++++++++++++++-------------
 2 files changed, 105 insertions(+), 50 deletions(-)
MAINTAINERS +1 -0
index 52ddc99cda..6b8b0783d2 100644
@@ -392,6 +392,7 @@ F:	drivers/phy/msm8916-usbh-phy.c
 F:	drivers/serial/serial_msm.c
 F:	drivers/serial/serial_msm_geni.c
 F:	drivers/smem/msm_smem.c
+F:	drivers/spmi/spmi-msm.c
 F:	drivers/usb/host/ehci-msm.c
 
 ARM STI
drivers/spmi/spmi-msm.c +104 -50

234 lines not on this page · raw message

Signature · 1 line
2.20.1
#7 lore raw

PATCH v2 3/6 pinctrl: qcom: add pinctrl and gpio drivers for SDM845 SoC

In reply to Dzmitry Sankouski
Cc Ramon Fried <[email protected]>
Cc Tom Rini <[email protected]>
Cc Stephan Gerhold <[email protected]>

---
Changes for v2:
- Add __section(".data") for pin_name variable.

 arch/arm/mach-snapdragon/pinctrl-sdm845.c     | 44 +++++++++++++++++++
 arch/arm/mach-snapdragon/pinctrl-snapdragon.c |  1 +
 arch/arm/mach-snapdragon/pinctrl-snapdragon.h |  1 +
 drivers/gpio/msm_gpio.c                       |  1 +
 drivers/gpio/pm8916_gpio.c                    |  8 ++--
 5 files changed, 52 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-snapdragon/pinctrl-sdm845.c
arch/arm/mach-snapdragon/pinctrl-sdm845.c new file +44 -0
new file mode 100644
index 0000000000..40f2f012fa
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm SDM845 pinctrl
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ *
+ */
+
+#include "pinctrl-snapdragon.h"
+#include <common.h>
+
+#define MAX_PIN_NAME_LEN 32
+static char pin_name[MAX_PIN_NAME_LEN] __section(".data");
+
+static const struct pinctrl_function msm_pinctrl_functions[] = {
+	{"qup9", 1},
+	{"gpio", 0},
+};
+
+static const char *sdm845_get_function_name(struct udevice *dev,
+					     unsigned int selector)
+{
+	return msm_pinctrl_functions[selector].name;
+}
+
+static const char *sdm845_get_pin_name(struct udevice *dev,
+					unsigned int selector)
+{
+	snprintf(pin_name, MAX_PIN_NAME_LEN, "GPIO_%u", selector);
+	return pin_name;
+}
+
+static unsigned int sdm845_get_function_mux(unsigned int selector)
+{
+	return msm_pinctrl_functions[selector].val;
+}
+
+struct msm_pinctrl_data sdm845_data = {
+	.pin_count = 150,
+	.functions_count = ARRAY_SIZE(msm_pinctrl_functions),
+	.get_function_name = sdm845_get_function_name,
+	.get_function_mux = sdm845_get_function_mux,
+	.get_pin_name = sdm845_get_pin_name,
+};
arch/arm/mach-snapdragon/pinctrl-snapdragon.c +1 -0
index e6b87c3573..c0ed943036 100644
@@ -116,6 +116,7 @@ static struct pinctrl_ops msm_pinctrl_ops = {
 static const struct udevice_id msm_pinctrl_ids[] = {
 	{ .compatible = "qcom,tlmm-apq8016", .data = (ulong)&apq8016_data },
 	{ .compatible = "qcom,tlmm-apq8096", .data = (ulong)&apq8096_data },
+	{ .compatible = "qcom,tlmm-sdm845", .data = (ulong)&sdm845_data },
 	{ }
 };
 
arch/arm/mach-snapdragon/pinctrl-snapdragon.h +1 -0
index 61d466f4d8..ea524312a0 100644
@@ -27,5 +27,6 @@ struct pinctrl_function {
 
 extern struct msm_pinctrl_data apq8016_data;
 extern struct msm_pinctrl_data apq8096_data;
+extern struct msm_pinctrl_data sdm845_data;
 
 #endif
drivers/gpio/msm_gpio.c +1 -0
index e1ff84c1c0..a3c3cd7824 100644
@@ -120,6 +120,7 @@ static const struct udevice_id msm_gpio_ids[] = {
 	{ .compatible = "qcom,msm8916-pinctrl" },
 	{ .compatible = "qcom,apq8016-pinctrl" },
 	{ .compatible = "qcom,ipq4019-pinctrl" },
+	{ .compatible = "qcom,sdm845-pinctrl" },
 	{ }
 };
 
drivers/gpio/pm8916_gpio.c +5 -3
index 40b0f2578b..7ad95784a8 100644
@@ -202,6 +202,7 @@ static int pm8916_gpio_of_to_plat(struct udevice *dev)
 static const struct udevice_id pm8916_gpio_ids[] = {
 	{ .compatible = "qcom,pm8916-gpio" },
 	{ .compatible = "qcom,pm8994-gpio" },	/* 22 GPIO's */
+	{ .compatible = "qcom,pm8998-gpio" },
 	{ }
 };
 
@@ -266,7 +267,7 @@ static int pm8941_pwrkey_probe(struct udevice *dev)
 		return log_msg_ret("bad type", -ENXIO);
 
 	reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
-	if (reg != 0x1)
+	if ((reg & 0x5) == 0)
 		return log_msg_ret("bad subtype", -ENXIO);
 
 	return 0;
@@ -287,11 +288,12 @@ static int pm8941_pwrkey_of_to_plat(struct udevice *dev)
 static const struct udevice_id pm8941_pwrkey_ids[] = {
 	{ .compatible = "qcom,pm8916-pwrkey" },
 	{ .compatible = "qcom,pm8994-pwrkey" },
+	{ .compatible = "qcom,pm8998-pwrkey" },
 	{ }
 };
 
-U_BOOT_DRIVER(pwrkey_pm8941) = {
-	.name	= "pwrkey_pm8916",
+U_BOOT_DRIVER(pwrkey_pm89xx) = {
+	.name	= "pwrkey_pm89xx",
 	.id	= UCLASS_GPIO,
 	.of_match = pm8941_pwrkey_ids,
 	.of_to_plat = pm8941_pwrkey_of_to_plat,
Signature · 1 line
2.20.1
#9 lore raw

PATCH v2 5/6 SoC: qcom: add support for SDM845

In reply to Dzmitry Sankouski

Hi-end qualcomm chip, introduced in late 2017. Mostly used in flagship phones and tablets of 2018. Features:
- arm64 arch
- total of 8 Kryo 385 Gold / Silver cores
- Hexagon 685 DSP
- Adreno 630 GPU

Tested only as second-stage bootloader.

Cc Ramon Fried <[email protected]>
Cc Tom Rini <[email protected]>
Cc Stephan Gerhold <[email protected]>

---
Changes for v2:
- refactor sdm845.dtsi.

 arch/arm/dts/sdm845.dtsi                      | 116 ++++++++++++++++++
 arch/arm/mach-snapdragon/Kconfig              |   4 +
 arch/arm/mach-snapdragon/Makefile             |   4 +
 .../include/mach/sysmap-sdm845.h              |  42 +++++++
 arch/arm/mach-snapdragon/init_sdm845.c        |  82 +++++++++++++
 arch/arm/mach-snapdragon/sysmap-sdm845.c      |  31 +++++
 include/configs/sdm845.h                      |  33 +++++
 7 files changed, 312 insertions(+)
 create mode 100644 arch/arm/dts/sdm845.dtsi
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-sdm845.h
 create mode 100644 arch/arm/mach-snapdragon/init_sdm845.c
 create mode 100644 arch/arm/mach-snapdragon/sysmap-sdm845.c
 create mode 100644 include/configs/sdm845.h
arch/arm/dts/sdm845.dtsi new file +116 -0
new file mode 100644
index 0000000000..1185b71216
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm SDM845 chip device tree source
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ *
+ */
+
+/dts-v1/;
+
+#include "skeleton64.dtsi"
+
+/ {
+	soc: soc {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0 0 0 0xffffffff>;
+		compatible = "simple-bus";
+
+		gcc: clock-controller@100000 {
+			u-boot,dm-pre-reloc;
+			compatible = "qcom,gcc-sdm845";
+			reg = <0x100000 0x1f0000>;
+			#clock-cells = <1>;
+			#reset-cells = <1>;
+			#power-domain-cells = <1>;
+		};
+
+		gpio_north: gpio_north@3900000 {
+			u-boot,dm-pre-reloc;
+			#gpio-cells = <2>;
+			compatible = "qcom,sdm845-pinctrl";
+			reg = <0x3900000 0x400000>;
+			gpio-count = <150>;
+			gpio-controller;
+			gpio-ranges = <&gpio_north 0 0 150>;
+			gpio-bank-name = "soc_north.";
+		};
+
+		tlmm_north: pinctrl_north@3900000 {
+			u-boot,dm-pre-reloc;
+			compatible = "qcom,tlmm-sdm845";
+			reg = <0x3900000 0x400000>;
+			gpio-count = <150>;
+			gpio-controller;
+			#gpio-cells = <2>;
+			gpio-ranges = <&tlmm_north 0 0 150>;
+
+			/* DEBUG UART */
+			qup_uart9: qup-uart9-default {
+				pinmux {
+					pins = "GPIO_4", "GPIO_5";
+					function = "qup9";
+				};
+			};
+		};
+
+		debug_uart: serial@a84000 {
+			compatible = "qcom,msm-geni-uart";
+			reg = <0xa84000 0x4000>;
+			reg-names = "se_phys";
+			clock-names = "se-clk";
+			clocks = <&gcc 0x58>;
+			pinctrl-names = "default";
+			pinctrl-0 = <&qup_uart9>;
+			qcom,wrapper-core = <0x8a>;
+			status = "disabled";
+		};
+
+		spmi@c440000 {
+			compatible = "qcom,spmi-pmic-arb";
+			reg = <0xc440000 0x1100>,
+			      <0xc600000 0x2000000>,
+			      <0xe600000 0x100000>;
+			reg-names = "cnfg", "core", "obsrvr";
+			#address-cells = <0x1>;
+			#size-cells = <0x1>;
+
+			qcom,revid@100 {
+				compatible = "qcom,qpnp-revid";
+				reg = <0x100 0x100>;
+			};
+
+			pmic0: pm8998@0 {
+				compatible = "qcom,spmi-pmic";
+				reg = <0x0 0x1>;
+				#address-cells = <0x1>;
+				#size-cells = <0x1>;
+
+				pm8998_pon: pm8998_pon@800 {
+					compatible = "qcom,pm8998-pwrkey";
+					reg = <0x800 0x100>;
+					#gpio-cells = <2>;
+					gpio-controller;
+					gpio-bank-name = "pm8998_key.";
+				};
+
+				pm8998_gpios: pm8998_gpios@c000 {
+					compatible = "qcom,pm8998-gpio";
+					reg = <0xc000 0x1a00>;
+					gpio-controller;
+					gpio-count = <21>;
+					#gpio-cells = <2>;
+					gpio-bank-name = "pm8998.";
+				};
+			};
+
+			pmic1: pm8998@1 {
+				compatible = "qcom,spmi-pmic";
+				reg = <0x1 0x0>;
+				#address-cells = <0x2>;
+				#size-cells = <0x0>;
+			};
+		};
+	};
+};
arch/arm/mach-snapdragon/Kconfig +4 -0
index 0ec74fa5d3..1a6a608967 100644
@@ -9,6 +9,10 @@ config SYS_MALLOC_F_LEN
 config SPL_SYS_MALLOC_F_LEN
 	default 0x2000
 
+config SDM845
+	bool "Qualcomm Snapdragon 845 SoC"
+	default n
+
 choice
 	prompt "Snapdragon board select"
 
arch/arm/mach-snapdragon/Makefile +4 -0
index 709919fce4..962855eb8c 100644
@@ -2,6 +2,9 @@
 #
 # (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
 
+obj-$(CONFIG_SDM845) += clock-sdm845.o
+obj-$(CONFIG_SDM845) += sysmap-sdm845.o
+obj-$(CONFIG_SDM845) += init_sdm845.o
 obj-$(CONFIG_TARGET_DRAGONBOARD820C) += clock-apq8096.o
 obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
 obj-$(CONFIG_TARGET_DRAGONBOARD410C) += clock-apq8016.o
@@ -12,3 +15,4 @@ obj-y += dram.o
 obj-y += pinctrl-snapdragon.o
 obj-y += pinctrl-apq8016.o
 obj-y += pinctrl-apq8096.o
+obj-$(CONFIG_SDM845) += pinctrl-sdm845.o
arch/arm/mach-snapdragon/include/mach/sysmap-sdm845.h new file +42 -0

42 lines not on this page · raw message

arch/arm/mach-snapdragon/init_sdm845.c new file +82 -0

82 lines not on this page · raw message

arch/arm/mach-snapdragon/sysmap-sdm845.c new file +31 -0
new file mode 100644
index 0000000000..721ac41166
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm SDM845 memory map
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ */
+
+#include <common.h>
+#include <asm/armv8/mmu.h>
+
+static struct mm_region sdm845_mem_map[] = {
+	{
+		.virt = 0x0UL, /* Peripheral block */
+		.phys = 0x0UL, /* Peripheral block */
+		.size = 0x10000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		.virt = 0x80000000UL, /* DDR */
+		.phys = 0x80000000UL, /* DDR */
+		.size = 0x200000000UL, /* 8GiB - maximum allowed memory */
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_INNER_SHARE
+	}, {
+		/* List terminator */
+		0,
+	}
+};
+
+struct mm_region *mem_map = sdm845_mem_map;
include/configs/sdm845.h new file +33 -0
new file mode 100644
index 0000000000..c77d0acac6
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration file for boards, based on Qualcomm SDM845 chip
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ */
+
+#ifndef __CONFIGS_SDM845_H
+#define __CONFIGS_SDM845_H
+
+#include <linux/sizes.h>
+#include <asm/arch/sysmap-sdm845.h>
+
+#define CONFIG_SYS_LOAD_ADDR	0x80000000
+#define CONFIG_SYS_BAUDRATE_TABLE	{ 115200, 230400, 460800, 921600 }
+
+/* Generic Timer Definitions */
+#define COUNTER_FREQUENCY	19000000
+
+#define EXTRA_ENV_SETTINGS \
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x80000000\0"
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN   (CONFIG_ENV_SIZE + SZ_8M)
+#define CONFIG_SYS_BOOTM_LEN	SZ_64M
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE	512
+#define CONFIG_SYS_MAXARGS	64
+
+#endif
Signature · 1 line
2.20.1
#11 lore raw

PATCH v4 6/6 board: samsung: add Samsung Galaxy S9/S9+(SM-G96x0) board

In reply to Dzmitry Sankouski

Samsung S9 SM-G9600 - Snapdragon SDM845 version of the phone, for China \ Hong Kong markets.
Has unlockable bootloader, unlike SM-G960U (American market version), which allows running u-boot as a chain-loaded bootloader.

---
Changes for v2:
- Create documentation file for SDM845 boards
- Add starqltechn board documentation Changes for v3:
- fix comment in starqltechn.c
Changes for v4:
- move configs to Kconfig file
- remove starqltechn.h file
- set SYS_CONFIG_NAME to default of sdm845
- remove unneeded options from starqltechn_defconfig

 arch/arm/dts/Makefile                   |  1 +
 arch/arm/dts/starqltechn-uboot.dtsi     | 39 ++++++++++++++++++
 arch/arm/dts/starqltechn.dts            | 53 +++++++++++++++++++++++++
 arch/arm/mach-snapdragon/Kconfig        | 17 ++++++++
 board/samsung/starqltechn/Kconfig       | 22 ++++++++++
 board/samsung/starqltechn/MAINTAINERS   |  6 +++
 board/samsung/starqltechn/Makefile      |  9 +++++
 board/samsung/starqltechn/starqltechn.c | 10 +++++
 configs/starqltechn_defconfig           | 30 ++++++++++++++
 doc/board/qualcomm/index.rst            |  1 +
 doc/board/qualcomm/sdm845.rst           | 38 ++++++++++++++++++
 11 files changed, 226 insertions(+)
 create mode 100644 arch/arm/dts/starqltechn-uboot.dtsi
 create mode 100644 arch/arm/dts/starqltechn.dts
 create mode 100644 board/samsung/starqltechn/Kconfig
 create mode 100644 board/samsung/starqltechn/MAINTAINERS
 create mode 100644 board/samsung/starqltechn/Makefile
 create mode 100644 board/samsung/starqltechn/starqltechn.c
 create mode 100644 configs/starqltechn_defconfig
 create mode 100644 doc/board/qualcomm/sdm845.rst
arch/arm/dts/Makefile +1 -0
index 82a0790cc0..90d922dab7 100644
@@ -467,6 +467,7 @@ dtb-$(CONFIG_TARGET_SL28) += fsl-ls1028a-kontron-sl28.dtb \
 
 dtb-$(CONFIG_TARGET_DRAGONBOARD410C) += dragonboard410c.dtb
 dtb-$(CONFIG_TARGET_DRAGONBOARD820C) += dragonboard820c.dtb
+dtb-$(CONFIG_TARGET_STARQLTECHN) += starqltechn.dtb
 
 dtb-$(CONFIG_TARGET_STEMMY) += ste-ux500-samsung-stemmy.dtb
 
arch/arm/dts/starqltechn-uboot.dtsi new file +39 -0
new file mode 100644
index 0000000000..d8d75e018a
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * U-Boot addition to handle Samsung S9 SM-G9600 (starqltechn) pins
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ *
+ */
+
+/
+{
+	soc {
+		u-boot,dm-pre-reloc;
+		gcc {
+			clock-controller@100000 {
+				u-boot,dm-pre-reloc;
+			};
+			serial@0xa84000 {
+				u-boot,dm-pre-reloc;
+			};
+			gpio_north@3900000 {
+				u-boot,dm-pre-reloc;
+			};
+			pinctrl@3900000 {
+				u-boot,dm-pre-reloc;
+			};
+		};
+	};
+};
+
+&pm8998_pon {
+	key_vol_down {
+		gpios = <&pm8998_pon 1 0>;
+		label = "key_vol_down";
+	};
+	key_power {
+		gpios = <&pm8998_pon 0 0>;
+		label = "key_power";
+	};
+};
arch/arm/dts/starqltechn.dts new file +53 -0

53 lines not on this page · raw message

arch/arm/mach-snapdragon/Kconfig +17 -0
index 1a6a608967..12cf02a56a 100644
@@ -12,6 +12,10 @@ config SPL_SYS_MALLOC_F_LEN
 config SDM845
 	bool "Qualcomm Snapdragon 845 SoC"
 	default n
+	select LINUX_KERNEL_IMAGE_HEADER
+
+config LNX_KRNL_IMG_TEXT_OFFSET_BASE
+	default 0x80000000
 
 choice
 	prompt "Snapdragon board select"
@@ -40,9 +44,22 @@ config TARGET_DRAGONBOARD820C
 	  - 3GiB RAM
 	  - 32GiB UFS drive
 
+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
+	select DM_ETH if NET
+
 endchoice
 
 source "board/qualcomm/dragonboard410c/Kconfig"
 source "board/qualcomm/dragonboard820c/Kconfig"
+source "board/samsung/starqltechn/Kconfig"
 
 endif
board/samsung/starqltechn/Kconfig new file +22 -0
new file mode 100644
index 0000000000..0eea666d03
@@ -0,0 +1,22 @@
+if TARGET_STARQLTECHN
+
+config SYS_BOARD
+	default "starqltechn"
+	help
+	  starqltechn is a production board for S9 and S9+ phones(SM-G96x0) phones based on SDM845 SoC.
+
+config SYS_CONFIG_NAME
+	string "Board configuration name"
+	default "sdm845"
+	help
+	  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.
+
+config SYS_VENDOR
+	default "samsung"
+
+config SYS_CONFIG_NAME
+	default "starqltechn"
+
+endif
board/samsung/starqltechn/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..135cafdd69
@@ -0,0 +1,6 @@
+Samsung S9 (SM-G9600)(starqltechn)  Board
+M:	Dzmitry Sankouski <[email protected]>
+S:	Maintained
+F:	board/samsung/starqltechn/
+F:	include/configs/starqltechn.h
+F:	configs/starqltechn_defconfig
board/samsung/starqltechn/Makefile new file +9 -0
new file mode 100644
index 0000000000..c38c0b4710
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+#
+# This empty file prevents make error.
+# Board logic defined in board/qualcomm/common/sdm845.c, no custom logic for starqltechn so far.
+#
+
+obj-y += starqltechn.o
board/samsung/starqltechn/starqltechn.c new file +10 -0
new file mode 100644
index 0000000000..f2cdb4eec2
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * This empty file prevents make linking error.
+ * No custom logic for starqltechn so far.
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski <[email protected]>
+ *
+ */
+
+void nooop(void) {}
configs/starqltechn_defconfig new file +30 -0
new file mode 100644
index 0000000000..438a6c2f05
@@ -0,0 +1,30 @@
+CONFIG_TARGET_STARQLTECHN=y
+CONFIG_ARM=y
+CONFIG_ARM_SMCCC=y
+CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_IDENT_STRING="\nSamsung S9 SM-G9600"
+CONFIG_DEFAULT_DEVICE_TREE="starqltechn"
+CONFIG_SYS_TEXT_BASE=0x80000000
+CONFIG_POSITION_INDEPENDENT=y
+CONFIG_BOARD_EARLY_INIT_F=n
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_DISPLAY_CPUINFO=n
+CONFIG_HUSH_PARSER=y
+CONFIG_OF_CONTROL=y
+CONFIG_DM_STDIO=n
+CONFIG_MSM_GPIO=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PM8916=y
+CONFIG_PM8916_GPIO=y
+CONFIG_SPMI_MSM=y
+CONFIG_CLK=y
+CONFIG_NET=n
+CONFIG_USE_PREBOOT=y
+CONFIG_CMD_GPIO=y
+CONFIG_PINCTRL=y
+CONFIG_MSM_GENI_SERIAL=y
+# CONFIG_DEBUG_UART=y
+# CONFIG_DEBUG_UART_MSM_GENI=y
+# CONFIG_DEBUG_UART_BASE=0xa84000
+# CONFIG_DEBUG_UART_CLOCK=7372800
+# CONFIG_DEBUG_UART_ANNOUNCE=y
doc/board/qualcomm/index.rst +1 -0
index f7e0aa9298..10b98214e9 100644
@@ -7,3 +7,4 @@ Qualcomm
    :maxdepth: 2
 
    dragonboard410c
+   sdm845
doc/board/qualcomm/sdm845.rst new file +38 -0
new file mode 100644
index 0000000000..cd46cbe9cf
@@ -0,0 +1,38 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. sectionauthor:: Dzmitry Sankouski <[email protected]>
+
+Snapdragon 845
+================
+
+About this
+----------
+This document describes the information about Qualcomm Snapdragon 845
+supported boards and it's usage steps.
+
+SDM845 - hi-end qualcomm chip, introduced in late 2017.
+Mostly used in flagship phones and tablets of 2018.
+
+U-Boot can be used as a replacement for Qualcomm's original ABL (UEFI) bootloader.
+It is loaded as an Android boot image through ABL
+
+Installation
+------------
+First, setup ``CROSS_COMPILE`` for aarch64. Then, build U-Boot for your board::
+
+	$ export CROSS_COMPILE=<aarch64 toolchain prefix>
+	$ make <your board name here, see Boards section>_defconfig
+	$ make
+
+This will build ``u-boot.bin`` in the configured output directory.
+
+Boards
+------------
+starqlte
+^^^^^^^^^^^^
+
+The starqltechn is a production board for Samsung S9 (SM-G9600) phone,
+based on the Qualcomm SDM845 SoC.
+
+More information can be found on the `Samsung S9 page`_.
+
+.. _Samsung S9 page: https://en.wikipedia.org/wiki/Samsung_Galaxy_S9
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH 1/6 v5] serial: qcom: add support for GENI serial driver

In reply to Dzmitry Sankouski
Quoted 8 lines · Dzmitry Sankouski

Generic Interface (GENI) Serial Engine (SE) based uart can be found on newer qualcomm SOCs, starting from SDM845. Tested on Samsung SM-G9600(starqltechn)
by chain-loading u-boot with stock bootloader.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#4 lore raw

Re: [PATCH 4/6] clocks: qcom: add clocks for SDM845 debug uart

In reply to Dzmitry Sankouski
Quoted 11 lines · Dzmitry Sankouski

Allows to change clock frequency of debug uart,
thus supporting wide range of baudrates.
Enable / disable functionality is not implemented yet. In most use cases of SDM845 (i.e. mobile phones and tablets) it's not needed, because qualcomm first stage bootloader leaves it initialized, and on the other hand there's no possibility to replace signed first stage bootloader with u-boot.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#10 lore raw

Re: [PATCH 5/6 v2] SoC: qcom: add support for SDM845

In reply to Dzmitry Sankouski
Quoted 8 lines · Dzmitry Sankouski

Hi-end qualcomm chip, introduced in late 2017. Mostly used in flagship phones and tablets of 2018. Features:
- arm64 arch
- total of 8 Kryo 385 Gold / Silver cores
- Hexagon 685 DSP
- Adreno 630 GPU

Quoted 6 lines

Tested only as second-stage bootloader.

Cc Ramon Fried <[email protected]>
Cc Tom Rini <[email protected]>
Cc Stephan Gerhold <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#12 lore raw

Re: [PATCH 6/6 v4] board: samsung: add Samsung Galaxy S9/S9+(SM-G96x0) board

In reply to Dzmitry Sankouski
Quoted 8 lines · Dzmitry Sankouski

Samsung S9 SM-G9600 - Snapdragon SDM845 version of the phone, for China \ Hong Kong markets.
Has unlockable bootloader, unlike SM-G960U (American market version), which allows running u-boot as a chain-loaded bootloader.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom