dm: add support of new binding in gpio and pincontrol
Subsystems (5)
cover dm: add support of new binding in gpio and pincontrol
Hi,
I create this patchset to prepare alignment of stm32mp157c-ev1 device-tree with the linux kernel v5.4.
One node for touch screen support use the IRQ line configuration using the new kernel binding introduced by the linux kernel commit ede033e1e863c from v5.1 ('dt-bindings:
gpio: document the new pull-up/pull-down flags')
https://github.com/torvalds/linux/commit/ede033e1e863c
gt9147: goodix_ts at 5d {
compatible = "goodix,gt9147";
reg = <0x5d>;
status = "okay";
irq-gpios = <&stmfx_pinctrl 14
(GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
irq-flags = <IRQ_TYPE_EDGE_RISING>;
};In Linux Kernel, the GPIO configuration (pull down/up) are now managed by GPIO lib but they are not yet supported by U-boot in uclass GPIO or pincontrol (when used by gpio-hog).
This serie adds the support of theses new defines (with ops get_config/set_config) added in kernel GPIO binding and adds the test in sandbox.
NB: In a second phasis set_open_drain/get_open_drain could be
replaced by the new ops get_config/set_config to avoid to manage 2 API in parallel.
I also align the gpio binding file with the version from the latest kernel v5.3 (I don't think I remove any U-Boot specific part with this patch)
I move the added information on gpio hog code in a new file doc/README.gpio.
To have functional test, I convert pinctrl-generic to livetree otherwise the pins are not correctly configured in sandbox, when CONFIG_OF_LIVE is activated.
For the test on gpio I add information for pin configuration in output of the command "pinmux status" with a simple pincontrol driver associated to GPIO driver.
NB: after rebase on master branch, the sandbox test "ut dm power_domain"
is failing; it was not the case for v2019.10.
=> ut dm power_domain
Test: dm_test_power_domain: power-domain.c../test/dm/test-main.c:73, dm_test_destroy(): 0 == uclass_destroy(uc): Expected 0, got -22 ../test/dm/test-main.c:108, dm_do_test(): 0 == dm_test_destroy(uts): Expected 0, got 1 ../test/dm/test-main.c:170, dm_test_main(): 0 == dm_do_test(uts, test, 1): Expected 0, got 1
I think it is linked to commit 52edfed65de9 ("dm: core:
device: switch off power domain after device removal")
After some investigation :
1/ pincontrol is remove in uclass_destroy(0)
2/ power domain is removed in uclass_destroy(0)
3/ device_chld_unbind()dev_power_domain_off
-> probe power domain (again)
--> pinctrl_select_state() in device_probe()
---> pincontrol is probed (again)
4/ at the end of dev_power_domain_off() function the power domain
is unbind in dev_power_domain_off device_remove(pd.dev, DM_REMOVE_NORMAL);
So power domain driver is correctly removed but it is not the case for the pincontrol driver and that cause the issue.
The problem occurs after my serie only because I introduce a second pincontrol driver for sandbox, so the dynamic changes but my serie is not the root cause of the issue,
it should be investigated by power domain users.
My working branch:
https://github.com/patrickdelaunay/u-boot/tree/dm
CI-Travis build:
https://travis-ci.org/patrickdelaunay/u-boot/builds/601829330
Regards
Patrick Delaunay
Patrick Delaunay (13):
pinctrol: dm: remove the function pinctrl_decode_pin_config
dm: pinctrl: convert pinctrl-single to livetree
dm: core: add ofnode function to iterate on node property
dm: pinctrl: migrate pinctrl-generic to livetree
dt-bindings: gpio: document the new pull-up/pull-down flags
gpio: add support for new flags on gpio configuration
dt-bindings: gpio: alignment with kernel v5.3
pinctrl: sandbox: Add mux information in get_pin_muxing
test: dm: update test for pins configuration in pinctrl node
gpio: sandbox: cleanup flag support
gpio: sandbox: cleanup binding support
test: dm: update test for pins configuration in gpio
test: pinmux: add pincontrol-gpio for pin configuration
arch/sandbox/dts/test.dts | 85 +++++-- doc/README.gpio | 42 ++++ doc/device-tree-bindings/gpio/gpio.txt | 304 ++++++++++++++---------- drivers/core/of_access.c | 32 +++ drivers/core/ofnode.c | 45 ++++ drivers/gpio/gpio-uclass.c | 62 ++++- drivers/gpio/sandbox.c | 281 ++++++++++++++++++++-- drivers/pinctrl/pinctrl-generic.c | 36 ++- drivers/pinctrl/pinctrl-sandbox.c | 44 +++- drivers/pinctrl/pinctrl-single.c | 33 ++- drivers/pinctrl/pinctrl-uclass.c | 12 - include/asm-generic/gpio.h | 56 +++++ include/dm/of_access.h | 40 ++++ include/dm/ofnode.h | 39 ++- include/dm/pinctrl.h | 13 - include/dt-bindings/gpio/gpio.h | 6 + include/dt-bindings/gpio/sandbox-gpio.h | 24 ++ test/dm/gpio.c | 31 ++- test/dm/test-fdt.c | 2 +- test/py/tests/test_pinmux.py | 38 ++- 20 files changed, 984 insertions(+), 241 deletions(-) create mode 100644 doc/README.gpio create mode 100644 include/dt-bindings/gpio/sandbox-gpio.h
Signature · 1 line
2.17.1
PATCH 1/13 pinctrol: dm: remove the function pinctrl_decode_pin_config
Remove the pinctrl_decode_pin_config() API, because this function is unused and not compatible with livetree (it uses fdtdec_get_bool instead of ofnode API).
---
drivers/pinctrl/pinctrl-uclass.c | 12 ------------ include/dm/pinctrl.h | 13 ------------- 2 files changed, 25 deletions(-)
drivers/pinctrl/pinctrl-uclass.c +0 -12
@@ -15,18 +15,6 @@DECLARE_GLOBAL_DATA_PTR ; -int pinctrl_decode_pin_config (const void *blob,int node) -{ -int flags =0 ; - -if (fdtdec_get_bool (blob, node,"bias-pull-up" )) - flags |=1 <<PIN_CONFIG_BIAS_PULL_UP ; -else if (fdtdec_get_bool (blob, node,"bias-pull-down" )) - flags |=1 <<PIN_CONFIG_BIAS_PULL_DOWN ; - -return flags; -} -#if CONFIG_IS_ENABLED (PINCTRL_FULL )/** * pinctrl_config_one() - apply pinctrl settings for a single node
include/dm/pinctrl.h +0 -13
@@ -369,19 +369,6 @@ int pinctrl_request_noflags(struct udevice *dev, int func);*/ int pinctrl_get_periph_id (struct udevice *dev,struct udevice *periph); -/** -* pinctrl_decode_pin_config() - decode pin configuration flags -* -* This decodes some of the PIN_CONFIG values into flags, with each value -* being (1 << pin_cfg). This does not support things with values like the -* slew rate. -* -* @blob: Device tree blob -* @node: Node containing the PIN_CONFIG values -* @return decoded flag value, or -ve on error -*/ -int pinctrl_decode_pin_config (const void *blob,int node); -/** * pinctrl_get_gpio_mux() - get the mux value for a particular GPIO *
Signature · 1 line
2.17.1
PATCH 1/13 pinctrol: dm: remove the function pinctrl_decode_pin_config
Quoted 11 lines · Patrick Delaunay
Remove the
pinctrl_decode_pin_config()API, because this function is unused and not compatible with livetree (it usesfdtdec_get_boolinstead of ofnode API).Signed-off-by Patrick Delaunay <[email protected]>---
drivers/pinctrl/pinctrl-uclass.c | 12 ------------ include/dm/pinctrl.h | 13 ------------- 2 files changed, 25 deletions(-)
PATCH 1/13 pinctrol: dm: remove the function pinctrl_decode_pin_config
Quoted 11 lines · Patrick Delaunay
Remove the
pinctrl_decode_pin_config()API, because this function is unused and not compatible with livetree (it usesfdtdec_get_boolinstead of ofnode API).Signed-off-by Patrick Delaunay <[email protected]>---
drivers/pinctrl/pinctrl-uclass.c | 12 ------------ include/dm/pinctrl.h | 13 ------------- 2 files changed, 25 deletions(-)
Applied to u-boot-dm, thanks!
PATCH 2/13 dm: pinctrl: convert pinctrl-single to livetree
In reply to Patrick DelaunayConvert 'pinctrl-single' using livetree functions
- ofnode_get_property
- ofnode_read_u32_default
- ofnode_read_u32_array
- ofnode_read_bool
- dev_read_addr
and get rid of DECLARE_GLOBAL_DATA_PTR.
---
drivers/pinctrl/pinctrl-single.c | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/pinctrl/pinctrl-single.c +15 -18
@@ -9,8 +9,6 @@#include <linux/libfdt.h> #include <asm/io.h> -DECLARE_GLOBAL_DATA_PTR ; -struct single_pdata {fdt_addr_t base;/* first configuration register */ int offset;/* index of last configuration register */
@@ -117,13 +115,12 @@ static int single_configure_bits(struct udevice *dev,static int single_set_state (struct udevice *dev,struct udevice *config) { -const void *fdt = gd->fdt_blob;const struct single_fdt_pin_cfg *prop;const struct single_fdt_bits_cfg *prop_bits;int len; - prop =fdt_getprop (fdt,dev_of_offset (config),"pinctrl-single,pins" , - &len); + prop =ofnode_get_property (dev_ofnode (dev),"pinctrl-single,pins" , + &len);if (prop) {dev_dbg (dev,"configuring pins for %s\n" , config->name);
@@ -136,9 +133,9 @@ static int single_set_state(struct udevice *dev, }/* pinctrl-single,pins not found so check for pinctrl-single,bits */ - prop_bits =fdt_getprop (fdt,dev_of_offset (config), -"pinctrl-single,bits" , - &len); + prop_bits =ofnode_get_property (dev_ofnode (dev), +"pinctrl-single,bits" , + &len);if (prop_bits) {dev_dbg (dev,"configuring pins for %s\n" , config->name);if (len %sizeof (struct single_fdt_bits_cfg )) {
@@ -160,27 +157,27 @@ static int single_ofdata_to_platdata(struct udevice *dev)int res;struct single_pdata *pdata = dev->platdata; - pdata->width =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,register-width" ,0 ); + pdata->width =ofnode_read_u32_default (dev_ofnode (dev), +"pinctrl-single,register-width" , +0 ); - res =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev), -"reg" , of_reg,2 ); + res =ofnode_read_u32_array (dev_ofnode (dev),"reg" , of_reg,2 );if (res)return res; pdata->offset = of_reg[1 ] - pdata->width /8 ; - addr =devfdt_get_addr (dev); + addr =dev_read_addr (dev);if (addr ==FDT_ADDR_T_NONE ) {dev_dbg (dev,"no valid base register address\n" );return -EINVAL ; } pdata->base = addr; - pdata->mask =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,function-mask" , -0xffffffff ); - pdata->bits_per_mux =fdtdec_get_bool (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,bit-per-mux" ); + pdata->mask =ofnode_read_u32_default (dev_ofnode (dev), +"pinctrl-single,function-mask" , +0xffffffff ); + pdata->bits_per_mux =ofnode_read_bool (dev_ofnode (dev), +"pinctrl-single,bit-per-mux" );return 0 ; }
Signature · 1 line
2.17.1
PATCH 2/13 dm: pinctrl: convert pinctrl-single to livetree
Hi Patrick,
Quoted 31 lines · Patrick Delaunay
Convert 'pinctrl-single' using livetree functions
-ofnode_get_property
-ofnode_read_u32_default
-ofnode_read_u32_array
-ofnode_read_bool
-dev_read_addr
and get rid ofDECLARE_GLOBAL_DATA_PTR.Signed-off-by Patrick Delaunay <[email protected]>---
drivers/pinctrl/pinctrl-single.c | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-)drivers/pinctrl/pinctrl-single.c +0
-2@@ -9,8 +9,6 @@#include <linux/libfdt.h> #include <asm/io.h> -DECLARE_GLOBAL_DATA_PTR ; -struct single_pdata {fdt_addr_t base;/* first configuration register */ int offset;/* index of last configuration register */ @@ -117,13 +115,12 @@ static int single_configure_bits(struct udevice *dev,static int single_set_state (struct udevice *dev,struct udevice *config)
drivers/pinctrl/pinctrl-single.c static int single_configure_bits(struct udevice *dev, · line 123
Quoted 10 lines
drivers/pinctrl/pinctrl-single.c +2
-3{ -const void *fdt = gd->fdt_blob;const struct single_fdt_pin_cfg *prop;const struct single_fdt_bits_cfg *prop_bits;int len; - prop =fdt_getprop (fdt,dev_of_offset (config),"pinctrl-single,pins" , - &len); + prop =ofnode_get_property (dev_ofnode (dev),"pinctrl-single,pins" , + &len);
dev_read_prop()
Similarly below
Quoted 55 lines
drivers/pinctrl/pinctrl-single.c +13
-14if (prop) {dev_dbg (dev,"configuring pins for %s\n" , config->name);@@ -136,9 +133,9 @@ static int single_set_state(struct udevice *dev, }/* pinctrl-single,pins not found so check for pinctrl-single,bits */ - prop_bits =fdt_getprop (fdt,dev_of_offset (config), -"pinctrl-single,bits" , - &len); + prop_bits =ofnode_get_property (dev_ofnode (dev), +"pinctrl-single,bits" , + &len);if (prop_bits) {dev_dbg (dev,"configuring pins for %s\n" , config->name);if (len %sizeof (struct single_fdt_bits_cfg )) {@@ -160,27 +157,27 @@ static int single_ofdata_to_platdata(struct udevice *dev)int res;struct single_pdata *pdata = dev->platdata; - pdata->width =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,register-width" ,0 ); + pdata->width =ofnode_read_u32_default (dev_ofnode (dev), +"pinctrl-single,register-width" , +0 ); - res =fdtdec_get_int_array (gd->fdt_blob,dev_of_offset (dev), -"reg" , of_reg,2 ); + res =ofnode_read_u32_array (dev_ofnode (dev),"reg" , of_reg,2 );if (res)return res; pdata->offset = of_reg[1 ] - pdata->width /8 ; - addr =devfdt_get_addr (dev); + addr =dev_read_addr (dev);if (addr ==FDT_ADDR_T_NONE ) {dev_dbg (dev,"no valid base register address\n" );return -EINVAL ; } pdata->base = addr; - pdata->mask =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,function-mask" , -0xffffffff ); - pdata->bits_per_mux =fdtdec_get_bool (gd->fdt_blob,dev_of_offset (dev), -"pinctrl-single,bit-per-mux" ); + pdata->mask =ofnode_read_u32_default (dev_ofnode (dev), +"pinctrl-single,function-mask" , +0xffffffff ); + pdata->bits_per_mux =ofnode_read_bool (dev_ofnode (dev), +"pinctrl-single,bit-per-mux" );return 0 ; } --
Quoted 1 line
2.17.1
Regards,
Simon
PATCH 3/13 dm: core: add ofnode function to iterate on node property
In reply to Patrick DelaunayAdd functions to iterate on all property with livetree
- ofnode_get_first_property
- ofnode_get_next_property
- ofnode_get_property_by_prop
For example:
for (prop = ofnode_get_first_property(dev_ofnode(dev));
prop;
prop = ofnode_get_next_property(dev_ofnode(dev),prop))
{
value = ofnode_get_property_by_prop(dev_ofnode(dev), prop,
&propname, &len);
....
}
---
drivers/core/of_access.c | 32 ++++++++++++++++++++++++++++ drivers/core/ofnode.c | 45 ++++++++++++++++++++++++++++++++++++++++ include/dm/of_access.h | 40 +++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 39 +++++++++++++++++++++++++++++++++- 4 files changed, 155 insertions(+), 1 deletion(-)
drivers/core/of_access.c +32 -0
@@ -170,6 +170,38 @@ const void *of_get_property(const struct device_node *np, const char *name,return pp ? pp->value :NULL ; } +const struct property *of_get_first_property (const struct device_node *np) +{ +if (!np) +return NULL ; + +return np->properties; +} + +const struct property *of_get_next_property (const struct device_node *np, +const struct property *property) +{ +if (!np) +return NULL ; + +return property->next; +} + +const void *of_get_property_by_prop (const struct device_node *np, +const struct property *property, +const char **name, +int *lenp) +{ +if (!np || !property) +return NULL ; +if (name) + *name = property->name; +if (lenp) + *lenp = property->length; + +return property->value; +} +static const char *of_prop_next_string (struct property *prop,const char *cur) {const void *curv = cur;
drivers/core/ofnode.c +45 -0
51 lines not on this page · raw message
include/dm/of_access.h +40 -0
@@ -103,6 +103,46 @@ struct property *of_find_property(const struct device_node *np,const void *of_get_property (const struct device_node *np,const char *name,int *lenp); +/** +* of_get_first_property()- get to the pointer of the first property +* +* Get pointer to the first property of the node, it is used to iterate +* and read all the property with of_get_next_property_by_prop(). +* +* @p: Pointer to device node +* @return pointer to property or NULL if not found +*/ +const struct property *of_get_first_property (const struct device_node *np); + +/** +* of_get_next_property() - get to the pointer of the next property +* +* Get pointer to the next property of the node, it is used to iterate +* and read all the property with of_get_property_by_prop(). +* +* @p: Pointer to device node +* @property: pointer of the current property +* @return pointer to next property or NULL if not found +*/ +const struct property *of_get_next_property (const struct device_node *np, +const struct property *property); + +/** +* of_get_property_by_prop() - get a property value of a node property +* +* Get value for the property identified by node and property pointer. +* +* @node: node to read +* @property: pointer of the property to read +* @propname: place to property name on success +* @lenp: place to put length on success +* @return pointer to property value or NULL if error +*/ +const void *of_get_property_by_prop (const struct device_node *np, +const struct property *property, +const char **name, +int *lenp); +/** * of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node
include/dm/ofnode.h +38 -1
@@ -543,7 +543,7 @@ int ofnode_decode_display_timing(ofnode node, int index, struct display_timing *config);/** -* ofnode_get_property()- - get a pointer to the value of a node property +* ofnode_get_property() - get a pointer to the value of a node property * * @node: node to read * @propname: property to read
@@ -552,6 +552,43 @@ int ofnode_decode_display_timing(ofnode node, int index,*/ const void *ofnode_get_property (ofnode node,const char *propname,int *lenp); +/** +* ofnode_get_first_property()- get to the pointer of the first property +* +* Get pointer to the first property of the node, it is used to iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @return pointer or offset to property, used to iterate, or NULL +*/ +const void *ofnode_get_first_property (ofnode node); + +/** +* ofnode_get_next_property() - get to the pointer of the next property +* +* Get pointer to the next property of the node, it is used to iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @property: pointer or offset of the current property +* @return pointer or offset to next property or NULL +*/ +const void *ofnode_get_next_property (ofnode node,const void *property); + +/** +* ofnode_get_property_by_prop() - get a pointer to the value of a node property +* +* Get value for the property identified by node and property. +* +* @node: node to read +* @property: pointer or offset of the property to read +* @propname: place to property name on success +* @lenp: place to put length on success +* @return pointer to property or NULL if error +*/ +const void *ofnode_get_property_by_prop (ofnode node,const void *property, +const char **propname,int *lenp); +/** * ofnode_is_available() - check if a node is marked available *
Signature · 1 line
2.17.1
PATCH 3/13 dm: core: add ofnode function to iterate on node property
Quoted 16 lines · Patrick Delaunay
Add functions to iterate on all property with livetree
-ofnode_get_first_property
-ofnode_get_next_property
-ofnode_get_property_by_propFor example:
for (prop = ofnode_get_first_property(dev_ofnode(dev));
prop;
prop = ofnode_get_next_property(dev_ofnode(dev),prop))
{
value = ofnode_get_property_by_prop(dev_ofnode(dev), prop,
&propname, &len);
....
}
Quoted 8 lines
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/core/of_access.c | 32 ++++++++++++++++++++++++++++ drivers/core/ofnode.c | 45 ++++++++++++++++++++++++++++++++++++++++ include/dm/of_access.h | 40 +++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 39 +++++++++++++++++++++++++++++++++- 4 files changed, 155 insertions(+), 1 deletion(-)
Please can you add the dev_read() interface too? Also need to support CONFIG_DM_DEV_READ_INLINE in read.h
[..]
Quoted 5 lines
include/dm/of_access.h +0
-0
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 112
Quoted 10 lines
include/dm/of_access.h +7
-0@@ -103,6 +103,46 @@ struct property *of_find_property(const struct device_node *np,const void *of_get_property (const struct device_node *np,const char *name,int *lenp); +/** +* of_get_first_property()- get to the pointer of the first property +* +* Get pointer to the first property of the node, it is used to iterate +* and read all the property with of_get_next_property_by_prop(). +* +* @p: Pointer to device node
np
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 123
Quoted 11 lines
include/dm/of_access.h +11
-0+* @return pointer to property or NULL if not found +*/ +const struct property *of_get_first_property (const struct device_node *np); + +/** +* of_get_next_property() - get to the pointer of the next property +* +* Get pointer to the next property of the node, it is used to iterate +* and read all the property with of_get_property_by_prop(). +* +* @p: Pointer to device node
np
Quoted 4 lines
include/dm/of_access.h +4
-0+* @property: pointer of the current property +* @return pointer to next property or NULL if not found +*/ +const struct property *of_get_next_property(const struct device_node *np,
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 137
Quoted 10 lines
include/dm/of_access.h +10
-0+ const struct property *property); + +/** +* of_get_property_by_prop() - get a property value of a node property +* +* Get value for the property identified by node and property pointer. +* +* @node: node to read +* @property: pointer of the property to read +* @propname: place to property name on success
This can be NULL so please document that
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 138
Quoted 1 line
include/dm/of_access.h +1
-0+* @lenp: place to put length on success
This can be NULL so please document that
Quoted 47 lines
include/dm/of_access.h +7
-0+* @return pointer to property value or NULL if error +*/ +const void *of_get_property_by_prop (const struct device_node *np, +const struct property *property, +const char **name, +int *lenp); +/** * of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node include/dm/ofnode.h +21
-1@@ -543,7 +543,7 @@ int ofnode_decode_display_timing(ofnode node, int index, struct display_timing *config);/** -* ofnode_get_property()- - get a pointer to the value of a node property +* ofnode_get_property() - get a pointer to the value of a node property * * @node: node to read * @propname: property to read @@ -552,6 +552,43 @@ int ofnode_decode_display_timing(ofnode node, int index,*/ const void *ofnode_get_property (ofnode node,const char *propname,int *lenp); +/** +* ofnode_get_first_property()- get to the pointer of the first property +* +* Get pointer to the first property of the node, it is used to iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @return pointer or offset to property, used to iterate, or NULL +*/ +const void *ofnode_get_first_property (ofnode node); + +/** +* ofnode_get_next_property() - get to the pointer of the next property +* +* Get pointer to the next property of the node, it is used to iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @property: pointer or offset of the current property +* @return pointer or offset to next property or NULL
include/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int index, · line 584
Quoted 10 lines
include/dm/ofnode.h +10
-0+*/ +const void *ofnode_get_next_property (ofnode node,const void *property); + +/** +* ofnode_get_property_by_prop() - get a pointer to the value of a node property +* +* Get value for the property identified by node and property. +* +* @node: node to read +* @property: pointer or offset of the property to read
Perhaps you should define an ofprop type for this? It is pretty ugly to use a pointer.
In fact I wonder if ofprop should be:
struct ofprop {
ofnode node;
union {
int offset;
struct property *prop; };
}
include/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int index, · line 586
Quoted 2 lines
include/dm/ofnode.h +2
-0+* @propname: place to property name on success +* @lenp: place to put length on success
These two above can be NULL so please document that
Quoted 11 lines
include/dm/ofnode.h +5
-1+* @return pointer to property or NULL if error +*/ +const void *ofnode_get_property_by_prop (ofnode node,const void *property, +const char **propname,int *lenp); +/** * ofnode_is_available() - check if a node is marked available * -- 2.17.1
Regards,
Simon
PATCH 3/13 dm: core: add ofnode function to iterate on node property
Hi Simon,
Quoted 23 lines
From: Simon Glass <[email protected]>
Sent: mercredi 30 octobre 2019 02:48Quoted 18 lines · Patrick Delaunay
Add functions to iterate on all property with livetree
-ofnode_get_first_property
-ofnode_get_next_property
-ofnode_get_property_by_propFor example:
for (prop = ofnode_get_first_property(dev_ofnode(dev));
prop;
prop = ofnode_get_next_property(dev_ofnode(dev),prop))
{
value = ofnode_get_property_by_prop(dev_ofnode(dev), prop,
&propname, &len); ....
}Signed-off-by Patrick Delaunay <[email protected]>---
Quoted 8 lines
Quoted 5 lines
drivers/core/of_access.c | 32 ++++++++++++++++++++++++++++ drivers/core/ofnode.c | 45 ++++++++++++++++++++++++++++++++++++++++ include/dm/of_access.h | 40 +++++++++++++++++++++++++++++++++++ include/dm/ofnode.h | 39 +++++++++++++++++++++++++++++++++- 4 files changed, 155 insertions(+), 1 deletion(-)Please can you add the
dev_read()interface too? Also need to supportCONFIG_DM_DEV_READ_INLINEinread.h
Yes I will it,
Quoted 45 lines
[..]
include/dm/of_access.h struct property *of_find_property(const struct · line 103
Quoted 6 lines
include/dm/of_access.h index renamed from include/dm/of_access.h +0
-0
13fedb7cf5..0418782aa2100644include/dm/of_access.h +0
-0@@ -103,6 +103,46 @@ struct property *of_find_property(const struct device_node *np, const void *of_get_property(const struct device_node *np,const char *name,
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 112
Quoted 10 lines
include/dm/of_access.h +8
-0int *lenp); +/** +* of_get_first_property()- get to the pointer of the first property +* +* Get pointer to the first property of the node, it is used to +iterate +* and read all the property with of_get_next_property_by_prop(). +* +* @p: Pointer to device node np
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 123
Quoted 11 lines
include/dm/of_access.h +11
-0+* @return pointer to property or NULL if not found */ const struct +property *of_get_first_property (const struct device_node *np); + +/** +* of_get_next_property() - get to the pointer of the next property +* +* Get pointer to the next property of the node, it is used to +iterate +* and read all the property with of_get_property_by_prop(). +* +* @p: Pointer to device node np
Quoted 9 lines
include/dm/of_access.h +9
-0+* @property: pointer of the current property +* @return pointer to next property or NULL if not found */ const +struct property *of_get_next_property (const struct device_node *np, +const struct property +*property); + +/** +* of_get_property_by_prop() - get a property value of a node +property
Quoted 8 lines
include/dm/of_access.h struct property *of_find_property(const struct device_node *np, · line 137
Quoted 6 lines
include/dm/of_access.h +6
-0+* +* Get value for the property identified by node and property pointer. +* +* @node: node to read +* @property: pointer of the property to read +* @propname: place to property name on success This can be NULL so please document that
ok
Quoted 73 lines
include/dm/of_access.h struct property *of_find_property(const struct · line 140
Quoted 1 line
include/dm/of_access.h +1
-0+* @lenp: place to put length on success This can be NULL so please document that
include/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int
Quoted 14 lines
include/dm/of_access.h +6
-0+* @return pointer to property value or NULL if error */ const void +*of_get_property_by_prop (const struct device_node *np, +const struct property *property, +const char **name, +int *lenp); +/** * of_device_is_compatible() - Check if the node matches given constraints * @device: pointer to node include/dm/ofnode.h index renamed from include/dm/ofnode.h +0
-0
5c4cbf0998..08d684cea0100644include/dm/ofnode.h +0
-0@@ -543,7 +543,7 @@ int ofnode_decode_display_timing(ofnode node, intindex,
include/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int
Quoted 11 lines
include/dm/ofnode.h +0
-1struct display_timing *config);/** -* ofnode_get_property()- - get a pointer to the value of a node property
+ *ofnode_get_property()- get a pointer to the value of a node
+ property
*
* @node: node to read
* @propname: property to readinclude/dm/ofnode.h +0
-0@@ -552,6 +552,43 @@ int ofnode_decode_display_timing(ofnode node, intindex,
Quoted 27 lines
include/dm/ofnode.h +23
-0*/ const void *ofnode_get_property (ofnode node,const char *propname,int *lenp); +/** +* ofnode_get_first_property()- get to the pointer of the first +property +* +* Get pointer to the first property of the node, it is used to +iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @return pointer or offset to property, used to iterate, or NULL +*/ const void *ofnode_get_first_property (ofnode node); + +/** +* ofnode_get_next_property() - get to the pointer of the next +property +* +* Get pointer to the next property of the node, it is used to +iterate +* and read all the property with ofnode_get_property_by_prop(). +* +* @node: node to read +* @property: pointer or offset of the current property + * @return pointer or offset to next property or NULL */ const voidinclude/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int index, · line 584
Quoted 10 lines
include/dm/ofnode.h +10
-0+*ofnode_get_next_property(ofnode node, const void *property); + +/** +* ofnode_get_property_by_prop() - get a pointer to the value of a +node property +* +* Get value for the property identified by node and property. +* +* @node: node to read +* @property: pointer or offset of the property to read Perhaps you should define an ofprop type for this? It is pretty ugly to use a pointer.
In fact I wonder if ofprop should be:
Quoted 7 lines
struct ofprop {
ofnode node;
union {
int offset;
struct property *prop;
};
}Ok, I will do it in v2
The API become:
int ofnode_get_first_property(ofnode node, struct ofprop *prop); int ofnode_get_next_property(struct ofprop *prop);
same prop is used as input parameter and ouput parameter.
const void *ofnode_get_property_by_prop(struct ofprop *prop,
const char **propname, int *lenp);
same for dev_ function
Quoted 4 lines
include/dm/ofnode.h int ofnode_decode_display_timing(ofnode node, int · line 590
Quoted 2 lines
include/dm/ofnode.h +2
-0+* @propname: place to property name on success +* @lenp: place to put length on success These two above can be NULL so please document that
OK
Quoted 14 lines
Quoted 11 lines
include/dm/ofnode.h +5
-1+* @return pointer to property or NULL if error */ const void +*ofnode_get_property_by_prop (ofnode node,const void *property, +const char **propname,int +*lenp); +/** * ofnode_is_available() - check if a node is marked available * -- 2.17.1
Regards,
Simon
PATCH 4/13 dm: pinctrl: migrate pinctrl-generic to livetree
In reply to Patrick DelaunayMigrate pinctrl-generic to livetree:
- ofnode_get_first_property
- ofnode_get_next_property
- ofnode_get_property_by_prop
- ofnode_read_string_count
- ofnode_read_string_index
and get rid of DECLARE_GLOBAL_DATA_PTR.
This solve parsing issue during test in sandbox for pin configuration (OF_LIVE is activated in sandbox_defconfig and sub node are not correctly parsed in pinctrl_generic_set_state_subnode with fdt lib API).
---
drivers/pinctrl/pinctrl-generic.c | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-)
drivers/pinctrl/pinctrl-generic.c +17 -19
@@ -8,8 +8,6 @@#include <linux/compat.h> #include <dm/pinctrl.h> -DECLARE_GLOBAL_DATA_PTR ; -/** * pinctrl_pin_name_to_selector() - return the pin selector for a pin *
@@ -243,18 +241,18 @@ static int pinctrl_generic_set_state_one(struct udevice *dev,struct udevice *config, bool is_group, unsigned selector) { - const void *fdt = gd->fdt_blob; -int node_offset =dev_of_offset (config); const char *propname;const void *value; -int prop_offset, len, func_selector, param, ret; +const void *property; +int len, func_selector, param, ret;u32 arg, default_val; -for (prop_offset =fdt_first_property_offset (fdt, node_offset); - prop_offset >0 ; - prop_offset =fdt_next_property_offset (fdt, prop_offset)) { - value =fdt_getprop_by_offset (fdt, prop_offset, - &propname, &len); +for (property =ofnode_get_first_property (dev_ofnode (config)); + property; + property =ofnode_get_next_property (dev_ofnode (config), + property)) { + value =ofnode_get_property_by_prop (dev_ofnode (config), + property, &propname, &len);if (!value)return -EINVAL ;
@@ -298,19 +296,18 @@ static int pinctrl_generic_set_state_one(struct udevice *dev,static int pinctrl_generic_set_state_subnode (struct udevice *dev,struct udevice *config) { -const void *fdt = gd->fdt_blob; -int node =dev_of_offset (config);const char *subnode_target_type ="pins" ;bool is_group = false;const char *name;int strings_count, selector, i, ret; - strings_count =fdt_stringlist_count (fdt, node, subnode_target_type); + strings_count =ofnode_read_string_count (dev_ofnode (config), + subnode_target_type);if (strings_count <0 ) { subnode_target_type ="groups" ; is_group = true; - strings_count =fdt_stringlist_count (fdt, node, - subnode_target_type); + strings_count =ofnode_read_string_count (dev_ofnode (config), + subnode_target_type);if (strings_count <0 ) {/* skip this node; may contain config child nodes */ return 0 ;
@@ -318,10 +315,11 @@ static int pinctrl_generic_set_state_subnode(struct udevice *dev, }for (i =0 ; i < strings_count; i++) { - name =fdt_stringlist_get (fdt, node, subnode_target_type, i, -NULL ); -if (!name) -return -EINVAL ; + ret =ofnode_read_string_index (dev_ofnode (config), + subnode_target_type, i, + &name); +if (ret) +return ret;if (is_group) selector =pinctrl_group_name_to_selector (dev, name);
Signature · 1 line
2.17.1
PATCH 4/13 dm: pinctrl: migrate pinctrl-generic to livetree
Hi Patrick,
Quoted 14 lines · Patrick Delaunay
Migrate pinctrl-generic to livetree:
-ofnode_get_first_property
-ofnode_get_next_property
-ofnode_get_property_by_prop
-ofnode_read_string_count
-ofnode_read_string_index
and get rid ofDECLARE_GLOBAL_DATA_PTR.This solve parsing issue during test in sandbox for pin configuration (
OF_LIVEis activated insandbox_defconfigand sub node are not correctly parsed inpinctrl_generic_set_state_subnodewith fdt lib API).
Quoted 6 lines
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/pinctrl/pinctrl-generic.c | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-)
It looks like this should use dev_read_...() too.
Regards,
Simon
PATCH 4/13 dm: pinctrl: migrate pinctrl-generic to livetree
Hi Simon
Quoted 24 lines
From: Simon Glass <[email protected]>
Sent: mercredi 30 octobre 2019 02:48Hi Patrick,
Quoted 17 lines · Patrick Delaunay
Migrate pinctrl-generic to livetree:
-ofnode_get_first_property
-ofnode_get_next_property
-ofnode_get_property_by_prop
-ofnode_read_string_count
-ofnode_read_string_index
and get rid ofDECLARE_GLOBAL_DATA_PTR.This solve parsing issue during test in sandbox for pin configuration (
OF_LIVEis activated insandbox_defconfigand sub node are not correctly parsed inpinctrl_generic_set_state_subnodewith fdt lib API).Signed-off-by Patrick Delaunay <[email protected]>---
Quoted 6 lines
Quoted 4 lines
drivers/pinctrl/pinctrl-generic.c | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-)It looks like this should use dev_read_...() too.
Yes I miss it.
Thanks
Quoted 2 lines
Regards,
Simon
Regards
Patrick
PATCH 5/13 dt-bindings: gpio: document the new pull-up/pull-down flags
In reply to Patrick DelaunayThis commit extends the flags that can be used in GPIO specifiers to indicate if a pull-up resistor or pull-down resistor should be enabled.
It is the backport of linux commit ede033e1e863c ('dt-bindings:
gpio: document the new pull-up/pull-down flags')
from Thomas Petazzoni <[email protected]> and integrated in v5.1-rc1
https://github.com/torvalds/linux/commit/ede033e1e863c
---
doc/device-tree-bindings/gpio/gpio.txt | 24 ++++++++++++++++++++++++ include/dt-bindings/gpio/gpio.h | 6 ++++++ 2 files changed, 30 insertions(+)
doc/device-tree-bindings/gpio/gpio.txt +24 -0
@@ -65,6 +65,30 @@ Example of a node using GPIOs: GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller. +Optional standard bitfield specifiers for the last cell: + +- Bit 0: 0 means active high, 1 means active low +- Bit 1: 0 mean push-pull wiring, see: + https://en.wikipedia.org/wiki/Push-pull_output + 1 means single-ended wiring, see: + https://en.wikipedia.org/wiki/Single-ended_triode +- Bit 2: 0 means open-source, 1 means open drain, see: + https://en.wikipedia.org/wiki/Open_collector +- Bit 3: 0 means the output should be maintained during sleep/low-power mode + 1 means the output state can be lost during sleep/low-power mode +- Bit 4: 0 means no pull-up resistor should be enabled + 1 means a pull-up resistor should be enabled + This setting only applies to hardware with a simple on/off + control for pull-up configuration. If the hardware has more + elaborate pull-up configuration, it should be represented + using a pin control binding. +- Bit 5: 0 means no pull-down resistor should be enabled + 1 means a pull-down resistor should be enabled + This setting only applies to hardware with a simple on/off + control for pull-down configuration. If the hardware has more + elaborate pull-down configuration, it should be represented + using a pin control binding. + 1.1) GPIO specifier best practices ----------------------------------
include/dt-bindings/gpio/gpio.h +6 -0
@@ -33,4 +33,10 @@#define GPIO_PERSISTENT 0#define GPIO_TRANSITORY 8 +/* Bit 4 express pull up */ +#define GPIO_PULL_UP 16 + +/* Bit 5 express pull down */ +#define GPIO_PULL_DOWN 32 +#endif
Signature · 1 line
2.17.1
PATCH 6/13 gpio: add support for new flags on gpio configuration
In reply to Patrick DelaunayThis commit manages the flags that can be used in GPIO specifiers to indicate if a pull-up resistor or pull-down resistor should be enabled for output GPIO and the Open Drain/Open Source configuration for input GPIO.
It is managed in driver with a new ops in gpio uclass set_config.
These flags are already support in Linux kernel in gpiolib.
---
drivers/gpio/gpio-uclass.c | 62 +++++++++++++++++++++++++++++++++++++- include/asm-generic/gpio.h | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-)
drivers/gpio/gpio-uclass.c +61 -1
@@ -128,7 +128,19 @@ int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,return 0 ;if (args->args[1 ] &GPIO_ACTIVE_LOW ) - desc->flags =GPIOD_ACTIVE_LOW ; + desc->flags |=GPIOD_ACTIVE_LOW ; + +if ((args->args[1 ] &GPIO_OPEN_DRAIN ) ==GPIO_OPEN_DRAIN ) + desc->flags |=GPIOD_OPEN_DRAIN ; + +if ((args->args[1 ] &GPIO_OPEN_SOURCE ) ==GPIO_OPEN_SOURCE ) + desc->flags |=GPIOD_OPEN_SOURCE ; + +if (args->args[1 ] &GPIO_PULL_UP ) + desc->flags |=GPIOD_PULL_UP ; + +if (args->args[1 ] &GPIO_PULL_DOWN ) + desc->flags |=GPIOD_PULL_DOWN ;return 0 ; }
@@ -517,12 +529,31 @@ int dm_gpio_set_open_drain(struct gpio_desc *desc, int value)if (ops->set_open_drain) ret = ops->set_open_drain (desc->dev, desc->offset, value); +else if (ops->set_config) + ret = ops->set_config (desc->dev, desc->offset, + value ?GPIO_CONF_DRIVE_OPEN_DRAIN : +GPIO_CONF_DRIVE_PULL_PUSH );else return 0 ;/* feature not supported -> ignore setting */ return ret; } +int gpio_get_config (const struct gpio_desc *desc) +{ +struct dm_gpio_ops *ops =gpio_get_ops (desc->dev); +int ret; + + ret =check_reserved (desc,"get_config" ); +if (ret) +return ret; + +if (ops->set_config) +return ops->get_config (desc->dev, desc->offset); +else +return -ENOSYS ; +} +int dm_gpio_set_dir_flags (struct gpio_desc *desc,ulong flags) {struct udevice *dev = desc->dev;
@@ -533,14 +564,39 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)if (ret)return ret; +/* both pull-up and pull-down enabled, invalid configuration */ +if ((flags &GPIOD_PULL_UP ) && (flags &GPIOD_PULL_DOWN )) +return -EINVAL ; +if (flags &GPIOD_IS_OUT ) {int value = flags &GPIOD_IS_OUT_ACTIVE ?1 :0 ; +if (ops->set_config) { +if (flags &GPIOD_OPEN_DRAIN ) + ops->set_config (dev, desc->offset, +GPIO_CONF_DRIVE_OPEN_DRAIN ); +else if (flags &GPIOD_OPEN_SOURCE ) + ops->set_config (dev, desc->offset, +GPIO_CONF_DRIVE_OPEN_SOURCE ); +else + ops->set_config (dev, desc->offset, +GPIO_CONF_DRIVE_PULL_PUSH ); + } +if (flags &GPIOD_ACTIVE_LOW ) value = !value; ret = ops->direction_output (dev, desc->offset, value); }else if (flags &GPIOD_IS_IN ) { ret = ops->direction_input (dev, desc->offset); + +if (ops->set_config) { +if (flags &GPIOD_PULL_UP ) + ops->set_config (dev, desc->offset, +GPIO_CONF_BIAS_PULL_UP ); +else if (flags &GPIOD_PULL_DOWN ) + ops->set_config (dev, desc->offset, +GPIO_CONF_BIAS_PULL_DOWN ); + } }if (ret)return ret;
@@ -1061,6 +1117,10 @@ static int gpio_post_bind(struct udevice *dev) ops->get_function += gd->reloc_off;if (ops->xlate) ops->xlate += gd->reloc_off; +if (ops->set_config) + ops->set_config += gd->reloc_off; +if (ops->get_config) + ops->get_config += gd->reloc_off; reloc_done++; }
include/asm-generic/gpio.h +56 -0
78 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 6/13 gpio: add support for new flags on gpio configuration
Hi Patrick,
Quoted 8 lines · Patrick Delaunay
This commit manages the flags that can be used in GPIO specifiers to indicate if a pull-up resistor or pull-down resistor should be enabled for output GPIO and the Open Drain/Open Source configuration for input GPIO.
It is managed in driver with a new ops in gpio uclass
set_config.
Quoted 9 lines
These flags are already support in Linux kernel in gpiolib.
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/gpio/gpio-uclass.c | 62 +++++++++++++++++++++++++++++++++++++- include/asm-generic/gpio.h | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-)
To me this seems like a pretty annoying interface. The uclass has to call the driver multiple times with each enum and the driver may end up reprogramming the pins multiple times to get it right.
Normally we want to program things correctly once, before enabling the function.
On the other handle I think what you have is better than adding new methods like set_open_drain().
But overall I think it would be better to define a new struct like gpio_config that holds some flags and perhaps a few other things. Then the uclass can set up that struct and call the driver once with it, to set up the pin. It could include input/output too, so that if set_config() is defined, the uclass uses that instead of direction_output(), etc.
What do you think?
Also we should update the sandbox driver to include tests for new methods. It looks like you have done pinctrl but not this?
Regards,
Simon
PATCH 6/13 gpio: add support for new flags on gpio configuration
Hi Simon,
Quoted 35 lines
From: Simon Glass <[email protected]>
Sent: mercredi 30 octobre 2019 02:49Hi Patrick,
Quoted 10 lines · Patrick Delaunay
This commit manages the flags that can be used in GPIO specifiers to indicate if a pull-up resistor or pull-down resistor should be enabled for output GPIO and the Open Drain/Open Source configuration for input GPIO.
It is managed in driver with a new ops in gpio uclass
set_config.These flags are already support in Linux kernel in gpiolib.
Quoted 8 lines
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/gpio/gpio-uclass.c | 62 +++++++++++++++++++++++++++++++++++++- include/asm-generic/gpio.h | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 1 deletion(-)To me this seems like a pretty annoying interface. The uclass has to call the driver multiple times with each enum and the driver may end up reprogramming the pins multiple times to get it right.
Normally we want to program things correctly once, before enabling the function.
On the other handle I think what you have is better than adding new methods like
set_open_drain().
Quoted 7 lines
But overall I think it would be better to define a new struct like
gpio_configthat holds some flags and perhaps a few other things. Then the uclass can set up that struct and call the driver once with it, to set up the pin. It could include input/output too, so that ifset_config()is defined, the uclass uses that instead ofdirection_output(), etc.What do you think?
I understand the issue....
You think something like the serial ops setconfig/getconfig.
So the API can evaluate without add new ops for each new parameter... It is clearly better.
I will think about and try to propose something without break nothing.
Quoted 2 lines
Also we should update the sandbox driver to include tests for new methods. It looks like you have done pinctrl but not this?
I think test are done in
[PATCH 12/13] test: dm: update test for pins configuration in gpio
- dm_test_gpio_pin_config
Do think about other tests ?
Quoted 2 lines
Regards,
Simon
Regards
Patrick
PATCH 7/13 dt-bindings: gpio: alignment with kernel v5.3
In reply to Patrick DelaunayUpdate the binding file for gpio, it is just an alignment with kernel v5.3.
The U-Boot code example for gpio-hog (not directly linked to binding) is moved in a new file doc/README.gpio. [commit 21676b706e99 ("gpio: fixes for gpio-hog support") & 'commit 4762a9988ede ("gpio: add gpio-hog support")']
---
doc/README.gpio | 42 ++++ doc/device-tree-bindings/gpio/gpio.txt | 280 ++++++++++++++----------- 2 files changed, 196 insertions(+), 126 deletions(-) create mode 100644 doc/README.gpio
doc/README.gpio new file +42 -0
@@ -0,0 +1,42 @@ + +GPIO hog (CONFIG_GPIO_HOG) +-------- + +All the GPIO hog are initialized in gpio_hog_probe_all() function called in +board_r.c just before board_late_init() but you can also acces directly to +the gpio with gpio_hog_lookup_name(). + + +Example, for the device tree: + + tca6416 at 20 { + compatible = "ti,tca6416"; + reg = <0x20>; + #gpio-cells = <2>; + gpio-controller; + + env_reset { + gpio-hog; + input; + gpios = <6 GPIO_ACTIVE_LOW>; + }; + boot_rescue { + gpio-hog; + input; + line-name = "foo-bar-gpio"; + gpios = <7 GPIO_ACTIVE_LOW>; + }; + }; + +You can than access the gpio in your board code with: + + struct gpio_desc *desc; + int ret; + + ret = gpio_hog_lookup_name("boot_rescue", &desc); + if (ret) + return; + if (dm_gpio_get_value(desc) == 1) + printf("\nBooting into Rescue System\n"); + else if (dm_gpio_get_value(desc) == 0) + printf("\nBoot normal\n");
doc/device-tree-bindings/gpio/gpio.txt +154 -126
333 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 8/13 pinctrl: sandbox: Add mux information in get_pin_muxing
In reply to Patrick DelaunayAdd param information in pin information output. This update prepare unitary test for pin configuration in pinctrl node.
---
drivers/pinctrl/pinctrl-sandbox.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/pinctrl/pinctrl-sandbox.c +30 -0
@@ -54,6 +54,10 @@ static const struct pinconf_param sandbox_conf_params[] = { { "input-disable", PIN_CONFIG_INPUT_ENABLE, 0 }, }; +/* bitfield used to save param and value of each pin/selector */ +static unsigned int sandbox_pins_param[ARRAY_SIZE (sandbox_pins)]; +static unsigned int sandbox_pins_value[ARRAY_SIZE (sandbox_pins)]; +static int sandbox_get_pins_count (struct udevice *dev) {return ARRAY_SIZE (sandbox_pins);
@@ -68,8 +72,25 @@ static int sandbox_get_pin_muxing(struct udevice *dev,unsigned int selector, char *buf, int size) { + const struct pinconf_param *p; +int i; +snprintf (buf, size,"%s" , sandbox_pins_muxing[selector]); +if (sandbox_pins_param[selector]) { +for (i =0 , p = sandbox_conf_params; + i <ARRAY_SIZE (sandbox_conf_params); + i++, p++) { +if ((sandbox_pins_param[selector] &BIT (p->param)) && + (!!(sandbox_pins_value[selector] &BIT (p->param)) == + p->default_value)) { +strncat (buf," " , size); +strncat (buf, p->property, size); + } + } + } +strncat (buf,"." , size); +return 0 ; }
@@ -102,6 +123,9 @@ static int sandbox_pinmux_set(struct udevice *dev, unsigned pin_selector, pin_selector,sandbox_get_pin_name (dev, pin_selector), func_selector, sandbox_get_function_name(dev, func_selector)); + sandbox_pins_param[pin_selector] =0 ; + sandbox_pins_value[pin_selector] =0 ; +return 0 ; }
@@ -123,6 +147,12 @@ static int sandbox_pinconf_set(struct udevice *dev, unsigned pin_selector, pin_selector,sandbox_get_pin_name (dev, pin_selector), param, argument); + sandbox_pins_param[pin_selector] |=BIT (param); +if (argument) + sandbox_pins_value[pin_selector] |=BIT (param); +else + sandbox_pins_value[pin_selector] &= ~BIT (param); +return 0 ; }
Signature · 1 line
2.17.1
PATCH 8/13 pinctrl: sandbox: Add mux information in get_pin_muxing
Quoted 11 lines · Patrick Delaunay
Add param information in pin information output. This update prepare unitary test for pin configuration in pinctrl node.
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/pinctrl/pinctrl-sandbox.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
PATCH 9/13 test: dm: update test for pins configuration in pinctrl node
In reply to Patrick DelaunayAdd test for "pins" configuration in gpio uclass with set_state() ops and test for generic parsing of pinconf_param array).
set_state() is called by:
- pinctrl_generic_set_state
|- pinctrl_generic_set_state_subnode
---
arch/sandbox/dts/test.dts | 25 +++++++++++++++++++++++++ drivers/pinctrl/pinctrl-sandbox.c | 14 +++++++++++++- test/py/tests/test_pinmux.py | 28 ++++++++++++++++++---------- 3 files changed, 56 insertions(+), 11 deletions(-)
arch/sandbox/dts/test.dts +25 -0
@@ -847,6 +847,31 @@ pinctrl { compatible = "sandbox,pinctrl"; + + pinctrl-names = "default"; + pinctrl-0 = <&gpios>; + + gpios: gpios { + gpio0 { + pins = "GPIO0"; + bias-pull-up; + input-disable; + }; + gpio1 { + pins = "GPIO1"; + output-high; + drive-open-drain; + }; + gpio2 { + pins = "GPIO2"; + bias-pull-down; + input-enable; + }; + gpio3 { + pins = "GPIO3"; + bias-disable; + }; + }; }; hwspinlock at 0 {
drivers/pinctrl/pinctrl-sandbox.c +13 -1
@@ -14,7 +14,11 @@ static const char * const sandbox_pins[] = {"SDA" ,"TX" ,"RX" , -"W1" +"W1" , +"GPIO0" , +"GPIO1" , +"GPIO2" , + "GPIO3", }; static const char * const sandbox_pins_muxing[] = {
@@ -23,6 +27,10 @@ static const char * const sandbox_pins_muxing[] = {"Uart TX" ,"Uart RX" ,"1-wire gpio" , +"gpio" , +"gpio" , +"gpio" , + "gpio", }; static const char * const sandbox_groups[] = {
@@ -38,6 +46,10 @@ static const char * const sandbox_functions[] = {"serial" ,"spi" ,"w1" , +"gpio" , +"gpio" , +"gpio" , + "gpio", }; static const struct pinconf_param sandbox_conf_params[] = {
test/py/tests/test_pinmux.py +18 -10
@@ -22,11 +22,15 @@ def test_pinmux_usage_2(u_boot_console): def test_pinmux_status_all(u_boot_console): """Test that 'pinmux status -a' displays pin's muxing.""" output = u_boot_console.run_command('pinmux status -a') - 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 ('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) @pytest.mark.buildconfigspec('cmd_pinmux') @pytest.mark.boardspec('sandbox')
@@ -59,8 +63,12 @@ def test_pinmux_status(u_boot_console): """Test that 'pinmux status' displays selected pincontroller's pin muxing descriptions.""" output = u_boot_console.run_command('pinmux status') - 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 ('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)
Signature · 1 line
2.17.1
PATCH 9/13 test: dm: update test for pins configuration in pinctrl node
Quoted 8 lines · Patrick Delaunay
Add test for "pins" configuration in gpio uclass with
set_state()ops and test for generic parsing ofpinconf_paramarray).
set_state()is called by:
-pinctrl_generic_set_state
|-pinctrl_generic_set_state_subnode
Quoted 7 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/sandbox/dts/test.dts | 25 +++++++++++++++++++++++++ drivers/pinctrl/pinctrl-sandbox.c | 14 +++++++++++++- test/py/tests/test_pinmux.py | 28 ++++++++++++++++++---------- 3 files changed, 56 insertions(+), 11 deletions(-)
PATCH 10/13 gpio: sandbox: cleanup flag support
In reply to Patrick DelaunayReplace the GPIOF_ defines of gpio UCLASS (they are not bitfields but enum gpio_func_t = State of a GPIO, as reported by get_function()) by GPIO_FLAG to access to the bitfield 'flags' of struct gpio_state.
This patch avoid confusion between sandbox and gpio UCLASS defines.
---
drivers/gpio/sandbox.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/gpio/sandbox.c +13 -13
@@ -11,14 +11,14 @@#include <dm/of.h> #include <dt-bindings/gpio/gpio.h> -/* Flags for each GPIO */ -#define GPIOF_OUTPUT (1 << 0)/* Currently set as an output */ -#define GPIOF_HIGH (1 << 1)/* Currently set high */ -#define GPIOF_ODR (1 << 2)/* Currently set to open drain mode */ +/* Internal flags for each GPIO : bitfield*/ +#define GPIO_FLAG_OUTPUT BIT(0)/* Currently set as an output */ +#define GPIO_FLAG_HIGH BIT(1)/* Currently set high */ +#define GPIO_FLAG_ODR BIT(2)/* Currently set to open drain mode */ struct gpio_state {const char *label;/* label given by requester */ -u8 flags;/* flags (GPIOF_...) */ +u8 flags;/* bitfield flags (GPIO_FLAG_...) */ };/* Access routines for GPIO state */
@@ -60,34 +60,34 @@ static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag,int sandbox_gpio_get_value (struct udevice *dev,unsigned offset) { -if (get_gpio_flag (dev, offset,GPIOF_OUTPUT )) +if (get_gpio_flag (dev, offset,GPIO_FLAG_OUTPUT ))debug ("sandbox_gpio: get_value on output gpio %u\n" , offset); -return get_gpio_flag (dev, offset,GPIOF_HIGH ); +return get_gpio_flag (dev, offset,GPIO_FLAG_HIGH ); }int sandbox_gpio_set_value (struct udevice *dev,unsigned offset,int value) { -return set_gpio_flag (dev, offset,GPIOF_HIGH , value); +return set_gpio_flag (dev, offset,GPIO_FLAG_HIGH , value); }int sandbox_gpio_get_open_drain (struct udevice *dev,unsigned offset) { -return get_gpio_flag (dev, offset,GPIOF_ODR ); +return get_gpio_flag (dev, offset,GPIO_FLAG_ODR ); }int sandbox_gpio_set_open_drain (struct udevice *dev,unsigned offset,int value) { -return set_gpio_flag (dev, offset,GPIOF_ODR , value); +return set_gpio_flag (dev, offset,GPIO_FLAG_ODR , value); }int sandbox_gpio_get_direction (struct udevice *dev,unsigned offset) { -return get_gpio_flag (dev, offset,GPIOF_OUTPUT ); +return get_gpio_flag (dev, offset,GPIO_FLAG_OUTPUT ); }int sandbox_gpio_set_direction (struct udevice *dev,unsigned offset,int output) { -return set_gpio_flag (dev, offset,GPIOF_OUTPUT , output); +return set_gpio_flag (dev, offset,GPIO_FLAG_OUTPUT , output); }/*
@@ -158,7 +158,7 @@ static int sb_gpio_set_open_drain(struct udevice *dev, unsigned offset, int valustatic int sb_gpio_get_function (struct udevice *dev,unsigned offset) { -if (get_gpio_flag (dev, offset,GPIOF_OUTPUT )) +if (get_gpio_flag (dev, offset,GPIO_FLAG_OUTPUT ))return GPIOF_OUTPUT ;return GPIOF_INPUT ; }
Signature · 1 line
2.17.1
PATCH 10/13 gpio: sandbox: cleanup flag support
Quoted 5 lines · Patrick Delaunay
Replace the
GPIOF_defines of gpio UCLASS (they are not bitfields but enumgpio_func_t= State of a GPIO, as reported byget_function()) byGPIO_FLAGto access to the bitfield 'flags' of structgpio_state.
Quoted 7 lines
This patch avoid confusion between sandbox and gpio UCLASS defines.
Signed-off-by Patrick Delaunay <[email protected]>---
drivers/gpio/sandbox.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
PATCH 11/13 gpio: sandbox: cleanup binding support
In reply to Patrick DelaunayCleanup binding support, use the generic binding by default (test u-class gpio_xlate_offs_flags function) and add specific binding for added value.
---
arch/sandbox/dts/test.dts | 14 ++++++++++---- drivers/gpio/sandbox.c | 13 ++++++++----- include/dt-bindings/gpio/sandbox-gpio.h | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 include/dt-bindings/gpio/sandbox-gpio.h
arch/sandbox/dts/test.dts +10 -4
@@ -1,5 +1,8 @@ /dts-v1/; +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/gpio/sandbox-gpio.h> + / { model = "sandbox"; compatible = "sandbox";
@@ -86,11 +89,14 @@ ping-expect = <0>; ping-add = <0>; u-boot,dm-pre-reloc; - test-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 5 0 3 2 1>, + test-gpios = <&gpio_a 1>, <&gpio_a 4>, + <&gpio_b 5 GPIO_ACTIVE_HIGH 3 2 1>, <0>, <&gpio_a 12>; - test2-gpios = <&gpio_a 1>, <&gpio_a 4>, <&gpio_b 6 1 3 2 1>, - <&gpio_b 7 2 3 2 1>, <&gpio_b 8 4 3 2 1>, - <&gpio_b 9 0xc 3 2 1>; + test2-gpios = <&gpio_a 1>, <&gpio_a 4>, + <&gpio_b 6 GPIO_ACTIVE_LOW 3 2 1>, + <&gpio_b 7 GPIO_IN 3 2 1>, + <&gpio_b 8 GPIO_OUT 3 2 1>, + <&gpio_b 9 (GPIO_OUT|GPIO_OUT_ACTIVE) 3 2 1>; int-value = <1234>; uint-value = <(-1234)>; };
drivers/gpio/sandbox.c +8 -5
@@ -10,6 +10,7 @@#include <asm/gpio.h> #include <dm/of.h> #include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/gpio/sandbox-gpio.h> /* Internal flags for each GPIO : bitfield*/ #define GPIO_FLAG_OUTPUT BIT(0)/* Currently set as an output */
@@ -169,13 +170,15 @@ static int sb_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, desc->offset = args->args[0 ];if (args->args_count <2 )return 0 ; -if (args->args[1 ] &GPIO_ACTIVE_LOW ) - desc->flags |=GPIOD_ACTIVE_LOW ; -if (args->args[1 ] &2 ) +/* treat generic binding with gpio uclass */ +gpio_xlate_offs_flags (dev, desc, args); + +/* sandbox test specific, not defined in gpio.h */ +if (args->args[1 ] &GPIO_IN ) desc->flags |=GPIOD_IS_IN ; -if (args->args[1 ] &4 ) +if (args->args[1 ] &GPIO_OUT ) desc->flags |=GPIOD_IS_OUT ; -if (args->args[1 ] &8 ) +if (args->args[1 ] &GPIO_OUT_ACTIVE ) desc->flags |=GPIOD_IS_OUT_ACTIVE ;return 0 ;
include/dt-bindings/gpio/sandbox-gpio.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* This header provides constants for binding sandbox,gpio +* +*/ +#ifndef _DT_BINDINGS_GPIO_SANDBOX_GPIO_H +#define _DT_BINDINGS_GPIO_SANDBOX_GPIO_H + +/* +* Add a specific binding for sandbox gpio. +* The value need to be after the generic defines of +* dt-bindings/gpio/gpio.h +*/ + +/* Bit 16 express GPIO input mode */ +#define GPIO_IN 0x10000 + +/* Bit 17 express GPIO output mode */ +#define GPIO_OUT 0x20000 + +/* Bit 18 express GPIO output is active */ +#define GPIO_OUT_ACTIVE 0x40000 + +#endif
Signature · 1 line
2.17.1
PATCH 11/13 gpio: sandbox: cleanup binding support
Quoted 5 lines · Patrick Delaunay
Cleanup binding support, use the generic binding by default (test u-class
gpio_xlate_offs_flagsfunction) and add specific binding for added value.
Quoted 8 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/sandbox/dts/test.dts | 14 ++++++++++---- drivers/gpio/sandbox.c | 13 ++++++++----- include/dt-bindings/gpio/sandbox-gpio.h | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 include/dt-bindings/gpio/sandbox-gpio.h
PATCH 12/13 test: dm: update test for pins configuration in gpio
In reply to Patrick DelaunayAdd tests for new API gpio_get_config and gpio_set_config and associated code in gpio uclass.
Test support for new flags GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE GPIO_PULL_UP and GPIO_PULL_DOWN.
---
arch/sandbox/dts/test.dts | 16 +++++++++++++ drivers/gpio/sandbox.c | 49 +++++++++++++++++++++++++++++++++++++++ test/dm/gpio.c | 31 +++++++++++++++++++++---- test/dm/test-fdt.c | 2 +- 4 files changed, 93 insertions(+), 5 deletions(-)
arch/sandbox/dts/test.dts +16 -0
@@ -16,6 +16,7 @@ eth5 = ð_5; gpio1 = &gpio_a; gpio2 = &gpio_b; + gpio3 = &gpio_c; i2c0 = "/i2c at 0"; mmc0 = "/mmc0"; mmc1 = "/mmc1";
@@ -97,6 +98,13 @@ <&gpio_b 7 GPIO_IN 3 2 1>, <&gpio_b 8 GPIO_OUT 3 2 1>, <&gpio_b 9 (GPIO_OUT|GPIO_OUT_ACTIVE) 3 2 1>; + test3-gpios = + <&gpio_c 0 (GPIO_OUT|GPIO_OPEN_DRAIN)>, + <&gpio_c 1 (GPIO_OUT|GPIO_OPEN_SOURCE)>, + <&gpio_c 2 GPIO_OUT>, + <&gpio_c 3 (GPIO_IN|GPIO_PULL_UP)>, + <&gpio_c 4 (GPIO_IN|GPIO_PULL_DOWN)>, + <&gpio_c 5 GPIO_IN>; int-value = <1234>; uint-value = <(-1234)>; };
@@ -292,6 +300,14 @@ sandbox,gpio-count = <10>; }; + gpio_c: extra2-gpios { + compatible = "sandbox,gpio"; + gpio-controller; + #gpio-cells = <2>; + gpio-bank-name = "c"; + sandbox,gpio-count = <10>; + }; + i2c at 0 { #address-cells = <1>; #size-cells = <0>;
drivers/gpio/sandbox.c +49 -0
73 lines not on this page · raw message
test/dm/gpio.c +27 -4
@@ -23,9 +23,9 @@ static int dm_test_gpio(struct unit_test_state *uts)char buf[80 ];/* -* We expect to get 3 banks. One is anonymous (just numbered) and -* comes from platdata. The other two are named a (20 gpios) -* and b (10 gpios) and come from the device tree. See +* We expect to get 4 banks. One is anonymous (just numbered) and +* comes from platdata. The other are named a (20 gpios), +* b (10 gpios) and c (10 gpios) and come from the device tree. See * test/dm/test.dts. */ ut_assertok (gpio_lookup_name ("b4" , &dev, &offset, &gpio));
@@ -243,7 +243,30 @@ static int dm_test_gpio_phandles(struct unit_test_state *uts)ut_asserteq (GPIOF_OUTPUT ,gpio_get_function (gpio_b,9 ,NULL ));ut_asserteq (1 ,dm_gpio_get_value (&desc_list[5 ])); -return 0 ; }DM_TEST (dm_test_gpio_phandles,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); + +/* Check the gpio pin configuration get from device tree information */ +static int dm_test_gpio_pin_config (struct unit_test_state *uts) +{ +struct gpio_desc desc_list[6 ]; +struct udevice *dev; + +ut_assertok (uclass_get_device (UCLASS_TEST_FDT ,0 , &dev)); + +ut_asserteq (6 ,gpio_request_list_by_name (dev,"test3-gpios" , desc_list, +ARRAY_SIZE (desc_list),0 )); +ut_asserteq (GPIO_CONF_DRIVE_OPEN_DRAIN ,gpio_get_config (&desc_list[0 ])); +ut_asserteq (GPIO_CONF_DRIVE_OPEN_SOURCE , +gpio_get_config (&desc_list[1 ])); +ut_asserteq (GPIO_CONF_DRIVE_PULL_PUSH ,gpio_get_config (&desc_list[2 ])); +ut_asserteq (GPIO_CONF_BIAS_PULL_UP ,gpio_get_config (&desc_list[3 ])); +ut_asserteq (GPIO_CONF_BIAS_PULL_DOWN ,gpio_get_config (&desc_list[4 ])); +ut_asserteq (GPIO_CONF_NONE ,gpio_get_config (&desc_list[5 ])); + +ut_assertok (gpio_free_list (dev, desc_list,6 )); + +return 0 ; +} +DM_TEST (dm_test_gpio_pin_config,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT );
test/dm/test-fdt.c +1 -1
@@ -227,7 +227,7 @@ static int dm_test_alias_highest_id(struct unit_test_state *uts)ut_asserteq (5 , ret); ret =dev_read_alias_highest_id ("gpio" ); -ut_asserteq (2 , ret); +ut_asserteq (3 , ret); ret =dev_read_alias_highest_id ("pci" );ut_asserteq (2 , ret);
Signature · 1 line
2.17.1
PATCH 13/13 test: pinmux: add pincontrol-gpio for pin configuration
In reply to Patrick DelaunayAdd a simple pincontrol associated to the sandbox gpio driver, that allow to check pin configuration check with the command pinmux.
The pinux test is also updated to test behavior with 2 pincontrols.
Example to check LED pin configuration:
=> pinmux list
| Device | Driver | Parent | pinctrl-gpio | sandbox_pinctrl_gpio | root_driver | pinctrl | sandbox_pinctrl | root_driver
=> pinmux dev pinctrl-gpio
=> pinmux status
a0 : gpio input .
a1 : gpio input .
a2 : gpio input .
a3 : gpio input .
a4 : gpio input .
a5 : gpio output drive-pull-push
a6 : gpio output drive-pull-push
...
Serie-cc: Heiko Schocher <[email protected]>
---
arch/sandbox/dts/test.dts | 48 +++++---- drivers/gpio/sandbox.c | 193 +++++++++++++++++++++++++++++++++++ test/py/tests/test_pinmux.py | 10 ++ 3 files changed, 229 insertions(+), 22 deletions(-)
arch/sandbox/dts/test.dts +26 -22
@@ -284,28 +284,32 @@ }; }; - gpio_a: base-gpios { - compatible = "sandbox,gpio"; - gpio-controller; - #gpio-cells = <1>; - gpio-bank-name = "a"; - sandbox,gpio-count = <20>; - }; - - gpio_b: extra-gpios { - compatible = "sandbox,gpio"; - gpio-controller; - #gpio-cells = <5>; - gpio-bank-name = "b"; - sandbox,gpio-count = <10>; - }; - - gpio_c: extra2-gpios { - compatible = "sandbox,gpio"; - gpio-controller; - #gpio-cells = <2>; - gpio-bank-name = "c"; - sandbox,gpio-count = <10>; + pinctrl-gpio { + compatible = "sandbox,pinctrl-gpio"; + + gpio_a: base-gpios { + compatible = "sandbox,gpio"; + gpio-controller; + #gpio-cells = <1>; + gpio-bank-name = "a"; + sandbox,gpio-count = <20>; + }; + + gpio_b: extra-gpios { + compatible = "sandbox,gpio"; + gpio-controller; + #gpio-cells = <5>; + gpio-bank-name = "b"; + sandbox,gpio-count = <10>; + }; + + gpio_c: pinmux-gpios { + compatible = "sandbox,gpio"; + gpio-controller; + #gpio-cells = <2>; + gpio-bank-name = "c"; + sandbox,gpio-count = <10>; + }; }; i2c at 0 {
drivers/gpio/sandbox.c +193 -0
209 lines not on this page · raw message
test/py/tests/test_pinmux.py +10 -0
@@ -22,6 +22,12 @@ def test_pinmux_usage_2(u_boot_console): def test_pinmux_status_all(u_boot_console): """Test that 'pinmux status -a' displays pin's muxing.""" output = u_boot_console.run_command('pinmux status -a') + + assert ('pinctrl-gpio:' in output) + assert ('a5 : gpio output drive-pull-push' in output) + assert ('a6 : gpio output drive-pull-push' in output) + + assert ('pinctrl:' in output) assert ('SCL : I2C SCL.' in output) assert ('SDA : I2C SDA.' in output) assert ('TX : Uart TX.' in output)
@@ -63,6 +69,10 @@ def test_pinmux_status(u_boot_console): """Test that 'pinmux status' displays selected pincontroller's pin muxing descriptions.""" output = u_boot_console.run_command('pinmux status') + + 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)
Signature · 1 line
2.17.1
PATCH 13/13 test: pinmux: add pincontrol-gpio for pin configuration
Quoted 29 lines · Patrick Delaunay
Add a simple pincontrol associated to the sandbox gpio driver, that allow to check pin configuration check with the command pinmux.
The pinux test is also updated to test behavior with 2 pincontrols.
Example to check LED pin configuration:
=> pinmux list
| Device | Driver | Parent | pinctrl-gpio | sandbox_pinctrl_gpio | root_driver | pinctrl | sandbox_pinctrl | root_driver=> pinmux dev pinctrl-gpio
=> pinmux status
a0 : gpio input .
a1 : gpio input .
a2 : gpio input .
a3 : gpio input .
a4 : gpio input .
a5 : gpio output drive-pull-push
a6 : gpio output drive-pull-push
...Serie-cc: Heiko Schocher <[email protected]>
Quoted 8 lines
Signed-off-by Patrick Delaunay <[email protected]>---
arch/sandbox/dts/test.dts | 48 +++++---- drivers/gpio/sandbox.c | 193 +++++++++++++++++++++++++++++++++++ test/py/tests/test_pinmux.py | 10 ++ 3 files changed, 229 insertions(+), 22 deletions(-)