Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4165500imd; Mon, 29 Oct 2018 19:40:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5f/fsGdVOAxTtMFRajDuzhYJIf7zY+6b23jBf3arQr5/o63y7vtogXFt4kWggM6A3oT2w7v X-Received: by 2002:a63:50b:: with SMTP id 11mr15890687pgf.411.1540867259462; Mon, 29 Oct 2018 19:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540867259; cv=none; d=google.com; s=arc-20160816; b=ct3ZXA/d6Rh5ZgfceWwASM6yZiZzyChIHHWVMCgg7Yqfsu7hZXUEnOxYcG0tPpS+M0 oh+ryiWB8ZFdmsD1NiQ4ebTEPns3xMozTTGgUU0+b0Ox6VMJAtewS3yQPklWQeZUa16e D1n2RHKnNdq8fT2FRX1qFrwGzpW6YwUp3w4mBO0g1LFB6EvlXN1jIALoRgUTfQ8u/Zkj 7KmzjtsykPvScrw9bXKitcCA5cLpY41gZfBzCVn1UbspwoVKT3c58f7Ku0wIDB1DQjII jX28dUOhH65Hh2qXqNoCXYV37yqyN8ErZISuizhdcSxEft7CvFsz1XtgVRLdHPa+88mp f/LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Jatpd6ZWEzYEM71voLNkb5oRT+tZoRyB1jy0+E+jjBg=; b=U1RcFykjFdJPre/sQOcqMPcHK9lYK7XpDtrs8YxaiA8TFWWUinOlYyH6CgkIhT/Q8t yvXY6RxiR2CXzQ0hzcTgUBUvRg+1E22giVZ4WR8JlzJm3BpDVBNXW4Rl+R+6MnBQ95nO 2MMIB5Zzy9E2fwOkx5yyhbmlBJl7QvTwQF5QEvYArSjGmoNcagRQgGNI7ufDPM3krzKb soLqDU6FPmuy3eILzjkXU1E4L2CQVUY8fnqnEch3sjMZNl8AzYC20fuXc27sfOC1iJXx mwCO+1fjOndMZazy+TO/ajioFnUq8Iy5Jc1hOhfaMgOxHNetpvMaDBZY30oTokqLsg16 GrCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si20761933plr.141.2018.10.29.19.40.44; Mon, 29 Oct 2018 19:40:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbeJ3Lbw (ORCPT + 99 others); Tue, 30 Oct 2018 07:31:52 -0400 Received: from inva020.nxp.com ([92.121.34.13]:39118 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbeJ3Lbv (ORCPT ); Tue, 30 Oct 2018 07:31:51 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id AAF521A0134; Tue, 30 Oct 2018 03:40:17 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 059F51A0016; Tue, 30 Oct 2018 03:40:11 +0100 (CET) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B569B40302; Tue, 30 Oct 2018 10:40:02 +0800 (SGT) From: Peng Ma To: vkoul@kernel.org Cc: robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, leoyang.li@nxp.com, dan.j.williams@intel.com, zw@zh-kernel.org, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Peng Ma , Wen He Subject: [v11 2/7] dmaengine: fsldma: Adding macro FSL_DMA_IN/OUT implement for ARM platform Date: Tue, 30 Oct 2018 10:35:59 +0800 Message-Id: <20181030023604.34027-2-peng.ma@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20181030023604.34027-1-peng.ma@nxp.com> References: <20181030023604.34027-1-peng.ma@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch add the macro FSL_DMA_IN/OUT implement for ARM platform. Signed-off-by: Wen He Signed-off-by: Peng Ma --- change in v11: - no drivers/dma/fsldma.h | 61 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 42 insertions(+), 19 deletions(-) diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h index 982845b..88db939 100644 --- a/drivers/dma/fsldma.h +++ b/drivers/dma/fsldma.h @@ -196,39 +196,62 @@ struct fsldma_chan { #define to_fsl_desc(lh) container_of(lh, struct fsl_desc_sw, node) #define tx_to_fsl_desc(tx) container_of(tx, struct fsl_desc_sw, async_tx) +#ifdef CONFIG_PPC +#define fsl_ioread32(p) in_le32(p) +#define fsl_ioread32be(p) in_be32(p) +#define fsl_iowrite32(v, p) out_le32(p, v) +#define fsl_iowrite32be(v, p) out_be32(p, v) + #ifndef __powerpc64__ -static u64 in_be64(const u64 __iomem *addr) +static u64 fsl_ioread64(const u64 __iomem *addr) { - return ((u64)in_be32((u32 __iomem *)addr) << 32) | - (in_be32((u32 __iomem *)addr + 1)); + u32 fsl_addr = lower_32_bits(addr); + u64 fsl_addr_hi = (u64)in_le32((u32 *)(fsl_addr + 1)) << 32; + + return fsl_addr_hi | in_le32((u32 *)fsl_addr); } -static void out_be64(u64 __iomem *addr, u64 val) +static void fsl_iowrite64(u64 val, u64 __iomem *addr) { - out_be32((u32 __iomem *)addr, val >> 32); - out_be32((u32 __iomem *)addr + 1, (u32)val); + out_le32((u32 __iomem *)addr + 1, val >> 32); + out_le32((u32 __iomem *)addr, (u32)val); } -/* There is no asm instructions for 64 bits reverse loads and stores */ -static u64 in_le64(const u64 __iomem *addr) +static u64 fsl_ioread64be(const u64 __iomem *addr) { - return ((u64)in_le32((u32 __iomem *)addr + 1) << 32) | - (in_le32((u32 __iomem *)addr)); + u32 fsl_addr = lower_32_bits(addr); + u64 fsl_addr_hi = (u64)in_be32((u32 *)fsl_addr) << 32; + + return fsl_addr_hi | in_be32((u32 *)(fsl_addr + 1)); } -static void out_le64(u64 __iomem *addr, u64 val) +static void fsl_iowrite64be(u64 val, u64 __iomem *addr) { - out_le32((u32 __iomem *)addr + 1, val >> 32); - out_le32((u32 __iomem *)addr, (u32)val); + out_be32((u32 __iomem *)addr, val >> 32); + out_be32((u32 __iomem *)addr + 1, (u32)val); } #endif +#endif -#define FSL_DMA_IN(fsl_chan, addr, width) \ - (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ - in_be##width(addr) : in_le##width(addr)) -#define FSL_DMA_OUT(fsl_chan, addr, val, width) \ - (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ - out_be##width(addr, val) : out_le##width(addr, val)) +#if defined(CONFIG_ARM64) || defined(CONFIG_ARM) +#define fsl_ioread32(p) ioread32(p) +#define fsl_ioread32be(p) ioread32be(p) +#define fsl_iowrite32(v, p) iowrite32(v, p) +#define fsl_iowrite32be(v, p) iowrite32be(v, p) +#define fsl_ioread64(p) ioread64(p) +#define fsl_ioread64be(p) ioread64be(p) +#define fsl_iowrite64(v, p) iowrite64(v, p) +#define fsl_iowrite64be(v, p) iowrite64be(v, p) +#endif + +#define FSL_DMA_IN(fsl_dma, addr, width) \ + (((fsl_dma)->feature & FSL_DMA_BIG_ENDIAN) ? \ + fsl_ioread##width##be(addr) : fsl_ioread##width(addr)) + +#define FSL_DMA_OUT(fsl_dma, addr, val, width) \ + (((fsl_dma)->feature & FSL_DMA_BIG_ENDIAN) ? \ + fsl_iowrite##width##be(val, addr) : fsl_iowrite \ + ##width(val, addr)) #define DMA_TO_CPU(fsl_chan, d, width) \ (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \ -- 1.7.1