Skip to content

Commit

Permalink
pinctrl: Add support for Kendryte K210 FPIOA
Browse files Browse the repository at this point in the history
The Fully-Programmable Input/Output Array (FPIOA) device controls pin
multiplexing on the K210. The FPIOA can remap any supported function to any
multifunctional IO pin. It can also perform basic GPIO functions, such as
reading the current value of a pin. However, GPIO functionality remains
largely unimplemented (in favor of the dedicated GPIO peripherals).

Signed-off-by: Sean Anderson <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
Forty-Bot authored and trini committed Oct 8, 2020
1 parent 7f0f180 commit 7224d5c
Show file tree
Hide file tree
Showing 6 changed files with 1,126 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,9 @@ RISC-V KENDRYTE
M: Sean Anderson <[email protected]>
S: Maintained
F: doc/device-tree-bindings/mfd/kendryte,k210-sysctl.txt
F: doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt
F: drivers/clk/kendryte/
F: drivers/pinctrl/kendryte/
F: include/kendryte/

RNG
Expand Down
102 changes: 102 additions & 0 deletions doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
Kendryte K210 FPIOA

This binding describes the Fully-Programmable Input/Output Array (FPIOA) found
in Kendryte K210 SoCs. Any of the 256 functions can be mapped to any of the 48
pins.

Required properties:
- compatible: should be "kendryte,k210-fpioa"
- reg: address and length of the FPIOA registers
- kendryte,sysctl: phandle to the "sysctl" register map node
- kendryte,power-offset: offset in the register map of the power bank control
register (in bytes)

Configuration nodes

Pin configuration nodes are documented in pinctrl-bindings.txt

Required properties for pin-configuration nodes or sub-nodes are:
- groups: list of power groups to which the configuration applies. Valid groups
are:
A0, A1, A2, B0, B1, B2, C0, C1
(either this or "pinmux" must be specified)
- pinmux: integer array representing pin multiplexing configuration. In addition
to the 256 standard functions, each pin can also output the direction
indicator (DO) of any function. This signal is high whenever the function
would normally drive the output. Helper macros to ease assembling the "pinmux"
arguments from the pin and function are provided by the FPIOA header file at:
<dt-bindings/pinctrl/k210-pinctrl.h>
Integer values in the "pinmux" argument list are assembled as:
((PIN << 16) | (DO << 8) | (FUNC))
Valid values for PIN are numbers 0 through 47.
Valid values for DO are 0 or 1.
Valid values for FUNC are numbers 0 through 255. For a complete list of
acceptable functions, consult the FPIOA header file.
(either this or "groups" must be specified)

Optional properties for "pinmux" nodes are:
bias-disable, bias-pull-down, bias-pull-up, drive-strength,
drive-strength-ua, input-enable, input-disable, input-schmitt-enable,
input-schmitt-disable, output-low, output-high, output-enable,
output-disable, slew-rate, output-polarity-invert, input-polarity-invert

Optional properties for "groups" nodes are:
power-source

Notes on specific properties include:
- bias-pull-up, -down, and -pin-default: The pull strength cannot be configured.
- drive-strength: There are 8 drive strength settings between 11 and 50 mA.
- input- and output-polarity-invert: Invert the polarity of either the input or
the output, respectively.
- power-source: Controls the output voltage of a bank of pins. Either
K210_PC_POWER_1V8 or K210_PC_POWER_3V3 may be specified.
- slew-rate: Specifying this property reduces the slew rate.

Example:
fpioa: pinmux@502B0000 {
compatible = "kendryte,k210-fpioa";
reg = <0x502B0000 0x100>;
kendryte,sysctl = <&sysctl>;
kendryte,power-offset = <K210_SYSCTL_POWER_SEL>;

/* JTAG running at 3.3V and driven at 11 mA */
fpioa_jtag: jtag {
voltage {
group = "A0";
power-source = <K210_PC_POWER_3V3>;
};

jtag {
pinmux = <K210_FPIOA(0, K210_PCF_JTAG_TCK)>,
<K210_FPIOA(1, K210_PCF_JTAG_TDI)>,
<K210_FPIOA(2, K210_PCF_JTAG_TMS)>,
<K210_FPIOA(3, K210_PCF_JTAG_TDO)>;
drive-strength = <11>;
}
};

/* I2C configured for use with a TCA9800 level shifter */
fpioa_i2c: i2c {
i2c {
pinmux = <K210_FPIOA(6, K210_PCF_I2C0_SCLK)>,
<K210_FPIOA(7, K210_PCF_I2C0_SDA)>;
};

direction {
pinmux = <K210_FPIOA_DO(8, K210_PCF_I2C0_SDA)>;
output-polarity-invert;
};
};

/* UART with an active-high TX status LED */
fpioa_uart1: uart1 {
uart {
pinmux = <K210_FPIOA(9, K210_PCF_UART1_TX)>,
<K210_FPIOA(10, K210_PCF_UART1_RX)>;
};

status {
pinmux = <K210_FPIOA_DO(11, K210_PCF_UART1_TX)>;
};
};
};
7 changes: 7 additions & 0 deletions drivers/pinctrl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ config ASPEED_AST2500_PINCTRL
uses Generic Pinctrl framework and is compatible with the Linux
driver, i.e. it uses the same device tree configuration.

config PINCTRL_K210
bool "Kendryte K210 Fully-Programmable Input/Output Array driver"
depends on DM && PINCTRL_GENERIC
help
Support pin multiplexing on the K210. The "FPIOA" can remap any
supported function to any multifunctional IO pin. It can also perform
basic GPIO functions, such as reading the current value of a pin.
endif

source "drivers/pinctrl/broadcom/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/pinctrl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ obj-$(CONFIG_PINCTRL_SANDBOX) += pinctrl-sandbox.o
obj-$(CONFIG_PINCTRL_UNIPHIER) += uniphier/
obj-$(CONFIG_PINCTRL_PIC32) += pinctrl_pic32.o
obj-$(CONFIG_PINCTRL_EXYNOS) += exynos/
obj-$(CONFIG_PINCTRL_K210) += pinctrl-kendryte.o
obj-$(CONFIG_PINCTRL_MESON) += meson/
obj-$(CONFIG_PINCTRL_MTK) += mediatek/
obj-$(CONFIG_PINCTRL_MSCC) += mscc/
Expand Down
Loading

0 comments on commit 7224d5c

Please sign in to comment.