arm: mach-k3: am62a: Simplify the logic for QOS reg and val propagation
For the QOS registers, instead of using the raw values for calculation
for each reg field, use a defined macro which takes in argument for all
the reg fields to get the desired value.
Do the similar simplification for QOS register and group registers and
make the corresponding changes for am62a_qos_uboot file.
Suggested-by: Andrew Davis <afd@ti.com>
Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
Acked-by: Andrew Davis <afd@ti.com>
diff --git a/arch/arm/mach-k3/include/mach/k3-qos.h b/arch/arm/mach-k3/include/mach/k3-qos.h
index 6ed5704..eb0f2a0 100644
--- a/arch/arm/mach-k3/include/mach/k3-qos.h
+++ b/arch/arm/mach-k3/include/mach/k3-qos.h
@@ -9,80 +9,26 @@
#include <linux/kernel.h>
-#define QOS_0 (0 << 0)
-#define QOS_1 (1 << 0)
-#define QOS_2 (2 << 0)
-#define QOS_3 (3 << 0)
-#define QOS_4 (4 << 0)
-#define QOS_5 (5 << 0)
-#define QOS_6 (6 << 0)
-#define QOS_7 (7 << 0)
+/* K3_QOS_REG: Registers to configure the channel for a given endpoint */
-#define ORDERID_0 (0 << 4)
-#define ORDERID_1 (1 << 4)
-#define ORDERID_2 (2 << 4)
-#define ORDERID_3 (3 << 4)
-#define ORDERID_4 (4 << 4)
-#define ORDERID_5 (5 << 4)
-#define ORDERID_6 (6 << 4)
-#define ORDERID_7 (7 << 4)
-#define ORDERID_8 (8 << 4)
-#define ORDERID_9 (9 << 4)
-#define ORDERID_10 (10 << 4)
-#define ORDERID_11 (11 << 4)
-#define ORDERID_12 (12 << 4)
-#define ORDERID_13 (13 << 4)
-#define ORDERID_14 (14 << 4)
-#define ORDERID_15 (15 << 4)
+#define K3_QOS_REG(base_reg, i) (base_reg + 0x100 + (i) * 4)
-#define ASEL_0 (0 << 8)
-#define ASEL_1 (1 << 8)
-#define ASEL_2 (2 << 8)
-#define ASEL_3 (3 << 8)
-#define ASEL_4 (4 << 8)
-#define ASEL_5 (5 << 8)
-#define ASEL_6 (6 << 8)
-#define ASEL_7 (7 << 8)
-#define ASEL_8 (8 << 8)
-#define ASEL_9 (9 << 8)
-#define ASEL_10 (10 << 8)
-#define ASEL_11 (11 << 8)
-#define ASEL_12 (12 << 8)
-#define ASEL_13 (13 << 8)
-#define ASEL_14 (14 << 8)
-#define ASEL_15 (15 << 8)
+#define K3_QOS_VAL(qos, orderid, asel, epriority, virtid, atype) \
+ (qos << 0 | \
+ orderid << 4 | \
+ asel << 8 | \
+ epriority << 12 | \
+ virtid << 16 | \
+ atype << 28)
-#define EPRIORITY_0 (0 << 12)
-#define EPRIORITY_1 (1 << 12)
-#define EPRIORITY_2 (2 << 12)
-#define EPRIORITY_3 (3 << 12)
-#define EPRIORITY_4 (4 << 12)
-#define EPRIORITY_5 (5 << 12)
-#define EPRIORITY_6 (6 << 12)
-#define EPRIORITY_7 (7 << 12)
-
-#define VIRTID_0 (0 << 16)
-#define VIRTID_1 (1 << 16)
-#define VIRTID_2 (2 << 16)
-#define VIRTID_3 (3 << 16)
-#define VIRTID_4 (4 << 16)
-#define VIRTID_5 (5 << 16)
-#define VIRTID_6 (6 << 16)
-#define VIRTID_7 (7 << 16)
-#define VIRTID_8 (8 << 16)
-#define VIRTID_9 (9 << 16)
-#define VIRTID_10 (10 << 16)
-#define VIRTID_11 (11 << 16)
-#define VIRTID_12 (12 << 16)
-#define VIRTID_13 (13 << 16)
-#define VIRTID_14 (14 << 16)
-#define VIRTID_15 (15 << 16)
-
-#define ATYPE_0 (0 << 28)
-#define ATYPE_1 (1 << 28)
-#define ATYPE_2 (2 << 28)
-#define ATYPE_3 (3 << 28)
+/*
+ * K3_QOS_GROUP_REG: Registers to set 1:1 mapping for orderID MAP1/MAP2
+ * remap registers.
+ */
+#define K3_QOS_GROUP_REG(base_reg, i) (base_reg + (i) * 4)
+#define K3_QOS_GROUP_DEFAULT_VAL_LOW 0x76543210
+#define K3_QOS_GROUP_DEFAULT_VAL_HIGH 0xfedcba98
struct k3_qos_data {
u32 reg;
u32 val;