Skip to content

Commit

Permalink
drivers: gpio: update k230 gpio driver
Browse files Browse the repository at this point in the history
Signed-off-by: 黄子懿 <[email protected]>
  • Loading branch information
MrThanlon committed Jun 26, 2024
1 parent ff9e431 commit f765315
Show file tree
Hide file tree
Showing 7 changed files with 653 additions and 1,943 deletions.
143 changes: 143 additions & 0 deletions Documentation/devicetree/bindings/gpio/canaan,k230-apb-gpio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/gpio/canaan,k230-apb-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: K230 GPIO controller

description: |
K230 GPIO controllers is based on Synopsys DesignWare GPIO controllers
with out pinctrl required.
maintainers:
- huangziyi <[email protected]>

properties:
$nodename:
pattern: "^gpio@[0-9a-f]+$"

compatible:
const: canaan,k230-apb-gpio

"#address-cells":
const: 1

"#size-cells":
const: 0

reg:
maxItems: 1

patternProperties:
"^gpio-(port|controller)@[0-9a-f]+$":
type: object
properties:
compatible:
const: canaan,k230-apb-gpio-port

reg:
maxItems: 1

gpio-controller: true

'#gpio-cells':
const: 2

gpio-line-names:
const: 32

ngpios:
const: 32

snps,nr-gpios:
description: The number of GPIO pins exported by the port.
deprecated: true
$ref: /schemas/types.yaml#/definitions/uint32
const: 32

interrupts:
description: |
The interrupts to the parent controller raised when GPIOs generate
the interrupts. If the controller provides one combined interrupt
for all GPIOs, specify a single interrupt. If the controller provides
one interrupt for each GPIO, provide a list of interrupts that
correspond to each of the GPIO pins.
const: 32

interrupt-controller: true

'#interrupt-cells':
const: 2

required:
- compatible
- reg
- gpio-controller
- '#gpio-cells'

dependencies:
interrupt-controller: [ interrupts ]

additionalProperties: false

additionalProperties: false

required:
- compatible
- reg
- "#address-cells"
- "#size-cells"

examples:
- |
gpio0: gpio@9140b000 {
compatible = "canaan,k230-apb-gpio";
reg = <0x0 0x9140b000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <0>;
gpio0_ports: gpio-port@0 {
compatible = "canaan,k230-apb-gpio-port";
reg = <0>;
gpio-controller;
#gpio-cells = <2>;
snps,nr-gpios = <32>;
interrupt-controller;
#interrupt-cells = <2>;
interrupts =
<32 IRQ_TYPE_EDGE_RISING>,
<33 IRQ_TYPE_EDGE_RISING>,
<34 IRQ_TYPE_EDGE_RISING>,
<35 IRQ_TYPE_EDGE_RISING>,
<36 IRQ_TYPE_EDGE_RISING>,
<37 IRQ_TYPE_EDGE_RISING>,
<38 IRQ_TYPE_EDGE_RISING>,
<39 IRQ_TYPE_EDGE_RISING>,
<40 IRQ_TYPE_EDGE_RISING>,
<41 IRQ_TYPE_EDGE_RISING>,
<42 IRQ_TYPE_EDGE_RISING>,
<43 IRQ_TYPE_EDGE_RISING>,
<44 IRQ_TYPE_EDGE_RISING>,
<45 IRQ_TYPE_EDGE_RISING>,
<46 IRQ_TYPE_EDGE_RISING>,
<47 IRQ_TYPE_EDGE_RISING>,
<48 IRQ_TYPE_EDGE_RISING>,
<49 IRQ_TYPE_EDGE_RISING>,
<50 IRQ_TYPE_EDGE_RISING>,
<51 IRQ_TYPE_EDGE_RISING>,
<52 IRQ_TYPE_EDGE_RISING>,
<53 IRQ_TYPE_EDGE_RISING>,
<54 IRQ_TYPE_EDGE_RISING>,
<55 IRQ_TYPE_EDGE_RISING>,
<56 IRQ_TYPE_EDGE_RISING>,
<57 IRQ_TYPE_EDGE_RISING>,
<58 IRQ_TYPE_EDGE_RISING>,
<59 IRQ_TYPE_EDGE_RISING>,
<60 IRQ_TYPE_EDGE_RISING>,
<61 IRQ_TYPE_EDGE_RISING>,
<62 IRQ_TYPE_EDGE_RISING>,
<63 IRQ_TYPE_EDGE_RISING>;
};
};
...
160 changes: 157 additions & 3 deletions arch/riscv/boot/dts/canaan/k230.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
sysctl: sysctl {
status = "okay";
#address-cells = <2>;
#size-cells = <2>;
#size-cells = <2>;
compatible = "simple-bus";
ranges;

Expand Down Expand Up @@ -134,7 +134,6 @@
};
};


clint: timer@f04000000 {
compatible = "canaan,k230-clint", "thead,c900-clint";
reg = <0xf 0x04000000 0x0 0x00010000>;
Expand Down Expand Up @@ -214,6 +213,7 @@
g-tx-fifo-size = <512 1024 64 64 64 64>;
status = "disabled";
};

mmc_sd1: sdhci1@91581000 {
compatible = "kendryte,k230-dw-mshc";
reg = <0x0 0x91581000 0x0 0x1000>;
Expand All @@ -228,7 +228,161 @@
//status = "disabled";/*disabled, okay*/
status = "disabled";
};

gpio0: gpio@9140b000 {
compatible = "canaan,k230-apb-gpio";
reg = <0x0 0x9140b000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <0>;

gpio0_ports: gpio-port@0 {
compatible = "canaan,k230-apb-gpio-port";
reg = <0>;
gpio-controller;
#gpio-cells = <2>;
snps,nr-gpios = <32>;
interrupt-controller;
#interrupt-cells = <2>;
interrupts =
<32 IRQ_TYPE_EDGE_RISING>,
<33 IRQ_TYPE_EDGE_RISING>,
<34 IRQ_TYPE_EDGE_RISING>,
<35 IRQ_TYPE_EDGE_RISING>,
<36 IRQ_TYPE_EDGE_RISING>,
<37 IRQ_TYPE_EDGE_RISING>,
<38 IRQ_TYPE_EDGE_RISING>,
<39 IRQ_TYPE_EDGE_RISING>,
<40 IRQ_TYPE_EDGE_RISING>,
<41 IRQ_TYPE_EDGE_RISING>,
<42 IRQ_TYPE_EDGE_RISING>,
<43 IRQ_TYPE_EDGE_RISING>,
<44 IRQ_TYPE_EDGE_RISING>,
<45 IRQ_TYPE_EDGE_RISING>,
<46 IRQ_TYPE_EDGE_RISING>,
<47 IRQ_TYPE_EDGE_RISING>,
<48 IRQ_TYPE_EDGE_RISING>,
<49 IRQ_TYPE_EDGE_RISING>,
<50 IRQ_TYPE_EDGE_RISING>,
<51 IRQ_TYPE_EDGE_RISING>,
<52 IRQ_TYPE_EDGE_RISING>,
<53 IRQ_TYPE_EDGE_RISING>,
<54 IRQ_TYPE_EDGE_RISING>,
<55 IRQ_TYPE_EDGE_RISING>,
<56 IRQ_TYPE_EDGE_RISING>,
<57 IRQ_TYPE_EDGE_RISING>,
<58 IRQ_TYPE_EDGE_RISING>,
<59 IRQ_TYPE_EDGE_RISING>,
<60 IRQ_TYPE_EDGE_RISING>,
<61 IRQ_TYPE_EDGE_RISING>,
<62 IRQ_TYPE_EDGE_RISING>,
<63 IRQ_TYPE_EDGE_RISING>;
};
};

gpio1: gpio@9140c000 {
compatible = "canaan,k230-apb-gpio";
reg = <0x0 0x9140c000 0x0 0x1000>;
#address-cells = <1>;
#size-cells = <0>;

gpio1_ports: gpio-port@0 {
compatible = "canaan,k230-apb-gpio-port";
reg = <0>;
gpio-controller;
#gpio-cells = <2>;
snps,nr-gpios = <32>;
interrupt-controller;
#interrupt-cells = <2>;
interrupts =
<64 IRQ_TYPE_EDGE_RISING>,
<65 IRQ_TYPE_EDGE_RISING>,
<66 IRQ_TYPE_EDGE_RISING>,
<67 IRQ_TYPE_EDGE_RISING>,
<68 IRQ_TYPE_EDGE_RISING>,
<69 IRQ_TYPE_EDGE_RISING>,
<70 IRQ_TYPE_EDGE_RISING>,
<71 IRQ_TYPE_EDGE_RISING>,
<72 IRQ_TYPE_EDGE_RISING>,
<73 IRQ_TYPE_EDGE_RISING>,
<74 IRQ_TYPE_EDGE_RISING>,
<75 IRQ_TYPE_EDGE_RISING>,
<76 IRQ_TYPE_EDGE_RISING>,
<77 IRQ_TYPE_EDGE_RISING>,
<78 IRQ_TYPE_EDGE_RISING>,
<79 IRQ_TYPE_EDGE_RISING>,
<80 IRQ_TYPE_EDGE_RISING>,
<81 IRQ_TYPE_EDGE_RISING>,
<82 IRQ_TYPE_EDGE_RISING>,
<83 IRQ_TYPE_EDGE_RISING>,
<84 IRQ_TYPE_EDGE_RISING>,
<85 IRQ_TYPE_EDGE_RISING>,
<86 IRQ_TYPE_EDGE_RISING>,
<87 IRQ_TYPE_EDGE_RISING>,
<88 IRQ_TYPE_EDGE_RISING>,
<89 IRQ_TYPE_EDGE_RISING>,
<90 IRQ_TYPE_EDGE_RISING>,
<91 IRQ_TYPE_EDGE_RISING>,
<92 IRQ_TYPE_EDGE_RISING>,
<93 IRQ_TYPE_EDGE_RISING>,
<94 IRQ_TYPE_EDGE_RISING>,
<95 IRQ_TYPE_EDGE_RISING>;
};
};

i2c0: i2c@91405000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0x0 0x91405000 0x0 0x1000>;
interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&i2c0_clk>;
clock-frequency = <100000>;
status = "disabled";
};

i2c1: i2c@91406000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0x0 0x91406000 0x0 0x1000>;
interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&i2c1_clk>;
clock-frequency = <400000>;
status = "disabled";
};

i2c2: i2c@91407000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0x0 0x91407000 0x0 0x1000>;
interrupts = <23 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&i2c2_clk>;
clock-frequency = <400000>;
status = "disabled";
};

i2c3: i2c@91408000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0x0 0x91408000 0x0 0x1000>;
interrupts = <24 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&i2c3_clk>;
clock-frequency = <400000>;
status = "disabled";
};

i2c4: i2c@91409000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0x0 0x91409000 0x0 0x1000>;
interrupts = <25 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&i2c4_clk>;
clock-frequency = <400000>;
status = "disabled";
};
};
};
#include "k230_gpio_provider.dtsi"
#include "k230_clock_provider.dtsi"
Loading

0 comments on commit f765315

Please sign in to comment.