Skip to content

Commit 8bfc4e2

Browse files
Alex Elderkuba-moo
authored andcommitted
net: ipa: add support to code for IPA v4.5
Update the IPA code to make use of the updated IPA v4.5 register definitions. Generally what this patch does is, if IPA v4.5 hardware is in use: - Ensure new registers or fields in IPA v4.5 are updated where required - Ensure registers or fields not supported in IPA v4.5 are not examined when read, or are set to 0 when written It does this while preserving the existing functionality for IPA versions lower than v4.5. The values to program for QSB_MAX_READS and QSB_MAX_WRITES and the source and destination resource counts are updated to be correct for all versions through v4.5 as well. Note that IPA_RESOURCE_GROUP_SRC_MAX and IPA_RESOURCE_GROUP_DST_MAX already reflect that 5 is an acceptable number of resources (which IPA v4.5 implements). Signed-off-by: Alex Elder <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1af15c2 commit 8bfc4e2

File tree

3 files changed

+57
-23
lines changed

3 files changed

+57
-23
lines changed

drivers/net/ipa/ipa_endpoint.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint)
520520
/* HDR_ADDITIONAL_CONST_LEN is 0; (RX only) */
521521
/* HDR_A5_MUX is 0 */
522522
/* HDR_LEN_INC_DEAGG_HDR is 0 */
523-
/* HDR_METADATA_REG_VALID is 0 (TX only) */
523+
/* HDR_METADATA_REG_VALID is 0 (TX only, version < v4.5) */
524524
}
525525

526526
iowrite32(val, ipa->reg_virt + offset);
@@ -655,6 +655,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
655655
/* other fields ignored */
656656
}
657657
/* AGGR_FORCE_CLOSE is 0 */
658+
/* AGGR_GRAN_SEL is 0 for IPA v4.5 */
658659
} else {
659660
val |= u32_encode_bits(IPA_BYPASS_AGGR, AGGR_EN_FMASK);
660661
/* other fields ignored */
@@ -865,9 +866,10 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint)
865866
val |= u32_encode_bits(status_endpoint_id,
866867
STATUS_ENDP_FMASK);
867868
}
868-
/* STATUS_LOCATION is 0 (status element precedes packet) */
869-
/* The next field is present for IPA v4.0 and above */
870-
/* STATUS_PKT_SUPPRESS_FMASK is 0 */
869+
/* STATUS_LOCATION is 0, meaning status element precedes
870+
* packet (not present for IPA v4.5)
871+
*/
872+
/* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v3.5.1) */
871873
}
872874

873875
iowrite32(val, ipa->reg_virt + offset);

drivers/net/ipa/ipa_main.c

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ static void ipa_hardware_config_comp(struct ipa *ipa)
230230
val &= ~IPA_QMB_SELECT_CONS_EN_FMASK;
231231
val &= ~IPA_QMB_SELECT_PROD_EN_FMASK;
232232
val &= ~IPA_QMB_SELECT_GLOBAL_EN_FMASK;
233-
} else {
233+
} else if (ipa->version < IPA_VERSION_4_5) {
234234
val |= GSI_MULTI_AXI_MASTERS_DIS_FMASK;
235+
} else {
236+
/* For IPA v4.5 IPA_FULL_FLUSH_WAIT_RSC_CLOSE_EN is 0 */
235237
}
236238

237239
val |= GSI_MULTI_INORDER_RD_DIS_FMASK;
@@ -243,25 +245,47 @@ static void ipa_hardware_config_comp(struct ipa *ipa)
243245
/* Configure DDR and PCIe max read/write QSB values */
244246
static void ipa_hardware_config_qsb(struct ipa *ipa)
245247
{
248+
enum ipa_version version = ipa->version;
249+
u32 max0;
250+
u32 max1;
246251
u32 val;
247252

248-
/* QMB_0 represents DDR; QMB_1 represents PCIe (not present in 4.2) */
253+
/* QMB_0 represents DDR; QMB_1 represents PCIe */
249254
val = u32_encode_bits(8, GEN_QMB_0_MAX_WRITES_FMASK);
250-
if (ipa->version == IPA_VERSION_4_2)
251-
val |= u32_encode_bits(0, GEN_QMB_1_MAX_WRITES_FMASK);
252-
else
253-
val |= u32_encode_bits(4, GEN_QMB_1_MAX_WRITES_FMASK);
255+
switch (version) {
256+
case IPA_VERSION_4_2:
257+
max1 = 0; /* PCIe not present */
258+
break;
259+
case IPA_VERSION_4_5:
260+
max1 = 8;
261+
break;
262+
default:
263+
max1 = 4;
264+
break;
265+
}
266+
val |= u32_encode_bits(max1, GEN_QMB_1_MAX_WRITES_FMASK);
254267
iowrite32(val, ipa->reg_virt + IPA_REG_QSB_MAX_WRITES_OFFSET);
255268

256-
if (ipa->version == IPA_VERSION_3_5_1) {
257-
val = u32_encode_bits(8, GEN_QMB_0_MAX_READS_FMASK);
258-
val |= u32_encode_bits(12, GEN_QMB_1_MAX_READS_FMASK);
259-
} else {
260-
val = u32_encode_bits(12, GEN_QMB_0_MAX_READS_FMASK);
261-
if (ipa->version == IPA_VERSION_4_2)
262-
val |= u32_encode_bits(0, GEN_QMB_1_MAX_READS_FMASK);
263-
else
264-
val |= u32_encode_bits(12, GEN_QMB_1_MAX_READS_FMASK);
269+
max1 = 12;
270+
switch (version) {
271+
case IPA_VERSION_3_5_1:
272+
max0 = 8;
273+
break;
274+
case IPA_VERSION_4_0:
275+
case IPA_VERSION_4_1:
276+
max0 = 12;
277+
break;
278+
case IPA_VERSION_4_2:
279+
max0 = 12;
280+
max1 = 0; /* PCIe not present */
281+
break;
282+
case IPA_VERSION_4_5:
283+
max0 = 16;
284+
break;
285+
}
286+
val = u32_encode_bits(max0, GEN_QMB_0_MAX_READS_FMASK);
287+
val |= u32_encode_bits(max1, GEN_QMB_1_MAX_READS_FMASK);
288+
if (version != IPA_VERSION_3_5_1) {
265289
/* GEN_QMB_0_MAX_READS_BEATS is 0 */
266290
/* GEN_QMB_1_MAX_READS_BEATS is 0 */
267291
}
@@ -294,7 +318,7 @@ static void ipa_idle_indication_cfg(struct ipa *ipa,
294318
*/
295319
static void ipa_hardware_dcd_config(struct ipa *ipa)
296320
{
297-
/* Recommended values for IPA 3.5 according to IPA HPG */
321+
/* Recommended values for IPA 3.5 and later according to IPA HPG */
298322
ipa_idle_indication_cfg(ipa, 256, false);
299323
}
300324

@@ -320,13 +344,14 @@ static void ipa_hardware_config(struct ipa *ipa)
320344
iowrite32(val, ipa->reg_virt + IPA_REG_BCR_OFFSET);
321345
}
322346

323-
if (version != IPA_VERSION_3_5_1) {
324-
/* Enable open global clocks (hardware workaround) */
347+
/* Implement some hardware workarounds */
348+
if (version != IPA_VERSION_3_5_1 && version < IPA_VERSION_4_5) {
349+
/* Enable open global clocks (not needed for IPA v4.5) */
325350
val = GLOBAL_FMASK;
326351
val |= GLOBAL_2X_CLK_FMASK;
327352
iowrite32(val, ipa->reg_virt + IPA_REG_CLKON_CFG_OFFSET);
328353

329-
/* Disable PA mask to allow HOLB drop (hardware workaround) */
354+
/* Disable PA mask to allow HOLB drop */
330355
val = ioread32(ipa->reg_virt + IPA_REG_TX_CFG_OFFSET);
331356
val &= ~PA_MASK_EN_FMASK;
332357
iowrite32(val, ipa->reg_virt + IPA_REG_TX_CFG_OFFSET);

drivers/net/ipa/ipa_reg.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ static inline u32 ipa_aggr_granularity_val(u32 usec)
238238
return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1;
239239
}
240240

241+
/* The next register is not present for IPA v4.5 */
241242
#define IPA_REG_TX_CFG_OFFSET 0x000001fc
242243
/* The first three fields are present for IPA v3.5.1 only */
243244
#define TX0_PREFETCH_DISABLE_FMASK GENMASK(0, 0)
@@ -285,6 +286,9 @@ static inline u32 ipa_resource_group_src_count(enum ipa_version version)
285286
case IPA_VERSION_4_2:
286287
return 1;
287288

289+
case IPA_VERSION_4_5:
290+
return 5;
291+
288292
default:
289293
return 0;
290294
}
@@ -304,6 +308,9 @@ static inline u32 ipa_resource_group_dst_count(enum ipa_version version)
304308
case IPA_VERSION_4_2:
305309
return 1;
306310

311+
case IPA_VERSION_4_5:
312+
return 5;
313+
307314
default:
308315
return 0;
309316
}

0 commit comments

Comments
 (0)