hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/dma/fsldma.h
....@@ -1,15 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Copyright (C) 2007-2010 Freescale Semiconductor, Inc. All rights reserved.
34 *
45 * Author:
56 * Zhang Wei <wei.zhang@freescale.com>, Jul 2007
67 * Ebony Zhu <ebony.zhu@freescale.com>, May 2007
7
- *
8
- * This is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
138 */
149 #ifndef __DMA_FSLDMA_H
1510 #define __DMA_FSLDMA_H
....@@ -196,39 +191,67 @@
196191 #define to_fsl_desc(lh) container_of(lh, struct fsl_desc_sw, node)
197192 #define tx_to_fsl_desc(tx) container_of(tx, struct fsl_desc_sw, async_tx)
198193
199
-#ifndef __powerpc64__
200
-static u64 in_be64(const u64 __iomem *addr)
194
+#ifdef CONFIG_PPC
195
+#define fsl_ioread32(p) in_le32(p)
196
+#define fsl_ioread32be(p) in_be32(p)
197
+#define fsl_iowrite32(v, p) out_le32(p, v)
198
+#define fsl_iowrite32be(v, p) out_be32(p, v)
199
+
200
+#ifdef __powerpc64__
201
+#define fsl_ioread64(p) in_le64(p)
202
+#define fsl_ioread64be(p) in_be64(p)
203
+#define fsl_iowrite64(v, p) out_le64(p, v)
204
+#define fsl_iowrite64be(v, p) out_be64(p, v)
205
+#else
206
+static u64 fsl_ioread64(const u64 __iomem *addr)
201207 {
202
- return ((u64)in_be32((u32 __iomem *)addr) << 32) |
203
- (in_be32((u32 __iomem *)addr + 1));
208
+ u32 val_lo = in_le32((u32 __iomem *)addr);
209
+ u32 val_hi = in_le32((u32 __iomem *)addr + 1);
210
+
211
+ return ((u64)val_hi << 32) + val_lo;
204212 }
205213
206
-static void out_be64(u64 __iomem *addr, u64 val)
207
-{
208
- out_be32((u32 __iomem *)addr, val >> 32);
209
- out_be32((u32 __iomem *)addr + 1, (u32)val);
210
-}
211
-
212
-/* There is no asm instructions for 64 bits reverse loads and stores */
213
-static u64 in_le64(const u64 __iomem *addr)
214
-{
215
- return ((u64)in_le32((u32 __iomem *)addr + 1) << 32) |
216
- (in_le32((u32 __iomem *)addr));
217
-}
218
-
219
-static void out_le64(u64 __iomem *addr, u64 val)
214
+static void fsl_iowrite64(u64 val, u64 __iomem *addr)
220215 {
221216 out_le32((u32 __iomem *)addr + 1, val >> 32);
222217 out_le32((u32 __iomem *)addr, (u32)val);
223218 }
219
+
220
+static u64 fsl_ioread64be(const u64 __iomem *addr)
221
+{
222
+ u32 val_hi = in_be32((u32 __iomem *)addr);
223
+ u32 val_lo = in_be32((u32 __iomem *)addr + 1);
224
+
225
+ return ((u64)val_hi << 32) + val_lo;
226
+}
227
+
228
+static void fsl_iowrite64be(u64 val, u64 __iomem *addr)
229
+{
230
+ out_be32((u32 __iomem *)addr, val >> 32);
231
+ out_be32((u32 __iomem *)addr + 1, (u32)val);
232
+}
233
+#endif
224234 #endif
225235
226
-#define DMA_IN(fsl_chan, addr, width) \
227
- (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
228
- in_be##width(addr) : in_le##width(addr))
229
-#define DMA_OUT(fsl_chan, addr, val, width) \
230
- (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \
231
- out_be##width(addr, val) : out_le##width(addr, val))
236
+#if defined(CONFIG_ARM64) || defined(CONFIG_ARM)
237
+#define fsl_ioread32(p) ioread32(p)
238
+#define fsl_ioread32be(p) ioread32be(p)
239
+#define fsl_iowrite32(v, p) iowrite32(v, p)
240
+#define fsl_iowrite32be(v, p) iowrite32be(v, p)
241
+#define fsl_ioread64(p) ioread64(p)
242
+#define fsl_ioread64be(p) ioread64be(p)
243
+#define fsl_iowrite64(v, p) iowrite64(v, p)
244
+#define fsl_iowrite64be(v, p) iowrite64be(v, p)
245
+#endif
246
+
247
+#define FSL_DMA_IN(fsl_dma, addr, width) \
248
+ (((fsl_dma)->feature & FSL_DMA_BIG_ENDIAN) ? \
249
+ fsl_ioread##width##be(addr) : fsl_ioread##width(addr))
250
+
251
+#define FSL_DMA_OUT(fsl_dma, addr, val, width) \
252
+ (((fsl_dma)->feature & FSL_DMA_BIG_ENDIAN) ? \
253
+ fsl_iowrite##width##be(val, addr) : fsl_iowrite \
254
+ ##width(val, addr))
232255
233256 #define DMA_TO_CPU(fsl_chan, d, width) \
234257 (((fsl_chan)->feature & FSL_DMA_BIG_ENDIAN) ? \