Skip to contentSkip to conversation

MIPS: sync asm header files with linux-4.4

PATCH New Daniel Schwierzeck 1 participant 8 messages Jan 12, 2016 – Jan 15, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover MIPS: sync asm header files with linux-4.4

This patch series updates all MIPS asm header files containing I/O code as well as processor, register and assembly definitions. The source of the update are the MIPS asm header files of linux-4.4.

The main goal is to get a complete set of I/O accessors on MIPS and to support platform-specific address spaces and mappings. Also a working ioremap() implementation will be added, which supports platform-specific callbacks. Furthermore support for bit manipulating I/O accessors (clrbits_X, setbits_X, clrsetbits_X) will be added.

The patch series is also available on git://git.denx.de/u-boot-mips.git
in branch mips_io_v2 and based on next branch.

Changes in v3:
- newly added due to a regression on MIPS Malta board
- rebased to u-boot-mips/next

Changes in v2:
- fix __ioremap_node() implementation for 64 Bit

Daniel Schwierzeck (6):
net: pcnet: refactor mapping of virtual addresses to physical ones
MIPS: sync I/O related header files with linux-4.4
MIPS: sync processor and register definitions with linux-4.4
MIPS: fix SPDX license identifier in remaining arch header files
MIPS: implement bit manipulating I/O accessors
MIPS: DO NOT MERGE: test I/O accessors

 arch/mips/Makefile                                 |    5 +-
 arch/mips/include/asm/addrspace.h                  |   10 +-
 arch/mips/include/asm/asm.h                        |  126 +-
 arch/mips/include/asm/bitops.h                     |    6 +-
 arch/mips/include/asm/byteorder.h                  |    6 +-
 arch/mips/include/asm/cachectl.h                   |    6 +-
 arch/mips/include/asm/cacheops.h                   |    6 +-
 arch/mips/include/asm/const.h                      |   31 +
 arch/mips/include/asm/cpu-features.h               |   30 +
 arch/mips/include/asm/io.h                         |  813 ++++++-----
 arch/mips/include/asm/isadep.h                     |    6 +-
 .../asm/mach-generic/cpu-feature-overrides.h       |   11 +
 arch/mips/include/asm/mach-generic/ioremap.h       |   32 +
 arch/mips/include/asm/mach-generic/mangle-port.h   |   50 +
 arch/mips/include/asm/mach-generic/spaces.h        |  102 ++
 arch/mips/include/asm/mipsregs.h                   | 1495 ++++++++++++++------
 arch/mips/include/asm/pgtable-bits.h               |  283 ++++
 arch/mips/include/asm/posix_types.h                |    9 +-
 arch/mips/include/asm/processor.h                  |    6 +-
 arch/mips/include/asm/ptrace.h                     |   99 +-
 arch/mips/include/asm/reboot.h                     |    6 +-
 arch/mips/include/asm/reg.h                        |    6 +-
 arch/mips/include/asm/regdef.h                     |   12 +-
 arch/mips/include/asm/sgidefs.h                    |    6 +-
 arch/mips/include/asm/string.h                     |    6 +-
 arch/mips/include/asm/system.h                     |    6 +-
 arch/mips/include/asm/types.h                      |    6 +-
 arch/mips/include/asm/unaligned.h                  |    6 +-
 arch/mips/lib/cache.c                              |    4 +-
 arch/mips/lib/cache_init.S                         |   16 +-
 arch/mips/lib/io.c                                 |  183 +++
 drivers/net/pcnet.c                                |   28 +-
 32 files changed, 2440 insertions(+), 977 deletions(-)
 create mode 100644 arch/mips/include/asm/const.h
 create mode 100644 arch/mips/include/asm/cpu-features.h
 create mode 100644 arch/mips/include/asm/mach-generic/cpu-feature-overrides.h
 create mode 100644 arch/mips/include/asm/mach-generic/ioremap.h
 create mode 100644 arch/mips/include/asm/mach-generic/mangle-port.h
 create mode 100644 arch/mips/include/asm/mach-generic/spaces.h
 create mode 100644 arch/mips/include/asm/pgtable-bits.h
Signature · 1 line
2.5.0
#1 lore raw

PATCH v3 1/6 net: pcnet: refactor mapping of virtual addresses to physical ones

pci_virt_to_mem() uses virt_to_phys() to get the physical address. But pci_virt_to_mem() is also called with uncached addresses which is wrong according to the documentation of virt_to_phys().

Refactor the PCI_TO_MEM() macro to optionally map an uncached address back to a cached one before calling pci_virt_to_mem().

Currently pcnet works because virt_to_phys() is incorrectly implemented on MIPS. With the upcoming asm header file update for MIPS, the virt_to_phys() implementation will be fixed. Thus this patch is needed to keep pcnet working on MIPS Malta board.

---
@Joe, MIPS Malta board is the only user of pcnet and the patch is required for my patch series which updates the MIPS asm header files. Thus I'd like to merge this via the MIPS tree.

Changes in v3:
- newly added due to a regression on MIPS Malta board

Changes in v2: None

 drivers/net/pcnet.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/net/pcnet.c +21 -7
index cfcb1b4..16a7512 100644
@@ -134,8 +134,17 @@ static int pcnet_recv (struct eth_device *dev);
 static void pcnet_halt (struct eth_device *dev);
 static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
 
-#define PCI_TO_MEM(d, a) pci_virt_to_mem((pci_dev_t)d->priv, (a))
-#define PCI_TO_MEM_LE(d,a) (u32)(cpu_to_le32(PCI_TO_MEM(d,a)))
+static inline pci_addr_t pcnet_virt_to_mem(const struct eth_device *dev,
+						void *addr, bool uncached)
+{
+	pci_dev_t devbusfn = (pci_dev_t)dev->priv;
+	void *virt_addr = addr;
+
+	if (uncached)
+		virt_addr = (void *)CKSEG0ADDR(addr);
+
+	return pci_virt_to_mem(devbusfn, virt_addr);
+}
 
 static struct pci_device_id supported[] = {
 	{PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE},
@@ -352,7 +361,8 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
 	 */
 	lp->cur_rx = 0;
 	for (i = 0; i < RX_RING_SIZE; i++) {
-		uc->rx_ring[i].base = PCI_TO_MEM_LE(dev, (*lp->rx_buf)[i]);
+		addr = pcnet_virt_to_mem(dev, (*lp->rx_buf)[i], false);
+		uc->rx_ring[i].base = cpu_to_le32(addr);
 		uc->rx_ring[i].buf_length = cpu_to_le16(-PKT_BUF_SZ);
 		uc->rx_ring[i].status = cpu_to_le16(0x8000);
 		PCNET_DEBUG1
@@ -383,8 +393,10 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
 
 	uc->init_block.tlen_rlen = cpu_to_le16(TX_RING_LEN_BITS |
 					       RX_RING_LEN_BITS);
-	uc->init_block.rx_ring = PCI_TO_MEM_LE(dev, uc->rx_ring);
-	uc->init_block.tx_ring = PCI_TO_MEM_LE(dev, uc->tx_ring);
+	addr = pcnet_virt_to_mem(dev, uc->rx_ring, true);
+	uc->init_block.rx_ring = cpu_to_le32(addr);
+	addr = pcnet_virt_to_mem(dev, uc->tx_ring, true);
+	uc->init_block.tx_ring = cpu_to_le32(addr);
 
 	PCNET_DEBUG1("\ntlen_rlen=0x%x rx_ring=0x%x tx_ring=0x%x\n",
 		     uc->init_block.tlen_rlen,
@@ -394,7 +406,7 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
 	 * Tell the controller where the Init Block is located.
 	 */
 	barrier();
-	addr = PCI_TO_MEM(dev, &lp->uc->init_block);
+	addr = pcnet_virt_to_mem(dev, &lp->uc->init_block, true);
 	pcnet_write_csr(dev, 1, addr & 0xffff);
 	pcnet_write_csr(dev, 2, (addr >> 16) & 0xffff);
 
@@ -424,6 +436,7 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
 static int pcnet_send(struct eth_device *dev, void *packet, int pkt_len)
 {
 	int i, status;
+	u32 addr;
 	struct pcnet_tx_head *entry = &lp->uc->tx_ring[lp->cur_tx];
 
 	PCNET_DEBUG2("Tx%d: %d bytes from 0x%p ", lp->cur_tx, pkt_len,
@@ -451,9 +464,10 @@ static int pcnet_send(struct eth_device *dev, void *packet, int pkt_len)
 	 * Setup Tx ring. Caution: the write order is important here,
 	 * set the status with the "ownership" bits last.
 	 */
+	addr = pcnet_virt_to_mem(dev, packet, false);
 	writew(-pkt_len, &entry->length);
 	writel(0, &entry->misc);
-	writel(PCI_TO_MEM(dev, packet), &entry->base);
+	writel(addr, &entry->base);
 	writew(0x8300, &entry->status);
 
 	/* Trigger an immediate send poll. */
Signature · 1 line
2.5.0
#2 lore raw

PATCH v3 2/6 MIPS: sync I/O related header files with linux-4.4

In reply to Daniel Schwierzeck

Mainly sync asm/io.h to get a working ioremap() implementation as well as the full set of I/O accessors. Pull in additional header files to make this work.

Furthermore port over the directory 'arch/mips/include/asm/mach-generic/' with contains default definitions for I/O and memory spaces and default implementations for mapping those spaces. All files in that directory can be overwritten by a SoC/machine.

---

Changes in v3: None
Changes in v2:
- fix __ioremap_node() implementation for 64 Bit

 arch/mips/Makefile                                 |   5 +-
 arch/mips/include/asm/addrspace.h                  |   4 +-
 arch/mips/include/asm/const.h                      |  27 +
 arch/mips/include/asm/cpu-features.h               |  30 +
 arch/mips/include/asm/io.h                         | 761 +++++++++++----------
 .../asm/mach-generic/cpu-feature-overrides.h       |  11 +
 arch/mips/include/asm/mach-generic/ioremap.h       |  32 +
 arch/mips/include/asm/mach-generic/mangle-port.h   |  50 ++
 arch/mips/include/asm/mach-generic/spaces.h        | 102 +++
 arch/mips/include/asm/pgtable-bits.h               | 283 ++++++++
 10 files changed, 941 insertions(+), 364 deletions(-)
 create mode 100644 arch/mips/include/asm/const.h
 create mode 100644 arch/mips/include/asm/cpu-features.h
 create mode 100644 arch/mips/include/asm/mach-generic/cpu-feature-overrides.h
 create mode 100644 arch/mips/include/asm/mach-generic/ioremap.h
 create mode 100644 arch/mips/include/asm/mach-generic/mangle-port.h
 create mode 100644 arch/mips/include/asm/mach-generic/spaces.h
 create mode 100644 arch/mips/include/asm/pgtable-bits.h
arch/mips/Makefile +4 -1
index 90cd590..2133e7e 100644
@@ -25,4 +25,7 @@ tune-$(CONFIG_MIPS_TUNE_4KC) += -mtune=4kc
 tune-$(CONFIG_MIPS_TUNE_14KC) += -mtune=14kc
 tune-$(CONFIG_MIPS_TUNE_24KC) += -mtune=24kc
 
-PLATFORM_CPPFLAGS += $(arch-y) $(tune-y)
+# Include default header files
+cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic
+
+PLATFORM_CPPFLAGS += $(arch-y) $(tune-y) $(cflags-y)
arch/mips/include/asm/addrspace.h +3 -1
index b768bb5..e7fe6ed 100644
@@ -10,6 +10,8 @@
 #ifndef _ASM_ADDRSPACE_H
 #define _ASM_ADDRSPACE_H
 
+#include <spaces.h>
+
 /*
  *  Configure language
  */
@@ -50,7 +52,7 @@
  */
 #define CPHYSADDR(a)		((_ACAST32_(a)) & 0x1fffffff)
 #define XPHYSADDR(a)		((_ACAST64_(a)) &			\
-				 _CONST64_(0x000000ffffffffff))
+				 _CONST64_(0x0000ffffffffffff))
 
 #ifdef CONFIG_64BIT
 
arch/mips/include/asm/const.h new file +27 -0
new file mode 100644
index 0000000..c872bfd
@@ -0,0 +1,27 @@
+/* const.h: Macros for dealing with constants.  */
+
+#ifndef _LINUX_CONST_H
+#define _LINUX_CONST_H
+
+/* Some constant macros are used in both assembler and
+ * C code.  Therefore we cannot annotate them always with
+ * 'UL' and other type specifiers unilaterally.  We
+ * use the following macros to deal with this.
+ *
+ * Similarly, _AT() will cast an expression with a type in C, but
+ * leave it unchanged in asm.
+ */
+
+#ifdef __ASSEMBLY__
+#define _AC(X,Y)	X
+#define _AT(T,X)	X
+#else
+#define __AC(X,Y)	(X##Y)
+#define _AC(X,Y)	__AC(X,Y)
+#define _AT(T,X)	((T)(X))
+#endif
+
+#define _BITUL(x)	(_AC(1,UL) << (x))
+#define _BITULL(x)	(_AC(1,ULL) << (x))
+
+#endif /* !(_LINUX_CONST_H) */
arch/mips/include/asm/cpu-features.h new file +30 -0
new file mode 100644
index 0000000..a6e9d94
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2003, 2004 Ralf Baechle
+ * Copyright (C) 2004  Maciej W. Rozycki
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+#ifndef __ASM_CPU_FEATURES_H
+#define __ASM_CPU_FEATURES_H
+
+#include <cpu-feature-overrides.h>
+
+#ifdef CONFIG_32BIT
+# ifndef cpu_has_64bits
+# define cpu_has_64bits			0
+# endif
+# ifndef cpu_has_64bit_addresses
+# define cpu_has_64bit_addresses	0
+# endif
+#endif
+
+#ifdef CONFIG_64BIT
+# ifndef cpu_has_64bits
+# define cpu_has_64bits			1
+# endif
+# ifndef cpu_has_64bit_addresses
+# define cpu_has_64bit_addresses	1
+# endif
+#endif
+
+#endif /* __ASM_CPU_FEATURES_H */
arch/mips/include/asm/io.h +399 -362

861 lines not on this page · raw message

arch/mips/include/asm/mach-generic/cpu-feature-overrides.h new file +11 -0
new file mode 100644
index 0000000..613f844
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2003 Ralf Baechle
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+#ifndef __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
+
+/* Intentionally empty file ...	 */
+
+#endif /* __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H */
arch/mips/include/asm/mach-generic/ioremap.h new file +32 -0
new file mode 100644
index 0000000..6b191d5
@@ -0,0 +1,32 @@
+/*
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+#ifndef __ASM_MACH_GENERIC_IOREMAP_H
+#define __ASM_MACH_GENERIC_IOREMAP_H
+
+#include <linux/types.h>
+
+/*
+ * Allow physical addresses to be fixed up to help peripherals located
+ * outside the low 32-bit range -- generic pass-through version.
+ */
+static inline phys_addr_t fixup_bigphys_addr(phys_addr_t phys_addr,
+						phys_addr_t size)
+{
+	return phys_addr;
+}
+
+static inline void __iomem *plat_ioremap(phys_addr_t offset, unsigned long size,
+						unsigned long flags)
+{
+	return NULL;
+}
+
+static inline int plat_iounmap(const volatile void __iomem *addr)
+{
+	return 0;
+}
+
+#define _page_cachable_default	_CACHE_CACHABLE_NONCOHERENT
+
+#endif /* __ASM_MACH_GENERIC_IOREMAP_H */
arch/mips/include/asm/mach-generic/mangle-port.h new file +50 -0

50 lines not on this page · raw message

arch/mips/include/asm/mach-generic/spaces.h new file +102 -0

102 lines not on this page · raw message

arch/mips/include/asm/pgtable-bits.h new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v3 3/6 MIPS: sync processor and register definitions with linux-4.4

In reply to Daniel Schwierzeck

Update definitions for processor, registers as well as assemby macros.

---

Changes in v3: None
Changes in v2: None

 arch/mips/include/asm/asm.h       |  126 ++--
 arch/mips/include/asm/isadep.h    |    6 +-
 arch/mips/include/asm/mipsregs.h  | 1495 ++++++++++++++++++++++++++-----------
 arch/mips/include/asm/processor.h |    6 +-
 arch/mips/include/asm/ptrace.h    |   99 ++-
 arch/mips/include/asm/regdef.h    |   12 +-
 arch/mips/lib/cache.c             |    4 +-
 arch/mips/lib/cache_init.S        |   16 +-
 8 files changed, 1211 insertions(+), 553 deletions(-)
arch/mips/include/asm/asm.h +67 -59
index 8c9c4e2..44694a3 100644
@@ -1,8 +1,4 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1995, 1996, 1997, 1999, 2001 by Ralf Baechle
  * Copyright (C) 1999 by Silicon Graphics, Inc.
  * Copyright (C) 2001 MIPS Technologies, Inc.
@@ -13,6 +9,8 @@
  * Some of the routines below contain useless nops that will be optimized
  * away by gas in -O mode. These nops are however required to fill delay
  * slots in noreorder mode.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef __ASM_ASM_H
 #define __ASM_ASM_H
@@ -33,58 +31,58 @@
  * Not used for the kernel but here seems to be the right place.
  */
 #ifdef __PIC__
-#define CPRESTORE(register)                             \
+#define CPRESTORE(register)				\
 		.cprestore register
-#define CPADD(register)                                 \
+#define CPADD(register)					\
 		.cpadd	register
-#define CPLOAD(register)                                \
-		.cpload	register
+#define CPLOAD(register)				\
+		.cpload register
 #else
 #define CPRESTORE(register)
 #define CPADD(register)
 #define CPLOAD(register)
 #endif
 
-#define ENTRY(symbol)                                   \
-		.globl	symbol;                         \
-		.type	symbol, @function;              \
-		.ent	symbol, 0;                      \
+#define ENTRY(symbol)					\
+		.globl	symbol;				\
+		.type	symbol, @function;		\
+		.ent	symbol, 0;			\
 symbol:
 
 /*
  * LEAF - declare leaf routine
  */
-#define	LEAF(symbol)                                    \
-		.globl	symbol;                         \
-		.align	2;                              \
-		.type	symbol, @function;              \
-		.ent	symbol, 0;                      \
+#define LEAF(symbol)					\
+		.globl	symbol;				\
+		.align	2;				\
+		.type	symbol, @function;		\
+		.ent	symbol, 0;			\
 		.section .text.symbol, "x";             \
 symbol:		.frame	sp, 0, ra
 
 /*
  * NESTED - declare nested routine entry point
  */
-#define	NESTED(symbol, framesize, rpc)                  \
-		.globl	symbol;                         \
-		.align	2;                              \
-		.type	symbol, @function;              \
-		.ent	symbol, 0;                      \
+#define NESTED(symbol, framesize, rpc)			\
+		.globl	symbol;				\
+		.align	2;				\
+		.type	symbol, @function;		\
+		.ent	symbol, 0;			\
 		.section .text.symbol, "x";             \
 symbol:		.frame	sp, framesize, rpc
 
 /*
  * END - mark end of function
  */
-#define	END(function)                                   \
-		.end	function;		        \
+#define END(function)					\
+		.end	function;			\
 		.size	function, .-function
 
 /*
  * EXPORT - export definition of symbol
  */
 #define EXPORT(symbol)					\
-		.globl	symbol;                         \
+		.globl	symbol;				\
 symbol:
 
 /*
@@ -98,16 +96,16 @@ symbol:
 /*
  * ABS - export absolute symbol
  */
-#define	ABS(symbol,value)                               \
-		.globl	symbol;                         \
+#define ABS(symbol,value)				\
+		.globl	symbol;				\
 symbol		=	value
 
-#define	PANIC(msg)                                      \
+#define PANIC(msg)					\
 		.set	push;				\
-		.set	reorder;                        \
-		PTR_LA	a0, 8f;                          \
-		jal	panic;                          \
-9:		b	9b;                             \
+		.set	reorder;			\
+		PTR_LA	a0, 8f;				 \
+		jal	panic;				\
+9:		b	9b;				\
 		.set	pop;				\
 		TEXT(msg)
 
@@ -115,31 +113,31 @@ symbol		=	value
  * Print formatted string
  */
 #ifdef CONFIG_PRINTK
-#define PRINT(string)                                   \
+#define PRINT(string)					\
 		.set	push;				\
-		.set	reorder;                        \
-		PTR_LA	a0, 8f;                          \
-		jal	printk;                         \
+		.set	reorder;			\
+		PTR_LA	a0, 8f;				 \
+		jal	printk;				\
 		.set	pop;				\
 		TEXT(string)
 #else
 #define PRINT(string)
 #endif
 
-#define	TEXT(msg)                                       \
+#define TEXT(msg)					\
 		.pushsection .data;			\
-8:		.asciiz	msg;                            \
+8:		.asciiz msg;				\
 		.popsection;
 
 /*
  * Build text tables
  */
-#define TTABLE(string)                                  \
+#define TTABLE(string)					\
 		.pushsection .text;			\
-		.word	1f;                             \
+		.word	1f;				\
 		.popsection				\
 		.pushsection .data;			\
-1:		.asciiz	string;                         \
+1:		.asciiz string;				\
 		.popsection
 
 /*
@@ -151,21 +149,29 @@ symbol		=	value
  */
 #ifdef CONFIG_CPU_HAS_PREFETCH
 
-#define PREF(hint,addr)                                 \
+#define PREF(hint, addr)				\
 		.set	push;				\
-		.set	mips4;				\
+		.set	arch=r5000;			\
 		pref	hint, addr;			\
 		.set	pop
 
-#define PREFX(hint,addr)                                \
+#define PREFE(hint, addr)				\
+		.set	push;				\
+		.set	mips0;				\
+		.set	eva;				\
+		prefe	hint, addr;			\
+		.set	pop
+
+#define PREFX(hint, addr)				\
 		.set	push;				\
-		.set	mips4;				\
+		.set	arch=r5000;			\
 		prefx	hint, addr;			\
 		.set	pop
 
 #else /* !CONFIG_CPU_HAS_PREFETCH */
 
 #define PREF(hint, addr)
+#define PREFE(hint, addr)
 #define PREFX(hint, addr)
 
 #endif /* !CONFIG_CPU_HAS_PREFETCH */
@@ -174,42 +180,42 @@ symbol		=	value
  * MIPS ISA IV/V movn/movz instructions and equivalents for older CPUs.
  */
 #if (_MIPS_ISA == _MIPS_ISA_MIPS1)
-#define MOVN(rd, rs, rt)                                \
+#define MOVN(rd, rs, rt)				\
 		.set	push;				\
 		.set	reorder;			\
-		beqz	rt, 9f;                         \
-		move	rd, rs;                         \
+		beqz	rt, 9f;				\
+		move	rd, rs;				\
 		.set	pop;				\
 9:
-#define MOVZ(rd, rs, rt)                                \
+#define MOVZ(rd, rs, rt)				\
 		.set	push;				\
 		.set	reorder;			\
-		bnez	rt, 9f;                         \
-		move	rd, rs;                         \
+		bnez	rt, 9f;				\
+		move	rd, rs;				\
 		.set	pop;				\
 9:
 #endif /* _MIPS_ISA == _MIPS_ISA_MIPS1 */
 #if (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3)
-#define MOVN(rd, rs, rt)                                \
+#define MOVN(rd, rs, rt)				\
 		.set	push;				\
 		.set	noreorder;			\
-		bnezl	rt, 9f;                         \
-		 move	rd, rs;                         \
+		bnezl	rt, 9f;				\
+		 move	rd, rs;				\
 		.set	pop;				\
 9:
-#define MOVZ(rd, rs, rt)                                \
+#define MOVZ(rd, rs, rt)				\
 		.set	push;				\
 		.set	noreorder;			\
-		beqzl	rt, 9f;                         \
-		 move	rd, rs;                         \
+		beqzl	rt, 9f;				\
+		 move	rd, rs;				\
 		.set	pop;				\
 9:
 #endif /* (_MIPS_ISA == _MIPS_ISA_MIPS2) || (_MIPS_ISA == _MIPS_ISA_MIPS3) */
 #if (_MIPS_ISA == _MIPS_ISA_MIPS4 ) || (_MIPS_ISA == _MIPS_ISA_MIPS5) || \
     (_MIPS_ISA == _MIPS_ISA_MIPS32) || (_MIPS_ISA == _MIPS_ISA_MIPS64)
-#define MOVN(rd, rs, rt)                                \
+#define MOVN(rd, rs, rt)				\
 		movn	rd, rs, rt
-#define MOVZ(rd, rs, rt)                                \
+#define MOVZ(rd, rs, rt)				\
 		movz	rd, rs, rt
 #endif /* MIPS IV, MIPS V, MIPS32 or MIPS64 */
 
@@ -304,6 +310,7 @@ symbol		=	value
 #define LONG_SUBU	subu
 #define LONG_L		lw
 #define LONG_S		sw
+#define LONG_SP		swp
 #define LONG_SLL	sll
 #define LONG_SLLV	sllv
 #define LONG_SRL	srl
@@ -326,6 +333,7 @@ symbol		=	value
 #define LONG_SUBU	dsubu
 #define LONG_L		ld
 #define LONG_S		sd
+#define LONG_SP		sdp
 #define LONG_SLL	dsll
 #define LONG_SLLV	dsllv
 #define LONG_SRL	dsrl
arch/mips/include/asm/isadep.h +4 -2
index 24c6cda..3d79ebc 100644
@@ -4,6 +4,8 @@
  * of Coprocessor 0 registers.
  *
  * Copyright (c) 1998 Harald Koerfgen
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 
 #ifndef __ASM_ISADEP_H
@@ -18,7 +20,7 @@
  * kernel or user mode? (CP0_STATUS)
  */
 #define KU_MASK 0x08
-#define	KU_USER 0x08
+#define KU_USER 0x08
 #define KU_KERN 0x00
 
 #else
@@ -26,7 +28,7 @@
  * kernel or user mode?
  */
 #define KU_MASK 0x18
-#define	KU_USER 0x10
+#define KU_USER 0x10
 #define KU_KERN 0x00
 
 #endif
arch/mips/include/asm/mipsregs.h +1061 -434

1,913 lines not on this page · raw message

arch/mips/include/asm/processor.h +2 -4
index ba7f538..02a3b16 100644
@@ -1,12 +1,10 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1994 Waldorf GMBH
  * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 Ralf Baechle
  * Copyright (C) 1996 Paul M. Antoine
  * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_PROCESSOR_H
 #define _ASM_PROCESSOR_H
arch/mips/include/asm/ptrace.h +59 -40

134 lines not on this page · raw message

arch/mips/include/asm/regdef.h +8 -4
index 2e65cc3..f1efc45 100644
@@ -1,11 +1,11 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1985 MIPS Computer Systems, Inc.
  * Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle
  * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc.
+ * Copyright (C) 2011 Wind River Systems,
+ *   written by Ralf Baechle <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_REGDEF_H
 #define _ASM_REGDEF_H
@@ -30,9 +30,13 @@
 #define t2	$10
 #define t3	$11
 #define t4	$12
+#define ta0	$12
 #define t5	$13
+#define ta1	$13
 #define t6	$14
+#define ta2	$14
 #define t7	$15
+#define ta3	$15
 #define s0	$16	/* callee saved */
 #define s1	$17
 #define s2	$18
arch/mips/lib/cache.c +2 -2
index e245614..bf8ff59 100644
@@ -27,7 +27,7 @@ static inline unsigned long icache_line_size(void)
 {
 	unsigned long conf1, il;
 	conf1 = read_c0_config1();
-	il = (conf1 & MIPS_CONF1_IL) >> MIPS_CONF1_IL_SHIFT;
+	il = (conf1 & MIPS_CONF1_IL) >> MIPS_CONF1_IL_SHF;
 	if (!il)
 		return 0;
 	return 2 << il;
@@ -37,7 +37,7 @@ static inline unsigned long dcache_line_size(void)
 {
 	unsigned long conf1, dl;
 	conf1 = read_c0_config1();
-	dl = (conf1 & MIPS_CONF1_DL) >> MIPS_CONF1_DL_SHIFT;
+	dl = (conf1 & MIPS_CONF1_DL) >> MIPS_CONF1_DL_SHF;
 	if (!dl)
 		return 0;
 	return 2 << dl;
arch/mips/lib/cache_init.S +8 -8
index 137d728..14cc2c4 100644
@@ -54,24 +54,24 @@
 	mfc0	$1, CP0_CONFIG, 1
 
 	/* detect line size */
-	srl	\line_sz, $1, \off + MIPS_CONF1_DL_SHIFT - MIPS_CONF1_DA_SHIFT
-	andi	\line_sz, \line_sz, (MIPS_CONF1_DL >> MIPS_CONF1_DL_SHIFT)
+	srl	\line_sz, $1, \off + MIPS_CONF1_DL_SHF - MIPS_CONF1_DA_SHF
+	andi	\line_sz, \line_sz, (MIPS_CONF1_DL >> MIPS_CONF1_DL_SHF)
 	move	\sz, zero
 	beqz	\line_sz, 10f
 	li	\sz, 2
 	sllv	\line_sz, \sz, \line_sz
 
 	/* detect associativity */
-	srl	\sz, $1, \off + MIPS_CONF1_DA_SHIFT - MIPS_CONF1_DA_SHIFT
-	andi	\sz, \sz, (MIPS_CONF1_DA >> MIPS_CONF1_DA_SHIFT)
+	srl	\sz, $1, \off + MIPS_CONF1_DA_SHF - MIPS_CONF1_DA_SHF
+	andi	\sz, \sz, (MIPS_CONF1_DA >> MIPS_CONF1_DA_SHF)
 	addi	\sz, \sz, 1
 
 	/* sz *= line_sz */
 	mul	\sz, \sz, \line_sz
 
 	/* detect log32(sets) */
-	srl	$1, $1, \off + MIPS_CONF1_DS_SHIFT - MIPS_CONF1_DA_SHIFT
-	andi	$1, $1, (MIPS_CONF1_DS >> MIPS_CONF1_DS_SHIFT)
+	srl	$1, $1, \off + MIPS_CONF1_DS_SHF - MIPS_CONF1_DA_SHF
+	andi	$1, $1, (MIPS_CONF1_DS >> MIPS_CONF1_DS_SHF)
 	addiu	$1, $1, 1
 	andi	$1, $1, 0x7
 
@@ -103,14 +103,14 @@ LEAF(mips_cache_reset)
 	li	t2, CONFIG_SYS_ICACHE_SIZE
 	li	t8, CONFIG_SYS_CACHELINE_SIZE
 #else
-	l1_info	t2, t8, MIPS_CONF1_IA_SHIFT
+	l1_info	t2, t8, MIPS_CONF1_IA_SHF
 #endif
 
 #ifdef CONFIG_SYS_DCACHE_SIZE
 	li	t3, CONFIG_SYS_DCACHE_SIZE
 	li	t9, CONFIG_SYS_CACHELINE_SIZE
 #else
-	l1_info	t3, t9, MIPS_CONF1_DA_SHIFT
+	l1_info	t3, t9, MIPS_CONF1_DA_SHF
 #endif
 
 #ifdef CONFIG_SYS_MIPS_CACHE_INIT_RAM_LOAD
Signature · 1 line
2.5.0
#4 lore raw

PATCH v3 4/6 MIPS: fix SPDX license identifier in remaining arch header files

In reply to Daniel Schwierzeck

Add a SPDX license identifier to MIPS header files where it is still missing.

---

Changes in v3: None
Changes in v2: None

 arch/mips/include/asm/addrspace.h   | 6 ++----
 arch/mips/include/asm/bitops.h      | 6 ++----
 arch/mips/include/asm/byteorder.h   | 6 ++----
 arch/mips/include/asm/cachectl.h    | 6 ++----
 arch/mips/include/asm/cacheops.h    | 6 ++----
 arch/mips/include/asm/const.h       | 6 +++++-
 arch/mips/include/asm/posix_types.h | 9 +++------
 arch/mips/include/asm/reboot.h      | 6 ++----
 arch/mips/include/asm/reg.h         | 6 ++----
 arch/mips/include/asm/sgidefs.h     | 6 ++----
 arch/mips/include/asm/string.h      | 6 ++----
 arch/mips/include/asm/system.h      | 6 ++----
 arch/mips/include/asm/types.h       | 6 ++----
 arch/mips/include/asm/unaligned.h   | 6 ++----
 14 files changed, 32 insertions(+), 55 deletions(-)
arch/mips/include/asm/addrspace.h +2 -4
index e7fe6ed..0994e96 100644
@@ -1,11 +1,9 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1996, 99 Ralf Baechle
  * Copyright (C) 2000, 2002  Maciej W. Rozycki
  * Copyright (C) 1990, 1999 by Silicon Graphics, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_ADDRSPACE_H
 #define _ASM_ADDRSPACE_H
arch/mips/include/asm/bitops.h +2 -4
index c31ff6e..cce6995 100644
@@ -1,10 +1,8 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (c) 1994 - 1997, 1999, 2000  Ralf Baechle (ralf at gnu.org)
  * Copyright (c) 2000  Silicon Graphics, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_BITOPS_H
 #define _ASM_BITOPS_H
arch/mips/include/asm/byteorder.h +2 -4
index b5e685f..67fdf71 100644
@@ -1,9 +1,7 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1996, 99, 2003 by Ralf Baechle
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_BYTEORDER_H
 #define _ASM_BYTEORDER_H
arch/mips/include/asm/cachectl.h +2 -4
index f3ce721..5e77dfa 100644
@@ -1,9 +1,7 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1994, 1995, 1996 by Ralf Baechle
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef	_ASM_CACHECTL
 #define	_ASM_CACHECTL
arch/mips/include/asm/cacheops.h +2 -4
index af2adc7..a3b07c6 100644
@@ -1,12 +1,10 @@
 /*
  * Cache operations for the cache instruction.
  *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * (C) Copyright 1996, 97, 99, 2002, 03 Ralf Baechle
  * (C) Copyright 1999 Silicon Graphics, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef	__ASM_CACHEOPS_H
 #define	__ASM_CACHEOPS_H
arch/mips/include/asm/const.h +5 -1
index c872bfd..f600e7a 100644
@@ -1,4 +1,8 @@
-/* const.h: Macros for dealing with constants.  */
+/*
+ * const.h: Macros for dealing with constants.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
 
 #ifndef _LINUX_CONST_H
 #define _LINUX_CONST_H
arch/mips/include/asm/posix_types.h +3 -6
index 4deac52..90c0aff 100644
@@ -1,10 +1,7 @@
-/* $Id: posix_types.h,v 1.6 2000/02/04 23:32:54 ralf Exp $
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
+/*
  * Copyright (C) 1996, 1997, 1998, 2000 by Ralf Baechle
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_POSIX_TYPES_H
 #define _ASM_POSIX_TYPES_H
arch/mips/include/asm/reboot.h +2 -4
index 978d206..2a6b724 100644
@@ -1,10 +1,8 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1997, 1999, 2001, 06 by Ralf Baechle
  * Copyright (C) 2001 MIPS Technologies, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_REBOOT_H
 #define _ASM_REBOOT_H
arch/mips/include/asm/reg.h +2 -4
index fc6bc0c..af6fbb4 100644
@@ -2,12 +2,10 @@
  * Various register offset definitions for debuggers, core file
  * examiners and whatnot.
  *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1995, 1999 by Ralf Baechle
  * Copyright (C) 1995, 1999 Silicon Graphics
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef __ASM_MIPS_REG_H
 #define __ASM_MIPS_REG_H
arch/mips/include/asm/sgidefs.h +2 -4
index 67f2658..2a03886 100644
@@ -1,11 +1,9 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1996, 1999, 2001 Ralf Baechle
  * Copyright (C) 1999 Silicon Graphics, Inc.
  * Copyright (C) 2001 MIPS Technologies, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef __ASM_SGIDEFS_H
 #define __ASM_SGIDEFS_H
arch/mips/include/asm/string.h +2 -4
index 579a591..1fbe899 100644
@@ -1,11 +1,9 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (c) 1994, 95, 96, 97, 98, 2000, 01 Ralf Baechle
  * Copyright (c) 2000 by Silicon Graphics, Inc.
  * Copyright (c) 2001 MIPS Technologies, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_STRING_H
 #define _ASM_STRING_H
arch/mips/include/asm/system.h +2 -4
index d56f73b..e6435cc 100644
@@ -1,8 +1,4 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1994 - 1999 by Ralf Baechle
  * Copyright (C) 1996 by Paul M. Antoine
  * Copyright (C) 1994 - 1999 by Ralf Baechle
@@ -12,6 +8,8 @@
  *
  * Kevin D. Kissell, kevink at mips.org and Carsten Langgaard, carstenl at mips.com
  * Copyright (C) 2000 MIPS Technologies, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_SYSTEM_H
 #define _ASM_SYSTEM_H
arch/mips/include/asm/types.h +2 -4
index aebafdb..627440d 100644
@@ -1,10 +1,8 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
  * Copyright (C) 1999 Silicon Graphics, Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_TYPES_H
 #define _ASM_TYPES_H
arch/mips/include/asm/unaligned.h +2 -4
index c25a846..eebe06a 100644
@@ -1,9 +1,7 @@
 /*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
  * Copyright (C) 2007 Ralf Baechle (ralf at linux-mips.org)
+ *
+ * SPDX-License-Identifier:	GPL-2.0
  */
 #ifndef _ASM_MIPS_UNALIGNED_H
 #define _ASM_MIPS_UNALIGNED_H
Signature · 1 line
2.5.0
#5 lore raw

PATCH v3 5/6 MIPS: implement bit manipulating I/O accessors

In reply to Daniel Schwierzeck

Add support for functions clrbits_X(), setbits_X() and clrsetbits_X() on MIPS.

---

Changes in v3: None
Changes in v2: None

 arch/mips/include/asm/io.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
arch/mips/include/asm/io.h +54 -0
index eb06afa..43b4326 100644
@@ -541,4 +541,58 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 {
 }
 
+#define __BUILD_CLRBITS(bwlq, sfx, end, type)				\
+									\
+static inline void clrbits_##sfx(volatile void __iomem *mem, type clr)	\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val &= ~clr;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define __BUILD_SETBITS(bwlq, sfx, end, type)				\
+									\
+static inline void setbits_##sfx(volatile void __iomem *mem, type set)	\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val |= set;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define __BUILD_CLRSETBITS(bwlq, sfx, end, type)			\
+									\
+static inline void clrsetbits_##sfx(volatile void __iomem *mem,		\
+					type clr, type set)		\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val &= ~clr;							\
+	__val |= set;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define BUILD_CLRSETBITS(bwlq, sfx, type)				\
+									\
+__BUILD_CLRBITS(bwlq, sfx, sfx, type)					\
+__BUILD_SETBITS(bwlq, sfx, sfx, type)					\
+__BUILD_CLRSETBITS(bwlq, sfx, sfx, type)
+
+#define __to_cpu(v)		(v)
+#define cpu_to__(v)		(v)
+
+__BUILD_CLRBITS(b, 8, _, u8)
+__BUILD_SETBITS(b, 8, _, u8)
+__BUILD_CLRSETBITS(b, 8, _, u8)
+BUILD_CLRSETBITS(w, le16, u16)
+BUILD_CLRSETBITS(w, be16, u16)
+BUILD_CLRSETBITS(l, le32, u32)
+BUILD_CLRSETBITS(l, be32, u32)
+BUILD_CLRSETBITS(q, le64, u64)
+BUILD_CLRSETBITS(q, be64, u64)
+
 #endif /* _ASM_IO_H */
Signature · 1 line
2.5.0
#7 lore raw

PATCH v3 6/6 MIPS: DO NOT MERGE: test I/O accessors

In reply to Daniel Schwierzeck

Test patch for compile testing and disassembly analysis of the updated and new I/O accessors.

---

Changes in v3:
- rebased to u-boot-mips/next

Changes in v2: None

 arch/mips/lib/io.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 183 insertions(+)
arch/mips/lib/io.c +183 -0
index b2d4a09..e80990e 100644
@@ -5,8 +5,191 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <common.h>
+#include <asm/io.h>
+
 /*
  * mips_io_port_base is the begin of the address space to which x86 style
  * I/O ports are mapped.
  */
 const unsigned long mips_io_port_base = -1;
+
+static const void __iomem *addr1 = (const void __iomem *)CKSEG1ADDR(0x80000000);
+static void __iomem *addr2 = (void __iomem *)CKSEG1ADDR(0x80001000);
+
+void test_readb(void)
+{
+	u8 val = readb(addr1);
+	writeb(val, addr2);
+}
+
+void test_readw(void)
+{
+	u16 val = readw(addr1);
+	writew(val, addr2);
+}
+
+void test_readl(void)
+{
+	u32 val = readl(addr1);
+	writel(val, addr2);
+}
+
+void test_readq(void)
+{
+	u32 val = readq(addr1);
+	writeq(val, addr2);
+}
+
+void test_readb_be(void)
+{
+	u8 val = readb_be(addr1);
+	writeb_be(val, addr2);
+}
+
+void test_readw_be(void)
+{
+	u16 val = readw_be(addr1);
+	writew_be(val, addr2);
+}
+
+void test_readl_be(void)
+{
+	u32 val = readl_be(addr1);
+	writel_be(val, addr2);
+}
+
+void test_readq_be(void)
+{
+	u32 val = readq_be(addr1);
+	writeq_be(val, addr2);
+}
+
+void test_raw_readb(void)
+{
+	u8 val = __raw_readb(addr1);
+	__raw_writeb(val, addr2);
+}
+
+void test_raw_readw(void)
+{
+	u16 val = __raw_readw(addr1);
+	__raw_writew(val, addr2);
+}
+
+void test_raw_readl(void)
+{
+	u32 val = __raw_readl(addr1);
+	__raw_writel(val, addr2);
+}
+
+void test_raw_readq(void)
+{
+	u32 val = __raw_readq(addr1);
+	__raw_writeq(val, addr2);
+}
+
+void test_clrbits_8(void)
+{
+	clrbits_8(addr2, BIT(2));
+}
+
+void test_setbits_8(void)
+{
+	setbits_8(addr2, BIT(3));
+}
+
+void test_clrsetbits_8(void)
+{
+	clrsetbits_8(addr2, BIT(2), BIT(3));
+}
+
+void test_clrbits_le16(void)
+{
+	clrbits_le16(addr2, BIT(9));
+}
+
+void test_setbits_le16(void)
+{
+	setbits_le16(addr2, BIT(10));
+}
+
+void test_clrsetbits_le16(void)
+{
+	clrsetbits_le16(addr2, BIT(9), BIT(10));
+}
+
+void test_clrbits_be16(void)
+{
+	clrbits_be16(addr2, BIT(9));
+}
+
+void test_setbits_be16(void)
+{
+	setbits_be16(addr2, BIT(10));
+}
+
+void test_clrsetbits_be16(void)
+{
+	clrsetbits_be16(addr2, BIT(9), BIT(10));
+}
+
+void test_clrbits_le32(void)
+{
+	clrbits_le32(addr2, BIT(9));
+}
+
+void test_setbits_le32(void)
+{
+	setbits_le32(addr2, BIT(10));
+}
+
+void test_clrsetbits_le32(void)
+{
+	clrsetbits_le32(addr2, BIT(9), BIT(10));
+}
+
+void test_clrbits_be32(void)
+{
+	clrbits_be32(addr2, BIT(9));
+}
+
+void test_setbits_be32(void)
+{
+	setbits_be32(addr2, BIT(10));
+}
+
+void test_clrsetbits_be32(void)
+{
+	clrsetbits_be32(addr2, BIT(9), BIT(10));
+}
+
+void test_clrbits_le64(void)
+{
+	clrbits_le64(addr2, BIT(9));
+}
+
+void test_setbits_le64(void)
+{
+	setbits_le64(addr2, BIT(10));
+}
+
+void test_clrsetbits_le64(void)
+{
+	clrsetbits_le64(addr2, BIT(9), BIT(10));
+}
+
+void test_clrbits_be64(void)
+{
+	clrbits_be64(addr2, BIT(9));
+}
+
+void test_setbits_be64(void)
+{
+	setbits_be64(addr2, BIT(10));
+}
+
+void test_clrsetbits_be64(void)
+{
+	clrsetbits_be64(addr2, BIT(9), BIT(10));
+}
Signature · 1 line
2.5.0
#6 lore raw

PATCH v4 5/6 MIPS: implement bit manipulating I/O accessors

In reply to Daniel Schwierzeck

Add support for functions clrbits_X(), setbits_X() and clrsetbits_X() on MIPS.

---
@Wills, after rebasing my own SoC code to this series and trying to use the new accessors I've hit the same problems with endianess in a driver. My drivers have to support Big and Little Endian, thus I have to use __raw_readX/__raw_writeX. So I also added variants of the new accessors without swapping and a similar behaviour as __raw_readX/__raw_writeX. This should address your concers too.

Changes in v4:
- added clrbits_X(), setbits_X() and clrsetbits_X() variants without endianess swapping

Changes in v3: None
Changes in v2: None

 arch/mips/include/asm/io.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/mips/include/asm/io.h +55 -0
index eb06afa..b8ac5a5 100644
@@ -541,4 +541,59 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 {
 }
 
+#define __BUILD_CLRBITS(bwlq, sfx, end, type)				\
+									\
+static inline void clrbits_##sfx(volatile void __iomem *mem, type clr)	\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val &= ~clr;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define __BUILD_SETBITS(bwlq, sfx, end, type)				\
+									\
+static inline void setbits_##sfx(volatile void __iomem *mem, type set)	\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val |= set;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define __BUILD_CLRSETBITS(bwlq, sfx, end, type)			\
+									\
+static inline void clrsetbits_##sfx(volatile void __iomem *mem,		\
+					type clr, type set)		\
+{									\
+	type __val = __raw_read##bwlq(mem);				\
+	__val = end##_to_cpu(__val);					\
+	__val &= ~clr;							\
+	__val |= set;							\
+	__val = cpu_to_##end(__val);					\
+	__raw_write##bwlq(__val, mem);					\
+}
+
+#define BUILD_CLRSETBITS(bwlq, sfx, end, type)				\
+									\
+__BUILD_CLRBITS(bwlq, sfx, end, type)					\
+__BUILD_SETBITS(bwlq, sfx, end, type)					\
+__BUILD_CLRSETBITS(bwlq, sfx, end, type)
+
+#define __to_cpu(v)		(v)
+#define cpu_to__(v)		(v)
+
+BUILD_CLRSETBITS(b, 8, _, u8)
+BUILD_CLRSETBITS(w, le16, le16, u16)
+BUILD_CLRSETBITS(w, be16, be16, u16)
+BUILD_CLRSETBITS(w, 16, _, u16)
+BUILD_CLRSETBITS(l, le32, le32, u32)
+BUILD_CLRSETBITS(l, be32, be32, u32)
+BUILD_CLRSETBITS(l, 32, _, u32)
+BUILD_CLRSETBITS(q, le64, le64, u64)
+BUILD_CLRSETBITS(q, be64, be64, u64)
+BUILD_CLRSETBITS(q, 64, _, u64)
+
 #endif /* _ASM_IO_H */
Signature · 1 line
2.5.0