@@ -221,8 +221,10 @@ static u32 ev_ch_e_cntxt_1_length_encode(enum ipa_version version, u32 length)
221
221
/* Update the GSI IRQ type register with the cached value */
222
222
static void gsi_irq_type_update (struct gsi * gsi , u32 val )
223
223
{
224
+ const struct reg * reg = gsi_reg (gsi , CNTXT_TYPE_IRQ_MSK );
225
+
224
226
gsi -> type_enabled_bitmap = val ;
225
- iowrite32 (val , gsi -> virt + GSI_CNTXT_TYPE_IRQ_MSK_OFFSET );
227
+ iowrite32 (val , gsi -> virt + reg_offset ( reg ) );
226
228
}
227
229
228
230
static void gsi_irq_type_enable (struct gsi * gsi , enum gsi_irq_type_id type_id )
@@ -243,22 +245,29 @@ static void gsi_irq_type_disable(struct gsi *gsi, enum gsi_irq_type_id type_id)
243
245
static void gsi_irq_ev_ctrl_enable (struct gsi * gsi , u32 evt_ring_id )
244
246
{
245
247
u32 val = BIT (evt_ring_id );
248
+ const struct reg * reg ;
246
249
247
250
/* There's a small chance that a previous command completed
248
251
* after the interrupt was disabled, so make sure we have no
249
252
* pending interrupts before we enable them.
250
253
*/
251
- iowrite32 (~0 , gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET );
254
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ_CLR );
255
+ iowrite32 (~0 , gsi -> virt + reg_offset (reg ));
252
256
253
- iowrite32 (val , gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET );
257
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ_MSK );
258
+ iowrite32 (val , gsi -> virt + reg_offset (reg ));
254
259
gsi_irq_type_enable (gsi , GSI_EV_CTRL );
255
260
}
256
261
257
262
/* Disable event ring control interrupts */
258
263
static void gsi_irq_ev_ctrl_disable (struct gsi * gsi )
259
264
{
265
+ const struct reg * reg ;
266
+
260
267
gsi_irq_type_disable (gsi , GSI_EV_CTRL );
261
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET );
268
+
269
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ_MSK );
270
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
262
271
}
263
272
264
273
/* Channel commands are performed one at a time. Their completion is
@@ -269,32 +278,43 @@ static void gsi_irq_ev_ctrl_disable(struct gsi *gsi)
269
278
static void gsi_irq_ch_ctrl_enable (struct gsi * gsi , u32 channel_id )
270
279
{
271
280
u32 val = BIT (channel_id );
281
+ const struct reg * reg ;
272
282
273
283
/* There's a small chance that a previous command completed
274
284
* after the interrupt was disabled, so make sure we have no
275
285
* pending interrupts before we enable them.
276
286
*/
277
- iowrite32 (~0 , gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_CLR_OFFSET );
287
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ_CLR );
288
+ iowrite32 (~0 , gsi -> virt + reg_offset (reg ));
289
+
290
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ_MSK );
291
+ iowrite32 (val , gsi -> virt + reg_offset (reg ));
278
292
279
- iowrite32 (val , gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET );
280
293
gsi_irq_type_enable (gsi , GSI_CH_CTRL );
281
294
}
282
295
283
296
/* Disable channel control interrupts */
284
297
static void gsi_irq_ch_ctrl_disable (struct gsi * gsi )
285
298
{
299
+ const struct reg * reg ;
300
+
286
301
gsi_irq_type_disable (gsi , GSI_CH_CTRL );
287
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET );
302
+
303
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ_MSK );
304
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
288
305
}
289
306
290
307
static void gsi_irq_ieob_enable_one (struct gsi * gsi , u32 evt_ring_id )
291
308
{
292
309
bool enable_ieob = !gsi -> ieob_enabled_bitmap ;
310
+ const struct reg * reg ;
293
311
u32 val ;
294
312
295
313
gsi -> ieob_enabled_bitmap |= BIT (evt_ring_id );
314
+
315
+ reg = gsi_reg (gsi , CNTXT_SRC_IEOB_IRQ_MSK );
296
316
val = gsi -> ieob_enabled_bitmap ;
297
- iowrite32 (val , gsi -> virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET );
317
+ iowrite32 (val , gsi -> virt + reg_offset ( reg ) );
298
318
299
319
/* Enable the interrupt type if this is the first channel enabled */
300
320
if (enable_ieob )
@@ -303,6 +323,7 @@ static void gsi_irq_ieob_enable_one(struct gsi *gsi, u32 evt_ring_id)
303
323
304
324
static void gsi_irq_ieob_disable (struct gsi * gsi , u32 event_mask )
305
325
{
326
+ const struct reg * reg ;
306
327
u32 val ;
307
328
308
329
gsi -> ieob_enabled_bitmap &= ~event_mask ;
@@ -311,8 +332,9 @@ static void gsi_irq_ieob_disable(struct gsi *gsi, u32 event_mask)
311
332
if (!gsi -> ieob_enabled_bitmap )
312
333
gsi_irq_type_disable (gsi , GSI_IEOB );
313
334
335
+ reg = gsi_reg (gsi , CNTXT_SRC_IEOB_IRQ_MSK );
314
336
val = gsi -> ieob_enabled_bitmap ;
315
- iowrite32 (val , gsi -> virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET );
337
+ iowrite32 (val , gsi -> virt + reg_offset ( reg ) );
316
338
}
317
339
318
340
static void gsi_irq_ieob_disable_one (struct gsi * gsi , u32 evt_ring_id )
@@ -323,34 +345,44 @@ static void gsi_irq_ieob_disable_one(struct gsi *gsi, u32 evt_ring_id)
323
345
/* Enable all GSI_interrupt types */
324
346
static void gsi_irq_enable (struct gsi * gsi )
325
347
{
348
+ const struct reg * reg ;
326
349
u32 val ;
327
350
328
351
/* Global interrupts include hardware error reports. Enable
329
352
* that so we can at least report the error should it occur.
330
353
*/
331
- iowrite32 (ERROR_INT , gsi -> virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET );
354
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_EN );
355
+ iowrite32 (ERROR_INT , gsi -> virt + reg_offset (reg ));
356
+
332
357
gsi_irq_type_update (gsi , gsi -> type_enabled_bitmap | GSI_GLOB_EE );
333
358
334
359
/* General GSI interrupts are reported to all EEs; if they occur
335
360
* they are unrecoverable (without reset). A breakpoint interrupt
336
361
* also exists, but we don't support that. We want to be notified
337
362
* of errors so we can report them, even if they can't be handled.
338
363
*/
364
+ reg = gsi_reg (gsi , CNTXT_GSI_IRQ_EN );
339
365
val = BUS_ERROR ;
340
366
val |= CMD_FIFO_OVRFLOW ;
341
367
val |= MCS_STACK_OVRFLOW ;
342
- iowrite32 (val , gsi -> virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET );
368
+ iowrite32 (val , gsi -> virt + reg_offset (reg ));
369
+
343
370
gsi_irq_type_update (gsi , gsi -> type_enabled_bitmap | GSI_GENERAL );
344
371
}
345
372
346
373
/* Disable all GSI interrupt types */
347
374
static void gsi_irq_disable (struct gsi * gsi )
348
375
{
376
+ const struct reg * reg ;
377
+
349
378
gsi_irq_type_update (gsi , 0 );
350
379
351
380
/* Clear the type-specific interrupt masks set by gsi_irq_enable() */
352
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET );
353
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET );
381
+ reg = gsi_reg (gsi , CNTXT_GSI_IRQ_EN );
382
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
383
+
384
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_EN );
385
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
354
386
}
355
387
356
388
/* Return the virtual address associated with a ring index */
@@ -1120,10 +1152,14 @@ static void gsi_trans_tx_completed(struct gsi_trans *trans)
1120
1152
/* Channel control interrupt handler */
1121
1153
static void gsi_isr_chan_ctrl (struct gsi * gsi )
1122
1154
{
1155
+ const struct reg * reg ;
1123
1156
u32 channel_mask ;
1124
1157
1125
- channel_mask = ioread32 (gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_OFFSET );
1126
- iowrite32 (channel_mask , gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_CLR_OFFSET );
1158
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ );
1159
+ channel_mask = ioread32 (gsi -> virt + reg_offset (reg ));
1160
+
1161
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ_CLR );
1162
+ iowrite32 (channel_mask , gsi -> virt + reg_offset (reg ));
1127
1163
1128
1164
while (channel_mask ) {
1129
1165
u32 channel_id = __ffs (channel_mask );
@@ -1137,10 +1173,14 @@ static void gsi_isr_chan_ctrl(struct gsi *gsi)
1137
1173
/* Event ring control interrupt handler */
1138
1174
static void gsi_isr_evt_ctrl (struct gsi * gsi )
1139
1175
{
1176
+ const struct reg * reg ;
1140
1177
u32 event_mask ;
1141
1178
1142
- event_mask = ioread32 (gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_OFFSET );
1143
- iowrite32 (event_mask , gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET );
1179
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ );
1180
+ event_mask = ioread32 (gsi -> virt + reg_offset (reg ));
1181
+
1182
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ_CLR );
1183
+ iowrite32 (event_mask , gsi -> virt + reg_offset (reg ));
1144
1184
1145
1185
while (event_mask ) {
1146
1186
u32 evt_ring_id = __ffs (event_mask );
@@ -1215,6 +1255,7 @@ static void gsi_isr_glob_err(struct gsi *gsi)
1215
1255
/* Generic EE interrupt handler */
1216
1256
static void gsi_isr_gp_int1 (struct gsi * gsi )
1217
1257
{
1258
+ const struct reg * reg ;
1218
1259
u32 result ;
1219
1260
u32 val ;
1220
1261
@@ -1237,7 +1278,8 @@ static void gsi_isr_gp_int1(struct gsi *gsi)
1237
1278
* In either case, we silently ignore a INCORRECT_CHANNEL_STATE
1238
1279
* error if we receive it.
1239
1280
*/
1240
- val = ioread32 (gsi -> virt + GSI_CNTXT_SCRATCH_0_OFFSET );
1281
+ reg = gsi_reg (gsi , CNTXT_SCRATCH_0 );
1282
+ val = ioread32 (gsi -> virt + reg_offset (reg ));
1241
1283
result = u32_get_bits (val , GENERIC_EE_RESULT_FMASK );
1242
1284
1243
1285
switch (result ) {
@@ -1262,14 +1304,17 @@ static void gsi_isr_gp_int1(struct gsi *gsi)
1262
1304
/* Inter-EE interrupt handler */
1263
1305
static void gsi_isr_glob_ee (struct gsi * gsi )
1264
1306
{
1307
+ const struct reg * reg ;
1265
1308
u32 val ;
1266
1309
1267
- val = ioread32 (gsi -> virt + GSI_CNTXT_GLOB_IRQ_STTS_OFFSET );
1310
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_STTS );
1311
+ val = ioread32 (gsi -> virt + reg_offset (reg ));
1268
1312
1269
1313
if (val & ERROR_INT )
1270
1314
gsi_isr_glob_err (gsi );
1271
1315
1272
- iowrite32 (val , gsi -> virt + GSI_CNTXT_GLOB_IRQ_CLR_OFFSET );
1316
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_CLR );
1317
+ iowrite32 (val , gsi -> virt + reg_offset (reg ));
1273
1318
1274
1319
val &= ~ERROR_INT ;
1275
1320
@@ -1285,11 +1330,16 @@ static void gsi_isr_glob_ee(struct gsi *gsi)
1285
1330
/* I/O completion interrupt event */
1286
1331
static void gsi_isr_ieob (struct gsi * gsi )
1287
1332
{
1333
+ const struct reg * reg ;
1288
1334
u32 event_mask ;
1289
1335
1290
- event_mask = ioread32 (gsi -> virt + GSI_CNTXT_SRC_IEOB_IRQ_OFFSET );
1336
+ reg = gsi_reg (gsi , CNTXT_SRC_IEOB_IRQ );
1337
+ event_mask = ioread32 (gsi -> virt + reg_offset (reg ));
1338
+
1291
1339
gsi_irq_ieob_disable (gsi , event_mask );
1292
- iowrite32 (event_mask , gsi -> virt + GSI_CNTXT_SRC_IEOB_IRQ_CLR_OFFSET );
1340
+
1341
+ reg = gsi_reg (gsi , CNTXT_SRC_IEOB_IRQ_CLR );
1342
+ iowrite32 (event_mask , gsi -> virt + reg_offset (reg ));
1293
1343
1294
1344
while (event_mask ) {
1295
1345
u32 evt_ring_id = __ffs (event_mask );
@@ -1304,10 +1354,14 @@ static void gsi_isr_ieob(struct gsi *gsi)
1304
1354
static void gsi_isr_general (struct gsi * gsi )
1305
1355
{
1306
1356
struct device * dev = gsi -> dev ;
1357
+ const struct reg * reg ;
1307
1358
u32 val ;
1308
1359
1309
- val = ioread32 (gsi -> virt + GSI_CNTXT_GSI_IRQ_STTS_OFFSET );
1310
- iowrite32 (val , gsi -> virt + GSI_CNTXT_GSI_IRQ_CLR_OFFSET );
1360
+ reg = gsi_reg (gsi , CNTXT_GSI_IRQ_STTS );
1361
+ val = ioread32 (gsi -> virt + reg_offset (reg ));
1362
+
1363
+ reg = gsi_reg (gsi , CNTXT_GSI_IRQ_CLR );
1364
+ iowrite32 (val , gsi -> virt + reg_offset (reg ));
1311
1365
1312
1366
dev_err (dev , "unexpected general interrupt 0x%08x\n" , val );
1313
1367
}
@@ -1323,17 +1377,25 @@ static void gsi_isr_general(struct gsi *gsi)
1323
1377
static irqreturn_t gsi_isr (int irq , void * dev_id )
1324
1378
{
1325
1379
struct gsi * gsi = dev_id ;
1380
+ const struct reg * reg ;
1326
1381
u32 intr_mask ;
1327
1382
u32 cnt = 0 ;
1383
+ u32 offset ;
1384
+
1385
+ reg = gsi_reg (gsi , CNTXT_TYPE_IRQ );
1386
+ offset = reg_offset (reg );
1328
1387
1329
1388
/* enum gsi_irq_type_id defines GSI interrupt types */
1330
- while ((intr_mask = ioread32 (gsi -> virt + GSI_CNTXT_TYPE_IRQ_OFFSET ))) {
1389
+ while ((intr_mask = ioread32 (gsi -> virt + offset ))) {
1331
1390
/* intr_mask contains bitmask of pending GSI interrupts */
1332
1391
do {
1333
1392
u32 gsi_intr = BIT (__ffs (intr_mask ));
1334
1393
1335
1394
intr_mask ^= gsi_intr ;
1336
1395
1396
+ /* Note: the IRQ condition for each type is cleared
1397
+ * when the type-specific register is updated.
1398
+ */
1337
1399
switch (gsi_intr ) {
1338
1400
case GSI_CH_CTRL :
1339
1401
gsi_isr_chan_ctrl (gsi );
@@ -1717,7 +1779,9 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
1717
1779
enum gsi_generic_cmd_opcode opcode ,
1718
1780
u8 params )
1719
1781
{
1782
+ const struct reg * reg ;
1720
1783
bool timeout ;
1784
+ u32 offset ;
1721
1785
u32 val ;
1722
1786
1723
1787
/* The error global interrupt type is always enabled (until we tear
@@ -1729,13 +1793,17 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
1729
1793
* channel), and only from this function. So we enable the GP_INT1
1730
1794
* IRQ type here, and disable it again after the command completes.
1731
1795
*/
1796
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_EN );
1732
1797
val = ERROR_INT | GP_INT1 ;
1733
- iowrite32 (val , gsi -> virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET );
1798
+ iowrite32 (val , gsi -> virt + reg_offset ( reg ) );
1734
1799
1735
1800
/* First zero the result code field */
1736
- val = ioread32 (gsi -> virt + GSI_CNTXT_SCRATCH_0_OFFSET );
1801
+ reg = gsi_reg (gsi , CNTXT_SCRATCH_0 );
1802
+ offset = reg_offset (reg );
1803
+ val = ioread32 (gsi -> virt + offset );
1804
+
1737
1805
val &= ~GENERIC_EE_RESULT_FMASK ;
1738
- iowrite32 (val , gsi -> virt + GSI_CNTXT_SCRATCH_0_OFFSET );
1806
+ iowrite32 (val , gsi -> virt + offset );
1739
1807
1740
1808
/* Now issue the command */
1741
1809
val = u32_encode_bits (opcode , GENERIC_OPCODE_FMASK );
@@ -1747,7 +1815,8 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
1747
1815
timeout = !gsi_command (gsi , GSI_GENERIC_CMD_OFFSET , val );
1748
1816
1749
1817
/* Disable the GP_INT1 IRQ type again */
1750
- iowrite32 (ERROR_INT , gsi -> virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET );
1818
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_EN );
1819
+ iowrite32 (ERROR_INT , gsi -> virt + reg_offset (reg ));
1751
1820
1752
1821
if (!timeout )
1753
1822
return gsi -> result ;
@@ -1904,32 +1973,41 @@ static void gsi_channel_teardown(struct gsi *gsi)
1904
1973
/* Turn off all GSI interrupts initially */
1905
1974
static int gsi_irq_setup (struct gsi * gsi )
1906
1975
{
1976
+ const struct reg * reg ;
1907
1977
int ret ;
1908
1978
1909
1979
/* Writing 1 indicates IRQ interrupts; 0 would be MSI */
1910
- iowrite32 (1 , gsi -> virt + GSI_CNTXT_INTSET_OFFSET );
1980
+ reg = gsi_reg (gsi , CNTXT_INTSET );
1981
+ iowrite32 (1 , gsi -> virt + reg_offset (reg ));
1911
1982
1912
1983
/* Disable all interrupt types */
1913
1984
gsi_irq_type_update (gsi , 0 );
1914
1985
1915
1986
/* Clear all type-specific interrupt masks */
1916
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET );
1917
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET );
1918
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET );
1919
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET );
1987
+ reg = gsi_reg (gsi , CNTXT_SRC_CH_IRQ_MSK );
1988
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
1989
+
1990
+ reg = gsi_reg (gsi , CNTXT_SRC_EV_CH_IRQ_MSK );
1991
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
1992
+
1993
+ reg = gsi_reg (gsi , CNTXT_GLOB_IRQ_EN );
1994
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
1995
+
1996
+ reg = gsi_reg (gsi , CNTXT_SRC_IEOB_IRQ_MSK );
1997
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
1920
1998
1921
1999
/* The inter-EE interrupts are not supported for IPA v3.0-v3.1 */
1922
2000
if (gsi -> version > IPA_VERSION_3_1 ) {
1923
- u32 offset ;
1924
-
1925
2001
/* These registers are in the non-adjusted address range */
1926
- offset = GSI_INTER_EE_SRC_CH_IRQ_MSK_OFFSET ;
1927
- iowrite32 (0 , gsi -> virt_raw + offset );
1928
- offset = GSI_INTER_EE_SRC_EV_CH_IRQ_MSK_OFFSET ;
1929
- iowrite32 (0 , gsi -> virt_raw + offset );
2002
+ reg = gsi_reg (gsi , INTER_EE_SRC_CH_IRQ_MSK );
2003
+ iowrite32 (0 , gsi -> virt_raw + reg_offset (reg ));
2004
+
2005
+ reg = gsi_reg (gsi , INTER_EE_SRC_EV_CH_IRQ_MSK );
2006
+ iowrite32 (0 , gsi -> virt_raw + reg_offset (reg ));
1930
2007
}
1931
2008
1932
- iowrite32 (0 , gsi -> virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET );
2009
+ reg = gsi_reg (gsi , CNTXT_GSI_IRQ_EN );
2010
+ iowrite32 (0 , gsi -> virt + reg_offset (reg ));
1933
2011
1934
2012
ret = request_irq (gsi -> irq , gsi_isr , 0 , "gsi" , gsi );
1935
2013
if (ret )
0 commit comments