pinctrl: common handling of generic pinconfig props in dt
Subsystems (3)
Heiko Stübner
maintainerv2 cover pinctrl: common handling of generic pinconfig props in dt
Hi Linus,
here is my second try ... after our talk today, hopefully more future proof (and acceptable).
I hadn't found a way to have the phandle as a simple argument in the pins property, so the example Rockchip driver now uses a second property rockchip,config = <&phandle>; to hold the link to the config node.
Surprisingly everything still works ;-) .
Heiko Stuebner (2):
pinctrl: add function to parse generic pinconfig properties from a dt node
pinctrl: add pinctrl driver for Rockchip SoCs
.../bindings/pinctrl/pinctrl-bindings.txt | 38 + .../bindings/pinctrl/rockchip,pinctrl.txt | 98 ++ drivers/pinctrl/Kconfig | 6 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinconf-generic.c | 81 ++ drivers/pinctrl/pinconf.h | 6 + drivers/pinctrl/pinctrl-rockchip.c | 1346 ++++++++++++++++++++ include/dt-bindings/pinctrl/rockchip.h | 32 + 8 files changed, 1608 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt create mode 100644 drivers/pinctrl/pinctrl-rockchip.c create mode 100644 include/dt-bindings/pinctrl/rockchip.h
Signature · 1 line
1.7.2.3
Heiko Stübner
maintainerPATCH v2 1/2 pinctrl: add function to parse generic pinconfig properties from a dt node
pinconf_generic_parse_dt_config() takes a node as input and generates an array of generic pinconfig values from the properties of this node.
As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
--- .../bindings/pinctrl/pinctrl-bindings.txt | 38 +++++++++ drivers/pinctrl/pinconf-generic.c | 81 ++++++++++++++++++++ drivers/pinctrl/pinconf.h | 6 ++ 3 files changed, 125 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +38 -0
@@ -126,3 +126,41 @@ device; they may be grandchildren, for example. Whether this is legal, and whether there is any interaction between the child and intermediate parent nodes, is again defined entirely by the binding for the individual pin controller device. + +== Using generic pinconfig options == + +Generic pinconfig parameters can be used by defining a separate node containing +the applicable parameters (and optional values), like: + +pcfg_pull_up: pcfg_pull_up { + bias-pull-up; + drive-strength = <20>; +}; + +This node should then be referenced in the appropriate pinctrl node as a phandle +and parsed in the driver using the pinconf_generic_parse_dt_config function. + +Supported configuration parameters are: + +bias-disable - disable any pin bias +bias-high-impedance - high impedance mode ("third-state", "floating") +bias-bus-hold - latch weakly +bias-pull-up - pull up the pin +bias-pull-down - pull down the pin +bias-pull-pin-default - use pin-default pull state +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-schmitt-enable - enable schmitt-trigger mode +input-schmitt-disable - disable schmitt-trigger mode +input-schmitt - run in schmitt-trigger mode with hysteresis X +input-debounce - debounce mode with debound time X +power-source - select power source X +slew-rate - use slew-rate X +low-power-mode - low power mode +output-low - set the pin to output mode with low level +output-high - set the pin to output mode with high level + +More in-depth documentation on these parameters can be found in +<include/linux/pinctrl/pinconfig-generic.h>
drivers/pinctrl/pinconf-generic.c +81 -0
90 lines not on this page · raw message
drivers/pinctrl/pinconf.h +6 -0
@@ -123,3 +123,9 @@ static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, return; }#endif + +#if defined(CONFIG_GENERIC_PINCONF ) && defined(CONFIG_OF ) +int pinconf_generic_parse_dt_config (struct device_node *np, +unsigned long **configs, +unsigned int *nconfigs); +#endif
Signature · 1 line
1.7.2.3
Heiko Stübner
maintainerPATCH v2 2/2 pinctrl: add pinctrl driver for Rockchip SoCs
In reply to Heiko StübnerThis driver adds support the Cortex-A9 based SoCs from Rockchip, so at least the RK2928, RK3066 (a and b) and RK3188. Earlier Rockchip SoCs seem to use similar mechanics for gpio handling so should be supportable with relative small changes. Pull handling on the rk3188 is currently a stub, due to it being a bit different to the earlier SoCs.
Pinmuxing as well as gpio (and interrupt-) handling tested on a rk3066a based machine.
---
After Stephen Warren's clarification, again with <dt-bindings/...> include. and of course adapted to the new expected dt node-structure
.../bindings/pinctrl/rockchip,pinctrl.txt | 98 ++ drivers/pinctrl/Kconfig | 6 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rockchip.c | 1346 ++++++++++++++++++++ include/dt-bindings/pinctrl/rockchip.h | 32 + 5 files changed, 1483 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt create mode 100644 drivers/pinctrl/pinctrl-rockchip.c create mode 100644 include/dt-bindings/pinctrl/rockchip.h
Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt new file +98 -0
@@ -0,0 +1,98 @@ +* Rockchip Pinmux Controller + +The Rockchip Pinmux Controller, enables the IC +to share one PAD to several functional blocks. The sharing is done by +multiplexing the PAD input/output signals. For each PAD there are up to +4 muxing options with option 0 being the use as a GPIO. + +Please refer to pinctrl-bindings.txt in this directory for details of the +common pinctrl bindings used by client devices, including the meaning of the +phrase "pin configuration node". + +The Rockchip pin configuration node is a node of a group of pins which can be +used for a specific device or function. This node represents both mux and +config of the pins in that group. The 'pins' selects the function mode(also +named pin mode) this pin can work on and the 'config' configures various pad +settings such as pull-up, etc. + +The pins are grouped into up to 5 individual pin banks which need to be +defined as gpio sub-nodes of the pinmux controller. + +Required properties for iomux controller: + - compatible: one of "rockchip,rk2928-pinctrl", "rockchip,rk3066a-pinctrl" + "rockchip,rk3066b-pinctrl", "rockchip,rk3188-pinctrl" + +Required properties for gpio sub nodes: + - compatible: "rockchip,gpio-bank" + - reg: register of the gpio bank (different than the iomux registerset) + - interrupts: base interrupt of the gpio bank in the interrupt controller + - clocks: clock that drives this bank + - gpio-controller: identifies the node as a gpio controller and pin bank. + - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO + binding is used, the amount of cells must be specified as 2. See generic + GPIO binding documentation for description of particular cells. + - interrupt-controller: identifies the controller node as interrupt-parent. + - #interrupt-cells: the value of this property should be 2 and the interrupt + cells should use the standard two-cell scheme described in + bindings/interrupt-controller/interrupts.txt + +Required properties for pin configuration node: + - rockchip,pins: 3 integers array, represents a group of pins mux and config + setting. The format is rockchip,pins = <PIN_BANK PIN_BANK_IDX MUX>. + The MUX 0 means gpio and MUX 1 to 3 mean the specific device function. + - rockchip,config: phandle of a node containing the generic pinconfig options + to use, as described in pinctrl-bindings.txt in this directory. + +Examples: + +#include <dt-bindings/pinctrl/rockchip.h> + +... + +pinctrl at 20008000 { + compatible = "rockchip,rk3066a-pinctrl"; + reg = <0x20008000 0x150>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + gpio0: gpio0 at 20034000 { + compatible = "rockchip,gpio-bank"; + reg = <0x20034000 0x100>; + interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk_gates8 9>; + + gpio-controller; + #gpio-cells = <2>; + + interrupt-controller; + #interrupt-cells = <2>; + }; + + ... + + pcfg_pull_default: pcfg_pull_default { + bias-pull-pin-default + }; + + uart2 { + uart2_xfer: uart2-xfer { + rockchip,pins = <RK_GPIO1 8 1>, + <RK_GPIO1 9 1>; + rockchip,config = <&pcfg_pull_default>; + }; + }; +}; + +uart2: serial at 20064000 { + compatible = "snps,dw-apb-uart"; + reg = <0x20064000 0x400>; + interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; + reg-shift = <2>; + reg-io-width = <1>; + clocks = <&mux_uart2>; + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart2_xfer>; +};
drivers/pinctrl/Kconfig +6 -0
@@ -158,6 +158,12 @@ config PINCTRL_DB8540 bool "DB8540 pin controller driver" depends on PINCTRL_NOMADIK && ARCH_U8500 +config PINCTRL_ROCKCHIP + bool + select PINMUX + select GENERIC_PINCONF + select GENERIC_IRQ_CHIP + config PINCTRL_SINGLE tristate "One-register-per-pin type device tree based pinctrl driver" depends on OF
drivers/pinctrl/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_PINCTRL_NOMADIK) += pinctrl-nomadik.o obj-$(CONFIG_PINCTRL_STN8815) += pinctrl-nomadik-stn8815.o obj-$(CONFIG_PINCTRL_DB8500) += pinctrl-nomadik-db8500.o obj-$(CONFIG_PINCTRL_DB8540) += pinctrl-nomadik-db8540.o +obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_SIRF) += sirf/ obj-$(CONFIG_PINCTRL_SUNXI) += pinctrl-sunxi.o
drivers/pinctrl/pinctrl-rockchip.c new file +1346 -0
1,346 lines not on this page · raw message
include/dt-bindings/pinctrl/rockchip.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Header providing constants for Rockchip pinctrl bindings. +* +* Copyright (c) 2013 MundoReader S.L. +* Author: Heiko Stuebner <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __DT_BINDINGS_ROCKCHIP_PINCTRL_H__ +#define __DT_BINDINGS_ROCKCHIP_PINCTRL_H__ + +#define RK_GPIO0 0 +#define RK_GPIO1 1 +#define RK_GPIO2 2 +#define RK_GPIO3 3 +#define RK_GPIO4 4 +#define RK_GPIO6 6 + +#define RK_FUNC_GPIO 0 +#define RK_FUNC_1 1 +#define RK_FUNC_2 2 + +#endif
Signature · 1 line
1.7.2.3
Heiko Stübner
maintainerPATCH v3 2/2 pinctrl: add pinctrl driver for Rockchip SoCs
This driver adds support the Cortex-A9 based SoCs from Rockchip, so at least the RK2928, RK3066 (a and b) and RK3188. Earlier Rockchip SoCs seem to use similar mechanics for gpio handling so should be supportable with relative small changes. Pull handling on the rk3188 is currently a stub, due to it being a bit different to the earlier SoCs.
Pinmuxing as well as gpio (and interrupt-) handling tested on a rk3066a based machine.
---
changes since v2:
Found out how to handle the phandle in the regular rockchip,pins property 5 minutes after sending the v2 ... damn :-) .
I'm terribly sorry for all the noise.
After Stephen Warren's clarification, again with <dt-bindings/...> include. and of course adapted to the new expected dt node-structure
.../bindings/pinctrl/rockchip,pinctrl.txt | 97 ++ drivers/pinctrl/Kconfig | 6 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rockchip.c | 1360 ++++++++++++++++++++ include/dt-bindings/pinctrl/rockchip.h | 32 + 5 files changed, 1496 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt create mode 100644 drivers/pinctrl/pinctrl-rockchip.c create mode 100644 include/dt-bindings/pinctrl/rockchip.h
Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt new file +97 -0
@@ -0,0 +1,97 @@ +* Rockchip Pinmux Controller + +The Rockchip Pinmux Controller, enables the IC +to share one PAD to several functional blocks. The sharing is done by +multiplexing the PAD input/output signals. For each PAD there are up to +4 muxing options with option 0 being the use as a GPIO. + +Please refer to pinctrl-bindings.txt in this directory for details of the +common pinctrl bindings used by client devices, including the meaning of the +phrase "pin configuration node". + +The Rockchip pin configuration node is a node of a group of pins which can be +used for a specific device or function. This node represents both mux and +config of the pins in that group. The 'pins' selects the function mode(also +named pin mode) this pin can work on and the 'config' configures various pad +settings such as pull-up, etc. + +The pins are grouped into up to 5 individual pin banks which need to be +defined as gpio sub-nodes of the pinmux controller. + +Required properties for iomux controller: + - compatible: one of "rockchip,rk2928-pinctrl", "rockchip,rk3066a-pinctrl" + "rockchip,rk3066b-pinctrl", "rockchip,rk3188-pinctrl" + +Required properties for gpio sub nodes: + - compatible: "rockchip,gpio-bank" + - reg: register of the gpio bank (different than the iomux registerset) + - interrupts: base interrupt of the gpio bank in the interrupt controller + - clocks: clock that drives this bank + - gpio-controller: identifies the node as a gpio controller and pin bank. + - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO + binding is used, the amount of cells must be specified as 2. See generic + GPIO binding documentation for description of particular cells. + - interrupt-controller: identifies the controller node as interrupt-parent. + - #interrupt-cells: the value of this property should be 2 and the interrupt + cells should use the standard two-cell scheme described in + bindings/interrupt-controller/interrupts.txt + +Required properties for pin configuration node: + - rockchip,pins: 3 integers array, represents a group of pins mux and config + setting. The format is rockchip,pins = <PIN_BANK PIN_BANK_IDX MUX &phandle>. + The MUX 0 means gpio and MUX 1 to 3 mean the specific device function. + The phandle of a node containing the generic pinconfig options + to use, as described in pinctrl-bindings.txt in this directory. + +Examples: + +#include <dt-bindings/pinctrl/rockchip.h> + +... + +pinctrl at 20008000 { + compatible = "rockchip,rk3066a-pinctrl"; + reg = <0x20008000 0x150>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + gpio0: gpio0 at 20034000 { + compatible = "rockchip,gpio-bank"; + reg = <0x20034000 0x100>; + interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk_gates8 9>; + + gpio-controller; + #gpio-cells = <2>; + + interrupt-controller; + #interrupt-cells = <2>; + }; + + ... + + pcfg_pull_default: pcfg_pull_default { + bias-pull-pin-default + }; + + uart2 { + uart2_xfer: uart2-xfer { + rockchip,pins = <RK_GPIO1 8 1 &pcfg_pull_default>, + <RK_GPIO1 9 1 &pcfg_pull_default>; + }; + }; +}; + +uart2: serial at 20064000 { + compatible = "snps,dw-apb-uart"; + reg = <0x20064000 0x400>; + interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; + reg-shift = <2>; + reg-io-width = <1>; + clocks = <&mux_uart2>; + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&uart2_xfer>; +};
drivers/pinctrl/Kconfig +6 -0
@@ -158,6 +158,12 @@ config PINCTRL_DB8540 bool "DB8540 pin controller driver" depends on PINCTRL_NOMADIK && ARCH_U8500 +config PINCTRL_ROCKCHIP + bool + select PINMUX + select GENERIC_PINCONF + select GENERIC_IRQ_CHIP + config PINCTRL_SINGLE tristate "One-register-per-pin type device tree based pinctrl driver" depends on OF
drivers/pinctrl/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_PINCTRL_NOMADIK) += pinctrl-nomadik.o obj-$(CONFIG_PINCTRL_STN8815) += pinctrl-nomadik-stn8815.o obj-$(CONFIG_PINCTRL_DB8500) += pinctrl-nomadik-db8500.o obj-$(CONFIG_PINCTRL_DB8540) += pinctrl-nomadik-db8540.o +obj-$(CONFIG_PINCTRL_ROCKCHIP) += pinctrl-rockchip.o obj-$(CONFIG_PINCTRL_SINGLE) += pinctrl-single.o obj-$(CONFIG_PINCTRL_SIRF) += sirf/ obj-$(CONFIG_PINCTRL_SUNXI) += pinctrl-sunxi.o
drivers/pinctrl/pinctrl-rockchip.c new file +1360 -0
1,360 lines not on this page · raw message
include/dt-bindings/pinctrl/rockchip.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Header providing constants for Rockchip pinctrl bindings. +* +* Copyright (c) 2013 MundoReader S.L. +* Author: Heiko Stuebner <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __DT_BINDINGS_ROCKCHIP_PINCTRL_H__ +#define __DT_BINDINGS_ROCKCHIP_PINCTRL_H__ + +#define RK_GPIO0 0 +#define RK_GPIO1 1 +#define RK_GPIO2 2 +#define RK_GPIO3 3 +#define RK_GPIO4 4 +#define RK_GPIO6 6 + +#define RK_FUNC_GPIO 0 +#define RK_FUNC_1 1 +#define RK_FUNC_2 2 + +#endif
Signature · 1 line
1.7.2.3
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerQuoted 8 lines · Heiko St?bner
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]>
Looks good, patch applied!
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt device; they may be grandchildren, for example. Whether this is legal, and · line 146
Quoted 4 lines
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +4
-0+Supported configuration parameters are: + +bias-disable - disable any pin bias +bias-high-impedance - high impedance mode ("third-state", "floating")
(...)
We should probably document applicable arguments to these, and indicate which ones are boolean. But that can be fixed up later.
Yours,
Linus Walleij
Re: [PATCH 2/2 v3] pinctrl: add pinctrl driver for Rockchip SoCs
In reply to Heiko StübnerQuoted 18 lines · Heiko St?bner
This driver adds support the Cortex-A9 based SoCs from Rockchip, so at least the RK2928, RK3066 (a and b) and RK3188. Earlier Rockchip SoCs seem to use similar mechanics for gpio handling so should be supportable with relative small changes. Pull handling on the rk3188 is currently a stub, due to it being a bit different to the earlier SoCs.
Pinmuxing as well as gpio (and interrupt-) handling tested on a rk3066a based machine.
Signed-off-by Heiko Stuebner <[email protected]>---
changes since v2:
Found out how to handle the phandle in the regular rockchip,pins property 5 minutes after sending the v2 ... damn :-) .
I'm terribly sorry for all the noise.
Quoted 2 lines
After Stephen Warren's clarification, again with <dt-bindings/...> include. and of course adapted to the new expected dt node-structure
Thanks, this v3 version applied.
And don't worry about the noise, it is normal in situations like these where we're seeing rapid development of core stuff and building consensus.
Yours,
Linus Walleij
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerHi Heiko,
Quoted 8 lines · Heiko St?bner
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]>
<snip>
Quoted 22 lines
drivers/pinctrl/pinconf-generic.c +18
-0@@ -139,3 +140,83 @@ void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinconf_generic_dump_config);#endif + +#ifdef CONFIG_OF +struct pinconf_generic_dt_params { +const char *const property; +enum pin_config_param param; +u32 default_value; +}; + +static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + { "drive-open-source", PIN_CONFIG_DRIVE_OPEN_SOURCE, 0 },
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 170
Quoted 10 lines
drivers/pinctrl/pinconf-generic.c +10
-0+ { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 }, + { "input-schmitt-enable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 1 }, + { "input-schmitt-disable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 0 }, + { "input-schmitt", PIN_CONFIG_INPUT_SCHMITT, 0 }, + { "input-debounce", PIN_CONFIG_INPUT_DEBOUNCE, 0 }, + { "power-source", PIN_CONFIG_POWER_SOURCE, 0 }, + { "slew-rate", PIN_CONFIG_SLEW_RATE, 0 }, + { "low-power-mode", PIN_CONFIG_LOW_POWER_MODE, 0 }, + { "output-low", PIN_CONFIG_OUTPUT, 0, }, + { "output-high", PIN_CONFIG_OUTPUT, 1, },
shouldn't half of these default to 1 instead of 0? i.e. it's much nicer for the lone flag "bias-pull-up" to enable pull up rather than disable it (you even do this in the DT example in the bindings doc).
Otherwise the patch looks good to me (though I haven't tried it yet).
Cheers
James
Heiko Stübner
maintainerRe: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Hi James,
Am Mittwoch, 12. Juni 2013, 16:55:12 schrieb James Hogan:
Quoted 45 lines
Hi Heiko,
Quoted 8 lines · Heiko St?bner
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]><snip>
Quoted 31 lines
drivers/pinctrl/pinconf-generic.c +24
-0@@ -139,3 +140,83 @@ void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinconf_generic_dump_config);#endif + +#ifdef CONFIG_OF +struct pinconf_generic_dt_params { +const char *const property; +enum pin_config_param param; +u32 default_value; +}; + +static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + { "power-source", PIN_CONFIG_POWER_SOURCE, 0 },
Quoted 8 lines
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 170
Quoted 4 lines
drivers/pinctrl/pinconf-generic.c +4
-0+ { "slew-rate", PIN_CONFIG_SLEW_RATE, 0 }, + { "low-power-mode", PIN_CONFIG_LOW_POWER_MODE, 0 }, + { "output-low", PIN_CONFIG_OUTPUT, 0, }, + { "output-high", PIN_CONFIG_OUTPUT, 1, },shouldn't half of these default to 1 instead of 0? i.e. it's much nicer for the lone flag "bias-pull-up" to enable pull up rather than disable it (you even do this in the DT example in the bindings doc).
on closer inspection it seems that you may be right. The documentation to the options in the pinconf-generic header even tells that for example the pull options do have a 0 or 1 argument.
I guess I got much inspiration from sh-pfc/pinctrl.c when learning about the generic pinconf, which ignores any argument for these options, which I then have mimiced in my rockchip driver and here.
But I'm not sure if I understand everything correctly :-) ... isn't the bias- disable the opposite of turning on a pull (like the sh-pfc/pinctrl does) and same with switching from one pull type to another, i.e. activating a pull up would turn off a pull down and on the whole making the argument redundant?
The only other candidate I could find was low-power-mode which really could use a "1" as default. All the other pinconf options either use custom arguments or ignore teir argument.
Quoted 1 line
Otherwise the patch looks good to me (though I haven't tried it yet).
nice
Heiko
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Tisdagen den 13:e Juni 2013 klock 12:22 AM, skrev Heiko St?bner <[email protected]>:
Quoted 23 lines
Am Mittwoch, 12. Juni 2013, 16:55:12 schrieb James Hogan:
Quoted 21 lines
Quoted 20 lines
drivers/pinctrl/pinconf-generic.c +20
-0+static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + {"power-source" ,PIN_CONFIG_POWER_SOURCE ,0 }, + {"slew-rate" ,PIN_CONFIG_SLEW_RATE ,0 }, + {"low-power-mode" ,PIN_CONFIG_LOW_POWER_MODE ,0 }, + {"output-low" ,PIN_CONFIG_OUTPUT ,0 , }, + {"output-high" ,PIN_CONFIG_OUTPUT ,1 , },
Quoted 5 lines
Quoted 3 lines
shouldn't half of these default to 1 instead of 0? i.e. it's much nicer for the lone flag "bias-pull-up" to enable pull up rather than disable it (you even do this in the DT example in the bindings doc).
on closer inspection it seems that you may be right.
Heiko can you write a patch for this? You can hit both this code and the Rockchip driver at the same time for sure. Please check that the bindings are consistent.
Quoted 3 lines
The documentation to the
options in the pinconf-generic header even tells that for example the pull options do have a 0 or 1 argument.
Yeah. Well.
Actually there has been plans to have the argument represent the number of Ohms on the pull-up, but we haven't seen any hardware that can actually select that.
Maybe we should add that now? It will still be that != 0 implies enablement on platforms that does not support specifying the pull up/down resistance.
Quoted 4 lines
But I'm not sure if I understand everything correctly :-) ... isn't the bias- disable the opposite of turning on a pull (like the sh-pfc/pinctrl does) and same with switching from one pull type to another, i.e. activating a pull up would turn off a pull down and on the whole making the argument redundant?
This is true, and the plan is surely for the core to not allow or print a big fat warning if someone does something really stupid like activate pull up and pull down at the same time (unless s/he's constructing a heater radiator or something).
Currently we don't make any sanity checks like that, BUT your generic parser could actually be extended to do that.
Patches welcome ;-)
Quoted 3 lines
The only other candidate I could find was low-power-mode which really could use a "1" as default. All the other pinconf options either use custom arguments or ignore teir argument.
A "1" for what? Not quite following....
Yours,
Linus Walleij
Heiko Stübner
maintainerRe: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Am Donnerstag, 13. Juni 2013, 10:11:28 schrieb Linus Walleij:
Quoted 41 lines
Tisdagen den 13:e Juni 2013 klock 12:22 AM, skrev Heiko St?bner
Quoted 22 lines
Am Mittwoch, 12. Juni 2013, 16:55:12 schrieb James Hogan:
Quoted 21 lines
Quoted 20 lines
drivers/pinctrl/pinconf-generic.c +20
-0+static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + {"power-source" ,PIN_CONFIG_POWER_SOURCE ,0 }, + {"slew-rate" ,PIN_CONFIG_SLEW_RATE ,0 }, + {"low-power-mode" ,PIN_CONFIG_LOW_POWER_MODE ,0 }, + {"output-low" ,PIN_CONFIG_OUTPUT ,0 , }, + {"output-high" ,PIN_CONFIG_OUTPUT ,1 , },Quoted 5 lines
Quoted 3 lines
shouldn't half of these default to 1 instead of 0? i.e. it's much nicer for the lone flag "bias-pull-up" to enable pull up rather than disable it (you even do this in the DT example in the bindings doc).
on closer inspection it seems that you may be right.
Heiko can you write a patch for this? You can hit both this code and the Rockchip driver at the same time for sure. Please check that the bindings are consistent.
Quoted 3 lines
The documentation to the
options in the pinconf-generic header even tells that for example the pull options do have a 0 or 1 argument.Yeah. Well.
Quoted 7 lines
Actually there has been plans to have the argument represent the number of Ohms on the pull-up, but we haven't seen any hardware that can actually select that.
Maybe we should add that now? It will still be that != 0 implies enablement on platforms that does not support specifying the pull up/down resistance.
Ok, I'll see that I get this fixed :-)
Quoted 12 lines
Quoted 6 lines
But I'm not sure if I understand everything correctly :-) ... isn't the bias- disable the opposite of turning on a pull (like the sh-pfc/pinctrl does) and same with switching from one pull type to another, i.e. activating a pull up would turn off a pull down and on the whole making the argument redundant?
This is true, and the plan is surely for the core to not allow or print a big fat warning if someone does something really stupid like activate pull up and pull down at the same time (unless s/he's constructing a heater radiator or something).
Quoted 4 lines
Currently we don't make any sanity checks like that, BUT your generic parser could actually be extended to do that.
Patches welcome ;-)
I don't seem to get of the hook here ;-)
But I'll try to fix the issue above first.
Quoted 5 lines
Quoted 3 lines
The only other candidate I could find was low-power-mode which really could use a "1" as default. All the other pinconf options either use custom arguments or ignore teir argument.
A "1" for what? Not quite following....
According to the pinconf header docs, low-power-mode also expects an argument of 1 or 0. So it's default value should change too ... or we could rename the property, like "low-power-enable" and "low-power-disable", which might make the dt more readable than an arbitary low-power-mode = <0>;
Heiko
Heiko Stübner
maintainerRe: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Am Donnerstag, 13. Juni 2013, 16:35:20 schrieb Heiko St?bner:
Quoted 46 lines
Am Donnerstag, 13. Juni 2013, 10:11:28 schrieb Linus Walleij:
Quoted 45 lines
Tisdagen den 13:e Juni 2013 klock 12:22 AM, skrev Heiko St?bner
Quoted 22 lines
Am Mittwoch, 12. Juni 2013, 16:55:12 schrieb James Hogan:
Quoted 21 lines
Quoted 20 lines
drivers/pinctrl/pinconf-generic.c +7
-0+static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + { "drive-push-pull",
PIN_CONFIG_DRIVE_PUSH_PULL, 0 },drivers/pinctrl/pinconf-generic.c +12
-0+ { "drive-open-drain", PIN_CONFIG_DRIVE_OPEN_DRAIN, 0 }, + { "drive-open-source", PIN_CONFIG_DRIVE_OPEN_SOURCE, 0 }, + { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 }, + { "input-schmitt-enable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 1 }, + { "input-schmitt-disable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 0 }, + { "input-schmitt", PIN_CONFIG_INPUT_SCHMITT, 0 }, + { "input-debounce", PIN_CONFIG_INPUT_DEBOUNCE, 0 }, + { "power-source", PIN_CONFIG_POWER_SOURCE, 0 }, + { "slew-rate", PIN_CONFIG_SLEW_RATE, 0 }, + { "low-power-mode", PIN_CONFIG_LOW_POWER_MODE, 0 }, + { "output-low", PIN_CONFIG_OUTPUT, 0, }, + { "output-high", PIN_CONFIG_OUTPUT, 1, },Quoted 5 lines
Quoted 3 lines
shouldn't half of these default to 1 instead of 0? i.e. it's much nicer for the lone flag "bias-pull-up" to enable pull up rather than disable it (you even do this in the DT example in the bindings doc).
on closer inspection it seems that you may be right.
Heiko can you write a patch for this? You can hit both this code and the Rockchip driver at the same time for sure. Please check that the bindings are consistent.
Quoted 3 lines
The documentation to the
options in the pinconf-generic header even tells that for example the pull options do have a 0 or 1 argument.Yeah. Well.
Actually there has been plans to have the argument represent the number of Ohms on the pull-up, but we haven't seen any hardware that can actually select that.
Quoted 5 lines
Quoted 3 lines
Maybe we should add that now? It will still be that != 0 implies enablement on platforms that does not support specifying the pull up/down resistance.
Ok, I'll see that I get this fixed :-)
Hmm ... what is the meaning of the argument of bias-disable and bias-high- impedance, as the kernel-doc in pinconf-generic.h does not tell?
bias-bus-hold ignores its argument and we already clarified that the pull-* do have != 0 or 0 argument.
Thanks
Heiko
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerQuoted 7 lines · Heiko St?bner
Am Donnerstag, 13. Juni 2013, 10:11:28 schrieb Linus Walleij:
Quoted 6 lines
Tisdagen den 13:e Juni 2013 klock 12:22 AM, skrev Heiko St?bner
Quoted 3 lines
The only other candidate I could find was low-power-mode which really could use a "1" as default. All the other pinconf options either use custom arguments or ignore teir argument.
Quoted 6 lines
Quoted 1 line
A "1" for what? Not quite following....
According to the pinconf header docs, low-power-mode also expects an argument of 1 or 0. So it's default value should change too ... or we could rename the property, like "low-power-enable" and "low-power-disable", which might make the dt more readable than an arbitary low-power-mode = <0>;
Oh yes, sorry, of course. Go ahead with this.
Yours,
Linus Walleij
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerQuoted 4 lines · Heiko St?bner
Quoted 1 line
Ok, I'll see that I get this fixed :-)
Hmm ... what is the meaning of the argument of bias-disable and bias-high- impedance, as the kernel-doc in
pinconf-generic.hdoes not tell?
I think those arguments are N/A, ignored, doesn't matter. If these options were typed, they would be bool.
Please improve documentation if you can... sorry for all the rough edges.
Quoted 2 lines
bias-bus-hold ignores its argument and we already clarified that the pull-* do have != 0 or 0 argument.
I think in the DT binding, both these forms:
bias-pull-up;
bias-pull-up = <150000>;
Should be allowed.
So when parsing, you first check if it exists, then if there is an argument, if there is no value supplied, just set it to 1, as that is clearly != 0...
Yours,
Linus Walleij
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Hi Linus,
Quoted 17 lines · On Thursday 13 June 2013 17:36:00 Linus Walleij wrote:
Quoted 4 lines · Heiko Stübner
Quoted 1 line
Ok, I'll see that I get this fixed :-)
Hmm ... what is the meaning of the argument of bias-disable and bias-high- impedance, as the kernel-doc in
pinconf-generic.hdoes not tell?I think those arguments are N/A, ignored, doesn't matter. If these options were typed, they would be bool.
Please improve documentation if you can... sorry for all the rough edges.
Quoted 2 lines
bias-bus-hold ignores its argument and we already clarified that the pull-* do have != 0 or 0 argument.
I think in the DT binding, both these forms:
Quoted 8 lines
bias-pull-up;
bias-pull-up = <150000>;Should be allowed.
So when parsing, you first check if it exists, then if there is an argument, if there is no value supplied, just set it to 1, as that is clearly != 0...
What's the expected way to disable pull-ups in DT ? Should it be 'bias-pull-up = <0>;' or 'bias-disable;' ?
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerHi Heiko,
Thank you for the patch. I've tested it on an sh73a0 KZM9G board with the sh- pfc driver and it seems to work fine. Please see the code below for comments.
Quoted 114 lines · On Monday 10 June 2013 21:40:29 Heiko Stübner wrote:
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]>--- .../bindings/pinctrl/pinctrl-bindings.txt | 38 +++++++++ drivers/pinctrl/pinconf-generic.c | 81 +++++++++++++++++ drivers/pinctrl/pinconf.h | 6 ++ 3 files changed, 125 insertions(+), 0 deletions(-)(quoted diff) +0
-0
b/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txtindex c95ea82..ef7cd57 100644Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +0
-0@@ -126,3 +126,41 @@ device; they may be grandchildren, for example. Whetherthis is legal, and whether there is any interaction between the child and intermediate parent nodes, is again defined entirely by the binding for the individual pin controller device.
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +4
-0+ +== Using generic pinconfig options == + +Generic pinconfig parameters can be used by defining a separate nodecontaining +the applicable parameters (and optional values), like:
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +7
-0+ +pcfg_pull_up: pcfg_pull_up { + bias-pull-up; + drive-strength = <20>; +}; + +This node should then be referenced in the appropriate pinctrl node as aphandle +and parsed in the driver using the
pinconf_generic_parse_dt_configfunction. +Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +24
-0+Supported configuration parameters are: + +bias-disable - disable any pin bias +bias-high-impedance - high impedance mode ("third-state", "floating") +bias-bus-hold - latch weakly +bias-pull-up - pull up the pin +bias-pull-down - pull down the pin +bias-pull-pin-default - use pin-default pull state +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-schmitt-enable - enable schmitt-trigger mode +input-schmitt-disable - disable schmitt-trigger mode +input-schmitt - run in schmitt-trigger mode with hysteresis X +input-debounce - debounce mode with debound time X +power-source - select power source X +slew-rate - use slew-rate X +low-power-mode - low power mode +output-low - set the pin to output mode with low level +output-high - set the pin to output mode with high level + +More in-depth documentation on these parameters can be found in +<include/linux/pinctrl/pinconfig-generic.h>(quoted diff) +0
-0
b/drivers/pinctrl/pinconf-generic.cindex 9a6812b..3610e7b 100644drivers/pinctrl/pinconf-generic.c +36
-0@@ -21,6 +21,7 @@#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinconf-generic.h> +#include <linux/of.h> #include "core.h" #include "pinconf.h" @@ -139,3 +140,83 @@ void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinconf_generic_dump_config);#endif + +#ifdef CONFIG_OF +struct pinconf_generic_dt_params { +const char *const property; +enum pin_config_param param; +u32 default_value; +}; + +static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + {"power-source" ,PIN_CONFIG_POWER_SOURCE ,0 }, + {"slew-rate" ,PIN_CONFIG_SLEW_RATE ,0 }, + {"low-power-mode" ,PIN_CONFIG_LOW_POWER_MODE ,0 }, + {"output-low" ,PIN_CONFIG_OUTPUT ,0 , }, + {"output-high" ,PIN_CONFIG_OUTPUT ,1 , }, +}; + +/** +* pinconf_generic_parse_dt_config() +* parse the config properties into generic pinconfig values. +* @np: node containing the pinconfig properties +* @configs: array with nconfigs entries containing the generic pinconf values + * @nconfigs: umber of configurations
+ */
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 184
Quoted 5 lines
drivers/pinctrl/pinconf-generic.c +5
-0+int pinconf_generic_parse_dt_config (struct device_node *np, +unsigned long **configs, +unsigned int *nconfigs) +{ +unsigned long cfg[ARRAY_SIZE (dt_params)];
I'm a bit uneasy about allocating large arrays on the stack. Would it be better to dynamically allocate cfg ? I've used kzrealloc in my implementation to grow the config array every time a config was found, but that might not be the most efficient implementation, although I wonder how many configuration options we will see in practice in a single node.
Quoted 14 lines
drivers/pinctrl/pinconf-generic.c +14
-0+unsigned int ncfg =0 ; +int ret; +int i; +u32 val; + +if (!np) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (dt_params); i++) { +struct pinconf_generic_dt_params *par = &dt_params[i]; + ret =of_property_read_u32 (np, par->property, &val); + +/* property not found */ +if (ret == -EINVAL )
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 208
Quoted 10 lines
drivers/pinctrl/pinconf-generic.c +10
-0+continue ; + +/* use default value, when no value is specified */ +if (ret) + val = par->default_value; + +pr_debug ("found %s with value %u\n" , par->property, val); + cfg[ncfg] =pinconf_to_config_packed (par->param, val); + ncfg++; + }
You could add
if (ncfg == 0) {
*configs = NULL;
*nconfigs = 0;
return 0;
}here.
Most of the issues I wanted to raise have already been addressed by comments sent to the list. Do you plan to send a v2 in the near future ?
Quoted 28 lines
drivers/pinctrl/pinconf-generic.c +14
-0+ +/* +* Now limit the number of configs to the real number of +* found properties. +*/ + *configs =kzalloc (ncfg *sizeof (unsigned long ),GFP_KERNEL ); +if (!*configs) +return -ENOMEM ; + +memcpy (*configs, &cfg, ncfg *sizeof (unsigned long )); + *nconfigs = ncfg; + return 0; +} +#endif drivers/pinctrl/pinconf.h +6
-0@@ -123,3 +123,9 @@ static inline void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, return; }#endif + +#if defined(CONFIG_GENERIC_PINCONF ) && defined(CONFIG_OF ) +int pinconf_generic_parse_dt_config (struct device_node *np, +unsigned long **configs, +unsigned int *nconfigs); +#endif
Signature · 3 lines
Regards, Laurent Pinchart
Heiko Stübner
maintainerRe: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Hi Laurent,
Am Freitag, 14. Juni 2013, 02:27:01 schrieb Laurent Pinchart:
Quoted 132 lines
Hi Heiko,
Thank you for the patch. I've tested it on an sh73a0 KZM9G board with the sh- pfc driver and it seems to work fine. Please see the code below for comments.
Quoted 125 lines · On Monday 10 June 2013 21:40:29 Heiko St?bner wrote:
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]>---
.../bindings/pinctrl/pinctrl-bindings.txt | 38 +++++++++ drivers/pinctrl/pinconf-generic.c | 81 +++++++++++++++++ drivers/pinctrl/pinconf.h | 6 ++ 3 files changed, 125 insertions(+), 0 deletions(-)diff --git
a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txtb/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txtindex c95ea82..ef7cd57 100644Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +0
-0@@ -126,3 +126,41 @@ device; they may be grandchildren, for example.Whether this is legal, and whether there is any interaction between the child and intermediate parent nodes, is again defined entirely by the binding for the individual pin controller device.
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +4
-0+ +== Using generic pinconfig options == + +Generic pinconfig parameters can be used by defining a separate nodecontaining +the applicable parameters (and optional values), like:
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +7
-0+ +pcfg_pull_up: pcfg_pull_up { + bias-pull-up; + drive-strength = <20>; +}; + +This node should then be referenced in the appropriate pinctrl node as aphandle +and parsed in the driver using the
pinconf_generic_parse_dt_configfunction. +Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +24
-0+Supported configuration parameters are: + +bias-disable - disable any pin bias +bias-high-impedance - high impedance mode ("third-state", "floating") +bias-bus-hold - latch weakly +bias-pull-up - pull up the pin +bias-pull-down - pull down the pin +bias-pull-pin-default - use pin-default pull state +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-schmitt-enable - enable schmitt-trigger mode +input-schmitt-disable - disable schmitt-trigger mode +input-schmitt - run in schmitt-trigger mode with hysteresis X +input-debounce - debounce mode with debound time X +power-source - select power source X +slew-rate - use slew-rate X +low-power-mode - low power mode +output-low - set the pin to output mode with low level +output-high - set the pin to output mode with high level + +More in-depth documentation on these parameters can be found in +<include/linux/pinctrl/pinconfig-generic.h>(quoted diff) +0
-0
b/drivers/pinctrl/pinconf-generic.cindex 9a6812b..3610e7b 100644drivers/pinctrl/pinconf-generic.c +1
-0@@ -21,6 +21,7 @@#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinconf-generic.h> +#include <linux/of.h> #include "
core.h"
#include "pinconf.h"drivers/pinctrl/pinconf-generic.c +35
-0@@ -139,3 +140,83 @@ void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinconf_generic_dump_config);#endif + +#ifdef CONFIG_OF +struct pinconf_generic_dt_params { +const char *const property; +enum pin_config_param param; +u32 default_value; +}; + +static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + {"power-source" ,PIN_CONFIG_POWER_SOURCE ,0 }, + {"slew-rate" ,PIN_CONFIG_SLEW_RATE ,0 }, + {"low-power-mode" ,PIN_CONFIG_LOW_POWER_MODE ,0 }, + {"output-low" ,PIN_CONFIG_OUTPUT ,0 , }, + {"output-high" ,PIN_CONFIG_OUTPUT ,1 , }, +}; + +/** +* pinconf_generic_parse_dt_config() +* parse the config properties into generic pinconfig values. +* @np: node containing the pinconfig properties +* @configs: array with nconfigs entries containing the generic pinconf values + * @nconfigs: umber of configurations
+ */drivers/pinctrl/pinconf-generic.c +3
-0+int pinconf_generic_parse_dt_config (struct device_node *np, +unsigned long **configs, +unsigned int *nconfigs)
Quoted 8 lines
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 184
Quoted 2 lines
drivers/pinctrl/pinconf-generic.c +2
-0+{ +unsigned long cfg[ARRAY_SIZE (dt_params)];I'm a bit uneasy about allocating large arrays on the stack. Would it be better to dynamically allocate cfg ? I've used kzrealloc in my implementation to grow the config array every time a config was found, but that might not be the most efficient implementation, although I wonder how many configuration options we will see in practice in a single node.
Personally I'm not sure ... using kzrealloc once for each found property like I saw it in your patch feels somehow slow, while my big array might cause other problems.
If there was a way to count properties in a dt node this would solve the problem, aka alloc an array of the number of properties, parse props and then move to correct sized array when we know the exact number of found ones.
But I hadn't found a way to get the number of properties and trying to write my own iterating over the properties did result in strange numbers, probably thru inheritance of properties.
Quoted 33 lines
Quoted 14 lines
drivers/pinctrl/pinconf-generic.c +14
-0+unsigned int ncfg =0 ; +int ret; +int i; +u32 val; + +if (!np) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (dt_params); i++) { +struct pinconf_generic_dt_params *par = &dt_params[i]; + ret =of_property_read_u32 (np, par->property, &val); + +/* property not found */ +if (ret == -EINVAL )drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 208
Quoted 10 lines
drivers/pinctrl/pinconf-generic.c +10
-0+continue ; + +/* use default value, when no value is specified */ +if (ret) + val = par->default_value; + +pr_debug ("found %s with value %u\n" , par->property, val); + cfg[ncfg] =pinconf_to_config_packed (par->param, val); + ncfg++; + }You could add
if (ncfg == 0) { *configs = NULL; *nconfigs = 0; return 0; }
Quoted 4 lines
here.
Most of the issues I wanted to raise have already been addressed by comments sent to the list. Do you plan to send a v2 in the near future ?
According to Linus this is already in his tree, so I'm currently working on fixup patches for the issues. Should be done hopefully today.
Heiko
Heiko Stübner
maintainerRe: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Laurent PinchartAm Freitag, 14. Juni 2013, 01:53:49 schrieb Laurent Pinchart:
Quoted 24 lines
Hi Linus,
Quoted 21 lines · On Thursday 13 June 2013 17:36:00 Linus Walleij wrote:
Quoted 5 lines · Heiko St?bner
Quoted 1 line
Ok, I'll see that I get this fixed :-)
Hmm ... what is the meaning of the argument of bias-disable and bias-high- impedance, as the kernel-doc in
pinconf-generic.hdoes not tell?I think those arguments are N/A, ignored, doesn't matter. If these options were typed, they would be bool.
Please improve documentation if you can... sorry for all the rough edges.
Quoted 2 lines
bias-bus-hold ignores its argument and we already clarified that the pull-* do have != 0 or 0 argument.
I think in the DT binding, both these forms:
bias-pull-up;
bias-pull-up = <150000>;
Quoted 8 lines
Quoted 5 lines
Should be allowed.
So when parsing, you first check if it exists, then if there is an argument, if there is no value supplied, just set it to 1, as that is clearly != 0...
What's the expected way to disable pull-ups in DT ? Should it be 'bias-pull-up = <0>;' or 'bias-disable;' ?
According to the kernedoc I think both are valid and should be handled. Using bias-disable is more descriptive but would also include disabling a "high- impedance" or "bus-hold" bias (if supported by the hardware).
Personally, for my rockchip stuff I go with using the "bias-pull-pin-default" <-> "bias-disable".
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerHi Heiko,
Quoted 143 lines · On Friday 14 June 2013 09:34:14 Heiko Stübner wrote:
Am Freitag, 14. Juni 2013, 02:27:01 schrieb Laurent Pinchart:
Quoted 133 lines
Hi Heiko,
Thank you for the patch. I've tested it on an sh73a0 KZM9G board with the sh- pfc driver and it seems to work fine. Please see the code below for comments.
Quoted 126 lines · On Monday 10 June 2013 21:40:29 Heiko Stübner wrote:
pinconf_generic_parse_dt_config()takes a node as input and generates an array of generic pinconfig values from the properties of this node.As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end.
Signed-off-by Heiko Stuebner <[email protected]>---
.../bindings/pinctrl/pinctrl-bindings.txt | 38 +++++++++ drivers/pinctrl/pinconf-generic.c | 81 +++++++++++++ drivers/pinctrl/pinconf.h | 6 ++3 files changed, 125 insertions(+), 0 deletions(-)diff --git
a/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txtb/Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txtindex c95ea82..ef7cd57 100644Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +0
-0@@ -126,3 +126,41 @@ device; they may be grandchildren, for example.Whether this is legal, and whether there is any interaction between the child and intermediate parent nodes, is again defined entirely by the binding for the individual pin controller device.
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +4
-0+ +== Using generic pinconfig options == + +Generic pinconfig parameters can be used by defining a separate nodecontaining +the applicable parameters (and optional values), like:
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +7
-0+ +pcfg_pull_up: pcfg_pull_up { + bias-pull-up; + drive-strength = <20>; +}; + +This node should then be referenced in the appropriate pinctrl node asa
phandle +and parsed in the driver using thepinconf_generic_parse_dt_configfunction. +Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +24
-0+Supported configuration parameters are: + +bias-disable - disable any pin bias +bias-high-impedance - high impedance mode ("third-state", "floating") +bias-bus-hold - latch weakly +bias-pull-up - pull up the pin +bias-pull-down - pull down the pin +bias-pull-pin-default - use pin-default pull state +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-schmitt-enable - enable schmitt-trigger mode +input-schmitt-disable - disable schmitt-trigger mode +input-schmitt - run in schmitt-trigger mode with hysteresis X +input-debounce - debounce mode with debound time X +power-source - select power source X +slew-rate - use slew-rate X +low-power-mode - low power mode +output-low - set the pin to output mode with low level +output-high - set the pin to output mode with high level + +More in-depth documentation on these parameters can be found in +<include/linux/pinctrl/pinconfig-generic.h>(quoted diff) +0
-0
b/drivers/pinctrl/pinconf-generic.cindex 9a6812b..3610e7b 100644drivers/pinctrl/pinconf-generic.c +1
-0@@ -21,6 +21,7 @@#include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinconf-generic.h> +#include <linux/of.h> #include "
core.h"
#include "pinconf.h"drivers/pinctrl/pinconf-generic.c +35
-0@@ -139,3 +140,83 @@ void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, }EXPORT_SYMBOL_GPL (pinconf_generic_dump_config);#endif + +#ifdef CONFIG_OF +struct pinconf_generic_dt_params { +const char *const property; +enum pin_config_param param; +u32 default_value; +}; + +static struct pinconf_generic_dt_params dt_params[] = { + {"bias-disable" ,PIN_CONFIG_BIAS_DISABLE ,0 }, + {"bias-high-impedance" ,PIN_CONFIG_BIAS_HIGH_IMPEDANCE ,0 }, + {"bias-bus-hold" ,PIN_CONFIG_BIAS_BUS_HOLD ,0 }, + {"bias-pull-up" ,PIN_CONFIG_BIAS_PULL_UP ,0 }, + {"bias-pull-down" ,PIN_CONFIG_BIAS_PULL_DOWN ,0 }, + {"bias-pull-pin-default" ,PIN_CONFIG_BIAS_PULL_PIN_DEFAULT ,0 }, + {"drive-push-pull" ,PIN_CONFIG_DRIVE_PUSH_PULL ,0 }, + {"drive-open-drain" ,PIN_CONFIG_DRIVE_OPEN_DRAIN ,0 }, + {"drive-open-source" ,PIN_CONFIG_DRIVE_OPEN_SOURCE ,0 }, + {"drive-strength" ,PIN_CONFIG_DRIVE_STRENGTH ,0 }, + {"input-schmitt-enable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,1 }, + {"input-schmitt-disable" ,PIN_CONFIG_INPUT_SCHMITT_ENABLE ,0 }, + {"input-schmitt" ,PIN_CONFIG_INPUT_SCHMITT ,0 }, + {"input-debounce" ,PIN_CONFIG_INPUT_DEBOUNCE ,0 }, + {"power-source" ,PIN_CONFIG_POWER_SOURCE ,0 }, + {"slew-rate" ,PIN_CONFIG_SLEW_RATE ,0 }, + {"low-power-mode" ,PIN_CONFIG_LOW_POWER_MODE ,0 }, + {"output-low" ,PIN_CONFIG_OUTPUT ,0 , }, + {"output-high" ,PIN_CONFIG_OUTPUT ,1 , }, +}; + +/** +* pinconf_generic_parse_dt_config() +* parse the config properties into generic pinconfig values. +* @np: node containing the pinconfig properties +* @configs: array with nconfigs entries containing the generic pinconf values + * @nconfigs: umber of configurations
+ */drivers/pinctrl/pinconf-generic.c +3
-0+int pinconf_generic_parse_dt_config (struct device_node *np, +unsigned long **configs, +unsigned int *nconfigs)Quoted 8 lines
drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 184
Quoted 2 lines
drivers/pinctrl/pinconf-generic.c +2
-0+{ +unsigned long cfg[ARRAY_SIZE (dt_params)];I'm a bit uneasy about allocating large arrays on the stack. Would it be better to dynamically allocate cfg ? I've used kzrealloc in my implementation to grow the config array every time a config was found, but that might not be the most efficient implementation, although I wonder how many configuration options we will see in practice in a single node.
Quoted 3 lines
Personally I'm not sure ... using kzrealloc once for each found property like I saw it in your patch feels somehow slow, while my big array might cause other problems.
What about allocating the larger array dynamically instead ? Something like
unsigned long *cfg; cfg = kzalloc(sizeof(*cfg) * ARRAY_SIZE(dt_params), GFP_KERNEL); ... (after allocating the returned array and copying data over) kfree(cfg);
Quoted 44 lines
If there was a way to count properties in a dt node this would solve the problem, aka alloc an array of the number of properties, parse props and then move to correct sized array when we know the exact number of found ones.
But I hadn't found a way to get the number of properties and trying to write my own iterating over the properties did result in strange numbers, probably thru inheritance of properties.
Quoted 35 lines
Quoted 14 lines
drivers/pinctrl/pinconf-generic.c +14
-0+unsigned int ncfg =0 ; +int ret; +int i; +u32 val; + +if (!np) +return -EINVAL ; + +for (i =0 ; i <ARRAY_SIZE (dt_params); i++) { +struct pinconf_generic_dt_params *par = &dt_params[i]; + ret =of_property_read_u32 (np, par->property, &val); + +/* property not found */ +if (ret == -EINVAL )drivers/pinctrl/pinconf-generic.c void pinconf_generic_dump_config(struct pinctrl_dev *pctldev, · line 208
Quoted 10 lines
drivers/pinctrl/pinconf-generic.c +10
-0+continue ; + +/* use default value, when no value is specified */ +if (ret) + val = par->default_value; + +pr_debug ("found %s with value %u\n" , par->property, val); + cfg[ncfg] =pinconf_to_config_packed (par->param, val); + ncfg++; + }You could add
if (ncfg == 0) { *configs = NULL; *nconfigs = 0; return 0; }
Quoted 7 lines
Quoted 4 lines
here.
Most of the issues I wanted to raise have already been addressed by comments sent to the list. Do you plan to send a v2 in the near future ?
According to Linus this is already in his tree, so I'm currently working on fixup patches for the issues. Should be done hopefully today.
Sounds good to me.
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
In reply to Heiko StübnerHi Heiko,
Quoted 29 lines · On Friday 14 June 2013 11:18:22 Heiko Stübner wrote:
Am Freitag, 14. Juni 2013, 01:53:49 schrieb Laurent Pinchart:
Quoted 28 lines · On Thursday 13 June 2013 17:36:00 Linus Walleij wrote:
Quoted 26 lines · Heiko Stübner
Quoted 5 lines
Quoted 1 line
Ok, I'll see that I get this fixed :-)
Hmm ... what is the meaning of the argument of bias-disable and bias-high- impedance, as the kernel-doc in
pinconf-generic.hdoes not tell?I think those arguments are N/A, ignored, doesn't matter. If these options were typed, they would be bool.
Please improve documentation if you can... sorry for all the rough edges.
Quoted 2 lines
bias-bus-hold ignores its argument and we already clarified that the pull-* do have != 0 or 0 argument.
I think in the DT binding, both these forms:
bias-pull-up;
bias-pull-up = <150000>;Should be allowed.
So when parsing, you first check if it exists, then if there is an argument, if there is no value supplied, just set it to 1, as that is clearly != 0...
Quoted 6 lines
Quoted 2 lines
What's the expected way to disable pull-ups in DT ? Should it be 'bias-pull-up = <0>;' or 'bias-disable;' ?
According to the kernedoc I think both are valid and should be handled. Using bias-disable is more descriptive but would also include disabling a "high-impedance" or "bus-hold" bias (if supported by the hardware).
OK. I still fail to see how the various bias options are supposed to interract together, but I don't think I'll get an answer on that.
Quoted 2 lines
Personally, for my rockchip stuff I go with using the "bias-pull-pin-default" <-> "bias-disable".
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH 1/2] pinctrl: add function to parse generic pinconfig properties from a dt node
Quoted 5 lines · Laurent Pinchart
Quoted 3 lines · On Friday 14 June 2013 11:18:22 Heiko St?bner wrote:
Quoted 2 lines
What's the expected way to disable pull-ups in DT ? Should it be 'bias-pull-up = <0>;' or 'bias-disable;' ?
Quoted 9 lines
Quoted 3 lines
According to the kernedoc I think both are valid and should be handled. Using bias-disable is more descriptive but would also include disabling a "high-impedance" or "bus-hold" bias (if supported by the hardware).
OK. I still fail to see how the various bias options are supposed to interract together, but I don't think I'll get an answer on that.
Quoted 2 lines
Personally, for my rockchip stuff I go with using the "bias-pull-pin-default" <-> "bias-disable".
I think bias-pull-up = <0>; should actually mean "connect the pin to VDD" and bias-pull-down = <0>; should mean "ground the pin".
This makes a lot of sense from the electronics side of things, let's not create a terminology that appeals to programmers, such that "zero always means boolean disable", because we're dealing with electronics here.
Yours,
Linus Walleij