AnsweredAssumed Answered

P1020 GPIO Access Issue

Question asked by Nakul Dhingra on Apr 12, 2018
Latest reply on Apr 15, 2018 by Pavel Chubakov

We want to access gpio14 of p1020. I tried it through sysfs

echo 494 > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio494/direction

This reboots/hangs the processor.

 

Then i tried to access the gpio through driver. Our device tree entry are as follow,

gpio0: gpio-controller@f000 {
                        #gpio-cells = <0x2>;
                        compatible = "fsl,pq3-gpio";
                        reg = <0xf000 0x100>;
                        interrupt-parent = <&mpic>;
                        interrupts = <0x2f 0x2 0x0 0x0>;
                        gpio-controller;
                };

ksz_reset@0  {
                                        #address-cells = <0x1>;
                                        #size-cells = <0x1>;
                                        compatible = "nakul,kszreset";
                                        reg = <0x0>;
                                        spi-max-frequency = <0x2625a00>;
                                        kszreset-gpios = <&gpio0 14 1>;
                                };
and this is my driver snippet
static int kszreset_probe(struct spi_device *spi)
{
        struct gpio_desc *resetgpio;
        int ret;
         resetgpio = gpiod_get(&spi->dev, "kszreset");
        if (resetgpio != NULL)
                printk(KERN_ERR"KSZRESET : Got the GPIO\n");
        ret = gpiod_get_direction(resetgpio);
        if (ret)
                printk(KERN_ERR"KSZRESET : Direction is input\n");

        gpiod_direction_output(resetgpio, 1);
        return 0;
}
When the driver loads I get following prints
    [    0.603123] KSZRESET : Got the GPIO
    [    0.608991] KSZRESET : Direction is input
After this Processor hangs. Can somebody please suggest what can be the issue?

Outcomes