From patchwork Sat Oct 1 14:19:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 677360 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3smVtB6Z9Lz9s2G for ; Sun, 2 Oct 2016 00:24:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8B4A8A7612; Sat, 1 Oct 2016 16:24:01 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SA9s6xavM0H7; Sat, 1 Oct 2016 16:24:01 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0071CA75CE; Sat, 1 Oct 2016 16:24:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BDC45A75CE for ; Sat, 1 Oct 2016 16:23:58 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05pno2CNdJW8 for ; Sat, 1 Oct 2016 16:23:58 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailapp01.imgtec.com (mailapp02.imgtec.com [217.156.133.132]) by theia.denx.de (Postfix) with ESMTP id 89606A75CA for ; Sat, 1 Oct 2016 16:23:58 +0200 (CEST) Received: from HHMAIL03.hh.imgtec.org (unknown [10.44.0.21]) by Forcepoint Email with ESMTPS id E119410FE251D; Sat, 1 Oct 2016 15:23:53 +0100 (IST) Received: from localhost (192.168.159.74) by HHMAIL03.hh.imgtec.org (10.44.0.22) with Microsoft SMTP Server (TLS) id 14.3.294.0; Sat, 1 Oct 2016 15:23:57 +0100 From: Paul Burton To: Date: Sat, 1 Oct 2016 15:19:20 +0100 Message-ID: <20161001141931.32354-18-paul.burton@imgtec.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161001141931.32354-1-paul.burton@imgtec.com> References: <20161001141931.32354-1-paul.burton@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.159.74] Subject: [U-Boot] [PATCH 17/27] sandbox: Use asm-generic/io.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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 --- arch/sandbox/cpu/cpu.c | 12 +++++++++++- arch/sandbox/include/asm/io.h | 17 ++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 2def722..e160f62 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -55,6 +55,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)(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) @@ -72,7 +82,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 6919632..3afbcea 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -7,22 +7,20 @@ #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 /* For sandbox, we want addresses to point into our RAM buffer */ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) @@ -71,6 +69,7 @@ static inline void _outsw(volatile u16 *port, const void *buf, int ns) #define out16(addr, val) #define in16(addr) 0 +#include #include #include