Skip to contentSkip to conversation

gpio: Add support for IDT 79RC3243x GPIO controller

PATCH Superseded Thomas Bogendoerfer 2 participants 9 messages Apr 20, 2021 – Apr 21, 2021 1 message not in the archive

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gpio: Add support for IDT 79RC3243x GPIO controller

IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as interrupt source.

---
 drivers/gpio/Kconfig         |  10 ++
 drivers/gpio/Makefile        |   1 +
 drivers/gpio/gpio-idt3243x.c | 210 +++++++++++++++++++++++++++++++++++
 3 files changed, 221 insertions(+)
 create mode 100644 drivers/gpio/gpio-idt3243x.c
drivers/gpio/Kconfig +10 -0
index e3607ec4c2e8..6847a06ffcfe 100644
@@ -770,6 +770,16 @@ config GPIO_MSC313
 	  Say Y here to support the main GPIO block on MStar/SigmaStar
 	  ARMv7 based SoCs.
 
+config GPIO_IDT3243X
+	bool "IDT 79RC3243X GPIO support"
+	default y if MIKROTIK_RB532
+	depends on MIKROTIK_RB532 || COMPILE_TEST
+	select GPIO_GENERIC
+	select GPIOLIB_IRQCHIP
+	help
+	  Select this option to enable GPIO driver for
+	  IDT 79RC3243X SoC devices.
+
 endmenu
 
 menu "Port-mapped I/O GPIO drivers"
drivers/gpio/Makefile +1 -0
index c58a90a3c3b1..75dd9c5665c5 100644
@@ -67,6 +67,7 @@ obj-$(CONFIG_GPIO_HISI)                 += gpio-hisi.o
 obj-$(CONFIG_GPIO_HLWD)			+= gpio-hlwd.o
 obj-$(CONFIG_HTC_EGPIO)			+= gpio-htc-egpio.o
 obj-$(CONFIG_GPIO_ICH)			+= gpio-ich.o
+obj-$(CONFIG_GPIO_IDT3243X)		+= gpio-idt3243x.o
 obj-$(CONFIG_GPIO_IOP)			+= gpio-iop.o
 obj-$(CONFIG_GPIO_IT87)			+= gpio-it87.o
 obj-$(CONFIG_GPIO_IXP4XX)		+= gpio-ixp4xx.o
drivers/gpio/gpio-idt3243x.c new file +210 -0

210 lines not on this page · raw message

Signature · 1 line
2.29.2
#1 lore raw

PATCH 2/2 dt-bindings: gpio: Add devicetree binding for IDT 79RC3243x GPIO controller

Add YAML devicetree binding for IDT 79RC3243x GPIO controller

---
 .../bindings/gpio/gpio-idt3243x.yaml          | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-idt3243x.yaml
Documentation/devicetree/bindings/gpio/gpio-idt3243x.yaml new file +73 -0
new file mode 100644
index 000000000000..346a57ef8298
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/gpio/gpio-idt3243x.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: IDT 79RC32434x GPIO controller
+
+maintainers:
+  - Thomas Bogendoerfer <[email protected]>
+
+properties:
+  compatible:
+    const: idt,3243x-gpio
+
+  reg:
+    maxItems: 2
+
+  reg-names:
+    items:
+      - const: gpio
+      - const: pic
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  ngpios:
+    description:
+      Number of available gpios in a bank.
+    minimum: 1
+    maximum: 32
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - gpio-controller
+  - "#gpio-cells"
+  - ngpios
+  - interrupt-controller
+  - "#interrupt-cells"
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    gpio0: interrupt-controller@50000 {
+        compatible = "idt,3243x-gpio";
+        reg = <0x50000 0x14>, <0x38030 0x0c>;
+        reg-names = "gpio", "pic";
+
+        interrupt-controller;
+        #interrupt-cells = <2>;
+
+        interrupt-parent = <&cpuintc>;
+        interrupts = <6>;
+
+        gpio-controller;
+        #gpio-cells = <2>;
+
+        ngpios = <14>;
+    };
Signature · 1 line
2.29.2

A message that is not in the archive (sent off-list or not yet received): CAHp75VcQ4WXm3uS2r=uDpA4+0vPWdKjev6=vV_JDxMLPzpHDRw@mail.gmail.com

#3 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Thomas Bogendoerfer

IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as interrupt source.

I would recommend looking for latest new drivers in GPIO subsystem to see how you may improve yours.

Could give me a better pointer to it ? I looked at a lot of gpio driver and took what fitted best.

Quoted 1 line

Here just one question, why it can not be a module

that's probably doable...

Quoted 1 line

why arch_initcall() is used

without that interrupts weren't avaiable early enough.

Quoted 2 lines

and why you put a dead code into it (see the first part of the question)?

hmm, pointer please ?

Quoted 1 line

I will perform a deep review later on.

thank you.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#4 lore raw
Quoted 19 lines · Thomas Bogendoerfer
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Thomas Bogendoerfer

IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as interrupt source.

I would recommend looking for latest new drivers in GPIO subsystem to see how you may improve yours.

Could give me a better pointer to it ? I looked at a lot of gpio driver and took what fitted best.

Quoted 1 line

Here just one question, why it can not be a module

that's probably doable...

Quoted 8 lines
Quoted 1 line

why arch_initcall() is used

without that interrupts weren't avaiable early enough.

Quoted 2 lines

and why you put a dead code into it (see the first part of the question)?

hmm, pointer please ?

It's already in the question above, do your homework :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 23 lines · Andy Shevchenko
Quoted 21 lines · Thomas Bogendoerfer
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Thomas Bogendoerfer

IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as interrupt source.

I would recommend looking for latest new drivers in GPIO subsystem to see how you may improve yours.

Could give me a better pointer to it ? I looked at a lot of gpio driver and took what fitted best.

Quoted 1 line

Here just one question, why it can not be a module

that's probably doable...

Quoted 1 line

why arch_initcall() is used

Quoted 8 lines
Quoted 6 lines

without that interrupts weren't avaiable early enough.

Quoted 2 lines

and why you put a dead code into it (see the first part of the question)?

hmm, pointer please ?

It's already in the question above, do your homework :-)

is this some sort of joke I'm not getting ?

git log --oneline drivers/gpio/Makefile

2ad74f40dacc gpio: visconti: Add Toshiba Visconti GPIO support

that's the latest driver added in v5.12-rc8. Is that a good one ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#6 lore raw
Quoted 26 lines · Thomas Bogendoerfer
Quoted 25 lines · Andy Shevchenko
Quoted 23 lines · Thomas Bogendoerfer
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Thomas Bogendoerfer

IDT 79RC3243x SoCs integrated a gpio controller, which handles up to 32 gpios. All gpios could be used as interrupt source.

I would recommend looking for latest new drivers in GPIO subsystem to see how you may improve yours.

Could give me a better pointer to it ? I looked at a lot of gpio driver and took what fitted best.

Quoted 1 line

Here just one question, why it can not be a module

that's probably doable...

Quoted 1 line

why arch_initcall() is used

without that interrupts weren't avaiable early enough.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

and why you put a dead code into it (see the first part of the question)?

hmm, pointer please ?

It's already in the question above, do your homework :-)

is this some sort of joke I'm not getting ?

Maybe, but no, it's not a joke. You asked where the dead code is. I answered that you as the author of the code should have a better understanding of what you are doing. I can admit that it's hard to cover all aspects of the kernel programming in one go, but at least this part is a low hanging fruit.

As I promised you, I will do a deep review later on, I'm giving you time to find issues yourself. That's how you may actually learn the things. It's solely your choice to follow or not, my promise will be kept and you will get an answer anyway.

Quoted 5 lines

git log --oneline drivers/gpio/Makefile

2ad74f40dacc gpio: visconti: Add Toshiba Visconti GPIO support

that's the latest driver added in v5.12-rc8. Is that a good one ?

Briefly looking, I haven't found any problems with that code. It looks neat.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
Quoted 4 lines · Andy Shevchenko

As I promised you, I will do a deep review later on, I'm giving you time to find issues yourself. That's how you may actually learn the things. It's solely your choice to follow or not, my promise will be kept and you will get an answer anyway.

so let's make it a challenge ;-)

I see I could use gpiochip_get_data() in few place.

Is there more you see ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#8 lore raw
Quoted 7 lines · Thomas Bogendoerfer
Quoted 4 lines · Andy Shevchenko

As I promised you, I will do a deep review later on, I'm giving you time to find issues yourself. That's how you may actually learn the things. It's solely your choice to follow or not, my promise will be kept and you will get an answer anyway.

Quoted 5 lines

so let's make it a challenge ;-)

I see I could use gpiochip_get_data() in few place.

Is there more you see ?

Good.

For now:
- dead code due to driver not being compiled as module
- too verbose Kconfig machinery (it's not about the "help" part!)
- open coded stuff in IRQ handler
- whatever you found.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Thomas Bogendoerfer
Quoted 4 lines · Andy Shevchenko

As I promised you, I will do a deep review later on, I'm giving you time to find issues yourself. That's how you may actually learn the things. It's solely your choice to follow or not, my promise will be kept and you will get an answer anyway.

so let's make it a challenge ;-)

Quoted 8 lines
Quoted 3 lines

I see I could use gpiochip_get_data() in few place.

Is there more you see ?

Good.

For now:
- dead code due to driver not being compiled as module

Can you explain, why it's dead code, if it's not compilable as module ?

Quoted 1 line

- too verbose Kconfig machinery (it's not about the "help" part!)

the default y part ? Well I'm converting the MIPS rb532 platform to device tree. So I'm trying to make the whole process as bisectable as possible. And this would help, but I've no problem dropping that.

Quoted 1 line

- open coded stuff in IRQ handler

done.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]