Add gpio driver support for Realtek DHC SoCs
Subsystems (2)
v2 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: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 | 74 ++ drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 736 ++++++++++++++++++ 4 files changed, 820 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml create mode 100644 drivers/gpio/gpio-rtd.c
Signature · 1 line
2.42.0
PATCH v2 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.
---
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 | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +74 -0
@@ -0,0 +1,74 @@ +# 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 SoC family, which are high-definition media processor SoCs. + +properties: + compatible: + oneOf: + - items: + - enum: + - realtek,rtd1295-misc-gpio + - realtek,rtd1295-iso-gpio + - realtek,rtd1395-iso-gpio + - realtek,rtd1619-iso-gpio + - items: + - enum: + - realtek,rtd1319-iso-gpio + - realtek,rtd1619b-iso-gpio + - realtek,rtd1319d-iso-gpio + - realtek,rtd1315e-iso-gpio + - const: realtek,rtd-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", "realtek,rtd-gpio"; + reg = <0x100 0x100>, + <0x000 0x0b0>; + interrupt-parent = <&iso_irq_mux>; + interrupts = <19>, <20>; + gpio-ranges = <&pinctrl 0 0 82>; + gpio-controller; + #gpio-cells = <2>; + };
Signature · 1 line
2.42.0
Re: [PATCH v2 1/2] dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Quoted 30 lines · Tzuyi Chang
Add the device tree bindings for the Realtek DHC(Digital Home Center) RTD SoCs GPIO controllers.
Signed-off-by Tzuyi Chang <[email protected]>---
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 | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yamlDocumentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +10
-0@@ -0,0 +1,74 @@ +# 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:
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml line 20
Quoted 10 lines
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +10
-0+ - Tzuyi Chang <[email protected]> + +description: + The GPIO controller is designed for the Realtek DHC (Digital Home Center) + RTD SoC family, which are high-definition media processor SoCs. + +properties: + compatible: + oneOf: + - items:
Drop items.
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml line 32
Quoted 12 lines
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +12
-0+ - enum: + - realtek,rtd1295-misc-gpio + - realtek,rtd1295-iso-gpio + - realtek,rtd1395-iso-gpio + - realtek,rtd1619-iso-gpio + - items: + - enum: + - realtek,rtd1319-iso-gpio + - realtek,rtd1619b-iso-gpio + - realtek,rtd1319d-iso-gpio + - realtek,rtd1315e-iso-gpio + - const: realtek,rtd-gpio
Either you use generic compatible for everything or not. Other variants do not use generic compatible, so neither should these. Use SoC-specific compatible as fallback.
I asked you to to drop this compatible. I could not be more specific, so you just ignored this remark.
So again: what is "rtd"? Why it does not appear anywhere in description or title? No, drop it.
Best regards,
Krzysztof
RE: [PATCH v2 1/2] dt-bindings: gpio: realtek: Add realtek,rtd-gpio
Hi, Krzysztof
Quoted 64 lines · Tzuyi Chang
Quoted 33 lines
Add the device tree bindings for the Realtek DHC(Digital Home Center) RTD SoCs GPIO controllers.
Signed-off-by Tzuyi Chang <[email protected]>---
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 | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yamldiff --git
a/Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yamlb/Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yamlnew file mode 100644
index 000000000000..11c8278801c3Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +10
-0@@ -0,0 +1,74 @@ +# 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]>Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml line 20
Quoted 10 lines
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +10
-0+ +description: + The GPIO controller is designed for the Realtek DHC (Digital Home +Center) + RTD SoC family, which are high-definition media processor SoCs. + +properties: + compatible: + oneOf: + - items:Drop items.
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml line 32
Quoted 12 lines
Documentation/devicetree/bindings/gpio/realtek,rtd-gpio.yaml new file +12
-0+ - enum: + - realtek,rtd1295-misc-gpio + - realtek,rtd1295-iso-gpio + - realtek,rtd1395-iso-gpio + - realtek,rtd1619-iso-gpio + - items: + - enum: + - realtek,rtd1319-iso-gpio + - realtek,rtd1619b-iso-gpio + - realtek,rtd1319d-iso-gpio + - realtek,rtd1315e-iso-gpio + - const: realtek,rtd-gpioEither you use generic compatible for everything or not. Other variants do not use generic compatible, so neither should these. Use SoC-specific compatible as fallback.
Quoted 6 lines
I asked you to to drop this compatible. I could not be more specific, so you just ignored this remark.
So again: what is "rtd"? Why it does not appear anywhere in description or title? No, drop it.
"rtd" is the product series identifier. I will drop this generic compatible and use SoC-specific compatible instead.
Thanks,
Tzuyi Chang
PATCH v2 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.
---
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 | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-rtd.c | 736 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 746 insertions(+) create mode 100644 drivers/gpio/gpio-rtd.c
drivers/gpio/Kconfig +9 -0
@@ -553,6 +553,15 @@ 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 + Say yes here to support GPIO on Realtek DHC(Digital Home Center) + 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 +736 -0
736 lines not on this page · raw message
Signature · 1 line
2.42.0
kernel test robot
build botRe: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
kernel test robot noticed the following build warnings:
Hi Tzuyi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on robh/for-next linus/master v6.7-rc1 next-20231116] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tzuyi-Chang/dt-bindings-gpio-realtek-Add-realtek-rtd-gpio/20231116-191928 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20231116111441.2339-3-tychang%40realtek.com patch subject: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs. config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20231117/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231117/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_dir' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_dato' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_dati' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_ie' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_dp' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_gpa' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_gpda' not described in 'rtd_gpio_info' >> drivers/gpio/gpio-rtd.c:71: warning: Function parameter or member 'num_deb' not described in 'rtd_gpio_info'
vim +71 drivers/gpio/gpio-rtd.c
34
35 /**
36 * struct rtd_gpio_info - Specific GPIO register information
37 * @name: GPIO device name
38 * @type: RTD GPIO ID
39 * @gpio_base: GPIO base number
40 * @num_gpios: Number of GPIOs
41 * @dir_offset: Offset for GPIO direction registers
42 * @dato_offset: Offset for GPIO data output registers
43 * @dati_offset: Offset for GPIO data input registers
44 * @ie_offset: Offset for GPIO interrupt enable registers
45 * @dp_offset: Offset for GPIO detection polarity registers
46 * @gpa_offset: Offset for GPIO assert interrupt status registers
47 * @gpda_offset: Offset for GPIO deassert interrupt status registers
48 * @deb_offset: Offset for GPIO debounce registers
49 */
50 struct rtd_gpio_info {
51 const char *name;
52 enum rtd_gpio_type type;
53 unsigned int gpio_base;
54 unsigned int num_gpios;
55 u8 *dir_offset;
56 u8 num_dir;
57 u8 *dato_offset;
58 u8 num_dato;
59 u8 *dati_offset;
60 u8 num_dati;
61 u8 *ie_offset;
62 u8 num_ie;
63 u8 *dp_offset;
64 u8 num_dp;
65 u8 *gpa_offset;
66 u8 num_gpa;
67 u8 *gpda_offset;
68 u8 num_gpda;
69 u8 *deb_offset;
70 u8 num_deb;
> 71 };
72 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
In reply to Tzuyi ChangHi Tzuyi,
Quoted 4 lines · Tzuyi Chang
This driver enables configuration of GPIO direction, GPIO values, GPIO debounce settings and handles GPIO interrupts.
Signed-off-by Tzuyi Chang <[email protected]>
Apart from the missing kerneldoc that the autobuilder is complaining about this looks good to me. If you fix the kerneldoc:
Yours,
Linus Walleij
Re: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
Quoted 10 lines · Linus Walleij
Quoted 4 lines · Tzuyi Chang
This driver enables configuration of GPIO direction, GPIO values, GPIO debounce settings and handles GPIO interrupts.
Signed-off-by Tzuyi Chang <[email protected]>Apart from the missing kerneldoc that the autobuilder is complaining about this looks good to me. If you fix the kerneldoc:
Reviewed-by Linus Walleij <[email protected]>
I think I might have comments in the future.
I haven't looked at the series due to noticing LKP complains.
Signature · 2 lines
With Best Regards, Andy Shevchenko
RE: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
Hi Andy,
Quoted 8 lines · Linus Walleij
Quoted 1 line
On Thu, Nov 16, 2023 at 12:14 PM Tzuyi Chang <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines
This driver enables configuration of GPIO direction, GPIO values, GPIO debounce settings and handles GPIO interrupts.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Tzuyi Chang <[email protected]>Apart from the missing kerneldoc that the autobuilder is complaining about this looks good to me. If you fix the kerneldoc:
Reviewed-by Linus Walleij <[email protected]>I think I might have comments in the future.
I haven't looked at the series due to noticing LKP complains.
I will fix the build warning in the next version.
Thanks,
Tzuyi Chang
RE: [PATCH v2 2/2] Add GPIO support for Realtek DHC(Digital Home Center) RTD SoCs.
In reply to Linus WalleijHi Linus,
Thank you for the review. I will revise the kerneldoc in the next version.
Quoted 9 lines
Hi Tzuyi,
Quoted 3 lines · Tzuyi Chang
This driver enables configuration of GPIO direction, GPIO values, GPIO debounce settings and handles GPIO interrupts.
Quoted 8 lines
Quoted 1 line
Signed-off-by Tzuyi Chang <[email protected]>Apart from the missing kerneldoc that the autobuilder is complaining about this looks good to me. If you fix the kerneldoc:
Reviewed-by Linus Walleij <[email protected]>Yours,
Linus Walleij
Thanks,
Tzuyi Chang