This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PROCESSOR-SDK-AM437X: Device tree and GPIO

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: AM4372

Tool/software: Linux

Hi,

I have the following GPIO defined in the device tree:

gpio5_mux_pins: gpio5_mux_pins {
pinctrl-single,pins = <
/* GPIO 5_8 to select LCD / HDMI */
AM4372_IOPAD(0xa38, PIN_OUTPUT_PULLUP | MUX_MODE7)
/* GPIO 5_4 to reset LCD */
AM4372_IOPAD(0xa50, PIN_OUTPUT_PULLUP | MUX_MODE7)
>;
};

&gpio5 {
pinctrl-names = "default";
pinctrl-0 = <&gpio5_mux_pins>;
status = "okay";
ti,no-reset-on-init;

p8 {
/*
* SelLCDorHDMI selects between display and audio paths:
* Low: HDMI display with audio via HDMI
* High: LCD display with analog audio via aic3111 codec
*/
gpio-hog;
gpios = <8 GPIO_ACTIVE_HIGH>;
output-high;
line-name = "SelLCDorHDMI";
};

p4 {
/*
* LCD_Reset
*/
gpio-hog;
gpios = <4 GPIO_ACTIVE_LOW>;
output-high;
line-name = "lcdReset";
};
};

In the c code, the devm_gpiod_get function return error. Which means the lcdReset is not defined in device tree.

struct gpio_desc *gpio;

gpio = devm_gpiod_get(&spi->dev, "lcdReset", GPIOD_OUT_HIGH);
if (IS_ERR(gpio))
{
    dev_err(&spi->dev, "Failed to get lcdReset GPIO\n");
    printk("Start probe: **** lcdreset_gpios is NOT defind in device tree! ****\n");
    printk("the spi dev is %x\n", &spi->dev);
    return PTR_ERR(gpio);
}

What wrong with this approach?

On the other hand, I try to add the following line in am437x-gp-evm.dts file, I got syntax error on the line. why?

lcdReset-gpios = <&gpio5 4 GPIO_ACTIVE_LOW>;

  • Hi Wang,

    We do not have "lcdReset-gpios" DTS entry available to use. You should use "reset-gpios" and/or "enable-gpios" DTS entries. This was explained in your other e2e thread, link below:

    e2e.ti.com/.../708842

    Regards,
    Pavel
  • Hi, Pavel,

    I may not communicate this issue to you well enough.
    Basically, we are modifying your sdk to accommodate our hardware, which has a LCD reset pin tied to the LCD chip connect to the SPI bus.
    We need to add such pin in DTS and the syntax I showed above has no error. I believe your sdk should allow customers to add/remove hardware also. Please advise what I did wrong in terms of adding such signal into sdk.

    Thanks.

    Jerry
  • Wang,

    Sorry for the late reply, I was out of office.

    Zhiwei Wang said:
    line-name = "lcdReset";

    Zhiwei Wang said:

    In the c code, the devm_gpiod_get function return error. Which means the lcdReset is not defined in device tree.

    struct gpio_desc *gpio;

    gpio = devm_gpiod_get(&spi->dev, "lcdReset", GPIOD_OUT_HIGH);

    Zhiwei Wang said:
    What wrong with this approach?

    You can not use "line-name" DTS entry in such way.

    This is the GPIO label name. This is to add GPIO names to the kernel based on devicetree descriptions. As the GPIO name information is a hardware description this series uses the devicetree bindings introduced by the GPIO hogging mechanism, specifically 'line-name', to identify GPIOs. The sysfs 'export' file is changed to accept names as fallback. The gpio numbers still have a higher priority to ensure backwards compatibility. Exported GPIOs are still using their number as directory name (gpio<ID>). But the directories now contain a 'name' file which is '(null)' for non-existent names and the name otherwise.

    devm_gpiod_get() takes as second argument the string from "<name>-gpio" or "<name>-gpios" DTS entry, not from "line-name". See for example below files:

    linux-4.9.69/arch/arm/boot/dts/omap3-n900.dts

    ti,ssi-cawake-gpio = <&gpio5 23 GPIO_ACTIVE_HIGH>; /* 151 */

    linux-4.9.69/drivers/hsi/controllers/omap_ssi_port.c

    cawake_gpio = devm_gpiod_get(&pd->dev, "ti,ssi-cawake", GPIOD_IN);
        if (IS_ERR(cawake_gpio)) {
            err = PTR_ERR(cawake_gpio);
            dev_err(&pd->dev, "couldn't get cawake gpio (err=%d)!\n", err);
            goto error;
        }

    Regards,
    Pavel

  • Zhiwei Wang said:

    On the other hand, I try to add the following line in am437x-gp-evm.dts file, I got syntax error on the line. why?

    lcdReset-gpios = <&gpio5 4 GPIO_ACTIVE_LOW>;

    Most probably, "lcdReset-gpios" does not exist in your LCD driver.

    Regards,
    Pavel