From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH v2 5/8] mips: octeon: Add mangle-port.h
Date: Thu, 20 Aug 2020 07:35:40 +0200 [thread overview]
Message-ID: <20200820053543.2801672-6-sr@denx.de> (raw)
In-Reply-To: <20200820053543.2801672-1-sr@denx.de>
Import platform specific mangle-port.h header, allowing a area specific
swapping, which is needed on Octeon for USB & PCI areas.
Imported from Linux v5.7.
Signed-off-by: Stefan Roese <sr@denx.de>
---
Changes in v2:
- Only use SPDX format for license info
arch/mips/mach-octeon/include/mangle-port.h | 56 +++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 arch/mips/mach-octeon/include/mangle-port.h
diff --git a/arch/mips/mach-octeon/include/mangle-port.h b/arch/mips/mach-octeon/include/mangle-port.h
new file mode 100644
index 0000000000..7e95dcef5a
--- /dev/null
+++ b/arch/mips/mach-octeon/include/mangle-port.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2003, 2004 Ralf Baechle
+ */
+
+#ifndef __ASM_MACH_GENERIC_MANGLE_PORT_H
+#define __ASM_MACH_GENERIC_MANGLE_PORT_H
+
+#include <asm/byteorder.h>
+
+#ifdef __BIG_ENDIAN
+
+static inline bool __should_swizzle_bits(volatile void *a)
+{
+ extern const bool octeon_should_swizzle_table[];
+ u64 did = ((u64)(uintptr_t)a >> 40) & 0xff;
+
+ return octeon_should_swizzle_table[did];
+}
+
+# define __swizzle_addr_b(port) (port)
+# define __swizzle_addr_w(port) (port)
+# define __swizzle_addr_l(port) (port)
+# define __swizzle_addr_q(port) (port)
+
+#else /* __LITTLE_ENDIAN */
+
+#define __should_swizzle_bits(a) false
+
+static inline bool __should_swizzle_addr(u64 p)
+{
+ /* boot bus? */
+ return ((p >> 40) & 0xff) == 0;
+}
+
+# define __swizzle_addr_b(port) \
+ (__should_swizzle_addr(port) ? (port) ^ 7 : (port))
+# define __swizzle_addr_w(port) \
+ (__should_swizzle_addr(port) ? (port) ^ 6 : (port))
+# define __swizzle_addr_l(port) \
+ (__should_swizzle_addr(port) ? (port) ^ 4 : (port))
+# define __swizzle_addr_q(port) (port)
+
+#endif /* __BIG_ENDIAN */
+
+
+# define ioswabb(a, x) (x)
+# define __mem_ioswabb(a, x) (x)
+# define ioswabw(a, x) (__should_swizzle_bits(a) ? le16_to_cpu(x) : x)
+# define __mem_ioswabw(a, x) (x)
+# define ioswabl(a, x) (__should_swizzle_bits(a) ? le32_to_cpu(x) : x)
+# define __mem_ioswabl(a, x) (x)
+# define ioswabq(a, x) (__should_swizzle_bits(a) ? le64_to_cpu(x) : x)
+# define __mem_ioswabq(a, x) (x)
+
+#endif /* __ASM_MACH_GENERIC_MANGLE_PORT_H */
--
2.28.0
next prev parent reply other threads:[~2020-08-20 5:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 5:35 [PATCH v2 0/8] mips/usb: Add Octeon xHCI USB support Stefan Roese
2020-08-20 5:35 ` [PATCH v2 1/8] usb: xhci: xhci-dwc3.c: Use dev_remap_addr() instead of dev_get_addr() Stefan Roese
2020-08-20 8:38 ` Bin Meng
2020-08-20 5:35 ` [PATCH v2 2/8] usb: xhci: xhci_bulk_tx: Don't "BUG" when comparing addresses Stefan Roese
2020-08-20 8:58 ` Bin Meng
2020-08-20 10:22 ` Stefan Roese
2020-08-20 5:35 ` [PATCH v2 3/8] usb: xhci: octeon: Add DWC3 glue layer for Octeon Stefan Roese
2020-08-20 9:07 ` Bin Meng
2020-08-20 11:45 ` Stefan Roese
2020-08-20 13:24 ` Bin Meng
2020-08-20 13:54 ` Stefan Roese
2020-08-20 5:35 ` [PATCH v2 4/8] mips: octeon: cpu.c: Add table for selective swapping Stefan Roese
2020-08-20 5:35 ` Stefan Roese [this message]
2020-08-20 5:35 ` [PATCH v2 6/8] mips: octeon: cache.c: Flush all pending writes in flush_dcache_range() Stefan Roese
2020-08-20 5:35 ` [PATCH v2 7/8] mips: octeon: Add USB DT nodes Stefan Roese
2020-08-20 9:09 ` Bin Meng
2020-08-20 10:24 ` Stefan Roese
2020-08-20 5:35 ` [PATCH v2 8/8] mips: octeon: octeon_ebb7304_defconfig: Enable USB support Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200820053543.2801672-6-sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox