Skip to contentSkip to conversation

pinctrl: qcom: add pinctrl and gpio drivers for SDM845 SoC

PATCH Superseded [email protected] 1 participant 2 messages Sep 26, 2021

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

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

From: Dzmitry Sankouski <[email protected]>

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
#1 lore raw

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

From: Dzmitry Sankouski <[email protected]>

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