Simple port IO on MPC5121e and Linux - an impossible task ? :)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Simple port IO on MPC5121e and Linux - an impossible task ? :)

跳至解决方案
1,620 次查看
cédricfoissac
Contributor I

Hello,

 

I can't believe it is so complex to set a simple chipselect on a MPC5121e running linux.

 

Gpio is detected (kernel is compiled with support of it, and i got gpiochip_find_base: found new base @224 in dmesg (kernel 3.0.4 with xenomai)

 

But i'm unable to access it through /sys/class/gpio. I can successfully export a pin (ie, if i type cat 224 > export, gpio224 is created), but i can't successfully control it:

 

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

cat /sys/class/gpio/gpio224/value

0

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

cat /sys/class/gpio/gpio224/value

0

 

My need is a simple chipselect (well, 3 chips - select ), for a custom design. Running linux is mandatory. I suspect the MPC5121 to be in the bad function mode, so:

- does anyone knows how to change mode ? What register can i acces and how ? does it worths a try ?

- does anyone successfully perform simple IO control ?

 

Last thing, i have tryed to access internal registers through /dev/mem, but no success. There are very few ressources available for this microcontroler, but i'm stick to it. Perhaps anybody knows how to access (read) internal registers with /proc or sys-fs ?

 

Thank you for your help !

标签 (1)
标记 (3)
0 项奖励
1 解答
1,282 次查看
Tim562
Senior Contributor I

Hi cédricfoissac,

     I use the MPC5125 (not sure how similar) and on that processor each pin can perform 1 of several possible functions. You need to configure the pin for the required function using the I/O control registers (section 20 in the MPC5125 manual). For example, on the 5125 most pins have 4 possible functions (like GPIO, LPC, PSC, etc) and you just write the 32 bit Pad I/O Control Register to specify which you want the pin to do. The address of these registers will be in the manual for the processor and it will probably be based on an offset/starting value. Hope this helps.

~Tim

在原帖中查看解决方案

0 项奖励
2 回复数
1,283 次查看
Tim562
Senior Contributor I

Hi cédricfoissac,

     I use the MPC5125 (not sure how similar) and on that processor each pin can perform 1 of several possible functions. You need to configure the pin for the required function using the I/O control registers (section 20 in the MPC5125 manual). For example, on the 5125 most pins have 4 possible functions (like GPIO, LPC, PSC, etc) and you just write the 32 bit Pad I/O Control Register to specify which you want the pin to do. The address of these registers will be in the manual for the processor and it will probably be based on an offset/starting value. Hope this helps.

~Tim

0 项奖励
1,282 次查看
cédricfoissac
Contributor I

Hi Tim,

Thank you, i finally follow the same way than you did - i had time to dig the MPC5121e hardware manual.

What was a problem for me was the fact the gpio were created in sys-fs even if not usable (i would have think they were simply not visible if not usable as an I/O).

Thank you,

CF

0 项奖励