From: Timur Tabi <timur@freescale.com>
To: linuxppc-dev@ozlabs.org, paulus@samba.org
Cc: Timur Tabi <timur@freescale.com>
Subject: [PATCH v2] powerpc: add setmaskedbits macros
Date: Wed, 15 Aug 2007 16:30:50 -0500 [thread overview]
Message-ID: <11872134502476-git-send-email-timur@freescale.com> (raw)
This patch adds the setmaskedbits_xxx() macros, which are used to set a
multiple-bit bit pattern in a register. The macros include a mask, which
zeros the respective bits before applying the value via a bitwise-OR.
There are big-endian and little-endian versions for 8, 16, 32, and 64 bits.
These new macros are useful because the setbits macros can only be used
to set single-bit fields. For example, if you have a 32-bit register
where bits 17-20 need to be set to 0100, you would do
setmaskedbits_be32(p, 4 << 11, 0xF << 11).
Signed-off-by: Timur Tabi <timur@freescale.com>
---
Updated the changelog to include a reason why you'd want these macros.
I have a number of new SOC device drivers coming up that will use these
macros, if this patch is accepted.
include/asm-powerpc/io.h | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index bb8d965..ac3defb 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -734,6 +734,19 @@ static inline void * bus_to_virt(unsigned long address)
#define setbits16(_addr, _v) out_be16((_addr), in_be16(_addr) | (_v))
#define clrbits16(_addr, _v) out_be16((_addr), in_be16(_addr) & ~(_v))
+#ifdef __powerpc64__
+#define setmaskedbits_be64(a, v, m) out_be64((a), (in_be64(a) & ~(m)) | (v))
+#define setmaskedbits_le64(a, v, m) out_le64((a), (in_le64(a) & ~(m)) | (v))
+#endif
+
+#define setmaskedbits_be32(a, v, m) out_be32((a), (in_be32(a) & ~(m)) | (v))
+#define setmaskedbits_be16(a, v, m) out_be16((a), (in_be16(a) & ~(m)) | (v))
+
+#define setmaskedbits_le32(a, v, m) out_le32((a), (in_le32(a) & ~(m)) | (v))
+#define setmaskedbits_le16(a, v, m) out_le16((a), (in_le16(a) & ~(m)) | (v))
+
+#define setmaskedbits_8(a, v, m) out_8((a), (in_8(a) & ~(m)) | (v))
+
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_IO_H */
--
1.5.2.4
next reply other threads:[~2007-08-15 21:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 21:30 Timur Tabi [this message]
2007-08-16 3:22 ` [PATCH v2] powerpc: add setmaskedbits macros Kumar Gala
2007-08-16 15:18 ` Timur Tabi
2007-08-16 15:21 ` Kumar Gala
2007-08-16 15:26 ` Timur Tabi
2007-08-16 16:40 ` Benjamin Herrenschmidt
2007-08-16 17:45 ` Timur Tabi
2007-08-16 3:55 ` Michael Ellerman
2007-08-16 7:19 ` Geert Uytterhoeven
2007-08-16 15:27 ` Timur Tabi
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=11872134502476-git-send-email-timur@freescale.com \
--to=timur@freescale.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.