Add pinctrl support for MSM8952
Subsystems (6)
v5 cover Add pinctrl support for MSM8952
MSM8952 has pinctrl system that is similar to MSM8917 pinctrl, but it has some differences in some of the pins and their functions. This driver tested on General Mobile GM 5 Plus.
---
Changes in v5:
- Add mpm map as Konrad Dybcio provided.
- Change "GPL v2" to "GPL" as Konrad Dybcio suggested.
- Add missing pin mappings for qdss_tracedata_b and
atest_combodac_to_gpio_native functions.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Revert back accidentally changed dt-bindings gpio regex.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Added missing functions and removed unnecessary functions
with Konrad Dybcio's suggestions.
- Because of the changes on functions, I changed dt-bindings too.
Dropped Krzysztof's Reviewed-By attribute because of the changes.
- Rebased and Tested on linux-next, next-20260902 tag.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Reworded dt-bindings commit as Krzysztof suggested.
- Added depends and default to kconfig entry of pinctrl
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Muzaffer Kadir (2):
dt-bindings: pinctrl: qcom: Add MSM8952 pinctrl
pinctrl: qcom: Add MSM8952 tlmm pinctrl driver
.../bindings/pinctrl/qcom,msm8952-pinctrl.yaml | 146 +++ drivers/pinctrl/qcom/Kconfig.msm | 8 + drivers/pinctrl/qcom/Makefile | 1 + drivers/pinctrl/qcom/pinctrl-msm8952.c | 1257 ++++++++++++++++++++ 4 files changed, 1412 insertions(+)
---
base-commit: 32b6ef9a5d0eca44f9cd91f52f4faa89f145a0de
change-id: 20260816-msm8952-pinctrl-bc2bd4849261
Best regards,
Signature · 1 line
Muzaffer Kadir <[email protected]>
PATCH v5 1/2 dt-bindings: pinctrl: qcom: Add MSM8952 pinctrl
Add device tree bindings for the TLMM pin controller found on the Qualcomm MSM8952 platform.
--- .../bindings/pinctrl/qcom,msm8952-pinctrl.yaml | 146 +++++++++++++++++++++ 1 file changed, 146 insertions(+)
Documentation/devicetree/bindings/pinctrl/qcom,msm8952-pinctrl.yaml new file +146 -0
@@ -0,0 +1,146 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/qcom,msm8952-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm MSM8952 TLMM pin controller + +maintainers: + - Muzaffer Kadir <[email protected]> + +description: + Top Level Mode Multiplexer pin controller in Qualcomm MSM8952 SoC. + +properties: + compatible: + const: qcom,msm8952-pinctrl + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + gpio-reserved-ranges: + minItems: 1 + maxItems: 66 + + gpio-line-names: + maxItems: 134 + +patternProperties: + "-state$": + oneOf: + - $ref: "#/$defs/qcom-msm8952-tlmm-state" + - patternProperties: + "-pins$": + $ref: "#/$defs/qcom-msm8952-tlmm-state" + additionalProperties: false + +$defs: + qcom-msm8952-tlmm-state: + type: object + description: + Pinctrl node's client devices use subnodes for desired pin configuration. + Client device subnodes use below standard properties. + $ref: qcom,tlmm-common.yaml#/$defs/qcom-tlmm-state + unevaluatedProperties: false + + properties: + pins: + description: + List of gpio pins affected by the properties specified in this + subnode. + items: + oneOf: + - pattern: "^gpio([0-9]|[1-9][0-9]|1[0-2][0-9]|13[0-3])$" + - enum: [ qdsd_clk, qdsd_cmd, qdsd_data0, qdsd_data1, qdsd_data2, + qdsd_data3, sdc1_clk, sdc1_cmd, sdc1_data, sdc1_rclk, + sdc2_clk, sdc2_cmd, sdc2_data ] + minItems: 1 + maxItems: 36 + + function: + description: + Specify the alternative function to be configured for the specified + pins. + + enum: [ gpio, blsp_uart1, blsp_spi1, adsp_ext, blsp_i2c1, prng_rosc, qdss_cti_trig_out_b0, + qdss_cti_trig_out_a1, blsp_spi2, blsp_uart2, ldo_update, qdss_tracedata_b, + pbs1, pwr_modem_enabled_b, blsp_i2c3, gcc_gp2_clk_b, atest_combodac_to_gpio_native, + ldo_en, blsp_i2c2, gcc_gp1_clk_b, atest_gpsadc_dtest0_native, blsp_spi3, + blsp_uart3, sec_mi2s, pbs0, gcc_gp3_clk_b, blsp_spi4, blsp_uart4, pbs2, + pwr_nav_enabled_b, pwr_crypto_enabled_b, blsp_i2c4, blsp_spi5, blsp_uart5, + qdss_traceclk_a, atest_bbrx1, qdss_tracectl_b, qdss_cti_trig_in_b0, blsp_i2c6, + qdss_traceclk_b, atest_wlan0, m_voc, qdss_cti_trig_in_a0, atest_bbrx0, blsp_i2c5, + qdss_tracectl_a, atest_gpsadc_dtest1_native, qdss_tracedata_a, blsp_spi6, + blsp_uart6, atest_wlan1, mdp_vsync, pri_mi2s_mclk_a, sec_mi2s_mclk_a, + cam_mclk, cci_i2c, pwr_modem_enabled_a, cci_timer0, cci_timer1, pwr_nav_enabled_a, + pwr_crypto_enabled_a, cci_async, sd_write, qdss_cti_trig_out_a0, gcc_gp1_clk_a, + gcc_gp2_clk_a, gcc_gp3_clk_a, blsp6_spi, qdss_cti_trig_in_b1, uim_batt, + qdss_cti_trig_out_b1, uim1_data, uim1_clk, uim1_reset, uim1_present, uim2_data, + uim2_clk, uim2_reset, uim2_present, uim3_data, usb_fs, uim3_clk, uim3_reset, + uim3_present, atest_char3, dbg_out, bimc_dte0, sec_mi2s_mclk_b, pri_mi2s, + atest_char1, ebi_cdc, atest_char0, cdc_pdm0, pri_mi2s_mclk_b, lpass_slimbus, + lpass_slimbus0, lpass_slimbus1, wcss_bt, atest_char2, ebi_ch0, wcss_wlan2, + wcss_wlan1, wcss_wlan0, wcss_wlan, wcss_fm, ext_lpass, gcc_tlmm, dmic0_clk, + dmic0_data, qdss_cti_trig_in_a1, blsp_spi7, blsp_uart7, pri_mi2s_ws, wsa_io, + blsp_i2c7, blsp_spi8, blsp_uart8, blsp_i2c8, gcc_plltest, nav_pps_in_a, + pa_indicator, nav_pps_in_b, nav_pps, modem_tsync, nav_tsync, ssbi_wtr1, + gsm1_tx, gsm0_tx, atest_char, atest_tsens, bimc_dte1, + gp_mn, gp_pdm_0a, gp_pdm_0b, gp_pdm_1a, gp_pdm_1b, + gp_pdm_2a, gp_pdm_2b, gp0_clk, gp1_clk] + + required: + - pins + +allOf: + - $ref: /schemas/pinctrl/qcom,tlmm-common.yaml# + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + msmgpio: pinctrl@1000000 { + compatible = "qcom,msm8952-pinctrl"; + reg = <0x01000000 0x300000>; + interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>; + gpio-controller; + gpio-ranges = <&msmgpio 0 0 134>; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + + blsp1-uart2-sleep-state { + pins = "gpio4", "gpio5"; + function = "gpio"; + + drive-strength = <2>; + bias-pull-down; + }; + + spi1-default-state { + spi-pins { + pins = "gpio0", "gpio1", "gpio3"; + function = "blsp_spi1"; + + drive-strength = <12>; + bias-disable; + }; + + cs-pins { + pins = "gpio2"; + function = "blsp_spi1"; + + drive-strength = <2>; + bias-disable; + }; + }; + };
Signature · 1 line
2.54.0
PATCH v5 2/2 pinctrl: qcom: Add MSM8952 tlmm pinctrl driver
In reply to Muzaffer KadirMSM8952 has same pin count and similar pinctrl
functions mostly with msm8917, but some functions use different pins.
--- drivers/pinctrl/qcom/Kconfig.msm | 8 + drivers/pinctrl/qcom/Makefile | 1 + drivers/pinctrl/qcom/pinctrl-msm8952.c | 1257 ++++++++++++++++++++++++++++++++ 3 files changed, 1266 insertions(+)
drivers/pinctrl/qcom/Kconfig.msm +8 -0
@@ -232,6 +232,14 @@ config PINCTRL_MSM8917 This is the pinctrl, pinmux, pinconf and gpiolib driver for the Qualcomm TLMM block found on the Qualcomm MSM8917, MSM8937 platform. +config PINCTRL_MSM8952 + tristate "Qualcomm 8952 pin controller driver" + depends on ARM64 || COMPILE_TEST + default ARCH_QCOM + help + This is the pinctrl, pinmux, pinconf and gpiolib driver for the + Qualcomm TLMM block found on the Qualcomm MSM8952 platform. + config PINCTRL_MSM8953 tristate "Qualcomm 8953 pin controller driver" depends on ARM64 || COMPILE_TEST
drivers/pinctrl/qcom/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_PINCTRL_MSM8X74) += pinctrl-msm8x74.o obj-$(CONFIG_PINCTRL_MSM8909) += pinctrl-msm8909.o obj-$(CONFIG_PINCTRL_MSM8916) += pinctrl-msm8916.o obj-$(CONFIG_PINCTRL_MSM8917) += pinctrl-msm8917.o +obj-$(CONFIG_PINCTRL_MSM8952) += pinctrl-msm8952.o obj-$(CONFIG_PINCTRL_MSM8953) += pinctrl-msm8953.o obj-$(CONFIG_PINCTRL_MSM8976) += pinctrl-msm8976.o obj-$(CONFIG_PINCTRL_MSM8994) += pinctrl-msm8994.o
drivers/pinctrl/qcom/pinctrl-msm8952.c new file +1257 -0
1,257 lines not on this page · raw message
Signature · 1 line
2.54.0
[email protected]
AI reviewRe: [PATCH v5 2/2] pinctrl: qcom: Add MSM8952 tlmm pinctrl driver
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] SDC_PINGROUP macro uses -1 for 5-bit unsigned bitfields, causing PIN_CONFIG_LEVEL to inadvertently modify GPIO_0_CTL.
Pre-existing issues:
- [High] Missing bounds check on ACPI/DT provided gpios array allows out-of-bounds heap write in msm_gpio_init_valid_mask. --
commit 092e7798eaa385b2192fd9af71a805996d90af7c
Author: Muzaffer Kadir <[email protected]>
pinctrl: qcom: Add MSM8952 tlmm pinctrl driver
This commit introduces the pinctrl, pinmux, pinconf, and gpiolib driver for the Qualcomm TLMM block found on the MSM8952 platform.
Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-msm8952.c new file +0
-0
[ ... ]
Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-msm8952.c new file +5
-0+#define SDC_PINGROUP (pg_name, ctl, pull, drv) \ + { \ + .grp = PINCTRL_PINGROUP(#pg_name, pg_name##_pins, \ + ARRAY_SIZE(pg_name##_pins)), \ + .ctl_reg = ctl, \
drivers/pinctrl/qcom/pinctrl-msm8952.c line 289
Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-msm8952.c new file +10
-0+ .io_reg = 0, \ + .intr_cfg_reg = 0, \ + .intr_status_reg = 0, \ + .intr_target_reg = 0, \ + .mux_bit = -1, \ + .pull_bit = pull, \ + .drv_bit = drv, \ + .oe_bit = -1, \ + .in_bit = -1, \ + .out_bit = -1, \
[Severity: High]
Does this macro lead to cross-pin corruption? It assigns -1 to 5-bit unsigned bitfields like oe_bit, in_bit, and out_bit, which silently truncates them to 31.
If PIN_CONFIG_LEVEL is applied to an SDC pin (for example, via a device tree output-high property), msm_config_group_set() in pinctrl-msm.c will use BIT(g->out_bit) (which evaluates to bit 31) to read-modify-write g->io_reg. Since io_reg is initialized to 0 for SDC pins, won't this end up unintentionally modifying offset 0, which corresponds to the GPIO_0_CTL register?
[ ... ]
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the related pinctrl-msm.c core code, I noticed a potential bounds checking issue in msm_gpio_init_valid_mask().
When device_property_read_u16_array() populates the tmp array with values from ACPI/DT firmware:
drivers/pinctrl/qcom/pinctrl-msm.c:msm_gpio_init_valid_mask() {
...
for (i = 0; i < len; i++)
set_bit(tmp[i], valid_mask);
...
}Does this loop have a bounds checking issue? The code doesn't appear to validate each tmp[i] element against ngpios. If a malformed or malicious device tree overlay provides a value greater than or equal to ngpios, won't set_bit(tmp[i], valid_mask) perform an out-of-bounds heap write beyond the valid_mask array allocation?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v5 2/2] pinctrl: qcom: Add MSM8952 tlmm pinctrl driver
In reply to Muzaffer KadirQuoted 7 lines · On 9/7/26 6:05 PM, Muzaffer Kadir via B4 Relay wrote:
From: Muzaffer Kadir <[email protected]>
MSM8952 has same pin count and similar pinctrl
functions mostly with msm8917, but some functions use different pins.Signed-off-by Muzaffer Kadir <[email protected]>---
Konrad
Bartosz Golaszewski
AppliedQuoted 5 lines · Muzaffer Kadir
MSM8952 has pinctrl system that is similar to MSM8917 pinctrl, but it has some differences in some of the pins and their functions. This driver tested on General Mobile GM 5 Plus.
Applied, thanks!
[1/2] dt-bindings: pinctrl: qcom: Add MSM8952 pinctrl
https://git.kernel.org/brgl/c/2f006f5c617a56afe7683b607727349e0aea7814 [2/2] pinctrl: qcom: Add MSM8952 tlmm pinctrl driver https://git.kernel.org/brgl/c/b53a6210af0fe559670e298349968beae2c7448b
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>