From: Yureka Lilian <yureka@cyberchaos.dev>
To: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Neal Gompa <neal@gompa.dev>, Linus Walleij <linusw@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Mark Kettenis <kettenis@openbsd.org>
Cc: Yureka Lilian <yureka@cyberchaos.dev>,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] pinctrl: apple: Add t8140-pinctrl support
Date: Sat, 26 Sep 2026 16:51:46 +0200 [thread overview]
Message-ID: <20260926-apple-pinctrl-t8140-v2-2-620bd11cd2a1@cyberchaos.dev> (raw)
In-Reply-To: <20260926-apple-pinctrl-t8140-v2-0-620bd11cd2a1@cyberchaos.dev>
Ensure the regmap does not attempt to read REG_GPIOx of any of the pins
marked with gpio-reserved-ranges. For this purpose, move the regmap_init
just before the first regmap_read, at which point the valid_mask has
been populated from the gpio-reserved-ranges device tree property.
With this, make the driver accept the new t8140 base compatible as with
this modifications the driver can now be loaded on this SoC without
crashing.
Signed-off-by: Yureka Lilian <yureka@cyberchaos.dev>
---
drivers/pinctrl/pinctrl-apple-gpio.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-apple-gpio.c b/drivers/pinctrl/pinctrl-apple-gpio.c
index 6305b96aaa73..6b26a23d283c 100644
--- a/drivers/pinctrl/pinctrl-apple-gpio.c
+++ b/drivers/pinctrl/pinctrl-apple-gpio.c
@@ -66,6 +66,13 @@ struct apple_gpio_pinctrl {
#define REG_GPIOx_DRIVE_STRENGTH1 GENMASK(23, 22)
#define REG_IRQ(g, x) (0x800 + 0x40 * (g) + 4 * ((x) >> 5))
+static bool apple_gpio_readable_register(struct device *dev, unsigned int reg)
+{
+ struct apple_gpio_pinctrl *pctl = dev_get_drvdata(dev);
+
+ return gpiochip_line_is_valid(&pctl->gpio_chip, reg / 4);
+}
+
static const struct regmap_config regmap_config = {
.reg_bits = 32,
.val_bits = 32,
@@ -75,6 +82,7 @@ static const struct regmap_config regmap_config = {
.num_reg_defaults_raw = 512,
.use_relaxed_mmio = true,
.use_raw_spinlock = true,
+ .readable_reg = apple_gpio_readable_register,
};
/* No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register. */
@@ -90,6 +98,13 @@ static u32 apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
int ret;
u32 val;
+ if (!pctl->map) {
+ pctl->map = devm_regmap_init_mmio(pctl->dev, pctl->base, ®map_config);
+ if (IS_ERR(pctl->map))
+ return dev_err_probe(pctl->dev, PTR_ERR(pctl->map),
+ "Failed to create regmap\n");
+ }
+
ret = regmap_read(pctl->map, REG_GPIO(pin), &val);
if (ret)
return 0;
@@ -475,11 +490,6 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev)
if (IS_ERR(pctl->base))
return PTR_ERR(pctl->base);
- pctl->map = devm_regmap_init_mmio(&pdev->dev, pctl->base, ®map_config);
- if (IS_ERR(pctl->map))
- return dev_err_probe(&pdev->dev, PTR_ERR(pctl->map),
- "Failed to create regmap\n");
-
for (i = 0; i < npins; i++) {
pins[i].number = i;
pins[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "PIN%u", i);
@@ -522,6 +532,7 @@ static int apple_gpio_pinctrl_probe(struct platform_device *pdev)
}
static const struct of_device_id apple_gpio_pinctrl_of_match[] = {
+ { .compatible = "apple,t8140-pinctrl", },
{ .compatible = "apple,t8103-pinctrl", },
{ .compatible = "apple,pinctrl", },
{ }
--
2.55.0
next prev parent reply other threads:[~2026-09-26 14:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 14:51 [PATCH v2 0/2] pinctrl: apple: Add t8140-pinctrl support Yureka Lilian
2026-09-26 14:51 ` [PATCH v2 1/2] dt-bindings: pinctrl: apple,pinctrl: Add t8140 compatible Yureka Lilian
2026-09-30 10:05 ` Krzysztof Kozlowski
2026-09-26 14:51 ` Yureka Lilian [this message]
2026-09-30 10:03 ` [PATCH v2 0/2] pinctrl: apple: Add t8140-pinctrl support Krzysztof Kozlowski
2026-09-30 22:54 ` Yureka Lilian
2026-10-01 21:13 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260926-apple-pinctrl-t8140-v2-2-620bd11cd2a1@cyberchaos.dev \
--to=yureka@cyberchaos.dev \
--cc=asahi@lists.linux.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=j@jannau.net \
--cc=kettenis@openbsd.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neal@gompa.dev \
--cc=robh@kernel.org \
--cc=sven@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox