riscv: Add FPIOA and GPIO support for Kendryte K210
Subsystems (4)
v6 cover riscv: Add FPIOA and GPIO support for Kendryte K210
This patch series adds support for pinmuxing, gpios, buttons, and leds on the Kendyte K210.
The fail-to-boot bug should be fixed by the timer driver cleanup patch :)
This patch series was previously part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
This series depends on
https://patchwork.ozlabs.org/project/uboot/list/?series=200642
Changes in v6:
- Add BOOT button binding
- Add dependency on "riscv: Clean up timer drivers", which fixes the bugs discovered earlier.
- DM_TESTF_SCAN_FDT -> UT_TESTF_SCAN_FDT
- Reformat documentation so sphinx likes it better
- Remove CONFIG_LOGLEVEL hack
- Reorganize driver to use one file, instead of creating a new directory
Changes in v5:
- Increase CONFIG_LOGLEVEL to 5 as a hack to get the board booting again
- Patch 05/12 "gpio: sifive: Use generic reg read function" has been superseded by commit 2548493ab4.
- Rebase onto u-boot/master
Changes in v4:
- Add sandbox dt-binding headers to MAINTAINERS
- Add test for led behavior
- Add test/dm/pinmux.c to patch
- Move sandbox_* variables into a priv structure. This resets them to the default state every time we re-probe.
- Reformat documentation in dm/pinctrl.h
Changes in v3:
- Add dt-bindings/pinctrl/sandbox-pinmux.h to patch
Changes in v2:
- Add test for pinmuxing
- Don't clear existing pinctrl settings on probe
- Re-order GPIOs to match the defaults more closely
- Rebase onto v13 of "riscv: Add Sipeed Maix support"
- Rewrite FPIOA driver to use pinmux property
- Support muxing the output enable signal for each function in the FPIOA
- Support output and input inversion in the pinmux driver
- Support pinmux property in pinctrl-generic
Heinrich Schuchardt (1):
riscv: add DT binding for BOOT button on Maix board
Sean Anderson (11):
pinctrl: Add pinmux property support to pinctrl-generic
pinctrl: Reformat documentation in dm/pinctrl.h
test: pinmux: Add test for pin muxing
pinctrl: Add support for Kendryte K210 FPIOA
gpio: dw: Fix warnings about casting int to pointer
gpio: dw: Add a trailing underscore to generated name
gpio: dw: Return output value when direction is out
led: gpio: Default to using node name if label is absent
test: dm: Test for default led naming
riscv: Add pinmux and gpio bindings for Kendryte K210
riscv: Add FPIOA and GPIO support for Kendryte K210
MAINTAINERS | 3 + arch/riscv/dts/k210-maix-bit.dts | 115 +++ arch/riscv/dts/k210.dtsi | 12 + arch/sandbox/dts/test.dts | 47 +- board/sipeed/maix/Kconfig | 9 + doc/api/index.rst | 1 + doc/api/pinctrl.rst | 7 + doc/board/sipeed/maix.rst | 64 +- .../pinctrl/kendryte,k210-fpioa.txt | 102 +++ .../pinctrl/pinctrl-bindings.txt | 65 +- drivers/gpio/dwapb_gpio.c | 33 +- drivers/led/led_gpio.c | 7 +- drivers/pinctrl/Kconfig | 7 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-generic.c | 125 ++- drivers/pinctrl/pinctrl-kendryte.c | 737 ++++++++++++++++++ drivers/pinctrl/pinctrl-sandbox.c | 186 +++-- include/dm/pinctrl.h | 498 ++++++++---- include/dt-bindings/pinctrl/k210-pinctrl.h | 277 +++++++ include/dt-bindings/pinctrl/sandbox-pinmux.h | 19 + test/dm/Makefile | 3 + test/dm/led.c | 3 +- test/dm/pinmux.c | 57 ++ test/py/tests/test_pinmux.py | 36 +- 24 files changed, 2129 insertions(+), 285 deletions(-) create mode 100644 doc/api/pinctrl.rst create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt create mode 100644 drivers/pinctrl/pinctrl-kendryte.c create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h create mode 100644 include/dt-bindings/pinctrl/sandbox-pinmux.h create mode 100644 test/dm/pinmux.c
Signature · 1 line
2.28.0
PATCH v6 1/12 pinctrl: Add pinmux property support to pinctrl-generic
The pinmux property allows for smaller and more compact device trees, especially when there are many pins which need to be assigned individually. Instead of specifying an array of strings to be parsed as pins and a function property, the pinmux property contains an array of integers representing pinmux groups. A pinmux group consists of the pin identifier and mux settings represented as a single integer or an array of integers. Each individual pin controller driver specifies the exact format of a pinmux group. As specified in the Linux documentation, a pinmux group may be multiple integers long. However, no existing drivers use multi-integer pinmux groups, so I have chosen to omit this feature. This makes the implementation easier, since there is no need to allocate a buffer to do endian conversions.
Support for the pinmux property is done differently than in Linux. As far as I can tell, inversion of control is used when implementing support for the pins and groups properties to avoid allocating. This results in some duplication of effort; every property in a config node is parsed once for each pin in that node. This is not such an overhead with pins and groups properties, since having multiple pins in one config node does not occur especially often. However, the semantics of the pinmux property make such a configuration much more appealing. A future patch could parse all config properties at once and store them in an array. This would make it easier to create drivers which do not function solely as callbacks from pinctrl-generic.
This commit increases the size of the sandbox build by approximately 48 bytes. However, it also decreases the size of the K210 device tree by 2 KiB from the previous version of this series.
The documentation has been updated from the last Linux commit before it was split off into yaml files.
---
(no changes since v2)
Changes in v2:
- New
.../pinctrl/pinctrl-bindings.txt | 65 ++++++++- drivers/pinctrl/pinctrl-generic.c | 125 ++++++++++++++---- include/dm/pinctrl.h | 21 +-- 3 files changed, 168 insertions(+), 43 deletions(-)
doc/device-tree-bindings/pinctrl/pinctrl-bindings.txt +59 -6
@@ -119,7 +119,8 @@ For example: The contents of each of those pin configuration child nodes is defined entirely by the binding for the individual pin controller device. There -exists no common standard for this content. +exists no common standard for this content. The pinctrl framework only +provides generic helper bindings that the pin controller driver can use. The pin configuration nodes need not be direct children of the pin controller device; they may be grandchildren, for example. Whether this is legal, and
@@ -156,6 +157,29 @@ state_2_node_a { pins = "mfio29", "mfio30"; }; +For hardware where pin multiplexing configurations have to be specified for +each single pin the number of required sub-nodes containing "pin" and +"function" properties can quickly escalate and become hard to write and +maintain. + +For cases like this, the pin controller driver may use the pinmux helper +property, where the pin identifier is provided with mux configuration settings +in a pinmux group. A pinmux group consists of the pin identifier and mux +settings represented as a single integer or an array of integers. + +The pinmux property accepts an array of pinmux groups, each of them describing +a single pin multiplexing configuration. + +pincontroller { + state_0_node_a { + pinmux = <PINMUX_GROUP>, <PINMUX_GROUP>, ...; + }; +}; + +Each individual pin controller driver bindings documentation shall specify +how pin IDs and pin multiplexing configuration are defined and assembled +together in a pinmux group. + == Generic pin configuration node content == Many data items that are represented in a pin configuration node are common
@@ -168,12 +192,15 @@ structure of the DT nodes that contain these properties. Supported generic properties are: pins - the list of pins that properties in the node - apply to (either this or "group" has to be + apply to (either this, "group" or "pinmux" has to be specified) group - the group to apply the properties to, if the driver supports configuration of whole groups rather than - individual pins (either this or "pins" has to be - specified) + individual pins (either this, "pins" or "pinmux" has + to be specified) +pinmux - the list of numeric pin ids and their mux settings + that properties in the node apply to (either this, + "pins" or "groups" have to be specified) bias-disable - disable any pin bias bias-high-impedance - high impedance mode ("third-state", "floating") bias-bus-hold - latch weakly
@@ -184,17 +211,30 @@ drive-push-pull - drive actively high and low drive-open-drain - drive with open drain drive-open-source - drive with open source drive-strength - sink or source at most X mA -input-enable - enable input on pin (no effect on output) -input-disable - disable input on pin (no effect on output) +drive-strength-microamp - sink or source at most X uA +input-enable - enable input on pin (no effect on output, such as + enabling an input buffer) +input-disable - disable input on pin (no effect on output, such as + disabling an input buffer) input-schmitt-enable - enable schmitt-trigger mode input-schmitt-disable - disable schmitt-trigger mode input-debounce - debounce mode with debound time X power-source - select between different power supplies low-power-enable - enable low power mode low-power-disable - disable low power mode +output-disable - disable output on a pin (such as disable an output + buffer) +output-enable - enable output on a pin without actively driving it + (such as enabling an output buffer) output-low - set the pin to output mode with low level output-high - set the pin to output mode with high level +sleep-hardware-state - indicate this is sleep related state which will be programmed + into the registers for the sleep state. slew-rate - set the slew rate +skew-delay - this affects the expected clock skew on input pins + and the delay before latching a value to an output + pin. Typically indicates how many double-inverters are + used to delay the signal. For example:
@@ -216,6 +256,12 @@ state_2_node_a { bias-pull-up; }; }; +state_3_node_a { + mux { + pinmux = <GPIOx_PINm_MUXn>, <GPIOx_PINj_MUXk)>; + input-enable; + }; +}; Some of the generic properties take arguments. For those that do, the arguments are described below.
@@ -224,11 +270,18 @@ arguments are described below. binding for the hardware defines: - Whether the entries are integers or strings, and their meaning. +- pinmux takes a list of pin IDs and mux settings as required argument. The + specific bindings for the hardware defines: + - How pin IDs and mux settings are defined and assembled together in a single + integer or an array of integers. + - bias-pull-up, -down and -pin-default take as optional argument on hardware supporting it the pull strength in Ohm. bias-disable will disable the pull. - drive-strength takes as argument the target strength in mA. +- drive-strength-microamp takes as argument the target strength in uA. + - input-debounce takes the debounce time in usec as argument or 0 to disable debouncing
drivers/pinctrl/pinctrl-generic.c +96 -29
183 lines not on this page · raw message
include/dm/pinctrl.h +13 -8
@@ -34,29 +34,33 @@ struct pinconf_param {* depending on your necessity. * * @get_pins_count: return number of selectable named pins available -* in this driver. (necessary to parse "pins" property in DTS) +* in this driver. (necessary to parse "pins" property in DTS) * @get_pin_name: return the pin name of the pin selector, * called by the core to figure out which pin it shall do -* operations to. (necessary to parse "pins" property in DTS) +* operations to. (necessary to parse "pins" property in DTS) * @get_groups_count: return number of selectable named groups available -* in this driver. (necessary to parse "groups" property in DTS) +* in this driver. (necessary to parse "groups" property in DTS) * @get_group_name: return the group name of the group selector, * called by the core to figure out which pin group it shall do -* operations to. (necessary to parse "groups" property in DTS) +* operations to. (necessary to parse "groups" property in DTS) * @get_functions_count: return number of selectable named functions available -* in this driver. (necessary for pin-muxing) +* in this driver. (necessary for pin-muxing) * @get_function_name: return the function name of the muxing selector, * called by the core to figure out which mux setting it shall map a -* certain device to. (necessary for pin-muxing) +* certain device to. (necessary for pin-muxing) * @pinmux_set: enable a certain muxing function with a certain pin. * The @func_selector selects a certain function whereas @pin_selector * selects a certain pin to be used. On simple controllers one of them -* may be ignored. (necessary for pin-muxing against a single pin) +* may be ignored. (necessary for pin-muxing against a single pin) * @pinmux_group_set: enable a certain muxing function with a certain pin -* group. The @func_selector selects a certain function whereas +* group. The @func_selector selects a certain function whereas * @group_selector selects a certain set of pins to be used. On simple * controllers one of them may be ignored. * (necessary for pin-muxing against a pin group) +* @pinmux_property_set: enable a pinmux group. @pinmux_group should specify the +* pin identifier and mux settings. The exact format of a pinmux group is +* left up to the driver. The pin selector for the mux-ed pin should be +* returned on success. (necessary to parse the "pinmux" property in DTS) * @pinconf_num_params: number of driver-specific parameters to be parsed * from device trees (necessary for pin-configuration) * @pinconf_params: list of driver_specific parameters to be parsed from
@@ -90,6 +94,7 @@ struct pinctrl_ops { unsigned func_selector);int (*pinmux_group_set)(struct udevice *dev,unsigned group_selector,unsigned func_selector); +int (*pinmux_property_set)(struct udevice *dev,u32 pinmux_group);unsigned int pinconf_num_params;const struct pinconf_param *pinconf_params; int (*pinconf_set)(struct udevice *dev, unsigned pin_selector,
Signature · 1 line
2.28.0
PATCH v6 1/12 pinctrl: Add pinmux property support to pinctrl-generic
Quoted 29 lines · Sean Anderson
The pinmux property allows for smaller and more compact device trees, especially when there are many pins which need to be assigned individually. Instead of specifying an array of strings to be parsed as pins and a function property, the pinmux property contains an array of integers representing pinmux groups. A pinmux group consists of the pin identifier and mux settings represented as a single integer or an array of integers. Each individual pin controller driver specifies the exact format of a pinmux group. As specified in the Linux documentation, a pinmux group may be multiple integers long. However, no existing drivers use multi-integer pinmux groups, so I have chosen to omit this feature. This makes the implementation easier, since there is no need to allocate a buffer to do endian conversions.
Support for the pinmux property is done differently than in Linux. As far as I can tell, inversion of control is used when implementing support for the pins and groups properties to avoid allocating. This results in some duplication of effort; every property in a config node is parsed once for each pin in that node. This is not such an overhead with pins and groups properties, since having multiple pins in one config node does not occur especially often. However, the semantics of the pinmux property make such a configuration much more appealing. A future patch could parse all config properties at once and store them in an array. This would make it easier to create drivers which do not function solely as callbacks from pinctrl-generic.
This commit increases the size of the sandbox build by approximately 48 bytes. However, it also decreases the size of the K210 device tree by 2 KiB from the previous version of this series.
Quoted 5 lines
The documentation has been updated from the last Linux commit before it was split off into yaml files.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/a0beb5f2/attachment.sig>
PATCH v6 2/12 pinctrl: Reformat documentation in dm/pinctrl.h
In reply to Sean AndersonThis normalizes the documentation to conform to kernel-doc style [1]. It also moves the documentation for pinctrl_ops inline, and adds argument and return-value documentation. I have kept the usual function style for these comments. I could not find any existing examples of function documentation inside structs.
[1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html
---
Changes in v6:
- Reformat documentation so sphinx likes it better
Changes in v4:
- New
doc/api/index.rst | 1 + doc/api/pinctrl.rst | 7 + include/dm/pinctrl.h | 501 +++++++++++++++++++++++++++++-------------- 3 files changed, 347 insertions(+), 162 deletions(-) create mode 100644 doc/api/pinctrl.rst
doc/api/index.rst +1 -0
@@ -9,6 +9,7 @@ U-Boot API documentation dfu efi linker_lists + pinctrl rng serial unicode
doc/api/pinctrl.rst new file +7 -0
@@ -0,0 +1,7 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Pinctrl and Pinmux +================== + +.. kernel-doc:: include/dm/pinctrl.h + :internal:
include/dm/pinctrl.h +339 -162
737 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH v6 2/12 pinctrl: Reformat documentation in dm/pinctrl.h
Quoted 10 lines · Sean Anderson
This normalizes the documentation to conform to kernel-doc style [1]. It also moves the documentation for
pinctrl_opsinline, and adds argument and return-value documentation. I have kept the usual function style for these comments. I could not find any existing examples of function documentation inside structs.[1] https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/ce2c8b82/attachment.sig>
PATCH v6 3/12 test: pinmux: Add test for pin muxing
In reply to Sean AndersonThis extends the pinctrl-sandbox driver to support pin muxing, and adds a test for that behaviour. The test is done in C and not python (like the existing tests for the pinctrl uclass) because it needs to call pinctrl_select_state. Another option could be to add a command that invokes pinctrl_select_state and then test everything in test/py/tests/test_pinmux.py.
The pinctrl-sandbox driver now mimics the way that many pinmux devices work. There are two groups of pins which are muxed together, as well as four pins which are muxed individually. I have tried to test all normal paths. However, very few error cases are explicitly checked for.
---
Changes in v6:
- DM_TESTF_SCAN_FDT -> UT_TESTF_SCAN_FDT
Changes in v4:
- Add sandbox dt-binding headers to MAINTAINERS
- Add test/dm/pinmux.c to patch
- Move sandbox_* variables into a priv structure. This resets them to the default state every time we re-probe.
Changes in v3:
- Add dt-bindings/pinctrl/sandbox-pinmux.h to patch
Changes in v2:
- New
MAINTAINERS | 1 + arch/sandbox/dts/test.dts | 45 ++++- drivers/pinctrl/pinctrl-sandbox.c | 186 ++++++++++++++----- include/dt-bindings/pinctrl/sandbox-pinmux.h | 19 ++ test/dm/Makefile | 3 + test/dm/pinmux.c | 57 ++++++ test/py/tests/test_pinmux.py | 36 ++-- 7 files changed, 274 insertions(+), 73 deletions(-) create mode 100644 include/dt-bindings/pinctrl/sandbox-pinmux.h create mode 100644 test/dm/pinmux.c
MAINTAINERS +1 -0
@@ -951,6 +951,7 @@ SANDBOX M: Simon Glass <[email protected]> S: Maintained F: arch/sandbox/ +F: include/dt-bindings/*/sandbox*.h SH M: Marek Vasut <[email protected]>
arch/sandbox/dts/test.dts +38 -7
74 lines not on this page · raw message
drivers/pinctrl/pinctrl-sandbox.c +138 -48
268 lines not on this page · raw message
include/dt-bindings/pinctrl/sandbox-pinmux.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020 Sean Anderson <[email protected]> +*/ + +#ifndef SANDBOX_PINMUX_H +#define SANDBOX_PINMUX_H + +#define SANDBOX_PINMUX_UART 0 +#define SANDBOX_PINMUX_I2C 1 +#define SANDBOX_PINMUX_SPI 2 +#define SANDBOX_PINMUX_I2S 3 +#define SANDBOX_PINMUX_GPIO 4 +#define SANDBOX_PINMUX_CS 5 +#define SANDBOX_PINMUX_PWM 6 + +#define SANDBOX_PINMUX (pin, func) ((func) << 16 | (pin)) + +#endif /* SANDBOX_PINMUX_H */
test/dm/Makefile +3 -0
@@ -80,4 +80,7 @@ obj-$(CONFIG_DM_RNG) += rng.o obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o +ifneq ($(CONFIG_PINMUX),) +obj-$(CONFIG_PINCONF) += pinmux.o +endif endif
test/dm/pinmux.c new file +57 -0
57 lines not on this page · raw message
test/py/tests/test_pinmux.py +18 -18
@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console): assert ('a6 : gpio output .' in output) assert ('pinctrl:' in output) - assert ('SCL : I2C SCL.' in output) - assert ('SDA : I2C SDA.' in output) - assert ('TX : Uart TX.' in output) - assert ('RX : Uart RX.' in output) - assert ('W1 : 1-wire gpio.' in output) - assert ('GPIO0 : gpio bias-pull-up input-disable.' in output) - assert ('GPIO1 : gpio drive-open-drain.' in output) - assert ('GPIO2 : gpio bias-pull-down input-enable.' in output) - assert ('GPIO3 : gpio bias-disable.' in output) + assert ('P0 : UART TX.' in output) + assert ('P1 : UART RX.' in output) + assert ('P2 : I2S SCK.' in output) + assert ('P3 : I2S SD.' in output) + assert ('P4 : I2S WS.' in output) + assert ('P5 : GPIO0 bias-pull-up input-disable.' in output) + assert ('P6 : GPIO1 drive-open-drain.' in output) + assert ('P7 : GPIO2 bias-pull-down input-enable.' in output) + assert ('P8 : GPIO3 bias-disable.' in output) @pytest.mark.buildconfigspec('cmd_pinmux') @pytest.mark.boardspec('sandbox')
@@ -73,12 +73,12 @@ def test_pinmux_status(u_boot_console): assert (not 'pinctrl-gpio:' in output) assert (not 'pinctrl:' in output) - assert ('SCL : I2C SCL.' in output) - assert ('SDA : I2C SDA.' in output) - assert ('TX : Uart TX.' in output) - assert ('RX : Uart RX.' in output) - assert ('W1 : 1-wire gpio.' in output) - assert ('GPIO0 : gpio bias-pull-up input-disable.' in output) - assert ('GPIO1 : gpio drive-open-drain.' in output) - assert ('GPIO2 : gpio bias-pull-down input-enable.' in output) - assert ('GPIO3 : gpio bias-disable.' in output) + assert ('P0 : UART TX.' in output) + assert ('P1 : UART RX.' in output) + assert ('P2 : I2S SCK.' in output) + assert ('P3 : I2S SD.' in output) + assert ('P4 : I2S WS.' in output) + assert ('P5 : GPIO0 bias-pull-up input-disable.' in output) + assert ('P6 : GPIO1 drive-open-drain.' in output) + assert ('P7 : GPIO2 bias-pull-down input-enable.' in output) + assert ('P8 : GPIO3 bias-disable.' in output)
Signature · 1 line
2.28.0
PATCH v6 3/12 test: pinmux: Add test for pin muxing
Quoted 7 lines · Sean Anderson
This extends the pinctrl-sandbox driver to support pin muxing, and adds a test for that behaviour. The test is done in C and not python (like the existing tests for the pinctrl uclass) because it needs to call
pinctrl_select_state. Another option could be to add a command that invokespinctrl_select_stateand then test everything intest/py/tests/test_pinmux.py.
Quoted 7 lines
The pinctrl-sandbox driver now mimics the way that many pinmux devices work. There are two groups of pins which are muxed together, as well as four pins which are muxed individually. I have tried to test all normal paths. However, very few error cases are explicitly checked for.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/55751bad/attachment.sig>
PATCH v6 4/12 pinctrl: Add support for Kendryte K210 FPIOA
In reply to Sean AndersonThe 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).
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
Changes from that version include:
- Reformat to reduce errors from checkpatch
Changes in v6:
- Reorganize driver to use one file, instead of creating a new directory
Changes in v2:
- Don't clear existing pinctrl settings on probe
- Rewrite to use pinmux property
- Support muxing the output enable signal for each function
- Support output and input inversion
- Update binding documentation
MAINTAINERS | 2 + .../pinctrl/kendryte,k210-fpioa.txt | 102 +++ drivers/pinctrl/Kconfig | 7 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-kendryte.c | 737 ++++++++++++++++++ include/dt-bindings/pinctrl/k210-pinctrl.h | 277 +++++++ 6 files changed, 1126 insertions(+) create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt create mode 100644 drivers/pinctrl/pinctrl-kendryte.c create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h
MAINTAINERS +2 -0
@@ -927,7 +927,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
doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt new file +102 -0
102 lines not on this page · raw message
drivers/pinctrl/Kconfig +7 -0
@@ -284,6 +284,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"
drivers/pinctrl/Makefile +1 -0
@@ -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/
drivers/pinctrl/pinctrl-kendryte.c new file +737 -0
737 lines not on this page · raw message
include/dt-bindings/pinctrl/k210-pinctrl.h new file +277 -0
277 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH v6 4/12 pinctrl: Add support for Kendryte K210 FPIOA
Quoted 8 lines · Sean Anderson
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]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/efea3757/attachment.sig>
PATCH v6 5/12 gpio: dw: Fix warnings about casting int to pointer
In reply to Sean AndersonChange the type of gpio_dwabp_platdata.base from fdt_addr_t to a void pointer, since we pass it to readl.
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
(no changes since v1)
drivers/gpio/dwapb_gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/dwapb_gpio.c +2 -2
@@ -40,7 +40,7 @@ struct gpio_dwapb_platdata {const char *name;int bank;int pins; -fdt_addr_t base; +void __iomem *base; };static int dwapb_gpio_direction_input (struct udevice *dev,unsigned pin)
@@ -176,7 +176,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (!plat)return -ENOMEM ; - plat->base = base; + plat->base = (void *)base; plat->bank = bank; plat->pins =ofnode_read_u32_default (node,"snps,nr-gpios" ,0 );
Signature · 1 line
2.28.0
PATCH v6 5/12 gpio: dw: Fix warnings about casting int to pointer
Quoted 7 lines · Sean Anderson
Change the type of gpio_dwabp_platdata.base from
fdt_addr_tto a void pointer, since we pass it to readl.Signed-off-by Sean Anderson <[email protected]>Reviewed-by Ley Foon Tan <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/5aeaacfb/attachment.sig>
PATCH v6 6/12 gpio: dw: Add a trailing underscore to generated name
In reply to Sean AndersonPreviously, if there was no bank-name property, it was easy to have confusing gpio names like "gpio1 at 08", instead of "gpio1 at 0_8". This patch follows the example of the sifive gpio driver.
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
(no changes since v1)
drivers/gpio/dwapb_gpio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpio/dwapb_gpio.c +9 -1
@@ -186,7 +186,15 @@ static int gpio_dwapb_bind(struct udevice *dev)* Fall back to node name. This means accessing pins * via bank name won't work. */ - plat->name =ofnode_get_name (node); +char name[32 ]; + +snprintf (name,sizeof (name),"%s_" , +ofnode_get_name (node)); + plat->name =strdup (name); +if (!plat->name) { +kfree (plat); +return -ENOMEM ; + } } ret = device_bind_ofnode(dev, dev->driver, plat->name,
Signature · 1 line
2.28.0
PATCH v6 6/12 gpio: dw: Add a trailing underscore to generated name
Quoted 6 lines · Sean Anderson
Previously, if there was no bank-name property, it was easy to have confusing gpio names like "gpio1 at 08", instead of "gpio1 at 0_8". This patch follows the example of the sifive gpio driver.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/251b4f80/attachment.sig>
PATCH v6 7/12 gpio: dw: Return output value when direction is out
In reply to Sean Andersondm_gpio_ops.get_value can be called when the gpio is either input or output. The current dw code always returns the input value, which is invalid if the direction is set to out.
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
(no changes since v3)
Changes in v3:
- Undo reorder to prevent use-before-declared error
Changes in v2:
- Reorder changes to minimize diff
drivers/gpio/dwapb_gpio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpio/dwapb_gpio.c +12 -7
@@ -66,13 +66,6 @@ static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin,return 0 ; } -static int dwapb_gpio_get_value (struct udevice *dev,unsigned pin) -{ -struct gpio_dwapb_platdata *plat =dev_get_platdata (dev); -return !!(readl (plat->base +GPIO_EXT_PORT (plat->bank)) & (1 << pin)); -} - -static int dwapb_gpio_set_value (struct udevice *dev,unsigned pin,int val) {struct gpio_dwapb_platdata *plat =dev_get_platdata (dev);
@@ -98,6 +91,18 @@ static int dwapb_gpio_get_function(struct udevice *dev, unsigned offset)return GPIOF_INPUT ; } +static int dwapb_gpio_get_value (struct udevice *dev,unsigned pin) +{ +struct gpio_dwapb_platdata *plat =dev_get_platdata (dev); +u32 value; + +if (dwapb_gpio_get_function (dev, pin) ==GPIOF_OUTPUT ) + value =readl (plat->base +GPIO_SWPORT_DR (plat->bank)); +else + value =readl (plat->base +GPIO_EXT_PORT (plat->bank)); +return !!(value &BIT (pin)); +} +static const struct dm_gpio_ops gpio_dwapb_ops = { .direction_input = dwapb_gpio_direction_input, .direction_output = dwapb_gpio_direction_output,
Signature · 1 line
2.28.0
PATCH v6 7/12 gpio: dw: Return output value when direction is out
Quoted 6 lines · Sean Anderson
dm_gpio_ops.get_value can be called when the gpio is either input or output. The current dw code always returns the input value, which is invalid if the direction is set to out.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Ley Foon Tan <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/616dc594/attachment.sig>
PATCH v6 8/12 led: gpio: Default to using node name if label is absent
In reply to Sean AndersonThis more closely mirrors Linux's behaviour, and will make it easier to transition to using function+color in the future.
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
(no changes since v1)
drivers/led/led_gpio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/led/led_gpio.c +2 -5
@@ -99,11 +99,8 @@ static int led_gpio_bind(struct udevice *parent)const char *label; label =ofnode_read_string (node,"label" ); -if (!label) { -debug ("%s: node %s has no label\n" , __func__, -ofnode_get_name (node)); -return -EINVAL ; - } +if (!label) + label =ofnode_get_name (node); ret =device_bind_driver_to_node (parent,"gpio_led" ,ofnode_get_name (node), node, &dev);
Signature · 1 line
2.28.0
PATCH v6 8/12 led: gpio: Default to using node name if label is absent
Quoted 5 lines · Sean Anderson
This more closely mirrors Linux's behaviour, and will make it easier to transition to using function+color in the future.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/6a1bbe2c/attachment.sig>
PATCH v6 9/12 test: dm: Test for default led naming
In reply to Sean AndersonThis modifies the existing led test to check for default led naming as added in the previous patch.
---
(no changes since v4)
Changes in v4:
- New
arch/sandbox/dts/test.dts | 2 +- test/dm/led.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/sandbox/dts/test.dts +1 -1
@@ -517,7 +517,7 @@ default_off { gpios = <&gpio_a 6 0>; - label = "sandbox:default_off"; + /* label intentionally omitted */ default-state = "off"; }; };
test/dm/led.c +2 -1
@@ -40,7 +40,8 @@ static int dm_test_led_default_state(struct unit_test_state *uts)ut_assertok (led_get_by_label ("sandbox:default_on" , &dev));ut_asserteq (LEDST_ON ,led_get_state (dev)); -ut_assertok (led_get_by_label ("sandbox:default_off" , &dev)); +/* Also tests default label behaviour */ +ut_assertok (led_get_by_label ("default_off" , &dev));ut_asserteq (LEDST_OFF ,led_get_state (dev));return 0 ;
Signature · 1 line
2.28.0
PATCH v6 9/12 test: dm: Test for default led naming
Quoted 5 lines · Sean Anderson
This modifies the existing led test to check for default led naming as added in the previous patch.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/f1d0870a/attachment.sig>
PATCH v6 10/12 riscv: Add pinmux and gpio bindings for Kendryte K210
In reply to Sean AndersonThis patch adds the necessary device tree bindings.
---
(no changes since v2)
Changes in v2:
- Convert to use pinmux property
- Don't hog ISP on boot
- Re-order GPIOs to match the defaults more closely
arch/riscv/dts/k210-maix-bit.dts | 104 +++++++++++++++++++++++++++++++ arch/riscv/dts/k210.dtsi | 12 ++++ 2 files changed, 116 insertions(+)
arch/riscv/dts/k210-maix-bit.dts +104 -0
@@ -17,6 +17,22 @@ stdout-path = "serial0:115200"; }; + gpio-leds { + compatible = "gpio-leds"; + + green { + gpios = <&gpio1_0 4 GPIO_ACTIVE_LOW>; + }; + + red { + gpios = <&gpio1_0 5 GPIO_ACTIVE_LOW>; + }; + + blue { + gpios = <&gpio1_0 6 GPIO_ACTIVE_LOW>; + }; + }; + sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s";
@@ -39,9 +55,97 @@ }; &uarths0 { + pinctrl-0 = <&fpioa_uarths>; + pinctrl-names = "default"; + status = "okay"; +}; + +&gpio0 { + pinctrl-0 = <&fpioa_gpiohs>; + pinctrl-names = "default"; + status = "okay"; +}; + +&gpio1 { + pinctrl-0 = <&fpioa_gpio>; + pinctrl-names = "default"; status = "okay"; }; &i2s0 { #sound-dai-cells = <1>; + pinctrl-0 = <&fpioa_i2s0>; + pinctrl-names = "default"; +}; + +&fpioa { + status = "okay"; + + fpioa_uarths: uarths { + pinmux = <K210_FPIOA(4, K210_PCF_UARTHS_RX)>, + <K210_FPIOA(5, K210_PCF_UARTHS_TX)>; + }; + + fpioa_gpio: gpio { + pinmux = <K210_FPIOA(8, K210_PCF_GPIO0)>, + <K210_FPIOA(9, K210_PCF_GPIO1)>, + <K210_FPIOA(10, K210_PCF_GPIO2)>, + <K210_FPIOA(11, K210_PCF_GPIO3)>, + <K210_FPIOA(12, K210_PCF_GPIO4)>, + <K210_FPIOA(13, K210_PCF_GPIO5)>, + <K210_FPIOA(14, K210_PCF_GPIO6)>, + <K210_FPIOA(15, K210_PCF_GPIO7)>; + }; + + fpioa_gpiohs: gpiohs { + pinmux = <K210_FPIOA(16, K210_PCF_GPIOHS0)>, + <K210_FPIOA(17, K210_PCF_GPIOHS1)>, + <K210_FPIOA(21, K210_PCF_GPIOHS5)>, + <K210_FPIOA(22, K210_PCF_GPIOHS6)>, + <K210_FPIOA(23, K210_PCF_GPIOHS7)>, + <K210_FPIOA(24, K210_PCF_GPIOHS8)>, + <K210_FPIOA(25, K210_PCF_GPIOHS9)>, + <K210_FPIOA(30, K210_PCF_GPIOHS14)>, + <K210_FPIOA(31, K210_PCF_GPIOHS15)>, + <K210_FPIOA(32, K210_PCF_GPIOHS16)>, + <K210_FPIOA(33, K210_PCF_GPIOHS17)>, + <K210_FPIOA(34, K210_PCF_GPIOHS18)>, + <K210_FPIOA(35, K210_PCF_GPIOHS19)>; + }; + + fpioa_i2s0: i2s0 { + pinmux = <K210_FPIOA(18, K210_PCF_I2S0_SCLK)>, + <K210_FPIOA(19, K210_PCF_I2S0_WS)>, + <K210_FPIOA(20, K210_PCF_I2S0_IN_D0)>; + }; + + fpioa_dvp: dvp { + pinmux = <K210_FPIOA(40, K210_PCF_SCCB_SDA)>, + <K210_FPIOA(41, K210_PCF_SCCB_SCLK)>, + <K210_FPIOA(42, K210_PCF_DVP_RST)>, + <K210_FPIOA(43, K210_PCF_DVP_VSYNC)>, + <K210_FPIOA(44, K210_PCF_DVP_PWDN)>, + <K210_FPIOA(45, K210_PCF_DVP_HSYNC)>, + <K210_FPIOA(46, K210_PCF_DVP_XCLK)>, + <K210_FPIOA(47, K210_PCF_DVP_PCLK)>; + }; + + fpioa_spi0: spi0 { + pinmux = <K210_FPIOA(36, K210_PCF_GPIOHS20)>, /* cs */ + <K210_FPIOA(37, K210_PCF_GPIOHS21)>, /* rst */ + <K210_FPIOA(38, K210_PCF_GPIOHS22)>, /* dc */ + <K210_FPIOA(39, K210_PCF_SPI0_SCLK)>; /* wr */ + }; + + fpioa_spi1: spi1 { + pinmux = <K210_FPIOA(26, K210_PCF_SPI1_D1)>, + <K210_FPIOA(27, K210_PCF_SPI1_SCLK)>, + <K210_FPIOA(28, K210_PCF_SPI1_D0)>, + <K210_FPIOA(29, K210_PCF_GPIOHS13)>; + }; +}; + +&dvp0 { + pinctrl-0 = <&fpioa_dvp>; + pinctrl-names = "default"; };
arch/riscv/dts/k210.dtsi +12 -0
@@ -5,6 +5,7 @@ #include <dt-bindings/clock/k210-sysctl.h> #include <dt-bindings/mfd/k210-sysctl.h> +#include <dt-bindings/pinctrl/k210-pinctrl.h> #include <dt-bindings/reset/k210-sysctl.h> / {
@@ -368,7 +369,18 @@ reg = <0x502B0000 0x100>; clocks = <&sysclk K210_CLK_FPIOA>; resets = <&sysrst K210_RST_FPIOA>; + kendryte,sysctl = <&sysctl>; + kendryte,power-offset = <K210_SYSCTL_POWER_SEL>; + pinctrl-0 = <&fpioa_jtag>; + pinctrl-names = "default"; status = "disabled"; + + fpioa_jtag: jtag { + pinmux = <K210_FPIOA(0, K210_PCF_JTAG_TCLK)>, + <K210_FPIOA(1, K210_PCF_JTAG_TDI)>, + <K210_FPIOA(2, K210_PCF_JTAG_TMS)>, + <K210_FPIOA(3, K210_PCF_JTAG_TDO)>; + }; }; sha256: sha256 at 502C0000 {
Signature · 1 line
2.28.0
PATCH v6 10/12 riscv: Add pinmux and gpio bindings for Kendryte K210
Quoted 8 lines
This patch adds the necessary device tree bindings.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>---
(no changes since v2)
Quoted 9 lines
Changes in v2:
- Convert to use pinmux property
- Don't hog ISP on boot
- Re-order GPIOs to match the defaults more closelyarch/riscv/dts/k210-maix-bit.dts | 104 +++++++++++++++++++++++++++++++ arch/riscv/dts/k210.dtsi | 12 ++++ 2 files changed, 116 insertions(+)
PATCH v6 10/12 riscv: Add pinmux and gpio bindings for Kendryte K210
In reply to Sean AndersonQuoted 5 lines · Sean Anderson
This patch adds the necessary device tree bindings.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Rick Chen <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/9965fd1d/attachment.sig>
PATCH v6 11/12 riscv: add DT binding for BOOT button on Maix board
In reply to Sean AndersonFrom: Heinrich Schuchardt <[email protected]>
Add a device tree binding for the BOOT button on the Maix board.
---
This commit was previously submitted on its own as
https://patchwork.ozlabs.org/project/uboot/patch/20200902201159.98034-1-xypron.glpk at gmx.de/
The following is the original commit note:
Together with
[PATCH 1/1] cmd/button: return button status
https://lists.denx.de/pipermail/u-boot/2020-September/425221.html
we can use the button status to decide which program to boot.
Changes in v6:
- New
arch/riscv/dts/k210-maix-bit.dts | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/riscv/dts/k210-maix-bit.dts +11 -0
@@ -8,6 +8,7 @@ #include "k210.dtsi" #include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/input/input.h> / { model = "Sipeed Maix Bit 2.0";
@@ -33,6 +34,16 @@ }; }; + gpio-keys { + compatible = "gpio-keys"; + + boot { + label = "BOOT"; + linux,code = <BTN_0>; + gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + }; + }; + sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s";
Signature · 1 line
2.28.0
PATCH v6 11/12 riscv: add DT binding for BOOT button on Maix board
Quoted 18 lines
From: Heinrich Schuchardt <[email protected]>
Add a device tree binding for the BOOT button on the Maix board.
Signed-off-by Heinrich Schuchardt <[email protected]>Reviewed-by Sean Anderson <[email protected]>Signed-off-by Sean Anderson <[email protected]>---
This commit was previously submitted on its own as
https://patchwork.ozlabs.org/project/uboot/patch/20200902201159.98034-1-xypron.glpk at gmx.de/The following is the original commit note:
Together with
[PATCH 1/1] cmd/button: return button status
https://lists.denx.de/pipermail/u-boot/2020-September/425221.html
we can use the button status to decide which program to boot.
Quoted 6 lines
Changes in v6:
- Newarch/riscv/dts/k210-maix-bit.dts | 11 +++++++++++ 1 file changed, 11 insertions(+)
PATCH v6 11/12 riscv: add DT binding for BOOT button on Maix board
In reply to Sean AndersonQuoted 8 lines · Sean Anderson
From: Heinrich Schuchardt <[email protected]>
Add a device tree binding for the BOOT button on the Maix board.
Signed-off-by Heinrich Schuchardt <[email protected]>Reviewed-by Sean Anderson <[email protected]>Signed-off-by Sean Anderson <[email protected]>Reviewed-by Rick Chen <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/a0943b79/attachment.sig>
PATCH v6 12/12 riscv: Add FPIOA and GPIO support for Kendryte K210
In reply to Sean AndersonThis patch adds the necessary configs and docs for FPIOA and GPIO support on the K210.
---
Changes in v6:
- Add dependency on "riscv: Clean up timer drivers", which fixes the bugs discovered earlier.
Changes in v5:
- Increase CONFIG_LOGLEVEL to 5 as a hack to get the board booting again
Changes in v3:
- Document pins 6 and 7 as not set
Changes in v2:
- Remove SPI flash related Kconfig settings
board/sipeed/maix/Kconfig | 9 ++++++ doc/board/sipeed/maix.rst | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-)
board/sipeed/maix/Kconfig +9 -0
@@ -44,4 +44,13 @@ config BOARD_SPECIFIC_OPTIONS imply RESET_SYSCON imply SYSRESET imply SYSRESET_SYSCON + imply PINCTRL + imply PINCONF + imply PINCTRL_K210 + imply DM_GPIO + imply DWAPB_GPIO + imply SIFIVE_GPIO + imply CMD_GPIO + imply LED + imply LED_GPIO endif
doc/board/sipeed/maix.rst +62 -2
82 lines not on this page · raw message
Signature · 1 line
2.28.0
PATCH v6 12/12 riscv: Add FPIOA and GPIO support for Kendryte K210
Hi Sean,
Quoted 10 lines · Sean Anderson
This patch adds the necessary configs and docs for FPIOA and GPIO support on the K210.
Signed-off-by Sean Anderson <[email protected]>---
Changes in v6:
- Add dependency on "riscv: Clean up timer drivers", which fixes the bugs discovered earlier.
I am curious about the weird bug you found in v5.
Is there any new discovery on the cause or how the bug is resolved ?
You have mentioned that any modification to init_sequence_f or init_sequence_r would lead to a successful boot. Is this related to "riscv: Clean up timer drivers" and thus resolve the bug ?
Best regards,
Leo
Quoted 123 lines
Changes in v5:
- IncreaseCONFIG_LOGLEVELto 5 as a hack to get the board booting againChanges in v3:
- Document pins 6 and 7 as not setChanges in v2:
- Remove SPI flash relatedKconfigsettingsboard/sipeed/maix/Kconfig | 9 ++++++ doc/board/sipeed/maix.rst | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-)board/sipeed/maix/Kconfig +9
-0@@ -44,4 +44,13 @@ config BOARD_SPECIFIC_OPTIONS imply RESET_SYSCON imply SYSRESET imply SYSRESET_SYSCON + imply PINCTRL + imply PINCONF + imply PINCTRL_K210 + imply DM_GPIO + imply DWAPB_GPIO + imply SIFIVE_GPIO + imply CMD_GPIO + imply LED + imply LED_GPIO endifdoc/board/sipeed/maix.rst +62
-2@@ -199,7 +199,7 @@ To run legacy images, use the ``bootm`` command: Load Address: 80000000 Entry Point: 80000000 - $ picocom -b 115200 /dev/ttyUSB0i + $ picocom -b 115200 /dev/ttyUSB0 => loady ## Ready for binary (ymodem) download to 0x80000000 at 115200 bps... C@@ -230,6 +230,66 @@ To run legacy images, use the ``bootm`` command: argv[0] = "<NULL>" Hit any key to exit ... +Pin Assignment +-------------- + +The K210 contains a Fully Programmable I/O Array (FPIOA), which can remap any of +its 256 input functions to any any of 48 output pins. The following table has +the default pin assignments for the BitM. + +===== ========== ======= +Pin Function Comment +===== ========== ======= +IO_0 JTAG_TCLK +IO_1 JTAG_TDI +IO_2 JTAG_TMS +IO_3 JTAG_TDO +IO_4 UARTHS_RX +IO_5 UARTHS_TX +IO_6 Not set +IO_7 Not set +IO_8 GPIO_0 +IO_9 GPIO_1 +IO_10 GPIO_2 +IO_11 GPIO_3 +IO_12 GPIO_4 Green LED +IO_13 GPIO_5 Red LED +IO_14 GPIO_6 Blue LED +IO_15 GPIO_7 +IO_16 GPIOHS_0 ISP +IO_17 GPIOHS_1 +IO_18 I2S0_SCLK MIC CLK +IO_19 I2S0_WS MIC WS +IO_20 I2S0_IN_D0 MIC SD +IO_21 GPIOHS_5 +IO_22 GPIOHS_6 +IO_23 GPIOHS_7 +IO_24 GPIOHS_8 +IO_25 GPIOHS_9 +IO_26 SPI1_D1 MMC MISO +IO_27 SPI1_SCLK MMC CLK +IO_28 SPI1_D0 MMC MOSI +IO_29 GPIOHS_13 MMC CS +IO_30 GPIOHS_14 +IO_31 GPIOHS_15 +IO_32 GPIOHS_16 +IO_33 GPIOHS_17 +IO_34 GPIOHS_18 +IO_35 GPIOHS_19 +IO_36 GPIOHS_20 Panel CS +IO_37 GPIOHS_21 Panel RST +IO_38 GPIOHS_22 Panel DC +IO_39 SPI0_SCK Panel WR +IO_40 SCCP_SDA +IO_41 SCCP_SCLK +IO_42 DVP_RST +IO_43 DVP_VSYNC +IO_44 DVP_PWDN +IO_45 DVP_HSYNC +IO_46 DVP_XCLK +IO_47 DVP_PCLK +===== ========== ======= + Over- and Under-clocking ------------------------@@ -404,7 +464,7 @@ Address Size Description 0x8801C000 0x1000 riscv priv spec 1.9 config 0x8801D000 0x2000 flattened device tree (contains only addresses and interrupts) -0x8801f000 0x1000 credits +0x8801F000 0x1000 credits ========== ========= =========== LinksSignature · 1 line
2.28.0
PATCH v6 12/12 riscv: Add FPIOA and GPIO support for Kendryte K210
Quoted 9 lines · Leo Liang
Hi Sean,
Quoted 6 lines · Sean Anderson
This patch adds the necessary configs and docs for FPIOA and GPIO support on the K210.
Signed-off-by Sean Anderson <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Changes in v6:
- Add dependency on "riscv: Clean up timer drivers", which fixes the bugs discovered earlier.I am curious about the weird bug you found in v5.
Is there any new discovery on the cause or how the bug is resolved ?
I don't really know the exact mechanism of the bug. I noticed that the timer series fixed it because I was unable to reproduce the bug (by adjusting the size of the binary with nops) with that series applied, but I was still able to reproduce it with it unapplied.
I suspect that the effects of the bug are caused by something unintentionally modifying the device tree. Most modifications to the device tree will not cause a boot to fail, because the k210 device tree is relatively large and contains many unused devices and properties. I don't know why U-Boot crashes instead of just resulting in an error. Another reason I suspect it is due to the device tree is that I can also reproduce this bug with the wdt series applied (and without the timer series).
To determine the direct cause of this bug, I would need to add some features to openocd to let it debug multiple cores at once. The k210 uses an older debug device, and openocd (even the kendryte fork) only supports debugging one hart at once. This bug only occurs when both harts are running at once; I can take a buggy U-Boot, jump to _start, and it will boot fine.
Quoted 2 lines
You have mentioned that any modification to
init_sequence_forinit_sequence_rwould lead to a successful boot.
Yeah. In general, the buggy sizes/alignments are fairly sparse. Usually, a buggy size occurs every 64 bytes or so.
Quoted 1 line
Is this related to "riscv: Clean up timer drivers" and thus resolve the bug ?
Sorry, I'm not sure what you mean by "this" in that sentence.
--Sean
Quoted 124 lines
Quoted 123 lines
Changes in v5:
- IncreaseCONFIG_LOGLEVELto 5 as a hack to get the board booting againChanges in v3:
- Document pins 6 and 7 as not setChanges in v2:
- Remove SPI flash relatedKconfigsettingsboard/sipeed/maix/Kconfig | 9 ++++++ doc/board/sipeed/maix.rst | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-)board/sipeed/maix/Kconfig +9
-0@@ -44,4 +44,13 @@ config BOARD_SPECIFIC_OPTIONS imply RESET_SYSCON imply SYSRESET imply SYSRESET_SYSCON + imply PINCTRL + imply PINCONF + imply PINCTRL_K210 + imply DM_GPIO + imply DWAPB_GPIO + imply SIFIVE_GPIO + imply CMD_GPIO + imply LED + imply LED_GPIO endifdoc/board/sipeed/maix.rst +62
-2@@ -199,7 +199,7 @@ To run legacy images, use the ``bootm`` command: Load Address: 80000000 Entry Point: 80000000 - $ picocom -b 115200 /dev/ttyUSB0i + $ picocom -b 115200 /dev/ttyUSB0 => loady ## Ready for binary (ymodem) download to 0x80000000 at 115200 bps... C@@ -230,6 +230,66 @@ To run legacy images, use the ``bootm`` command: argv[0] = "<NULL>" Hit any key to exit ... +Pin Assignment +-------------- + +The K210 contains a Fully Programmable I/O Array (FPIOA), which can remap any of +its 256 input functions to any any of 48 output pins. The following table has +the default pin assignments for the BitM. + +===== ========== ======= +Pin Function Comment +===== ========== ======= +IO_0 JTAG_TCLK +IO_1 JTAG_TDI +IO_2 JTAG_TMS +IO_3 JTAG_TDO +IO_4 UARTHS_RX +IO_5 UARTHS_TX +IO_6 Not set +IO_7 Not set +IO_8 GPIO_0 +IO_9 GPIO_1 +IO_10 GPIO_2 +IO_11 GPIO_3 +IO_12 GPIO_4 Green LED +IO_13 GPIO_5 Red LED +IO_14 GPIO_6 Blue LED +IO_15 GPIO_7 +IO_16 GPIOHS_0 ISP +IO_17 GPIOHS_1 +IO_18 I2S0_SCLK MIC CLK +IO_19 I2S0_WS MIC WS +IO_20 I2S0_IN_D0 MIC SD +IO_21 GPIOHS_5 +IO_22 GPIOHS_6 +IO_23 GPIOHS_7 +IO_24 GPIOHS_8 +IO_25 GPIOHS_9 +IO_26 SPI1_D1 MMC MISO +IO_27 SPI1_SCLK MMC CLK +IO_28 SPI1_D0 MMC MOSI +IO_29 GPIOHS_13 MMC CS +IO_30 GPIOHS_14 +IO_31 GPIOHS_15 +IO_32 GPIOHS_16 +IO_33 GPIOHS_17 +IO_34 GPIOHS_18 +IO_35 GPIOHS_19 +IO_36 GPIOHS_20 Panel CS +IO_37 GPIOHS_21 Panel RST +IO_38 GPIOHS_22 Panel DC +IO_39 SPI0_SCK Panel WR +IO_40 SCCP_SDA +IO_41 SCCP_SCLK +IO_42 DVP_RST +IO_43 DVP_VSYNC +IO_44 DVP_PWDN +IO_45 DVP_HSYNC +IO_46 DVP_XCLK +IO_47 DVP_PCLK +===== ========== ======= + Over- and Under-clocking ------------------------@@ -404,7 +464,7 @@ Address Size Description 0x8801C000 0x1000 riscv priv spec 1.9 config 0x8801D000 0x2000 flattened device tree (contains only addresses and interrupts) -0x8801f000 0x1000 credits +0x8801F000 0x1000 credits ========== ========= =========== LinksSignature · 1 line
2.28.0
PATCH v6 12/12 riscv: Add FPIOA and GPIO support for Kendryte K210
In reply to Sean AndersonQuoted 4 lines · Sean Anderson
This patch adds the necessary configs and docs for FPIOA and GPIO support on the K210.
Signed-off-by Sean Anderson <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201009/0ec2273b/attachment.sig>
v6 cover riscv: Add FPIOA and GPIO support for Kendryte K210
In reply to Sean AndersonQuoted 86 lines · Sean Anderson
This patch series adds support for pinmuxing, gpios, buttons, and leds on the Kendyte K210.
The fail-to-boot bug should be fixed by the timer driver cleanup patch :)
This patch series was previously part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576This series depends on
https://patchwork.ozlabs.org/project/uboot/list/?series=200642Changes in v6:
- Add BOOT button binding
- Add dependency on "riscv: Clean up timer drivers", which fixes the bugs discovered earlier.
-DM_TESTF_SCAN_FDT->UT_TESTF_SCAN_FDT
- Reformat documentation so sphinx likes it better
- RemoveCONFIG_LOGLEVELhack
- Reorganize driver to use one file, instead of creating a new directoryChanges in v5:
- IncreaseCONFIG_LOGLEVELto 5 as a hack to get the board booting again
- Patch 05/12 "gpio: sifive: Use generic reg read function" has been superseded by commit2548493ab4.
- Rebase onto u-boot/masterChanges in v4:
- Add sandbox dt-binding headers toMAINTAINERS
- Add test for led behavior
- Addtest/dm/pinmux.cto patch
- Move sandbox_* variables into a priv structure. This resets them to the default state every time we re-probe.
- Reformat documentation indm/pinctrl.hChanges in v3:
- Adddt-bindings/pinctrl/sandbox-pinmux.hto patchChanges in v2:
- Add test for pinmuxing
- Don't clear existing pinctrl settings on probe
- Re-order GPIOs to match the defaults more closely
- Rebase onto v13 of "riscv: Add Sipeed Maix support"
- Rewrite FPIOA driver to use pinmux property
- Support muxing the output enable signal for each function in the FPIOA
- Support output and input inversion in the pinmux driver
- Support pinmux property in pinctrl-genericHeinrich Schuchardt (1):
riscv: add DT binding for BOOT button on Maix boardSean Anderson (11):
pinctrl: Add pinmux property support to pinctrl-generic
pinctrl: Reformat documentation indm/pinctrl.h
test: pinmux: Add test for pin muxing
pinctrl: Add support for Kendryte K210 FPIOA
gpio: dw: Fix warnings about casting int to pointer
gpio: dw: Add a trailing underscore to generated name
gpio: dw: Return output value when direction is out
led: gpio: Default to using node name if label is absent
test: dm: Test for default led naming
riscv: Add pinmux and gpio bindings for Kendryte K210
riscv: Add FPIOA and GPIO support for Kendryte K210MAINTAINERS | 3 + arch/riscv/dts/k210-maix-bit.dts | 115 +++ arch/riscv/dts/k210.dtsi | 12 + arch/sandbox/dts/test.dts | 47 +- board/sipeed/maix/Kconfig | 9 + doc/api/index.rst | 1 + doc/api/pinctrl.rst | 7 + doc/board/sipeed/maix.rst | 64 +- .../pinctrl/kendryte,k210-fpioa.txt | 102 +++ .../pinctrl/pinctrl-bindings.txt | 65 +- drivers/gpio/dwapb_gpio.c | 33 +- drivers/led/led_gpio.c | 7 +- drivers/pinctrl/Kconfig | 7 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-generic.c | 125 ++- drivers/pinctrl/pinctrl-kendryte.c | 737 ++++++++++++++++++ drivers/pinctrl/pinctrl-sandbox.c | 186 +++-- include/dm/pinctrl.h | 498 ++++++++---- include/dt-bindings/pinctrl/k210-pinctrl.h | 277 +++++++ include/dt-bindings/pinctrl/sandbox-pinmux.h | 19 + test/dm/Makefile | 3 + test/dm/led.c | 3 +- test/dm/pinmux.c | 57 ++
Quoted 9 lines
test/py/tests/test_pinmux.py | 36 +- 24 files changed, 2129 insertions(+), 285 deletions(-) create mode 100644 doc/api/pinctrl.rst create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt create mode 100644 drivers/pinctrl/pinctrl-kendryte.c create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h create mode 100644 include/dt-bindings/pinctrl/sandbox-pinmux.h create mode 100644 test/dm/pinmux.c
*bump*
Is this ready to be merged, or are there still people who need to sign off? It's marked as "Needs Review / ACK" in Patchwork.
--Sean