From patchwork Thu Sep 14 22:05:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 813969 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xtXps0L5rz9s3T for ; Fri, 15 Sep 2017 08:13:08 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C9F49C21F4B; Thu, 14 Sep 2017 22:12:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 64FA3C21F26; Thu, 14 Sep 2017 22:12:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 73195C21F74; Thu, 14 Sep 2017 22:09:28 +0000 (UTC) Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by lists.denx.de (Postfix) with ESMTP id 74727C21F01 for ; Thu, 14 Sep 2017 22:09:25 +0000 (UTC) Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 7DC31D59A4CCC; Thu, 14 Sep 2017 23:09:19 +0100 (IST) Received: from localhost (10.20.1.88) by hhmail02.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 14 Sep 2017 23:09:24 +0100 From: Paul Burton To: Date: Thu, 14 Sep 2017 15:05:13 -0700 Message-ID: <20170914220513.9359-14-paul.burton@imgtec.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170914220513.9359-1-paul.burton@imgtec.com> References: <20170914220513.9359-1-paul.burton@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.20.1.88] Subject: [U-Boot] [PATCH v2 13/13] sandbox: Use asm-generic/io.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Convert the sandbox architecture to make use of the new asm-generic/io.h to provide address mapping functions. As sandbox actually performs non-identity mapping between physical & virtual addresses we can't simply make use of the generic mapping functions, but are able to implement phys_to_virt() & make use of it from map_physmem(). Signed-off-by: Paul Burton Cc: Simon Glass Acked-by: Simon Glass --- Changes in v2: - Move include earlier to get MAP_WRBACK for (un)map_sysmem() - Cast vaddr to uint8_t* in virt_to_phys() for arithmetic with ram_buf arch/sandbox/cpu/cpu.c | 12 +++++++++++- arch/sandbox/include/asm/io.h | 18 +++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 01991049cc..66c3a6a88a 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -56,6 +56,16 @@ int cleanup_before_linux_select(int flags) return 0; } +void *phys_to_virt(phys_addr_t paddr) +{ + return (void *)(gd->arch.ram_buf + paddr); +} + +phys_addr_t virt_to_phys(void *vaddr) +{ + return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf); +} + void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) { #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD) @@ -73,7 +83,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) } #endif - return (void *)(gd->arch.ram_buf + paddr); + return phys_to_virt(paddr); } void unmap_physmem(const void *vaddr, unsigned long flags) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index a6856356df..fd3c2478f7 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -7,22 +7,22 @@ #ifndef __SANDBOX_ASM_IO_H #define __SANDBOX_ASM_IO_H -/* - * Given a physical address and a length, return a virtual address - * that can be used to access the memory range with the caching - * properties specified by "flags". - */ -#define MAP_NOCACHE (0) -#define MAP_WRCOMBINE (0) -#define MAP_WRBACK (0) -#define MAP_WRTHROUGH (0) +void *phys_to_virt(phys_addr_t paddr); +#define phys_to_virt phys_to_virt + +phys_addr_t virt_to_phys(void *vaddr); +#define virt_to_phys virt_to_phys void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags); +#define map_physmem map_physmem /* * Take down a mapping set up by map_physmem(). */ void unmap_physmem(const void *vaddr, unsigned long flags); +#define unmap_physmem unmap_physmem + +#include /* For sandbox, we want addresses to point into our RAM buffer */ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)