[Most of the threads on GPIO use the deprecated sysfs interface; this request is for the current ABI character-based interface using GPIO descriptors]
AM3351 - custom board; similar to evm or BBB
TI-SDK v08.02 (w/kernel 5.10)
I am trying to gpiod_export() from a driver (drivers/pinctrl/pinctrl-single.c), some named user gpios declared in the devicetree. I want them available in userspace to get/set from an application. I also expect they would show as "named" and "used" from # gpioinfo
. I can get the gpiod_count() and an associated name from the devicetree using of_property_read_string_index(), but I fail to get descriptors using either gpiod_get_array() or gpiod_get_index().
After getting the descriptors, I was planning to gpiod_export() the array of gpios and gpiod_export_link() to associate a name with them.
Why is gpiod_get_array() failing in the sequence below to return the descriptors gpio_count() sees?
(Some error checking omitted for conciseness)
int gpio_count, gpio_name_count; struct gpio_descs *gpiodescs; gpio_count = gpiod_count(pcs->dev, "my"); // RETURNS 3 gpio_name_count = of_property_count_strings(np, "my-gpio-names"); // RETURNS 3 // THE FOLLOWING FAILS TO RETURN THE DESCRIPTORS gpiodescs = devm_gpiod_get_array(pcs->dev, "my", GPIOD_OUT_LOW); // returns IN_ERR if (IS_ERR(gpiodescs)) { dev_warn(pcs->dev, "failed to get gpio array (%d)\n", gpiodescs); }
Also tested in a loop, the following which also fails to get the descriptor
descp = devm_gpiod_get_index(pcs->dev, "my", i, GPIOD_OUT_LOW); if (IS_ERR(descp)) { dev_warn(pcs->dev, "failed to get gpio desc\n"); }
My abbreviated dts is:
&am33xx_pinmux { pinctrl-names = "default"; my-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>, <&gpio2 3 GPIO_ACTIVE_HIGH>, <&gpio2 0 GPIO_ACTIVE_HIGH>; my-gpio-names = "name1", "name2", "name3";