MPC8309 GPIO

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

MPC8309 GPIO

Jump to solution
1,144 Views
lijiankun198
Contributor II

Hi all,

I need to control a gpio of MPC8309twr. In my driver, I used gpio_request(38, "gpio_reset") function to request the "USBDR_TXDRXD6/GPIO_38/QE_BRG_9" I/O signal. But the function alway return a negative number.

I have configurated the kernel, added the "QE GPIO support" and "GPIO Support" and "/sys/class/gpio/... (sysfs interface)". In order to multiplex the GPIO_38, I set the SICR_2 register as 0x00080000. In mpc8390twr.dts, I add lines as follows:

gpio2: gpio-controller@d00 {

  #gpio-cells = <2>;

  compatible = "fsl,mpc8347-gpio", "fsl,mpc8349-gpio";

  reg = <0xd00 0x100>;

  interrupts = <75 0x8>;

  interrupt-parent = <&ipic>;

  gpio-controller;

};

Is there anything wrong in my configuration ?

I will appreciate all your comments and suggestions!

Thanks.

0 Kudos
1 Solution
757 Views
Pavel
NXP Employee
NXP Employee

NXP BSP 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).

The GPIO0 usually is GPIO224 under Linux (256-32).  

2) Look at our dump. It is dump for P2020. Similar command sequence can be used for MPC8309.

// OUTPUT

root@p2020ds:/sys/class/gpio/gpio224# echo out > direction

This command sets direction (input/output)

root@p2020ds:/sys/class/gpio/gpio224# echo 1 > value

This command sets high level on the GPIO.

root@p2020ds:/sys/class/gpio/gpio224# echo 0 > value

This command sets low level on the GPIO.

The second method consist of using mmap command.

It is a POSIX-compliant Linux/Unix system call that maps files or devices into memory.

It is a method of memory-mapped file I/O.

For example, look at the following links (http://en.wikipedia.org/wiki/Mmap) and

(http://beej.us/guide/bgipc/output/html/multipage/mmap.html).


Have a great day,
Pavel Chubakov

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

View solution in original post

0 Kudos
1 Reply
758 Views
Pavel
NXP Employee
NXP Employee

NXP BSP 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).

The GPIO0 usually is GPIO224 under Linux (256-32).  

2) Look at our dump. It is dump for P2020. Similar command sequence can be used for MPC8309.

// OUTPUT

root@p2020ds:/sys/class/gpio/gpio224# echo out > direction

This command sets direction (input/output)

root@p2020ds:/sys/class/gpio/gpio224# echo 1 > value

This command sets high level on the GPIO.

root@p2020ds:/sys/class/gpio/gpio224# echo 0 > value

This command sets low level on the GPIO.

The second method consist of using mmap command.

It is a POSIX-compliant Linux/Unix system call that maps files or devices into memory.

It is a method of memory-mapped file I/O.

For example, look at the following links (http://en.wikipedia.org/wiki/Mmap) and

(http://beej.us/guide/bgipc/output/html/multipage/mmap.html).


Have a great day,
Pavel Chubakov

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

0 Kudos