LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Problem using SA-1100 GPIO registers (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/problem-using-sa-1100-gpio-registers-849231/)

Milosman 12-09-2010 02:28 AM

Problem using SA-1100 GPIO registers
 
Hi there,

I'm having some serious trouble using my GPIO pin registers on my intel SA-1100 device, from kernel space ofc..
I want to map the physical addresses to some usable ones using ioremap and then use write32 and read32 to write and read them. Should be simple.. But is this the easiest way?
For reference, the devmanual of the SA-1100 can be found here: HERE

Here is the code I have:

#define GPIO_BASE 0x90040000
#define GPIO_LENGTH 0xFFF

static void *io_base, *GPLR, *GPDR, *GPSR, *GPCR;

void InitGPIO(void)
{
io_base = ioremap(GPIO_BASE, GPIO_LENGTH);
GPLR = io_base;
GPDR = io_base + 0x04;
GPSR = io_base + 0x08;
GPCR = io_base + 0x0C;

printk("io ports remapped %p\n ", GPLR);
}


Now I should be able to read the pins using:

ioread32(GPLR);


But this is returning the incorrect values.. (not dependent on what i write) Somehow I have the feeling that I didn't map the correct address. The address returned by ioremap is ca000000 but that shouldn't say anything right? What am I not seeing? Or am I not using the right methods?

Any help is greatly appreciated.

nini09 12-13-2010 02:25 PM

Using ioremap to access GPIO in kernel space is fine. The issue is GPIO_BASE define. Is it correct physical address?

archieval 12-13-2010 07:50 PM

Perhaps the value of GPIO_BASE is already mapped or some mapped address space already covers it? Have you tried reading directly on the GPIO_BASE address?

Milosman 12-14-2010 01:41 AM

Yes, since GPIO_BASE = GPLR. But the matter has just been solved using register shortcuts i found in hardware.h ... so much effort for nothing.

But thanks for the advice!


All times are GMT -5. The time now is 09:18 PM.