Skip to content

Commit cdeee49

Browse files
Alex Elderkuba-moo
authored andcommitted
net: ipa: adjust GSI register addresses
The offsets for almost all GSI registers we use have different offsets starting at IPA version 4.5. Only two registers remain in their original location. In a way though, the new register locations are not *that* different. The entire group of affected registers has simply been shifted down in memory by a fixed amount (0xd000). So for example, the channel context 0 register that has a base offset of 0x0001c000 for "older" hardware now has a base offset of 0x0000f000. This patch aims to add support for IPA v4.5 registers at their new offets in a way that minimizes the amount of code that needs to change. It is not ideal, but it avoids the need to maintain a nearly complete set of additional register offset definitions. The approach takes advantage of the fact that when accessing GSI registers we do not access any of memory at lower end of the "gsi" memory range (with two exceptions already noted). In particular, we do not access anything within the bottom 0xd000 bytes of the GSI memory range. For IPA version 4.5, after we map the GSI memory, we adjust the virtual memory pointer downward by the fixed amount (0xd000). That way, register accesses using the offsets defined by the existing GSI_REG_*() macros will resolve to the proper locations for IPA version 4.5. The two registers *not* affected by this offset are accessed only in gsi_irq_setup(). There, for IPA version 4.5, we undo the general register adjustment by adding the fixed amount back to the virtual address to access these registers. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b0b6f0d commit cdeee49

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

drivers/net/ipa/gsi.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ static void gsi_irq_type_disable(struct gsi *gsi, enum gsi_irq_type_id type_id)
195195
/* Turn off all GSI interrupts initially */
196196
static void gsi_irq_setup(struct gsi *gsi)
197197
{
198+
u32 adjust;
199+
198200
/* Disable all interrupt types */
199201
gsi_irq_type_update(gsi, 0);
200202

@@ -203,8 +205,12 @@ static void gsi_irq_setup(struct gsi *gsi)
203205
iowrite32(0, gsi->virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET);
204206
iowrite32(0, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET);
205207
iowrite32(0, gsi->virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET);
206-
iowrite32(0, gsi->virt + GSI_INTER_EE_SRC_CH_IRQ_OFFSET);
207-
iowrite32(0, gsi->virt + GSI_INTER_EE_SRC_EV_CH_IRQ_OFFSET);
208+
209+
/* Reverse the offset adjustment for inter-EE register offsets */
210+
adjust = gsi->version < IPA_VERSION_4_5 ? 0 : GSI_EE_REG_ADJUST;
211+
iowrite32(0, gsi->virt + adjust + GSI_INTER_EE_SRC_CH_IRQ_OFFSET);
212+
iowrite32(0, gsi->virt + adjust + GSI_INTER_EE_SRC_EV_CH_IRQ_OFFSET);
213+
208214
iowrite32(0, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET);
209215
}
210216

@@ -2089,6 +2095,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev,
20892095
struct device *dev = &pdev->dev;
20902096
struct resource *res;
20912097
resource_size_t size;
2098+
u32 adjust;
20922099
int ret;
20932100

20942101
gsi_validate_build();
@@ -2115,11 +2122,21 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev,
21152122
return -EINVAL;
21162123
}
21172124

2125+
/* Make sure we can make our pointer adjustment if necessary */
2126+
adjust = gsi->version < IPA_VERSION_4_5 ? 0 : GSI_EE_REG_ADJUST;
2127+
if (res->start < adjust) {
2128+
dev_err(dev, "DT memory resource \"gsi\" too low (< %u)\n",
2129+
adjust);
2130+
return -EINVAL;
2131+
}
2132+
21182133
gsi->virt = ioremap(res->start, size);
21192134
if (!gsi->virt) {
21202135
dev_err(dev, "unable to remap \"gsi\" memory\n");
21212136
return -ENOMEM;
21222137
}
2138+
/* Adjust register range pointer downward for newer IPA versions */
2139+
gsi->virt -= adjust;
21232140

21242141
init_completion(&gsi->completion);
21252142

drivers/net/ipa/gsi_reg.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
* (though the actual limit is hardware-dependent).
3939
*/
4040

41+
/* GSI EE registers as a group are shifted downward by a fixed
42+
* constant amount for IPA versions 4.5 and beyond. This applies
43+
* to all GSI registers we use *except* the ones that disable
44+
* inter-EE interrupts for channels and event channels.
45+
*
46+
* We handle this by adjusting the pointer to the mapped GSI memory
47+
* region downward. Then in the one place we use them (gsi_irq_setup())
48+
* we undo that adjustment for the inter-EE interrupt registers.
49+
*/
50+
#define GSI_EE_REG_ADJUST 0x0000d000 /* IPA v4.5+ */
51+
4152
#define GSI_INTER_EE_SRC_CH_IRQ_OFFSET \
4253
GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(GSI_EE_AP)
4354
#define GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(ee) \

0 commit comments

Comments
 (0)