* [PATCH v4 0/2] gpio: Add Cortina Systems CS75xx GPIO driver
@ 2026-11-16 2:08 Fil Dunsky via B4 Relay
2026-11-16 2:08 ` [PATCH v4 1/2] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay
2026-11-16 2:08 ` [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay
0 siblings, 2 replies; 4+ messages in thread
From: Fil Dunsky via B4 Relay @ 2026-11-16 2:08 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley
Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel,
Fil Dunsky
The Cortina Systems CS75xx ("Goldengate G2") SoCs have five banks of 32
GPIO lines, each bank with its own interrupt. This series adds the
binding and a driver based on gpio-mmio; level and edge triggers are
supported, both edges are emulated by flipping the polarity.
Each pin is either a GPIO line or belongs to a peripheral (NAND,
Ethernet, UART, I2C, ...). That choice is made in the global control
block, which is not part of the GPIO controller: as discussed on v1 [1],
the driver does not touch the pin mux and leaves it as the boot loader
set it up, until there is a pin controller driver for that block. On the
Securifi Almond+ the boot loader already leaves the reset button and the
touchscreen interrupt lines in the GPIO function.
The driver used to be part of a series with the interrupt controller,
I2C and watchdog drivers and the device tree changes. That series is now
split per subsystem: the driver builds with COMPILE_TEST and does not
depend on the platform series [2], which is under review separately. The
device tree nodes will follow with the other CS75xx dts changes once the
platform is merged.
There is no public documentation; the register layout comes from the GPL
vendor kernels. Tested on a Securifi Almond+ (CS7542): the reset button
(GPIO 37) works as an active-low gpio-keys input, and the SX8650
touchscreen uses a level-triggered GPIO interrupt.
[1] https://lore.kernel.org/all/20261012-dreamlike-hazily-19bb60326f0a@spud/
[2] https://lore.kernel.org/all/20261114-b4-cs75xx-v7-0-8f17f38821b4@gmail.com/
---
Changes in v4:
- rebase on v7.4-rc1
- split out of "Cortina Systems CS75xx: interrupt controller, GPIO, I2C
and TWD watchdog" so that each driver can go through its own tree; no
longer based on the platform series
- the pin mux registers are not part of the GPIO controller (Conor): the
binding has a single reg entry and the driver no longer switches the
pin mux when a line is requested
(Rob, your Reviewed-by on v3 is not carried because of this change)
- switch a line to input for an interrupt only when it is not requested;
flip the polarity of a both-edges line after the ack, so that an edge
in between is not lost (sashiko-bot)
- drop the gpio_chip owner, gpiolib sets it; sort the Makefile entry
- Link to v3: https://patch.msgid.link/20261013-b4-cs75xx-s2-v3-0-181bb0d23f4c@gmail.com
Changes in v3:
- rebase on v6 of the platform series
- Link to v2: https://patch.msgid.link/20261013-b4-cs75xx-s2-v2-0-94f8c0a90cda@gmail.com
Changes in v2:
- rebase on v5 of the platform series
- do not include <linux/mod_devicetable.h> (Uwe)
- update the both-edges mask only for a valid trigger type and test it
under the lock in the interrupt handler; refuse more than 32 lines
(sashiko-bot)
- Link to v1: https://patch.msgid.link/20261012-b4-cs75xx-s2-v1-0-8a7641b7b79c@gmail.com
To: Linus Walleij <linusw@kernel.org>
To: Bartosz Golaszewski <brgl@kernel.org>
To: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzk+dt@kernel.org>
To: Conor Dooley <conor+dt@kernel.org>
Cc: linux-gpio@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
---
Fil Dunsky (2):
dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller
gpio: Add Cortina Systems CS75xx GPIO driver
.../bindings/gpio/cortina,cs7542-gpio.yaml | 65 +++++
drivers/gpio/Kconfig | 12 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-cs75xx.c | 281 +++++++++++++++++++++
4 files changed, 359 insertions(+)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261015-cs75xx-gpio-ed0a37ee4a68
Best regards,
--
Fil Dunsky <filipp.dunsky@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v4 1/2] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller 2026-11-16 2:08 [PATCH v4 0/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay @ 2026-11-16 2:08 ` Fil Dunsky via B4 Relay 2026-11-16 2:08 ` [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay 1 sibling, 0 replies; 4+ messages in thread From: Fil Dunsky via B4 Relay @ 2026-11-16 2:08 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, Fil Dunsky From: Fil Dunsky <filipp.dunsky@gmail.com> The Cortina Systems CS75xx SoCs have five banks of 32 GPIO lines. Each pin is shared between a GPIO line and a peripheral function; the pin mux lives in the global control block and is not described here. Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com> --- .../bindings/gpio/cortina,cs7542-gpio.yaml | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/cortina,cs7542-gpio.yaml b/Documentation/devicetree/bindings/gpio/cortina,cs7542-gpio.yaml new file mode 100644 index 000000000..faa302180 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/cortina,cs7542-gpio.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/cortina,cs7542-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cortina Systems CS7542 GPIO controller + +maintainers: + - Fil Dunsky <filipp.dunsky@gmail.com> + +description: + The Cortina Systems CS75xx (Goldengate G2) SoCs have five banks of 32 + GPIO lines, each with its own interrupt. Every pin is shared between a + GPIO line and a peripheral function; the choice is made in the global + control block and is not part of the GPIO controller. + +properties: + compatible: + const: cortina,cs7542-gpio + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + gpio-controller: true + + "#gpio-cells": + const: 2 + + gpio-line-names: + maxItems: 32 + + gpio-reserved-ranges: true + + interrupt-controller: true + + "#interrupt-cells": + const: 2 + +required: + - compatible + - reg + - interrupts + - gpio-controller + - "#gpio-cells" + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | + gpio@f00701f0 { + compatible = "cortina,cs7542-gpio"; + reg = <0xf00701f0 0x20>; + interrupt-parent = <&intc>; + interrupts = <7>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver 2026-11-16 2:08 [PATCH v4 0/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay 2026-11-16 2:08 ` [PATCH v4 1/2] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay @ 2026-11-16 2:08 ` Fil Dunsky via B4 Relay 2026-11-16 2:42 ` sashiko-bot 1 sibling, 1 reply; 4+ messages in thread From: Fil Dunsky via B4 Relay @ 2026-11-16 2:08 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley Cc: linux-gpio, devicetree, linux-kernel, linux-arm-kernel, Fil Dunsky From: Fil Dunsky <filipp.dunsky@gmail.com> Add a driver for the GPIO banks of the Cortina Systems CS75xx SoCs. The data and direction registers are handled by gpio-mmio; each bank has its own interrupt with level and edge triggers, both edges are emulated by flipping the polarity. A pin only works as a GPIO when the pin mux in the global control block selects the GPIO function. That is not part of the GPIO controller and is left to the boot loader until there is a pin controller driver. Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com> --- drivers/gpio/Kconfig | 12 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cs75xx.c | 281 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 294 insertions(+) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 55e428002..cc00cfe48 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -300,6 +300,18 @@ config GPIO_CLPS711X help Say yes here to support GPIO on CLPS711X SoCs. +config GPIO_CS75XX + tristate "Cortina Systems CS75xx GPIO support" + depends on ARCH_CORTINA_ACCESS || COMPILE_TEST + select GPIO_GENERIC + select GPIOLIB_IRQCHIP + help + Say yes here to support the GPIO banks of the Cortina Systems + CS75xx SoCs, including their interrupts. + + This driver can also be built as a module. If so, the module + will be called gpio-cs75xx. + config GPIO_DAVINCI tristate "TI Davinci/Keystone GPIO support" default y if ARCH_DAVINCI diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 88f748846..2c2e18ef2 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_GPIO_SNPS_CREG) += gpio-creg-snps.o obj-$(CONFIG_GPIO_CROS_EC) += gpio-cros-ec.o obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o +obj-$(CONFIG_GPIO_CS75XX) += gpio-cs75xx.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o diff --git a/drivers/gpio/gpio-cs75xx.c b/drivers/gpio/gpio-cs75xx.c new file mode 100644 index 000000000..b4f288910 --- /dev/null +++ b/drivers/gpio/gpio-cs75xx.c @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Cortina Systems CS75xx GPIO controller + * + * Each bank has 32 lines with direction, data and interrupt registers. + * Whether a pin is driven by the GPIO bank or by its peripheral function + * (NAND, Ethernet, UART, ...) is selected in the global control block, + * which this driver does not touch: the pin mux is left as the boot loader + * set it up. + */ + +#include <linux/bitops.h> +#include <linux/cleanup.h> +#include <linux/gpio/driver.h> +#include <linux/gpio/generic.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/irq.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +#define CS75XX_GPIO_CFG 0x00 /* 1: input, 0: output */ +#define CS75XX_GPIO_OUT 0x04 +#define CS75XX_GPIO_IN 0x08 +#define CS75XX_GPIO_LVL 0x0c /* 1: high level or rising edge */ +#define CS75XX_GPIO_EDGE 0x10 /* 1: edge, 0: level */ +#define CS75XX_GPIO_IE 0x14 +#define CS75XX_GPIO_INT 0x18 /* write 1 to clear */ + +struct cs75xx_gpio { + struct gpio_generic_chip chip; + void __iomem *base; + u32 both_edges; +}; + +/* Both edges are emulated by flipping the polarity on every interrupt */ +static void cs75xx_gpio_set_polarity(struct cs75xx_gpio *g, u32 mask) +{ + u32 lvl = readl(g->base + CS75XX_GPIO_LVL); + + if (readl(g->base + CS75XX_GPIO_IN) & mask) + lvl &= ~mask; + else + lvl |= mask; + + writel(lvl, g->base + CS75XX_GPIO_LVL); +} + +static void cs75xx_gpio_irq_ack(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct cs75xx_gpio *g = gpiochip_get_data(gc); + u32 mask = BIT(irqd_to_hwirq(d)); + + guard(gpio_generic_lock_irqsave)(&g->chip); + writel(mask, g->base + CS75XX_GPIO_INT); + /* Arm the opposite edge after the ack, so that it is not lost */ + if (g->both_edges & mask) + cs75xx_gpio_set_polarity(g, mask); +} + +static void cs75xx_gpio_irq_mask(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct cs75xx_gpio *g = gpiochip_get_data(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); + + scoped_guard(gpio_generic_lock_irqsave, &g->chip) { + u32 ie = readl(g->base + CS75XX_GPIO_IE); + + writel(ie & ~BIT(hwirq), g->base + CS75XX_GPIO_IE); + } + + gpiochip_disable_irq(gc, hwirq); +} + +static void cs75xx_gpio_irq_unmask(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct cs75xx_gpio *g = gpiochip_get_data(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); + u32 ie; + + gpiochip_enable_irq(gc, hwirq); + + guard(gpio_generic_lock_irqsave)(&g->chip); + /* + * The status of a level interrupt is latched while the line is + * asserted, also after the ack, so it may be stale by now. Clear it, + * it is set again right away if the line is still asserted. + */ + if (irqd_is_level_type(d)) + writel(BIT(hwirq), g->base + CS75XX_GPIO_INT); + ie = readl(g->base + CS75XX_GPIO_IE); + writel(ie | BIT(hwirq), g->base + CS75XX_GPIO_IE); +} + +static int cs75xx_gpio_irq_set_type(struct irq_data *d, unsigned int type) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct cs75xx_gpio *g = gpiochip_get_data(gc); + u32 mask = BIT(irqd_to_hwirq(d)); + u32 lvl, edge, both_edges; + + guard(gpio_generic_lock_irqsave)(&g->chip); + + lvl = readl(g->base + CS75XX_GPIO_LVL); + edge = readl(g->base + CS75XX_GPIO_EDGE); + both_edges = g->both_edges & ~mask; + + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_LEVEL_LOW: + lvl &= ~mask; + edge &= ~mask; + break; + case IRQ_TYPE_LEVEL_HIGH: + lvl |= mask; + edge &= ~mask; + break; + case IRQ_TYPE_EDGE_FALLING: + lvl &= ~mask; + edge |= mask; + break; + case IRQ_TYPE_EDGE_RISING: + lvl |= mask; + edge |= mask; + break; + case IRQ_TYPE_EDGE_BOTH: + both_edges |= mask; + edge |= mask; + break; + default: + return -EINVAL; + } + + g->both_edges = both_edges; + writel(lvl, g->base + CS75XX_GPIO_LVL); + writel(edge, g->base + CS75XX_GPIO_EDGE); + if (g->both_edges & mask) + cs75xx_gpio_set_polarity(g, mask); + + if (type & IRQ_TYPE_LEVEL_MASK) + irq_set_handler_locked(d, handle_level_irq); + else + irq_set_handler_locked(d, handle_edge_irq); + + return 0; +} + +static int cs75xx_gpio_irq_reqres(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + irq_hw_number_t hwirq = irqd_to_hwirq(d); + int ret; + + /* + * The boot loader may leave the line configured as an output. Only + * touch it when nobody else has requested it. + */ + char *label __free(kfree) = gpiochip_dup_line_label(gc, hwirq); + if (IS_ERR(label)) + return PTR_ERR(label); + if (!label) { + ret = gc->direction_input(gc, hwirq); + if (ret) + return ret; + } + + return gpiochip_reqres_irq(gc, hwirq); +} + +static void cs75xx_gpio_irq_relres(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + + gpiochip_relres_irq(gc, irqd_to_hwirq(d)); +} + +static const struct irq_chip cs75xx_gpio_irq_chip = { + .name = "cs75xx-gpio", + .irq_ack = cs75xx_gpio_irq_ack, + .irq_mask = cs75xx_gpio_irq_mask, + .irq_unmask = cs75xx_gpio_irq_unmask, + .irq_set_type = cs75xx_gpio_irq_set_type, + .irq_request_resources = cs75xx_gpio_irq_reqres, + .irq_release_resources = cs75xx_gpio_irq_relres, + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND, +}; + +static void cs75xx_gpio_irq_handler(struct irq_desc *desc) +{ + struct gpio_chip *gc = irq_desc_get_handler_data(desc); + struct cs75xx_gpio *g = gpiochip_get_data(gc); + struct irq_chip *chip = irq_desc_get_chip(desc); + unsigned long pending; + unsigned int offset; + + chained_irq_enter(chip, desc); + + pending = readl(g->base + CS75XX_GPIO_INT) & + readl(g->base + CS75XX_GPIO_IE); + + for_each_set_bit(offset, &pending, gc->ngpio) + generic_handle_domain_irq(gc->irq.domain, offset); + + chained_irq_exit(chip, desc); +} + +static int cs75xx_gpio_probe(struct platform_device *pdev) +{ + struct gpio_generic_chip_config config; + struct device *dev = &pdev->dev; + struct gpio_irq_chip *girq; + struct cs75xx_gpio *g; + int irq, ret; + + g = devm_kzalloc(dev, sizeof(*g), GFP_KERNEL); + if (!g) + return -ENOMEM; + + g->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(g->base)) + return PTR_ERR(g->base); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return irq; + + config = (struct gpio_generic_chip_config) { + .dev = dev, + .sz = 4, + .dat = g->base + CS75XX_GPIO_IN, + .set = g->base + CS75XX_GPIO_OUT, + .dirin = g->base + CS75XX_GPIO_CFG, + }; + + ret = gpio_generic_chip_init(&g->chip, &config); + if (ret) + return dev_err_probe(dev, ret, "unable to init generic GPIO\n"); + + if (g->chip.gc.ngpio > 32) + return dev_err_probe(dev, -EINVAL, "too many lines: %u\n", + g->chip.gc.ngpio); + + /* Mask and clear all interrupts before the parent is set up */ + writel(0, g->base + CS75XX_GPIO_IE); + writel(~0, g->base + CS75XX_GPIO_INT); + + girq = &g->chip.gc.irq; + gpio_irq_chip_set_chip(girq, &cs75xx_gpio_irq_chip); + girq->parent_handler = cs75xx_gpio_irq_handler; + girq->num_parents = 1; + girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), + GFP_KERNEL); + if (!girq->parents) + return -ENOMEM; + girq->parents[0] = irq; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_bad_irq; + + return devm_gpiochip_add_data(dev, &g->chip.gc, g); +} + +static const struct of_device_id cs75xx_gpio_of_match[] = { + { .compatible = "cortina,cs7542-gpio" }, + { } +}; +MODULE_DEVICE_TABLE(of, cs75xx_gpio_of_match); + +static struct platform_driver cs75xx_gpio_driver = { + .probe = cs75xx_gpio_probe, + .driver = { + .name = "cs75xx-gpio", + .of_match_table = cs75xx_gpio_of_match, + }, +}; +module_platform_driver(cs75xx_gpio_driver); + +MODULE_DESCRIPTION("Cortina Systems CS75xx GPIO driver"); +MODULE_LICENSE("GPL"); -- 2.53.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver 2026-11-16 2:08 ` [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay @ 2026-11-16 2:42 ` sashiko-bot 0 siblings, 0 replies; 4+ messages in thread From: sashiko-bot @ 2026-11-16 2:42 UTC (permalink / raw) To: Fil Dunsky; +Cc: linux-gpio, devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] gpio: cs75xx: spurious interrupt when enabling edge-triggered IRQs - [Low] gpio: cs75xx: Kconfig depends on undefined symbol ARCH_CORTINA_ACCESS -- commit 6e394706938fa0fbfbaaa8045989b5a4c049c014 Author: Fil Dunsky <filipp.dunsky@gmail.com> gpio: Add Cortina Systems CS75xx GPIO driver This commit adds a GPIO and interrupt controller driver for the Cortina Systems CS75xx SoCs using gpio-mmio. > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index 55e4280029d86..cc00cfe48d941 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -300,6 +300,18 @@ config GPIO_CLPS711X > help > Say yes here to support GPIO on CLPS711X SoCs. > > +config GPIO_CS75XX > + tristate "Cortina Systems CS75xx GPIO support" > + depends on ARCH_CORTINA_ACCESS || COMPILE_TEST [Severity: Low] Is ARCH_CORTINA_ACCESS defined anywhere in the tree? Without that Kconfig symbol, GPIO_CS75XX can only be enabled when COMPILE_TEST is set, and scripts/checkkconfigsymbols.py will report an undefined symbol. [ ... ] > diff --git a/drivers/gpio/gpio-cs75xx.c b/drivers/gpio/gpio-cs75xx.c > new file mode 100644 > index 0000000000000..b4f2889103311 > --- /dev/null > +++ b/drivers/gpio/gpio-cs75xx.c [ ... ] > +static void cs75xx_gpio_irq_unmask(struct irq_data *d) > +{ > + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > + struct cs75xx_gpio *g = gpiochip_get_data(gc); > + irq_hw_number_t hwirq = irqd_to_hwirq(d); > + u32 ie; > + > + gpiochip_enable_irq(gc, hwirq); > + > + guard(gpio_generic_lock_irqsave)(&g->chip); > + /* > + * The status of a level interrupt is latched while the line is > + * asserted, also after the ack, so it may be stale by now. Clear it, > + * it is set again right away if the line is still asserted. > + */ > + if (irqd_is_level_type(d)) > + writel(BIT(hwirq), g->base + CS75XX_GPIO_INT); > + ie = readl(g->base + CS75XX_GPIO_IE); > + writel(ie | BIT(hwirq), g->base + CS75XX_GPIO_IE); > +} > + > +static int cs75xx_gpio_irq_set_type(struct irq_data *d, unsigned int type) > +{ > + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > + struct cs75xx_gpio *g = gpiochip_get_data(gc); > + u32 mask = BIT(irqd_to_hwirq(d)); > + u32 lvl, edge, both_edges; > + > + guard(gpio_generic_lock_irqsave)(&g->chip); > + > + lvl = readl(g->base + CS75XX_GPIO_LVL); > + edge = readl(g->base + CS75XX_GPIO_EDGE); > + both_edges = g->both_edges & ~mask; > + > + switch (type & IRQ_TYPE_SENSE_MASK) { > + case IRQ_TYPE_LEVEL_LOW: > + lvl &= ~mask; > + edge &= ~mask; > + break; > + case IRQ_TYPE_LEVEL_HIGH: > + lvl |= mask; > + edge &= ~mask; > + break; > + case IRQ_TYPE_EDGE_FALLING: > + lvl &= ~mask; > + edge |= mask; > + break; > + case IRQ_TYPE_EDGE_RISING: > + lvl |= mask; > + edge |= mask; > + break; > + case IRQ_TYPE_EDGE_BOTH: > + both_edges |= mask; > + edge |= mask; > + break; > + default: > + return -EINVAL; > + } > + > + g->both_edges = both_edges; > + writel(lvl, g->base + CS75XX_GPIO_LVL); > + writel(edge, g->base + CS75XX_GPIO_EDGE); > + if (g->both_edges & mask) > + cs75xx_gpio_set_polarity(g, mask); [Severity: Medium] Can configuring and unmasking an edge-triggered interrupt fire an immediate spurious interrupt? cs75xx_gpio_probe() leaves CS75XX_GPIO_EDGE and CS75XX_GPIO_LVL at their reset or boot loader state, so any line initially in level mode will re-latch its bit in CS75XX_GPIO_INT whenever the input matches CS75XX_GPIO_LVL. In addition, cs75xx_gpio_irq_set_type() writes CS75XX_GPIO_LVL before switching CS75XX_GPIO_EDGE to edge mode, which latches CS75XX_GPIO_INT if the pin already matches the new lvl bit. Because neither cs75xx_gpio_irq_set_type() nor cs75xx_gpio_irq_unmask() clears CS75XX_GPIO_INT for edge interrupts, unmasking the line in CS75XX_GPIO_IE immediately triggers a spurious interrupt. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261116-cs75xx-gpio-v4-0-ad80a944e966@gmail.com?part=2 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-16 2:43 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-16 2:08 [PATCH v4 0/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay 2026-11-16 2:08 ` [PATCH v4 1/2] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay 2026-11-16 2:08 ` [PATCH v4 2/2] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay 2026-11-16 2:42 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox