AM62L-LINUX-SDK: GPIO/Interrupt/Wakeup early implementation in linux driver.

Part Number: AM62L-LINUX-SDK

Hello,

I have a driver statically compiled in the kernel image. The driver configured the gpio, interrupt to  detect a power failure and wakeup interrupt as well to wakeup the device from deep sleep. The driver works fine but I would like to run it in early boot.

I tried to use subsys_initcall_sync(test_driver_init) and saw the driver loaded early. But the problem is that the driver couldn't get the gpio.

 

static int boot_gpio_init(void)
{
    struct device_node *np;

    np = of_find_compatible_node(NULL, NULL, "test,node");
    if (!np)
        return -ENODEV;

    int pwr_boot_gpio = of_get_named_gpio(np, "test-pin-gpios", 0);
    of_node_put(np);

    if (pwr_boot_gpio < 0)
    {
        pr_err("boot_gpio_init: pwr_boot_gpio %d\n", pwr_boot_gpio);
        return pwr_boot_gpio;
    }

    if (gpio_request(pwr_boot_gpio, "pfail-boot"))
        return -EBUSY;

    gpio_direction_input(pwr_boot_gpio);
    return 0;
}


static int __init test_driver_init(void)
{

    boot_gpio_init();
    return platform_driver_register(&test_driver);
}

subsys_initcall_sync(test_driver_init);

 

The output is:
boot_gpio_init: pwr_boot_gpio -517 or (-EPROBE_DEFER).

I would like to know if there's a way to initialize the gpio, interrupt and the wakeup interrupt early?

 

Thanks,

John Tobias

 

 

  • Hi John,

    Just so I understand the requirements correct, the same GPIO needs to be used as a wakeup source from Deep Sleep as well as an input interrupt in early boot?

    To keep expectations clear, on the TI E2E forums, we don't provide support on customer developed code. 

    Are you using SPL boot for your application?

    Best Regards,

    Anshu

  • Hi Anshu,

    I posted some sample code so that anyone could easily understand the scenario and I am not sure I was in the correct channel?. 
    My intention is to get the information on how configure the gpio early as possible so that I can read the state of the gpio. The code that I posted showing it was relying to the pinctrl.

    If configuring the interrupt and wakeup interrupt is impossible in very early stage of the kernel boot level, I do believe reading a gpio is possible without depending on pinctrl.

    Regards,

    John

  • Hi,

    I managed to access the gpio in early stage of the kernel bool level.