summaryrefslogtreecommitdiff
path: root/include/linux/soundwire/sdw.h
diff options
context:
space:
mode:
authorVinod Koul <vkoul@kernel.org>2020-09-03 14:44:56 +0300
committerVinod Koul <vkoul@kernel.org>2020-09-04 12:16:41 +0300
commit25e804926da39f1de7ae486920bfe65b099195f1 (patch)
tree3e8eabdb942cce90d3b55a31ed9b84fc1bfbec40 /include/linux/soundwire/sdw.h
parent5ee74eb280d0aa1f27fbdba5dcbde31e2df369e2 (diff)
downloadlinux-25e804926da39f1de7ae486920bfe65b099195f1.tar.xz
soundwire: define and use addr bit masks
Soundwire addr is a 52bit value encoding link, version, unique id, mfg id, part id and class id. Define bit masks for these and use FIELD_GET() to extract these fields. Signed-off-by: Vinod Koul <vkoul@kernel.org> Tested-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20200903114504.1202143-2-vkoul@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'include/linux/soundwire/sdw.h')
-rw-r--r--include/linux/soundwire/sdw.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 78f52cdeb2c9..1e9010c139f0 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -5,6 +5,7 @@
#define __SOUNDWIRE_H
#include <linux/mod_devicetable.h>
+#include <linux/bitfield.h>
struct sdw_bus;
struct sdw_slave;
@@ -456,13 +457,19 @@ struct sdw_slave_id {
*
* The MIPI DisCo for SoundWire defines in addition the link_id as bits 51:48
*/
-
-#define SDW_DISCO_LINK_ID(adr) (((adr) >> 48) & GENMASK(3, 0))
-#define SDW_VERSION(adr) (((adr) >> 44) & GENMASK(3, 0))
-#define SDW_UNIQUE_ID(adr) (((adr) >> 40) & GENMASK(3, 0))
-#define SDW_MFG_ID(adr) (((adr) >> 24) & GENMASK(15, 0))
-#define SDW_PART_ID(adr) (((adr) >> 8) & GENMASK(15, 0))
-#define SDW_CLASS_ID(adr) ((adr) & GENMASK(7, 0))
+#define SDW_DISCO_LINK_ID_MASK GENMASK_ULL(51, 48)
+#define SDW_VERSION_MASK GENMASK_ULL(47, 44)
+#define SDW_UNIQUE_ID_MASK GENMASK_ULL(43, 40)
+#define SDW_MFG_ID_MASK GENMASK_ULL(39, 24)
+#define SDW_PART_ID_MASK GENMASK_ULL(23, 8)
+#define SDW_CLASS_ID_MASK GENMASK_ULL(7, 0)
+
+#define SDW_DISCO_LINK_ID(addr) FIELD_GET(SDW_DISCO_LINK_ID_MASK, addr)
+#define SDW_VERSION(addr) FIELD_GET(SDW_VERSION_MASK, addr)
+#define SDW_UNIQUE_ID(addr) FIELD_GET(SDW_UNIQUE_ID_MASK, addr)
+#define SDW_MFG_ID(addr) FIELD_GET(SDW_MFG_ID_MASK, addr)
+#define SDW_PART_ID(addr) FIELD_GET(SDW_PART_ID_MASK, addr)
+#define SDW_CLASS_ID(addr) FIELD_GET(SDW_CLASS_ID_MASK, addr)
/**
* struct sdw_slave_intr_status - Slave interrupt status