Skip to content

Commit 76924eb

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: add more GSI register definitions
Continue populating with GSI register definitions, adding remaining registers whose offset depends on a channel ID. Use gsi_reg() and reg_n_offset() to determine offsets for those registers, and get rid of the corresponding GSI_CH_C_*_OFFSET() macros. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d2bb6e6 commit 76924eb

File tree

3 files changed

+62
-38
lines changed

3 files changed

+62
-38
lines changed

drivers/net/ipa/gsi.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,14 @@ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id)
500500
/* Fetch the current state of a channel from hardware */
501501
static enum gsi_channel_state gsi_channel_state(struct gsi_channel *channel)
502502
{
503+
const struct reg *reg = gsi_reg(channel->gsi, CH_C_CNTXT_0);
503504
u32 channel_id = gsi_channel_id(channel);
504-
void __iomem *virt = channel->gsi->virt;
505+
struct gsi *gsi = channel->gsi;
506+
void __iomem *virt = gsi->virt;
505507
u32 val;
506508

507-
val = ioread32(virt + GSI_CH_C_CNTXT_0_OFFSET(channel_id));
509+
reg = gsi_reg(gsi, CH_C_CNTXT_0);
510+
val = ioread32(virt + reg_n_offset(reg, channel_id));
508511

509512
return u32_get_bits(val, CHSTATE_FMASK);
510513
}
@@ -799,27 +802,34 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
799802
struct gsi *gsi = channel->gsi;
800803
const struct reg *reg;
801804
u32 wrr_weight = 0;
805+
u32 offset;
802806
u32 val;
803807

808+
reg = gsi_reg(gsi, CH_C_CNTXT_0);
809+
804810
/* We program all channels as GPI type/protocol */
805811
val = ch_c_cntxt_0_type_encode(gsi->version, GSI_CHANNEL_TYPE_GPI);
806812
if (channel->toward_ipa)
807813
val |= CHTYPE_DIR_FMASK;
808814
val |= u32_encode_bits(channel->evt_ring_id, ERINDEX_FMASK);
809815
val |= u32_encode_bits(GSI_RING_ELEMENT_SIZE, ELEMENT_SIZE_FMASK);
810-
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_0_OFFSET(channel_id));
816+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
811817

818+
reg = gsi_reg(gsi, CH_C_CNTXT_1);
812819
val = ch_c_cntxt_1_length_encode(gsi->version, size);
813-
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_1_OFFSET(channel_id));
820+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
814821

815822
/* The context 2 and 3 registers store the low-order and
816823
* high-order 32 bits of the address of the channel ring,
817824
* respectively.
818825
*/
826+
reg = gsi_reg(gsi, CH_C_CNTXT_2);
819827
val = lower_32_bits(channel->tre_ring.addr);
820-
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id));
828+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
829+
830+
reg = gsi_reg(gsi, CH_C_CNTXT_3);
821831
val = upper_32_bits(channel->tre_ring.addr);
822-
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id));
832+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
823833

824834
reg = gsi_reg(gsi, CH_C_QOS);
825835

@@ -857,22 +867,27 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
857867
GSI_RING_ELEMENT_SIZE;
858868
gpi->outstanding_threshold = 2 * GSI_RING_ELEMENT_SIZE;
859869

870+
reg = gsi_reg(gsi, CH_C_SCRATCH_0);
860871
val = scr.data.word1;
861-
iowrite32(val, gsi->virt + GSI_CH_C_SCRATCH_0_OFFSET(channel_id));
872+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
862873

874+
reg = gsi_reg(gsi, CH_C_SCRATCH_1);
863875
val = scr.data.word2;
864-
iowrite32(val, gsi->virt + GSI_CH_C_SCRATCH_1_OFFSET(channel_id));
876+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
865877

878+
reg = gsi_reg(gsi, CH_C_SCRATCH_2);
866879
val = scr.data.word3;
867-
iowrite32(val, gsi->virt + GSI_CH_C_SCRATCH_2_OFFSET(channel_id));
880+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
868881

869882
/* We must preserve the upper 16 bits of the last scratch register.
870883
* The next sequence assumes those bits remain unchanged between the
871884
* read and the write.
872885
*/
873-
val = ioread32(gsi->virt + GSI_CH_C_SCRATCH_3_OFFSET(channel_id));
886+
reg = gsi_reg(gsi, CH_C_SCRATCH_3);
887+
offset = reg_n_offset(reg, channel_id);
888+
val = ioread32(gsi->virt + offset);
874889
val = (scr.data.word4 & GENMASK(31, 16)) | (val & GENMASK(15, 0));
875-
iowrite32(val, gsi->virt + GSI_CH_C_SCRATCH_3_OFFSET(channel_id));
890+
iowrite32(val, gsi->virt + offset);
876891

877892
/* All done! */
878893
}
@@ -1506,11 +1521,13 @@ void gsi_channel_doorbell(struct gsi_channel *channel)
15061521
struct gsi_ring *tre_ring = &channel->tre_ring;
15071522
u32 channel_id = gsi_channel_id(channel);
15081523
struct gsi *gsi = channel->gsi;
1524+
const struct reg *reg;
15091525
u32 val;
15101526

1527+
reg = gsi_reg(gsi, CH_C_DOORBELL_0);
15111528
/* Note: index *must* be used modulo the ring count here */
15121529
val = gsi_ring_addr(tre_ring, tre_ring->index % tre_ring->count);
1513-
iowrite32(val, gsi->virt + GSI_CH_C_DOORBELL_0_OFFSET(channel_id));
1530+
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
15141531
}
15151532

15161533
/* Consult hardware, move newly completed transactions to completed state */

drivers/net/ipa/gsi_reg.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ enum gsi_reg_id {
105105

106106
/* All other register offsets are relative to gsi->virt */
107107

108-
#define GSI_CH_C_CNTXT_0_OFFSET(ch) \
109-
(0x0001c000 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
108+
/* CH_C_CNTXT_0 register */
110109
#define CHTYPE_PROTOCOL_FMASK GENMASK(2, 0)
111110
#define CHTYPE_DIR_FMASK GENMASK(3, 3)
112111
#define EE_FMASK GENMASK(7, 4)
@@ -131,15 +130,6 @@ enum gsi_channel_type {
131130
GSI_CHANNEL_TYPE_11AD = 0x9,
132131
};
133132

134-
#define GSI_CH_C_CNTXT_1_OFFSET(ch) \
135-
(0x0001c004 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
136-
137-
#define GSI_CH_C_CNTXT_2_OFFSET(ch) \
138-
(0x0001c008 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
139-
140-
#define GSI_CH_C_CNTXT_3_OFFSET(ch) \
141-
(0x0001c00c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
142-
143133
/* CH_C_QOS register */
144134
#define WRR_WEIGHT_FMASK GENMASK(3, 0)
145135
#define MAX_PREFETCH_FMASK GENMASK(8, 8)
@@ -160,18 +150,6 @@ enum gsi_prefetch_mode {
160150
GSI_FREE_PREFETCH = 0x3,
161151
};
162152

163-
#define GSI_CH_C_SCRATCH_0_OFFSET(ch) \
164-
(0x0001c060 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
165-
166-
#define GSI_CH_C_SCRATCH_1_OFFSET(ch) \
167-
(0x0001c064 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
168-
169-
#define GSI_CH_C_SCRATCH_2_OFFSET(ch) \
170-
(0x0001c068 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
171-
172-
#define GSI_CH_C_SCRATCH_3_OFFSET(ch) \
173-
(0x0001c06c + 0x4000 * GSI_EE_AP + 0x80 * (ch))
174-
175153
#define GSI_EV_CH_E_CNTXT_0_OFFSET(ev) \
176154
(0x0001d000 + 0x4000 * GSI_EE_AP + 0x80 * (ev))
177155
/* enum gsi_channel_type defines EV_CHTYPE field values in EV_CH_E_CNTXT_0 */
@@ -221,9 +199,6 @@ enum gsi_prefetch_mode {
221199
#define GSI_EV_CH_E_SCRATCH_1_OFFSET(ev) \
222200
(0x0001d04c + 0x4000 * GSI_EE_AP + 0x80 * (ev))
223201

224-
#define GSI_CH_C_DOORBELL_0_OFFSET(ch) \
225-
(0x0001e000 + 0x4000 * GSI_EE_AP + 0x08 * (ch))
226-
227202
#define GSI_EV_CH_E_DOORBELL_0_OFFSET(ev) \
228203
(0x0001e100 + 0x4000 * GSI_EE_AP + 0x08 * (ev))
229204

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,42 @@
88
#include "../reg.h"
99
#include "../gsi_reg.h"
1010

11+
REG_STRIDE(CH_C_CNTXT_0, ch_c_cntxt_0, 0x0001c000 + 0x4000 * GSI_EE_AP, 0x80);
12+
13+
REG_STRIDE(CH_C_CNTXT_1, ch_c_cntxt_1, 0x0001c004 + 0x4000 * GSI_EE_AP, 0x80);
14+
15+
REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
16+
17+
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
18+
1119
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
1220

21+
REG_STRIDE(CH_C_SCRATCH_0, ch_c_scratch_0,
22+
0x0001c060 + 0x4000 * GSI_EE_AP, 0x80);
23+
24+
REG_STRIDE(CH_C_SCRATCH_1, ch_c_scratch_1,
25+
0x0001c064 + 0x4000 * GSI_EE_AP, 0x80);
26+
27+
REG_STRIDE(CH_C_SCRATCH_2, ch_c_scratch_2,
28+
0x0001c068 + 0x4000 * GSI_EE_AP, 0x80);
29+
30+
REG_STRIDE(CH_C_SCRATCH_3, ch_c_scratch_3,
31+
0x0001c06c + 0x4000 * GSI_EE_AP, 0x80);
32+
33+
REG_STRIDE(CH_C_DOORBELL_0, ch_c_doorbell_0,
34+
0x0001e000 + 0x4000 * GSI_EE_AP, 0x08);
35+
1336
static const struct reg *reg_array[] = {
37+
[CH_C_CNTXT_0] = &reg_ch_c_cntxt_0,
38+
[CH_C_CNTXT_1] = &reg_ch_c_cntxt_1,
39+
[CH_C_CNTXT_2] = &reg_ch_c_cntxt_2,
40+
[CH_C_CNTXT_3] = &reg_ch_c_cntxt_3,
1441
[CH_C_QOS] = &reg_ch_c_qos,
42+
[CH_C_SCRATCH_0] = &reg_ch_c_scratch_0,
43+
[CH_C_SCRATCH_1] = &reg_ch_c_scratch_1,
44+
[CH_C_SCRATCH_2] = &reg_ch_c_scratch_2,
45+
[CH_C_SCRATCH_3] = &reg_ch_c_scratch_3,
46+
[CH_C_DOORBELL_0] = &reg_ch_c_doorbell_0,
1547
};
1648

1749
const struct regs gsi_regs_v3_1 = {

0 commit comments

Comments
 (0)