The MMCR registers are memory-mapped, but you are using the I/O
routines, trying to address them in I/O space. I haven't done this in
Linux, but FreeBSD has a device /dev/elan-mmcr that you can open and
mmap() for direct access. I would imagine you could open /dev/mem and
mmap() the MMCR region and access it in that manner.
Ralph
On Apr 7, 2009, at 4:17 PM, Jim Jones wrote:
I have a net4501 device and I want to do a direct read of the GPIO
pins without using a driver. The GPIO pins are floating and I am
using the following code:
#include <stdio.h>
#include <sys/io.h>
#include <sys/types.h>
int main()
{
unsigned int MMCR = 0xFFEF000; // Offset Address
unsigned int PIODIR15_0 = 0xC2A; // PIO15-PIO00 input/output register
unsigned int PIODATA15_0 = 0xC30; // Read/write directly the state
of the PIO15-PIO0 pins, PIO5-PIO8 = GPIO0-GPIO3
iopl(3); // Open the permissions.
outl(0xF0F0F0F0, MMCR + PIODIR15_0); // Write some data to the
direction register
printf("Direction Reg = 0x%x\n", inl(MMCR + PIODIR15_0)); // Print
state of direction register
outl(0xA1A1A1A1, MMCR + PIODATA15_0); // Write some data to the DATA
register
printf("DATA Reg = 0x%x\n", inl(MMCR + PIODIR15_0)); // Print state
of DATA register
printf("0x000000F0 Reg = 0x%x\n", inl(0x000000F0)); // Print result
of randomly chosen reg to screen
printf("0xFFFFFFFA Reg = 0x%x\n", inl(0xFFFFFFFA)); // Print result
of randomly chosen reg to screen
}
When I run this file, the following is output:
Direction Reg = 0xffffffff
DATA Reg = 0xffffffff
0x000000F0 Reg = 0xffffffc1
0xFFFFFFFA Reg = 0xc000ffff
0xFFFFFFFF is not the correct data. I am not sure why I can not
write to the PIODIR15_0 and PIODATA15_0 registers. Do you have any
suggestions?
Also, is the net4501 and Elan SC520 processor still in production?
Rediscover HotmailĀ®: Now available on your iPhone or BlackBerry
Check it out._______________________________________________
Soekris-tech mailing list
Soekris-tech@lists.soekris.com
http://lists.soekris.com/mailman/listinfo/soekris-tech
_______________________________________________
Soekris-tech mailing list
Soekris-tech@lists.soekris.com
http://lists.soekris.com/mailman/listinfo/soekris-tech