summaryrefslogtreecommitdiff
path: root/include/linux/soundwire
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2020-02-25 11:00:41 -0600
committerVinod Koul <vkoul@kernel.org>2020-02-26 14:18:25 +0530
commit2c6cff682d6681fb1cdb03b3cdbbecd3fb0e4c89 (patch)
tree0359dfc953b820f3b73eb1a2175c1d81740903ee /include/linux/soundwire
parentbb6d3fb354c5ee8d6bde2d576eb7220ea09862b9 (diff)
soundwire: add helper macros for devID fields
Move bit extractors to macros, so that the definitions can be used by other drivers parsing the MIPI definitions extracted from firmware tables (ACPI or DT). Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200225170041.23644-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'include/linux/soundwire')
-rw-r--r--include/linux/soundwire/sdw.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index b451bb622335..56273c5c1f6b 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -424,6 +424,29 @@ struct sdw_slave_id {
__u8 sdw_version:4;
};
+/*
+ * Helper macros to extract the MIPI-defined IDs
+ *
+ * Spec definition
+ * Register Bit Contents
+ * DevId_0 [7:4] 47:44 sdw_version
+ * DevId_0 [3:0] 43:40 unique_id
+ * DevId_1 39:32 mfg_id [15:8]
+ * DevId_2 31:24 mfg_id [7:0]
+ * DevId_3 23:16 part_id [15:8]
+ * DevId_4 15:08 part_id [7:0]
+ * DevId_5 07:00 class_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))
+
/**
* struct sdw_slave_intr_status - Slave interrupt status
* @control_port: control port status