For an imx91 based project I am stuck with defining my first GPIO as output.
I have read several posts where examples towards the device trees are explained but I am still getting the `-22` return value.
Defined in device tree:
gpio_reset: gpio-reset {
compatible = "gpio-reset";
pinctrl-names = "default";
reset-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
status = "okay";
label = "RSTO";
gpio-name = "RSTO";
line-name = "RSTO";
};
Here I tried adding label,gpio-name and line-name. Not sure which one is needed.
Then in function
static void board_gpio_init(void){
struct gpio_desc desc;
int ret;
/* De-assert RSTO */
ret = dm_gpio_lookup_name("RSTO", &desc);
if (ret) {
printf("%s lookup 'RSTO' failed ret = %d\n", __func__, ret);
return;
}
...
}
This always returns -22 and it's the first pin to look up.
Then I thought let's try a proven example code based on leds,
gpio-leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_led>;
led-0 {
gpios = <&gpio3 26 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
led-1 {
gpios = <&gpio3 27 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
};
Then
ret = dm_gpio_lookup_name("led-1", &desc);
also returns -22
已解决! 转到解答。
I did find a missing _defconfig setting called
CONFIG_IMX_RGPIO2P=y
ret = dm_gpio_lookup_name("gpio1_8", &desc);
Hi David:
The dm_gpio_lookup_name() function does not parse gpio-name, or line-name from the device tree. It only understands the format "gpioX_Y" where
X is the GPIO controller
Y is the pin number.
If you are working in the Linux Kernel (not U-BOOT), you can use
And define in DTS
Regards
Daniel
Thanks for reply!
I did notice this example:
ret = dm_gpio_lookup_name("adp5585-gpio4", &exp_sel_desc);
adp5585: io-expander@34 {
compatible = "adi,adp5585-00", "adi,adp5585";
reg = <0x34>;
#gpio-cells = <2>;
gpio-controller;
#pwm-cells = <3>;
gpio-reserved-ranges = <5 1>;
exp-sel-hog {
gpio-hog;
gpios = <4 GPIO_ACTIVE_HIGH>;
output-low;
};
So how can I check how the syntax should be? for instance: is it connecting with a ''_" or "-"... ?
Ok so finding out which ports are actual available just requires a print like,
len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
printf("%s: lookup %s\n", __func__,uc_priv->bank_name);
if (!strncasecmp(name, uc_priv->bank_name, len)) {
And then I get to see the available&correct names on my console!
file location is `uboot/drivers/gpio/gpio-uclass.c`