Hi Jeff,<br><br>I read the device drivers part of the LDD3, it's really difficult as I expected. Thanks for the sample codes. I'll develop my own driver basing from your samples. Regarding reading the status of the LED, is it really necessary to use proc?<br><br>Regards,<br>dell<br><br><b><i>Jeff Mock <jeff@mock.com></i></b> wrote:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> <br>David Hawkins wrote:<br>>> I have a PPC440EPx Sequoia Evaluation board that runs on Linux 2.6.21. <br>>> What I would want to do is to control (write and read values to) its <br>>> GPIO. Perhaps similar to Turbo C's outputb(0x378,0x01) to write and <br>>> inportb(0x378) to read. I read the PPC440EPx manual but I find it <br>>> difficult to understand.<br>>><br>>> Could anyone show me any tutorial or some sample codes?<br>> <br>> I copied the code below from some test code I
wrote for a TS7300<br>> board (uses an ARM EP9302 processor). However, since its user-space<br>> code it should work fine.<br>> <br><br>I might be a little out of date, but I think you must write your own <br>driver to wiggle the GPIO pins on a 440 processor. I just finished a <br>project using a 440GX with a 2.6.15 kernel (we froze the code about 8 <br>months ago).<br><br>The 440 powerPC core is a 32-bit processor with 36-bit physical <br>addresses. The physical address for the GPIO pins is someplace above <br>4GB. An mmap() of /dev/mem only lets you map the lower 4GB of the <br>address space, as a result you can't write a user space program on the <br>440 to wiggle the GPIO pins. (This was true with 2.6.15, I can't speak <br>for later kernels).<br><br>This tossed me into writing device drivers, which turned out to be not <br>nearly as scary as I imagined. The Linux Device Drivers book is fabulous:<br><br> http://lwn.net/Kernel/LDD3/<br><br>Here is a
driver for the 440GX that controls an LED on one of the GPIO <br>pins you can use as an example. The device /dev/pdev-led has a <br>read/write interface so you can do something like this:<br><br> # echo "1" > /dev/pdev-led # turn on LED<br> # echo "0" > /dev/pdev-led # turn off LED<br><br>It also has a /proc interface so you can cat /proc/pdev-led to read the <br>status of the LED. There are several other drivers there that probably <br>won't be interesting, but pdev-led.c is probably a good starting point:<br> <br>http://www.mock.com/wsvn/listing.php?repname=mock.pdev&path=/trunk/sw/driver/<br><br>jeff<br><br><br></blockquote><br><p> __________________________________________________<br>Do You Yahoo!?<br>Tired of spam? Yahoo! Mail has the best spam protection around <br>http://mail.yahoo.com