]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: ipa: start creating GSI register definitions
authorAlex Elder <elder@linaro.org>
Fri, 10 Feb 2023 19:36:50 +0000 (13:36 -0600)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Feb 2023 09:56:16 +0000 (09:56 +0000)
Create a new register definition file in the "reg" subdirectory,
and begin populating it with GSI register definitions based on IPA
version.  The GSI registers haven't changed much, so several IPA
versions can share the same GSI register definitions.

As with IPA registers, an array of pointers indexed by GSI register ID
refers to these register definitions, and a new "regs" field in the
GSI structure is initialized in gsi_reg_init() to refer to register
information based on the IPA version (though for now there's only
one).  The new function gsi_reg() returns register information for
a given GSI register, and the result can be used to look up that
register's offset.

This patch is meant only to put the infrastructure in place, so only
eon register (CH_C_QOS) is defined for each version, and only the
offset and stride are defined for that register.  Use new function
gsi_reg() to look up that register's information to get its offset,
This makes the GSI_CH_C_QOS_OFFSET() unnecessary, so get rid of it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipa/Makefile
drivers/net/ipa/gsi.c
drivers/net/ipa/gsi.h
drivers/net/ipa/gsi_reg.c
drivers/net/ipa/gsi_reg.h
drivers/net/ipa/reg/gsi_reg-v3.1.c [new file with mode: 0644]

index 166ef86f7ad3f0afffbfc3021190867b4ad15c3b..d87f2cfe08c611e4faa842cf3048d98fd22c1095 100644 (file)
@@ -4,6 +4,9 @@
 
 IPA_VERSIONS           :=      3.1 3.5.1 4.2 4.5 4.7 4.9 4.11
 
+# Some IPA versions can reuse another set of GSI register definitions.
+GSI_IPA_VERSIONS       :=      3.1
+
 obj-$(CONFIG_QCOM_IPA) +=      ipa.o
 
 ipa-y                  :=      ipa_main.o ipa_power.o ipa_reg.o ipa_mem.o \
@@ -13,6 +16,8 @@ ipa-y                 :=      ipa_main.o ipa_power.o ipa_reg.o ipa_mem.o \
                                ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \
                                ipa_sysfs.o
 
+ipa-y                  +=      $(GSI_IPA_VERSIONS:%=reg/gsi_reg-v%.o)
+
 ipa-y                  +=      $(IPA_VERSIONS:%=reg/ipa_reg-v%.o)
 
 ipa-y                  +=      $(IPA_VERSIONS:%=data/ipa_data-v%.o)
index a000bef49f8e53a6ac77d722fc4146d8c1dbaf8e..f07b7554d21fdb05e36b9f80e14f9c3709f629ed 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/netdevice.h>
 
 #include "gsi.h"
+#include "reg.h"
 #include "gsi_reg.h"
 #include "gsi_private.h"
 #include "gsi_trans.h"
@@ -796,6 +797,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
        union gsi_channel_scratch scr = { };
        struct gsi_channel_scratch_gpi *gpi;
        struct gsi *gsi = channel->gsi;
+       const struct reg *reg;
        u32 wrr_weight = 0;
        u32 val;
 
@@ -819,6 +821,8 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
        val = upper_32_bits(channel->tre_ring.addr);
        iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
 
+       reg = gsi_reg(gsi, CH_C_QOS);
+
        /* Command channel gets low weighted round-robin priority */
        if (channel->command)
                wrr_weight = field_max(WRR_WEIGHT_FMASK);
@@ -845,7 +849,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
        if (gsi->version >= IPA_VERSION_4_9)
                val |= DB_IN_BYTES;
 
-       iowrite32(val, gsi->virt + GSI_CH_C_QOS_OFFSET(channel_id));
+       iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
 
        /* Now update the scratch registers for GPI protocol */
        gpi = &scr.gpi;
index 49dcadba4e0b9a772d3d5a99af1a35dd56d969ce..bc5ff617341a7f85485a3950a63df95434d792f7 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
- * Copyright (C) 2018-2022 Linaro Ltd.
+ * Copyright (C) 2018-2023 Linaro Ltd.
  */
 #ifndef _GSI_H_
 #define _GSI_H_
@@ -142,6 +142,8 @@ struct gsi {
        enum ipa_version version;
        void __iomem *virt_raw;         /* I/O mapped address range */
        void __iomem *virt;             /* Adjusted for most registers */
+       const struct regs *regs;
+
        u32 irq;
        u32 channel_count;
        u32 evt_ring_count;
index c20b3bcdd41510a86e8ad580841aad701b56e8e4..2334244d40da07448bdafbba0118d06107d581cc 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/io.h>
 
 #include "gsi.h"
+#include "reg.h"
 #include "gsi_reg.h"
 
 /* GSI EE registers as a group are shifted downward by a fixed constant amount
@@ -85,6 +86,31 @@ static bool gsi_reg_id_valid(struct gsi *gsi, enum gsi_reg_id reg_id)
        }
 }
 
+const struct reg *gsi_reg(struct gsi *gsi, enum gsi_reg_id reg_id)
+{
+       if (WARN(!gsi_reg_id_valid(gsi, reg_id), "invalid reg %u\n", reg_id))
+               return NULL;
+
+       return reg(gsi->regs, reg_id);
+}
+
+static const struct regs *gsi_regs(struct gsi *gsi)
+{
+       switch (gsi->version) {
+       case IPA_VERSION_3_1:
+       case IPA_VERSION_3_5_1:
+       case IPA_VERSION_4_2:
+       case IPA_VERSION_4_5:
+       case IPA_VERSION_4_7:
+       case IPA_VERSION_4_9:
+       case IPA_VERSION_4_11:
+               return &gsi_regs_v3_1;
+
+       default:
+               return NULL;
+       }
+}
+
 /* Sets gsi->virt_raw and gsi->virt, and I/O maps the "gsi" memory range */
 int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
 {
@@ -93,8 +119,6 @@ int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
        resource_size_t size;
        u32 adjust;
 
-       (void)gsi_reg_id_valid; /* Avoid a warning */
-
        /* Get GSI memory range and map it */
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi");
        if (!res) {
@@ -116,6 +140,12 @@ int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
                return -EINVAL;
        }
 
+       gsi->regs = gsi_regs(gsi);
+       if (!gsi->regs) {
+               dev_err(dev, "unsupported IPA version %u (?)\n", gsi->version);
+               return -EINVAL;
+       }
+
        gsi->virt_raw = ioremap(res->start, size);
        if (!gsi->virt_raw) {
                dev_err(dev, "unable to remap \"gsi\" memory\n");
index 1f613cd677b01793eb79b71093d86360fcae716a..398546fbfd697918e4270d42e965f760f978c438 100644 (file)
@@ -140,8 +140,7 @@ enum gsi_channel_type {
 #define GSI_CH_C_CNTXT_3_OFFSET(ch) \
                        (0x0001c00c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
 
-#define GSI_CH_C_QOS_OFFSET(ch) \
-                       (0x0001c05c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
+/* CH_C_QOS register */
 #define WRR_WEIGHT_FMASK               GENMASK(3, 0)
 #define MAX_PREFETCH_FMASK             GENMASK(8, 8)
 #define USE_DB_ENG_FMASK               GENMASK(9, 9)
@@ -443,6 +442,15 @@ enum gsi_generic_ee_result {
        GENERIC_EE_NO_RESOURCES                 = 0x7,
 };
 
+extern const struct regs gsi_regs_v3_1;
+
+/**
+ * gsi_reg() - Return the structure describing a GSI register
+ * @gsi:       GSI pointer
+ * @reg_id:    GSI register ID
+ */
+const struct reg *gsi_reg(struct gsi *gsi, enum gsi_reg_id reg_id);
+
 /**
  * gsi_reg_init() - Perform GSI register initialization
  * @gsi:       GSI pointer
diff --git a/drivers/net/ipa/reg/gsi_reg-v3.1.c b/drivers/net/ipa/reg/gsi_reg-v3.1.c
new file mode 100644 (file)
index 0000000..c4d4beb
--- /dev/null
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* Copyright (C) 2023 Linaro Ltd. */
+
+#include <linux/types.h>
+
+#include "../gsi.h"
+#include "../reg.h"
+#include "../gsi_reg.h"
+
+REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
+
+static const struct reg *reg_array[] = {
+       [CH_C_QOS]                      = &reg_ch_c_qos,
+};
+
+const struct regs gsi_regs_v3_1 = {
+       .reg_count      = ARRAY_SIZE(reg_array),
+       .reg            = reg_array,
+};