Add gpio driver support for Realtek DHC SoCs
Subsystems (2)
v5 cover Add gpio driver support for Realtek DHC SoCs
These patches add the bindings and the gpio driver for Realtek DHC(Digital Home Center) RTD SoCs, including RTD1295, RTD1395, RTD1619, RTD1319, RTD1619B, RTD1319D and RTD1315E.
Change log:v4->v5:
1. Add more description in the Kconfig.
2. Add comment for the counter-intuitive number 31.
3. Convert to use cleanup API and module_platform_driver() macro.
4. Simplify some of the code as suggested in patch v4.v3->v4:
1. Arrange the compatible list in alphanumerical order.
2. Remove the size check for the offset array.
3. Add the debounce callback.
4. Conducted a review of the critical section, employing raw_spinlock_t for locking purposes.
5. Add gpiochip_enable_irq/gpiochip_disable_irq to fulfill the immutability requirements.
6. Use irqd_to_hwirq to get hwirq.v2->v3:
1. Remove generic compatible and use SoC-specific compatible instead.
2. Add the missing descriptions for the rtd_gpio_info structure members.
3. Assign gpio_chip fwnode.v1->v2:
1. Add description for DHC RTD SoCs in the bindings.
2. Revise the compatible names in the bindings.
3. Transitioned from OF API to platform_device API.
4. Use u8 for the offset array within the rtd_gpio_info structure.
5. Record the size of each array within the rtd_gpio_info structure and implement checks to prevent out-of-bounds access.
6. Use GPIOLIB_IRQCHIP helpers to register interrupts.
7. Use dynamic allocation for GPIO base.
Tzuyi Chang (2):
dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
.../bindings/gpio/realtek,rtd-gpio.yaml | 69 ++ drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 604 ++++++++++++++++++ 4 files changed, 687 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml create mode 100644 drivers/gpio/gpio-rtd.c
Signature · 1 line
2.43.0
PATCH v5 1/2 dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Add the device tree bindings for the Realtek DHC(Digital Home Center) RTD SoCs GPIO controllers.
---
v4 to v5 change:
No change.
v3 to v4 change:
1. Arrange the compatible list in alphanumerical order.
v2 to v3 change:
1. Remove generic compatible and use SoC-specific compatible instead.
v1 to v2 change:
1. Add description for DHC RTD SoCs.
2. Revise the compatible names.
3. Add descriptions for reg and interrupts properties.
--- .../bindings/gpio/realtek,rtd-gpio.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Realtek Semiconductor Corporation +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/realtek,rtd-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek DHC GPIO controller + +maintainers: + - Tzuyi Chang <[email protected]> + +description: + The GPIO controller is designed for the Realtek DHC (Digital Home Center) + RTD series SoC family, which are high-definition media processor SoCs. + +properties: + compatible: + enum: + - realtek,rtd1295-misc-gpio + - realtek,rtd1295-iso-gpio + - realtek,rtd1315e-iso-gpio + - realtek,rtd1319-iso-gpio + - realtek,rtd1319d-iso-gpio + - realtek,rtd1395-iso-gpio + - realtek,rtd1619-iso-gpio + - realtek,rtd1619b-iso-gpio + + reg: + items: + - description: GPIO controller registers + - description: GPIO interrupt registers + + interrupts: + items: + - description: Interrupt number of the assert GPIO interrupt, which is + triggered when there is a rising edge. + - description: Interrupt number of the deassert GPIO interrupt, which is + triggered when there is a falling edge. + + gpio-ranges: true + + gpio-controller: true + + "#gpio-cells": + const: 2 + +required: + - compatible + - reg + - interrupts + - gpio-ranges + - gpio-controller + - "#gpio-cells" + +additionalProperties: false + +examples: + - | + gpio@100 { + compatible = "realtek,rtd1319d-iso-gpio"; + reg = <0x100 0x100>, + <0x0 0xb0>; + interrupt-parent = <&iso_irq_mux>; + interrupts = <19>, <20>; + gpio-ranges = <&pinctrl 0 0 82>; + gpio-controller; + #gpio-cells = <2>; + };
Signature · 1 line
2.43.0
PATCH v5 2/2 Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
In reply to Tzuyi ChangThis driver enables configuration of GPIO direction, GPIO values, GPIO debounce settings and handles GPIO interrupts.
---
v4 to v5 change:
1. Add comment for the counter-intuitive number 31.
2. Convert to use cleanup API.
3. Convert to use module_platform_driver() macro.
4. Simplify some of the code as suggested in patch v4.
5. Add more description in the Kconfig.
v3 to v4 change:
1. Remove the size check for the offset array.
2. Add the debounce callback to get values, register offsets and shifts for each chip.
3. Conducted a review of the critical section, employing raw_spinlock_t for locking purposes.
4. Use irqd_to_hwirq to get hwirq.
5. Add gpiochip_enable_irq/gpiochip_disable_irq to fulfill the immutability requirements.
v2 to v3 change:
1. Remove generic compatible and use SoC-specific compatible instead.
2. Add the missing descriptions for the rtd_gpio_info structure members.
3. Assign gpio_chip fwnode.
v1 to v2 change:
1. Remove legacy headers.
2. Transitioned from OF API to platform_device API.
3. Use u8 for the offset member within the rtd_gpio_info structure.
4. Record the size of each array within the rtd_gpio_info structure and implement checks to prevent out-of-bounds access.
5. Use GPIOLIB_IRQCHIP helpers to register interrupts.
6. Use dynamic allocation for GPIO base.
--- drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 604 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 618 insertions(+) create mode 100644 drivers/gpio/gpio-rtd.c
drivers/gpio/Kconfig +13 -0
@@ -553,6 +553,19 @@ config GPIO_ROCKCHIP help Say yes here to support GPIO on Rockchip SoCs. +config GPIO_RTD + tristate "Realtek DHC GPIO support" + depends on ARCH_REALTEK + default y + select GPIOLIB_IRQCHIP + help + This option enables support for GPIOs found on Realtek DHC(Digital + Home Center) SoCs family, including RTD1295, RTD1315E, RTD1319, + RTD1319D, RTD1395, RTD1619 and RTD1619B. + + Say yes here to support GPIO functionality and GPIO interrupt on + Realtek DHC SoCs. + config GPIO_SAMA5D2_PIOBU tristate "SAMA5D2 PIOBU GPIO support" depends on MFD_SYSCON
drivers/gpio/Makefile +1 -0
@@ -137,6 +137,7 @@ obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o obj-$(CONFIG_GPIO_REALTEK_OTTO) += gpio-realtek-otto.o obj-$(CONFIG_GPIO_REG) += gpio-reg.o obj-$(CONFIG_GPIO_ROCKCHIP) += gpio-rockchip.o +obj-$(CONFIG_GPIO_RTD) += gpio-rtd.o obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o
drivers/gpio/gpio-rtd.c new file +604 -0
604 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 44 lines · Tzuyi Chang
These patches add the bindings and the gpio driver for Realtek DHC(Digital Home Center) RTD SoCs, including RTD1295, RTD1395, RTD1619, RTD1319, RTD1619B, RTD1319D and RTD1315E.
Change log:
v4->v5:
1. Add more description in theKconfig.
2. Add comment for the counter-intuitive number 31.
3. Convert to use cleanup API andmodule_platform_driver()macro.
4. Simplify some of the code as suggested in patch v4.v3->v4:
1. Arrange the compatible list in alphanumerical order.
2. Remove the size check for the offset array.
3. Add the debounce callback.
4. Conducted a review of the critical section, employingraw_spinlock_tfor locking purposes.
5. Add gpiochip_enable_irq/gpiochip_disable_irq to fulfill the immutability requirements.
6. Useirqd_to_hwirqto get hwirq.v2->v3:
1. Remove generic compatible and use SoC-specific compatible instead.
2. Add the missing descriptions for thertd_gpio_infostructure members.
3. Assigngpio_chipfwnode.v1->v2:
1. Add description for DHC RTD SoCs in the bindings.
2. Revise the compatible names in the bindings.
3. Transitioned from OF API toplatform_deviceAPI.
4. Use u8 for the offset array within thertd_gpio_infostructure.
5. Record the size of each array within thertd_gpio_infostructure and implement checks to prevent out-of-bounds access.
6. UseGPIOLIB_IRQCHIPhelpers to register interrupts.
7. Use dynamic allocation for GPIO base.Tzuyi Chang (2):
dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs..../bindings/gpio/realtek,rtd-gpio.yaml | 69 ++ drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 604 ++++++++++++++++++ 4 files changed, 687 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml create mode 100644 drivers/gpio/gpio-rtd.c
Quoted 3 lines
--
2.43.0
I applied this series. For the future: the commit subject should have the "gpio: rtd: ..." prefix. I added it this time.
Bart
Hi Bartosz,
Quoted 50 lines
Quoted 5 lines · Tzuyi Chang
These patches add the bindings and the gpio driver for Realtek DHC(Digital Home Center) RTD SoCs, including RTD1295, RTD1395, RTD1619, RTD1319, RTD1619B, RTD1319D and RTD1315E.
Quoted 11 lines
Change log:
v4->v5:
1. Add more description in theKconfig.
2. Add comment for the counter-intuitive number 31.
3. Convert to use cleanup API andmodule_platform_driver()macro.
4. Simplify some of the code as suggested in patch v4.v3->v4:
1. Arrange the compatible list in alphanumerical order.
2. Remove the size check for the offset array.
3. Add the debounce callback.
4. Conducted a review of the critical section, employingraw_spinlock_tforlocking purposes.
Quoted 1 line
5. Add gpiochip_enable_irq/gpiochip_disable_irq to fulfill the immutability
requirements.
Quoted 15 lines
6. Use
irqd_to_hwirqto get hwirq.v2->v3:
1. Remove generic compatible and use SoC-specific compatible instead.
2. Add the missing descriptions for thertd_gpio_infostructure members.
3. Assigngpio_chipfwnode.v1->v2:
1. Add description for DHC RTD SoCs in the bindings.
2. Revise the compatible names in the bindings.
3. Transitioned from OF API toplatform_deviceAPI.
4. Use u8 for the offset array within thertd_gpio_infostructure.
5. Record the size of each array within thertd_gpio_infostructure and implement checks to prevent out-of-bounds access.
6. UseGPIOLIB_IRQCHIPhelpers to register interrupts.
7. Use dynamic allocation for GPIO base.Quoted 8 lines
Tzuyi Chang (2):
dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs..../bindings/gpio/realtek,rtd-gpio.yaml | 69 ++ drivers/gpio/Kconfig | 13 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 604++++++++++++++++++
Quoted 5 lines
4 files changed, 687 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml create mode 100644 drivers/gpio/gpio-rtd.c
Quoted 7 lines
Quoted 3 lines
--
2.43.0I applied this series. For the future: the commit subject should have the "gpio:
rtd: ..." prefix. I added it this time.
Thank you. I'll make sure to take note of it next time.
Thanks,
Tzuyi Chang