i.MX28 GPIO access

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

i.MX28 GPIO access

Jump to solution
4,683 Views
chris321
Contributor IV

Hello Freescale Community,

I have some trouble adding GPIO support on a i.MX28 Pin.

There is a two color LED on the Pins K4 and L4.

I'm using an 3.9 Kernel and it seems to run a Heartbeat on the LED on Pin K4.

I figured out with the file fsl,mxs-pinctrl.txt that the IDs are:

MX28_PAD_AUART1_RX__GPIO_3_4            0x3043

MX28_PAD_AUART1_TX__GPIO_3_5            0x3053

So I modified the imx28-evk.dts by copying something similar from the GPIO_3_5 to 3_4.

                led_pin_gpio3_4: led_gpio3_4@0 {

                    reg = <0>;

                    fsl,pinmux-ids = <

                        0x3043 /* MX28_PAD_AUART1_RX__GPIO_3_4 */

                    >;

                    fsl,drive-strength = <0>;

                    fsl,voltage = <1>;

                    fsl,pull-up = <0>;

                };

               

then I crosscompiled this dts to a dtb and attached it to the zImage

cat arch/arm/boot/zImage arch/arm/boot/dts/imx28-evk.dtb > arch/arm/boot/zImage_dtb

sudo cp arch/arm/boot/zImage_dtb ~/freescale/imx28/ltib/rootfs/boot/zImage

Now I tried to switch the LED GPIO on and off

Linux GPIO Number = <GPIO Instance – 1> × 32 + <GPIO Port number> = (3-1)*32+4 = 68

(found this formula here https://community.freescale.com/message/317413#317413 which document is the source?)

echo 68 >/sys/class/gpio/export

echo out >/sys/class/gpio/gpio68/direction

echo 1 >/sys/class/gpio/gpio68/value

echo 0 >/sys/class/gpio/gpio68/value

but the LED did not go on and off, have I forgot something?


Labels (2)
1 Solution
929 Views
fabio_estevam
NXP Employee
NXP Employee

The formula you mentioned applies only to other i.mx devices, that starts counting the gpio from 1.

For mxs you should do: 3*32 + 4

View solution in original post

0 Kudos
4 Replies
930 Views
fabio_estevam
NXP Employee
NXP Employee

The formula you mentioned applies only to other i.mx devices, that starts counting the gpio from 1.

For mxs you should do: 3*32 + 4

0 Kudos
929 Views
chris321
Contributor IV

thank you very much, this was the answer.

But where are this formula from? I can't find something like this in the docu.

0 Kudos
929 Views
fabio_estevam
NXP Employee
NXP Employee

This comes from the fact that mxs SoCs have 32 GPIOs per GPIO port and the hardware GPIOnumbering start from zero:

For example:

GPIO0_5 --> Linux number is 0*32 + 5

GPIO1_10 --> Linux number is 1*32 + 10

This differs from other i.mx, where we start counting from GPIO1, ie, there is no GPIO0 as per the SoC manual.

For example (there is no GPIO0 port on this family):

GPIO1_3 ---> Linux number (1-1)*32 + 3

GPIO3_7 ---> Linux number is (3-1)*32 + 7

Hope this helps to clarify why mxs and imx have different schemes to calculate the Linux gpio number.

929 Views
chris321
Contributor IV

Thank you very much.

0 Kudos