lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

ARM versus MIPS GPIO.

Wed Oct 29, 2014 6:17 am

For Pi ARM GPIO is accessed through memory mapped

Code: Select all

 gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
 *(gpio_map+offset) =value
where gpio_map is virtual address. different GPIO is accessed through different offset.

For MIPS the GPIO is accessed through bus address using ioremap function instead of mmap of ARM.
the memory address from ioremap of MIPS cannot be directly derefenced like ARm. It must use readl and writel to access those memory location..


So, the question is why the difference and two different approach between the two. why can't MIPS use mmap or why can't ARM use ioremap?
Last edited by lilzz on Wed Oct 29, 2014 4:10 pm, edited 1 time in total.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: ARM versus MIP GPIO.

Wed Oct 29, 2014 3:15 pm

lilzz wrote:For Pi ARM GPIO is accessed through memory mapped

Code: Select all

 gpio_map = (uint32_t *)mmap( (caddr_t)gpio_mem, BLOCK_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, mem_fd, GPIO_BASE);
 *(gpio_map+offset) =value
where gpio_map is virtual address. different GPIO is accessed through different offset.

For MIPS the GPIO is accessed through bus address using ioremap function instead of mmap of ARM.
the memory address from ioremap of MIPS cannot be directly derefenced like ARm. It must use readl and writel to access those memory location..


So, the question is why the difference and two different approach between the two. why can't MIPS use mmap or why can't ARM use ioremap?
ioremap is a Linux kernel call AIUI. mmap works from userland.

Is the MIPS code you're looking at running in the Kernel or a user program?

-Gordon
--
Gordons projects: https://projects.drogon.net/

lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

Re: ARM versus MIP GPIO.

Wed Oct 29, 2014 4:10 pm

gordon@drogon.net wrote: ioremap is a Linux kernel call AIUI. mmap works from userland.

Is the MIPS code you're looking at running in the Kernel or a user program?

-Gordon
End goal is I want to use it in the user land.
So, is that means I can adopt the ARM code for the MIPS ?

dwelch67
Posts: 966
Joined: Sat May 26, 2012 5:32 pm

Re: ARM versus MIPS GPIO.

Fri Oct 31, 2014 11:16 pm

mmap() isnt an arm thing, it is present on mips, arm, x86, and all others. but it really doesnt matter because the peripherals you are punching through the operating system to talk to will vary from one system to another, even from one arm to one arm or one mips to one mips or x86 to x86, as well as ppc to arm or mips vs x86, etc...

Note, this is a bare metal forum...

Return to “Bare metal, Assembly language”