riscv: Add FPIOA and GPIO support for Kendryte K210
Subsystems (5)
v2 cover riscv: Add FPIOA and GPIO support for Kendryte K210
This patch series adds support for pinmuxing, gpios, and leds on the Kendyte K210.
This patch series was previously part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
This patch series depends on
https://patchwork.ozlabs.org/project/uboot/list/?series=178480
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
Sean Anderson (10):
pinctrl: Add pinmux property support to pinctrl-generic
test: pinmux: Add test for pin muxing
pinctrl: Add support for Kendryte K210 FPIOA
gpio: sifive: Use generic reg read function
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
riscv: Add pinmux and gpio bindings for Kendryte K210
riscv: Add FPIOA and GPIO support for Kendryte K210
MAINTAINERS | 2 + arch/riscv/dts/k210-maix-bit.dts | 104 +++ arch/riscv/dts/k210.dtsi | 12 + arch/sandbox/dts/test.dts | 45 +- board/sipeed/maix/Kconfig | 9 + doc/board/sipeed/maix.rst | 64 +- .../pinctrl/kendryte,k210-fpioa.txt | 102 +++ .../pinctrl/pinctrl-bindings.txt | 65 +- drivers/gpio/dwapb_gpio.c | 23 +- drivers/gpio/sifive-gpio.c | 2 +- drivers/led/led_gpio.c | 7 +- drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/kendryte/Kconfig | 7 + drivers/pinctrl/kendryte/Makefile | 1 + drivers/pinctrl/kendryte/pinctrl.c | 678 ++++++++++++++++++ drivers/pinctrl/kendryte/pinctrl.h | 70 ++ drivers/pinctrl/pinctrl-generic.c | 125 +++- drivers/pinctrl/pinctrl-sandbox.c | 155 +++- include/dm/pinctrl.h | 21 +- include/dt-bindings/pinctrl/k210-pinctrl.h | 277 +++++++ test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +- 23 files changed, 1693 insertions(+), 117 deletions(-) create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt create mode 100644 drivers/pinctrl/kendryte/Kconfig create mode 100644 drivers/pinctrl/kendryte/Makefile create mode 100644 drivers/pinctrl/kendryte/pinctrl.c create mode 100644 drivers/pinctrl/kendryte/pinctrl.h create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h
Signature · 1 line
2.26.2
PATCH v2 1/10 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.
---
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.26.2
PATCH v2 1/10 pinctrl: Add pinmux property support to pinctrl-generic
Hi Sean,
Quoted 36 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.
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]>---
Quoted 7 lines
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(-)
[..]
include/dm/pinctrl.h struct pinconf_param { · line 37
Quoted 10 lines
include/dm/pinctrl.h +1
-1@@ -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)
What is happening here? I don't think we want the period.
Quoted 37 lines
include/dm/pinctrl.h +11
-7* @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
include/dm/pinctrl.h struct pinctrl_ops { · line 97
Quoted 4 lines
include/dm/pinctrl.h +1
-0@@ -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);
I am not a fan of how the comments work in this file and would prefer that each function is commented individually. If you have the energy, you could do a follow-up patch.
Quoted 6 lines
include/dm/pinctrl.h +0
-1unsigned int pinconf_num_params;const struct pinconf_param *pinconf_params; int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, --2.26.2
Regards,
Simon
PATCH v2 1/10 pinctrl: Add pinmux property support to pinctrl-generic
Quoted 52 lines · Simon Glass
Hi Sean,
Quoted 36 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.
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]>---
Quoted 7 lines
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(-)Reviewed-by Simon Glass <[email protected]>[..]
Quoted 13 lines
include/dm/pinctrl.h struct pinconf_param { · line 37
Quoted 10 lines
include/dm/pinctrl.h +1
-1@@ -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) What is happening here? I don't think we want the period.
I'm just removing the double-spaces. The period here matches how the rest of the comments also have a period before their parentheses (despite that not being grammatically correct).
Quoted 37 lines
Quoted 37 lines
include/dm/pinctrl.h +11
-7* @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 {
Quoted 8 lines
include/dm/pinctrl.h struct pinctrl_ops { · line 97
Quoted 4 lines
include/dm/pinctrl.h +1
-0unsigned 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);I am not a fan of how the comments work in this file and would prefer that each function is commented individually. If you have the energy, you could do a follow-up patch.
Sure, I can have a look at that.
Quoted 11 lines
Quoted 7 lines
include/dm/pinctrl.h +0
-1unsigned int pinconf_num_params;const struct pinconf_param *pinconf_params; int (*pinconf_set)(struct udevice *dev, unsigned pin_selector, --2.26.2
Regards,
Simon
--Sean
PATCH v2 2/10 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 v2:
- New
arch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)
arch/sandbox/dts/test.dts +38 -7
@@ -2,6 +2,7 @@ #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/gpio/sandbox-gpio.h> +#include <dt-bindings/pinctrl/sandbox-pinmux.h> / { model = "sandbox";
@@ -967,30 +968,60 @@ pinctrl { compatible = "sandbox,pinctrl"; - pinctrl-names = "default"; - pinctrl-0 = <&gpios>; + pinctrl-names = "default", "alternate"; + pinctrl-0 = <&pinctrl_gpios>, <&pinctrl_i2s>; + pinctrl-1 = <&pinctrl_spi>, <&pinctrl_i2c>; - gpios: gpios { + pinctrl_gpios: gpios { gpio0 { - pins = "GPIO0"; + pins = "P5"; + function = "GPIO"; bias-pull-up; input-disable; }; gpio1 { - pins = "GPIO1"; + pins = "P6"; + function = "GPIO"; output-high; drive-open-drain; }; gpio2 { - pins = "GPIO2"; + pinmux = <SANDBOX_PINMUX(7, SANDBOX_PINMUX_GPIO)>; bias-pull-down; input-enable; }; gpio3 { - pins = "GPIO3"; + pinmux = <SANDBOX_PINMUX(8, SANDBOX_PINMUX_GPIO)>; bias-disable; }; }; + + pinctrl_i2c: i2c { + groups { + groups = "I2C_UART"; + function = "I2C"; + }; + + pins { + pins = "P0", "P1"; + drive-open-drain; + }; + }; + + pinctrl_i2s: i2s { + groups = "SPI_I2S"; + function = "I2S"; + }; + + pinctrl_spi: spi { + groups = "SPI_I2S"; + function = "SPI"; + + cs { + pinmux = <SANDBOX_PINMUX(5, SANDBOX_PINMUX_CS)>, + <SANDBOX_PINMUX(6, SANDBOX_PINMUX_CS)>; + }; + }; }; hwspinlock at 0 {
drivers/pinctrl/pinctrl-sandbox.c +119 -36
216 lines not on this page · raw message
test/dm/Makefile +3 -0
@@ -76,4 +76,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/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.26.2
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)
[..]
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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
I don't see this file in your patch.
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 7 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):
Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Quoted 47 lines
test/py/tests/test_pinmux.py +18
-19assert ('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) --
Quoted 2 lines
2.26.2
Regards,
Simon
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Quoted 32 lines · Simon Glass
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)[..]
Quoted 12 lines
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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.oI don't see this file in your patch.
Whoops, will add it next revision.
Quoted 11 lines
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 8 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Ok, I can have a look.
Should C be preferred for new tests?
--Sean
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Hi Sean,
Quoted 61 lines · Sean Anderson
Quoted 32 lines · Simon Glass
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)[..]
Quoted 12 lines
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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.oI don't see this file in your patch.
Whoops, will add it next revision.
Quoted 11 lines
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 8 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Quoted 3 lines
Ok, I can have a look.
Should C be preferred for new tests?
+Stephen Warren
For sandbox tests, yes. If there is a lot of interaction, Python is extremely slow.
But with Python we can run a test on real hardware without compiling the test into U-Boot. So there are benefits on both sides.
Regards,
Simon
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Quoted 68 lines · Simon Glass
Hi Sean,
Quoted 61 lines · Sean Anderson
Quoted 32 lines · Simon Glass
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)[..]
Quoted 12 lines
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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.oI don't see this file in your patch.
Whoops, will add it next revision.
Quoted 11 lines
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 8 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Quoted 3 lines
Ok, I can have a look.
Should C be preferred for new tests?
Quoted 7 lines
+Stephen Warren
For sandbox tests, yes. If there is a lot of interaction, Python is extremely slow.
But with Python we can run a test on real hardware without compiling the test into U-Boot. So there are benefits on both sides.
Ok, I looked into it, and the python test uses the
assert 'somestring' in output
idiom a lot. From what I can tell, there's not an easy way to replicate this behavior on the C side of things. Adding a function to do this would probably call for its own patch. I could also use the existing functionality to test for lines, but I think that would be much more brittle when compared to the python version.
--Sean
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Hi Sean,
Quoted 78 lines · Sean Anderson
Quoted 68 lines · Simon Glass
Hi Sean,
Quoted 61 lines · Sean Anderson
Quoted 32 lines · Simon Glass
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)[..]
Quoted 12 lines
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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.oI don't see this file in your patch.
Whoops, will add it next revision.
Quoted 11 lines
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 8 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Quoted 3 lines
Ok, I can have a look.
Should C be preferred for new tests?
Quoted 7 lines
+Stephen Warren
For sandbox tests, yes. If there is a lot of interaction, Python is extremely slow.
But with Python we can run a test on real hardware without compiling the test into U-Boot. So there are benefits on both sides.
Quoted 7 lines
Ok, I looked into it, and the python test uses the
assert 'somestring' in output
idiom a lot. From what I can tell, there's not an easy way to replicate this behavior on the C side of things. Adding a function to do this would probably call for its own patch. I could also use the existing functionality to test for lines, but I think that would be much more brittle when compared to the python version.
Well you could add assert_nextline_contains() for example?
Regards,
Simon
PATCH v2 2/10 test: pinmux: Add test for pin muxing
Quoted 89 lines · Simon Glass
Hi Sean,
Quoted 78 lines · Sean Anderson
Quoted 68 lines · Simon Glass
Hi Sean,
Quoted 61 lines · Sean Anderson
Quoted 32 lines · Simon Glass
Hi Sean,
Quoted 25 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.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]>---
Changes in v2:
- Newarch/sandbox/dts/test.dts | 45 +++++++-- drivers/pinctrl/pinctrl-sandbox.c | 155 +++++++++++++++++++++++------- test/dm/Makefile | 3 + test/py/tests/test_pinmux.py | 36 +++---- 4 files changed, 178 insertions(+), 61 deletions(-)[..]
Quoted 12 lines
test/dm/Makefile obj-$(CONFIG_DM_RNG) += rng.o · line 80
Quoted 10 lines
test/dm/Makefile +2
-0@@ -76,4 +76,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.oI don't see this file in your patch.
Whoops, will add it next revision.
Quoted 11 lines
test/py/tests/test_pinmux.py def test_pinmux_status_all(u_boot_console):
Quoted 8 lines
test/dm/Makefile +1
-0+endif endiftest/py/tests/test_pinmux.py +0
-0@@ -28,15 +28,15 @@ def test_pinmux_status_all(u_boot_console):Feel free to convert this to C also if you like. It is faster, although perhaps not much faster since it only runs a few commands?
Quoted 3 lines
Ok, I can have a look.
Should C be preferred for new tests?
Quoted 7 lines
+Stephen Warren
For sandbox tests, yes. If there is a lot of interaction, Python is extremely slow.
But with Python we can run a test on real hardware without compiling the test into U-Boot. So there are benefits on both sides.
Quoted 7 lines
Ok, I looked into it, and the python test uses the
assert 'somestring' in output
idiom a lot. From what I can tell, there's not an easy way to replicate this behavior on the C side of things. Adding a function to do this would probably call for its own patch. I could also use the existing functionality to test for lines, but I think that would be much more brittle when compared to the python version.
Quoted 1 line
Well you could add
assert_nextline_contains()for example?
Yes, but I would also have to skip a specific number of lines, e.g.
console_record_reset();run_command("pinmux", 0);ut_assert_nextline_contains("");ut_assert_nextline_contains("");ut_assert_nextline_contains("Usage:");
console_record_reset();
/* ... */
That's ok, but still fairly brittle in how it tests the output.
Oh well, perhaps I'll add something like that next revision...
--Sean
PATCH v2 3/10 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 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 | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/kendryte/Kconfig | 7 + drivers/pinctrl/kendryte/Makefile | 1 + drivers/pinctrl/kendryte/pinctrl.c | 678 ++++++++++++++++++ drivers/pinctrl/kendryte/pinctrl.h | 70 ++ include/dt-bindings/pinctrl/k210-pinctrl.h | 277 +++++++ 9 files changed, 1139 insertions(+) create mode 100644 doc/device-tree-bindings/pinctrl/kendryte,k210-fpioa.txt create mode 100644 drivers/pinctrl/kendryte/Kconfig create mode 100644 drivers/pinctrl/kendryte/Makefile create mode 100644 drivers/pinctrl/kendryte/pinctrl.c create mode 100644 drivers/pinctrl/kendryte/pinctrl.h create mode 100644 include/dt-bindings/pinctrl/k210-pinctrl.h
MAINTAINERS +2 -0
@@ -876,7 +876,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 +1 -0
@@ -289,6 +289,7 @@ endif source "drivers/pinctrl/broadcom/Kconfig" source "drivers/pinctrl/exynos/Kconfig" source "drivers/pinctrl/intel/Kconfig" +source "drivers/pinctrl/kendryte/Kconfig" source "drivers/pinctrl/mediatek/Kconfig" source "drivers/pinctrl/meson/Kconfig" source "drivers/pinctrl/mscc/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) += kendryte/ obj-$(CONFIG_PINCTRL_MESON) += meson/ obj-$(CONFIG_PINCTRL_MTK) += mediatek/ obj-$(CONFIG_PINCTRL_MSCC) += mscc/
drivers/pinctrl/kendryte/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +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.
drivers/pinctrl/kendryte/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += pinctrl.o
drivers/pinctrl/kendryte/pinctrl.c new file +678 -0
678 lines not on this page · raw message
drivers/pinctrl/kendryte/pinctrl.h new file +70 -0
70 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.26.2
PATCH v2 4/10 gpio: sifive: Use generic reg read function
In reply to Sean AndersonUsing an fdt-specific function causes problems with a live tree.
---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
(no changes since v1)
drivers/gpio/sifive-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/sifive-gpio.c +1 -1
@@ -159,7 +159,7 @@ static int sifive_gpio_ofdata_to_platdata(struct udevice *dev)struct sifive_gpio_platdata *plat =dev_get_platdata (dev);fdt_addr_t addr; - addr =devfdt_get_addr (dev); + addr =dev_read_addr (dev);if (addr ==FDT_ADDR_T_NONE )return -EINVAL ;
Signature · 1 line
2.26.2
PATCH v2 5/10 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.26.2
Tan
PATCH v2 5/10 gpio: dw: Fix warnings about casting int to pointer
Quoted 18 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Monday, June 8, 2020 9:27 AM
To: u-boot at lists.denx.de
Cc: Tom Rini <[email protected]>; Bin Meng <[email protected]>; Rick Chen <[email protected]>; Simon Glass <[email protected]>; Sean Anderson <[email protected]>; Anatolij Gustschin <[email protected]>; Tan, Ley Foon <[email protected]>; Marek Vasut <[email protected]>; Simon Goldschmidt <[email protected]>
Subject: [PATCH v2 05/10] gpio: dw: Fix warnings about casting int to pointerChange 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 Bin Meng <[email protected]>
Quoted 9 lines
---
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(-)
PATCH v2 5/10 gpio: dw: Fix warnings about casting int to pointer
In reply to Sean AndersonQuoted 6 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 Bin Meng <[email protected]>
Quoted 8 lines
---
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(-)
PATCH v2 6/10 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.26.2
PATCH v2 7/10 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
Changes in v2:
- Reorder changes to minimize diff
drivers/gpio/dwapb_gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/dwapb_gpio.c +7 -2
@@ -69,9 +69,14 @@ static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin,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)); -} +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 int dwapb_gpio_set_value (struct udevice *dev,unsigned pin,int val) {
Signature · 1 line
2.26.2
Tan
PATCH v2 7/10 gpio: dw: Return output value when direction is out
Quoted 23 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Monday, June 8, 2020 9:27 AM
To: u-boot at lists.denx.de
Cc: Tom Rini <[email protected]>; Bin Meng <[email protected]>; Rick Chen <[email protected]>; Simon Glass <[email protected]>; Sean Anderson <[email protected]>; Anatolij Gustschin <[email protected]>; Tan, Ley Foon <[email protected]>; Marek Vasut <[email protected]>; Simon Goldschmidt <[email protected]>
Subject: [PATCH v2 07/10] gpio: dw: Return output value when direction is outdm_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]>---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
Quoted 6 lines
Changes in v2:
- Reorder changes to minimize diffdrivers/gpio/dwapb_gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
PATCH v2 7/10 gpio: dw: Return output value when direction is out
In reply to Sean AndersonQuoted 11 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]>---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576Changes in v2:
- Reorder changes to minimize diff
...and I just noticed that this breaks the build since dwapb_gpio_get_function is not declared yet. Will revert to the previous version of this patch in the next revision.
Quoted 16 lines
drivers/gpio/dwapb_gpio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/gpio/dwapb_gpio.c +1
-2@@ -69,9 +69,14 @@ static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin,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)); -} +u32 value;
drivers/gpio/dwapb_gpio.c static int dwapb_gpio_direction_output(struct udevice *dev, unsigned pin, · line 82
Quoted 10 lines
drivers/gpio/dwapb_gpio.c +6
-0+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 int dwapb_gpio_set_value (struct udevice *dev,unsigned pin,int val) {
--Sean
PATCH v2 8/10 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.26.2
PATCH v2 8/10 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]>
Quoted 8 lines
---
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(-)
Is there no test for this?
PATCH v2 8/10 led: gpio: Default to using node name if label is absent
Quoted 10 lines · Simon Glass
Quoted 9 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]>---
This patch was previously submitted as part of
https://patchwork.ozlabs.org/project/uboot/list/?series=161576
Quoted 9 lines
Quoted 4 lines
(no changes since v1)
drivers/led/led_gpio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Reviewed-by Simon Glass <[email protected]>Is there no test for this?
There is not; I can add one in the next revision if you'd like. We probably just need to delete a label from the test device tree.
--Sean
PATCH v2 8/10 led: gpio: Default to using node name if label is absent
Hi Sean,
Quoted 18 lines · Sean Anderson
Quoted 15 lines · Simon Glass
Quoted 13 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]>---
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(-)
Quoted 8 lines
Quoted 4 lines
Reviewed-by Simon Glass <[email protected]>Is there no test for this?
There is not; I can add one in the next revision if you'd like. We probably just need to delete a label from the test device tree.
Yes please.
Regards,
Simon
PATCH v2 9/10 riscv: Add pinmux and gpio bindings for Kendryte K210
In reply to Sean AndersonThis patch adds the necessary device tree bindings.
---
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> / {
@@ -367,7 +368,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.26.2
PATCH v2 10/10 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 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
80 lines not on this page · raw message
Signature · 1 line
2.26.2