From patchwork Tue Oct 25 11:03:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 121598 X-Patchwork-Delegate: macpaul@andestech.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 25C981007D9 for ; Tue, 25 Oct 2011 22:03:32 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51D52291DA; Tue, 25 Oct 2011 13:03:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 LRbU6Cqh7M5E; Tue, 25 Oct 2011 13:03:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CDA572928E; Tue, 25 Oct 2011 13:03:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EB5072928E for ; Tue, 25 Oct 2011 13:03:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 xWA7iPhFq2nw for ; Tue, 25 Oct 2011 13:03:25 +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 atces.andestech.com (59-124-160-118.HINET-IP.hinet.net [59.124.160.118]) by theia.denx.de (Postfix) with ESMTP id 1C6D6291DA for ; Tue, 25 Oct 2011 13:03:23 +0200 (CEST) Received: from ATCPCS06.andestech.com (atcpcs06.andestech.com [10.0.1.236]) by atces.andestech.com (Postfix) with ESMTP id 46CC72E200A8; Tue, 25 Oct 2011 19:03:20 +0800 (CST) Received: from app01.andestech.com ([10.0.4.31]) by ATCPCS06.andestech.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 25 Oct 2011 19:03:19 +0800 From: Macpaul Lin To: macpaul@gmail.com, marek.vasut@gmail.com, wd@denx.de, vapier@gentoo.org, sjg@chromium.org, robotboy@chromium.org, u-boot@lists.denx.de Date: Tue, 25 Oct 2011 19:03:10 +0800 Message-Id: <1319540590-28395-1-git-send-email-macpaul@andestech.com> X-Mailer: git-send-email 1.7.3.5 In-Reply-To: <201110251029.07517.marek.vasut@gmail.com> References: <201110251029.07517.marek.vasut@gmail.com> X-OriginalArrivalTime: 25 Oct 2011 11:03:19.0637 (UTC) FILETIME=[B4532850:01CC9305] Cc: Macpaul Lin Subject: [U-Boot] [PATCH v2] nds32: asm/io.h: add __iormb __iowmb and inline io support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 1. This patch add required __iormb and __iowmb to io.h. This also fix some misbehavior to periphal drivers. This io.h has been fixed with referencing arm/include/asm/io.h. 2. This patch replaced macro writeb and readb into inline function. Signed-off-by: Macpaul Lin --- Changes for v2: - translate writeb macro into inline function. arch/nds32/include/asm/io.h | 72 +++++++++++++++++++++++++++++++------------ 1 files changed, 52 insertions(+), 20 deletions(-) diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h index 2504c2b..2c105f7 100644 --- a/arch/nds32/include/asm/io.h +++ b/arch/nds32/include/asm/io.h @@ -98,13 +98,59 @@ extern void __raw_readsl(unsigned int addr, void *data, int longlen); #define __raw_readw(a) __arch_getw(a) #define __raw_readl(a) __arch_getl(a) -#define writeb(v, a) __arch_putb(v, a) -#define writew(v, a) __arch_putw(v, a) -#define writel(v, a) __arch_putl(v, a) +/* + * TODO: The kernel offers some more advanced versions of barriers, it might + * have some advantages to use them instead of the simple one here. + */ +#define dmb() __asm__ __volatile__ ("" : : : "memory") +#define __iormb() dmb() +#define __iowmb() dmb() + +static inline void writeb(unsigned char val, unsigned char *addr) +{ + __iowmb(); + __arch_putb(val, addr); +} + +static inline void writew(unsigned short val, unsigned short *addr) +{ + __iowmb(); + __arch_putw(val, addr); + +} + +static inline void writel(unsigned int val, unsigned int *addr) +{ + __iowmb(); + __arch_putl(val, addr); +} + +static inline unsigned char readb(unsigned char *addr) +{ + u8 val; -#define readb(a) __arch_getb(a) -#define readw(a) __arch_getw(a) -#define readl(a) __arch_getl(a) + val = __arch_getb(addr); + __iormb(); + return val; +} + +static inline unsigned short readw(unsigned short *addr) +{ + u16 val; + + val = __arch_getw(addr); + __iormb(); + return val; +} + +static inline unsigned int readl(unsigned int *addr) +{ + u32 val; + + val = __arch_getl(addr); + __iormb(); + return val; +} /* * The compiler seems to be incapable of optimising constants @@ -338,20 +384,6 @@ check_signature(unsigned long io_addr, const unsigned char *signature, out: return retval; } - -#elif !defined(readb) - -#define readb(addr) (__readwrite_bug("readb"), 0) -#define readw(addr) (__readwrite_bug("readw"), 0) -#define readl(addr) (__readwrite_bug("readl"), 0) -#define writeb(v, addr) __readwrite_bug("writeb") -#define writew(v, addr) __readwrite_bug("writew") -#define writel(v, addr) __readwrite_bug("writel") - -#define eth_io_copy_and_sum(a, b, c, d) __readwrite_bug("eth_io_copy_and_sum") - -#define check_signature(io, sig, len) (0) - #endif /* __mem_pci */ /*