Skip to content

Commit d2bb6e6

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: start creating GSI register definitions
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8f0fece commit d2bb6e6

File tree

6 files changed

+75
-6
lines changed

6 files changed

+75
-6
lines changed

drivers/net/ipa/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
IPA_VERSIONS := 3.1 3.5.1 4.2 4.5 4.7 4.9 4.11
66

7+
# Some IPA versions can reuse another set of GSI register definitions.
8+
GSI_IPA_VERSIONS := 3.1
9+
710
obj-$(CONFIG_QCOM_IPA) += ipa.o
811

912
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 \
1316
ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \
1417
ipa_sysfs.o
1518

19+
ipa-y += $(GSI_IPA_VERSIONS:%=reg/gsi_reg-v%.o)
20+
1621
ipa-y += $(IPA_VERSIONS:%=reg/ipa_reg-v%.o)
1722

1823
ipa-y += $(IPA_VERSIONS:%=data/ipa_data-v%.o)

drivers/net/ipa/gsi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/netdevice.h>
1717

1818
#include "gsi.h"
19+
#include "reg.h"
1920
#include "gsi_reg.h"
2021
#include "gsi_private.h"
2122
#include "gsi_trans.h"
@@ -796,6 +797,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
796797
union gsi_channel_scratch scr = { };
797798
struct gsi_channel_scratch_gpi *gpi;
798799
struct gsi *gsi = channel->gsi;
800+
const struct reg *reg;
799801
u32 wrr_weight = 0;
800802
u32 val;
801803

@@ -819,6 +821,8 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
819821
val = upper_32_bits(channel->tre_ring.addr);
820822
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
821823

824+
reg = gsi_reg(gsi, CH_C_QOS);
825+
822826
/* Command channel gets low weighted round-robin priority */
823827
if (channel->command)
824828
wrr_weight = field_max(WRR_WEIGHT_FMASK);
@@ -845,7 +849,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
845849
if (gsi->version >= IPA_VERSION_4_9)
846850
val |= DB_IN_BYTES;
847851

848-
iowrite32(val, gsi->virt + GSI_CH_C_QOS_OFFSET(channel_id));
852+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
849853

850854
/* Now update the scratch registers for GPI protocol */
851855
gpi = &scr.gpi;

drivers/net/ipa/gsi.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

33
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2018-2022 Linaro Ltd.
4+
* Copyright (C) 2018-2023 Linaro Ltd.
55
*/
66
#ifndef _GSI_H_
77
#define _GSI_H_
@@ -142,6 +142,8 @@ struct gsi {
142142
enum ipa_version version;
143143
void __iomem *virt_raw; /* I/O mapped address range */
144144
void __iomem *virt; /* Adjusted for most registers */
145+
const struct regs *regs;
146+
145147
u32 irq;
146148
u32 channel_count;
147149
u32 evt_ring_count;

drivers/net/ipa/gsi_reg.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/io.h>
77

88
#include "gsi.h"
9+
#include "reg.h"
910
#include "gsi_reg.h"
1011

1112
/* 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)
8586
}
8687
}
8788

89+
const struct reg *gsi_reg(struct gsi *gsi, enum gsi_reg_id reg_id)
90+
{
91+
if (WARN(!gsi_reg_id_valid(gsi, reg_id), "invalid reg %u\n", reg_id))
92+
return NULL;
93+
94+
return reg(gsi->regs, reg_id);
95+
}
96+
97+
static const struct regs *gsi_regs(struct gsi *gsi)
98+
{
99+
switch (gsi->version) {
100+
case IPA_VERSION_3_1:
101+
case IPA_VERSION_3_5_1:
102+
case IPA_VERSION_4_2:
103+
case IPA_VERSION_4_5:
104+
case IPA_VERSION_4_7:
105+
case IPA_VERSION_4_9:
106+
case IPA_VERSION_4_11:
107+
return &gsi_regs_v3_1;
108+
109+
default:
110+
return NULL;
111+
}
112+
}
113+
88114
/* Sets gsi->virt_raw and gsi->virt, and I/O maps the "gsi" memory range */
89115
int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
90116
{
@@ -93,8 +119,6 @@ int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
93119
resource_size_t size;
94120
u32 adjust;
95121

96-
(void)gsi_reg_id_valid; /* Avoid a warning */
97-
98122
/* Get GSI memory range and map it */
99123
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi");
100124
if (!res) {
@@ -116,6 +140,12 @@ int gsi_reg_init(struct gsi *gsi, struct platform_device *pdev)
116140
return -EINVAL;
117141
}
118142

143+
gsi->regs = gsi_regs(gsi);
144+
if (!gsi->regs) {
145+
dev_err(dev, "unsupported IPA version %u (?)\n", gsi->version);
146+
return -EINVAL;
147+
}
148+
119149
gsi->virt_raw = ioremap(res->start, size);
120150
if (!gsi->virt_raw) {
121151
dev_err(dev, "unable to remap \"gsi\" memory\n");

drivers/net/ipa/gsi_reg.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ enum gsi_channel_type {
140140
#define GSI_CH_C_CNTXT_3_OFFSET(ch) \
141141
(0x0001c00c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
142142

143-
#define GSI_CH_C_QOS_OFFSET(ch) \
144-
(0x0001c05c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
143+
/* CH_C_QOS register */
145144
#define WRR_WEIGHT_FMASK GENMASK(3, 0)
146145
#define MAX_PREFETCH_FMASK GENMASK(8, 8)
147146
#define USE_DB_ENG_FMASK GENMASK(9, 9)
@@ -443,6 +442,15 @@ enum gsi_generic_ee_result {
443442
GENERIC_EE_NO_RESOURCES = 0x7,
444443
};
445444

445+
extern const struct regs gsi_regs_v3_1;
446+
447+
/**
448+
* gsi_reg() - Return the structure describing a GSI register
449+
* @gsi: GSI pointer
450+
* @reg_id: GSI register ID
451+
*/
452+
const struct reg *gsi_reg(struct gsi *gsi, enum gsi_reg_id reg_id);
453+
446454
/**
447455
* gsi_reg_init() - Perform GSI register initialization
448456
* @gsi: GSI pointer

drivers/net/ipa/reg/gsi_reg-v3.1.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
/* Copyright (C) 2023 Linaro Ltd. */
4+
5+
#include <linux/types.h>
6+
7+
#include "../gsi.h"
8+
#include "../reg.h"
9+
#include "../gsi_reg.h"
10+
11+
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
12+
13+
static const struct reg *reg_array[] = {
14+
[CH_C_QOS] = &reg_ch_c_qos,
15+
};
16+
17+
const struct regs gsi_regs_v3_1 = {
18+
.reg_count = ARRAY_SIZE(reg_array),
19+
.reg = reg_array,
20+
};

0 commit comments

Comments
 (0)