GPIO MPC8315 board

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

GPIO MPC8315 board

Jump to solution
1,394 Views
Vasanthragavend
Contributor II

Hi

 

I am using a MPC8315ERDB board. For this i've an external button which is connected to GPIO pin 7 of the board. And if this button is pressed then certain files have to be deleted. Browsing through the internet i found that GPIO drivers have to be included into the kernel and hence i set a 'y' to CONFIG_MPC8xxx_GPIO, CONFIG_GPIO_SYSFS and CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB etc. And the dts file has be modified to include the following lines 

 

gpio1: gpio-controller@c00 {                

#gpio-cells = <2>;                

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

reg = <0xc00 0x100>;                

interrupts = <74 0x8>;                

interrupt-parent = <&ipic>;                

gpio-controller;         };          

 

this is included under immr@e0000000.

 

further i included

 

erase-button@0 {

compatible = "erase-button";

interrupts = <7 2>;

interrupt-parent = <&gpio1>;

};

 

am i right in including this? coz after compiling the kernel i get a folder under /sys/class/gpio. I did an export using

 

echo 192 > /sys/class/gpio/export.

 

192 was the number appearing in gpiochip192/base.

 

It created another folder gpio192.

 

However i'm not able to set the value in them nor the direction.

 

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

cat /sys/class/gpio/gpio192/value

returns a value of 0 only.

 

Am i doing it correctly? How to check it programatically if the button is pressed and take the corresponding action! Plz help!

 

My kernel version is 2.6.35.9.

 

Thanking you in advance.

1 Solution
526 Views
Vasanthragavend
Contributor II

I fixed it myself! And some changes had to be made. The erase-button is not needed in the dts file. Further since the Gpio pin 7 needs to be controlled, the value in gpiochipN/base should be added with 7 and then the command should be given

echo N+7 > export.

 

Further in order to make the GPIO pin to be functional the SICRH register should be reset for GPIO pin 7 to be enabled. The bits 6 and 7 of SICRH register in 0xe0000118 should be set 1 so that the pin 7 would become functional. Thanks all if u happened to visit my post here!

View solution in original post

0 Kudos
1 Reply
527 Views
Vasanthragavend
Contributor II

I fixed it myself! And some changes had to be made. The erase-button is not needed in the dts file. Further since the Gpio pin 7 needs to be controlled, the value in gpiochipN/base should be added with 7 and then the command should be given

echo N+7 > export.

 

Further in order to make the GPIO pin to be functional the SICRH register should be reset for GPIO pin 7 to be enabled. The bits 6 and 7 of SICRH register in 0xe0000118 should be set 1 so that the pin 7 would become functional. Thanks all if u happened to visit my post here!

0 Kudos