P1020 GPIO Access Issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

P1020 GPIO Access Issue

526 Views
nakuldhingra
Contributor I

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?
0 Kudos
1 Reply

330 Views
Pavel
NXP Employee
NXP Employee

NXP SDK supports sysfs possibility for GPIO using from user space.

Check please that the following kernel configuration options are set. These options are necessary

for sysfs GPIO support:

CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB

CONFIG_MPC8XXX_GPIO (Platform Support / MPC8xxx GPIO support)

CONFIG_OF_GPIO

CONFIG_GPIOLIB (-*- GPIO Support  --->  )

CONFIG_GPIO_SYSFS (/sys/class/gpio/... (sysfs interface))

CONFIG_GENERIC_GPIO

 

This option can be checked using the .config file in the kernel source folder.

 

GPIO controllers should be declared in the Device Tree file.

More information on the device tree GPIO declaration can be found in the kernel source.

See please the following files:

/Documentation/powerpc/dts-bindings/gpio.txt and /Documentation/powerpc/dts-bindings/fsl/8xxx_gpio.txt

 

This possibility is available using sysfs from user space.

See the following pages

(http://elinux.org/GPIO)

and

(https://www.kernel.org/doc/Documentation/gpio/sysfs.txt).

and

 (http://www.lindusembedded.com/blog/2011/12/29/gpio-general-purpose-inputoutput-interfaces-in-linux-2...)

and

(https://www.kernel.org/doc/Documentation/gpio/sysfs.txt).

 

Attached file contains .dts file and command dump for GPIO using.


Have a great day,
Pavel Chubakov

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos