diff mbox

[U-Boot,v2,1/3] nios2: map physical address to uncached virtual address

Message ID 1442151606-10266-2-git-send-email-thomas@wytron.com.tw
State Superseded
Delegated to: Thomas Chou
Headers show

Commit Message

Thomas Chou Sept. 13, 2015, 1:40 p.m. UTC
Add ioremap() to map physical address to uncached virtual
address. We need this to convert the reg address from the
device tree.

The order of headers inclusion in interrupts.c is changed
because common.h will include board header that contains
IO_REGION_BASE.

In the future, the IO_REGION_BASE should be decided from
the device tree.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/cpu/interrupts.c | 4 ++--
 arch/nios2/include/asm/io.h | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Marek Vasut Sept. 13, 2015, 1:46 p.m. UTC | #1
On Sunday, September 13, 2015 at 03:40:04 PM, Thomas Chou wrote:
> Add ioremap() to map physical address to uncached virtual
> address. We need this to convert the reg address from the
> device tree.
> 
> The order of headers inclusion in interrupts.c is changed
> because common.h will include board header that contains
> IO_REGION_BASE.
> 
> In the future, the IO_REGION_BASE should be decided from
> the device tree.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

This is good :)

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut
Simon Glass Oct. 1, 2015, 10:49 p.m. UTC | #2
Hi,

On Sunday, 13 September 2015, Marek Vasut <marex@denx.de> wrote:
>
> On Sunday, September 13, 2015 at 03:40:04 PM, Thomas Chou wrote:
> > Add ioremap() to map physical address to uncached virtual
> > address. We need this to convert the reg address from the
> > device tree.
> >
> > The order of headers inclusion in interrupts.c is changed
> > because common.h will include board header that contains
> > IO_REGION_BASE.
> >
> > In the future, the IO_REGION_BASE should be decided from
> > the device tree.
> >
> > Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>
> This is good :)
>
> Acked-by: Marek Vasut <marex@denx.de>
>
Can we not rely on the 'ranges' property to sort this out?

Regards,
Simon
Thomas Chou Oct. 2, 2015, 12:16 a.m. UTC | #3
Hi Simon,

On 10/02/2015 06:49 AM, Simon Glass wrote:
>>> Add ioremap() to map physical address to uncached virtual
>>> address. We need this to convert the reg address from the
>>> device tree.
> Can we not rely on the 'ranges' property to sort this out?

The ranges translate address across buses/bridges. The address is still 
physical address. In the case of nios2, the virtual address map of mmu 
or nonmmu are different, though the physical address should be the same. 
So we really need sort of ioremap(). You may find a lots of call to 
ioremap() in linux drivers. It is quite standard. We also want to use 
the same dts/dtb for both u-boot and linux. I would suggest ioremap() is 
the way.

Thanks a lot for your review.

Best regards,
Thomas
Simon Glass Oct. 2, 2015, 11:21 a.m. UTC | #4
On 1 October 2015 at 18:16, Thomas Chou <thomas@wytron.com.tw> wrote:
> Hi Simon,
>
> On 10/02/2015 06:49 AM, Simon Glass wrote:
>>>>
>>>> Add ioremap() to map physical address to uncached virtual
>>>> address. We need this to convert the reg address from the
>>>> device tree.
>>
>> Can we not rely on the 'ranges' property to sort this out?
>
>
> The ranges translate address across buses/bridges. The address is still
> physical address. In the case of nios2, the virtual address map of mmu or
> nonmmu are different, though the physical address should be the same. So we
> really need sort of ioremap(). You may find a lots of call to ioremap() in
> linux drivers. It is quite standard. We also want to use the same dts/dtb
> for both u-boot and linux. I would suggest ioremap() is the way.

Yes I see this on another thread. Thanks for explaining it.

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c
index 9d85eb0..1599674 100644
--- a/arch/nios2/cpu/interrupts.c
+++ b/arch/nios2/cpu/interrupts.c
@@ -8,12 +8,12 @@ 
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
+#include <command.h>
 #include <asm/nios2.h>
 #include <asm/types.h>
 #include <asm/io.h>
 #include <asm/ptrace.h>
-#include <common.h>
-#include <command.h>
 
 /*************************************************************************/
 struct	irq_action {
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index 69ab23e..b4bd20f 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -42,6 +42,11 @@  static inline phys_addr_t virt_to_phys(void * vaddr)
 	return (phys_addr_t)(vaddr);
 }
 
+static inline void *ioremap(unsigned long physaddr, unsigned long size)
+{
+	return (void *)(IO_REGION_BASE | physaddr);
+}
+
 extern unsigned char inb (unsigned char *port);
 extern unsigned short inw (unsigned short *port);
 extern unsigned inl (unsigned port);