Skip to content

Commit 40899ac

Browse files
LaurentiuM1234mmahadevan108
authored andcommitted
drivers: irqsteer: adjust CHn_MASK index computation
For IRQ_STEER, lower CHn_MASK register indexes are used to mask higher interrupt IDs. For instance, in the case of i.MX8MP, the mapping is as follows: CHn_MASK4 => masks interrupts [31:0] CHn_MASK3 => masks interrupts [63:32] CHn_MASK2 => masks interrupts [95:64] CHn_MASK1 => masks interrupts [127:96] CHn_MASK0 => masks interrupts [159:128] The `IRQSTEER_GetRegIndex()` function is used to fetch the CHn_MASK register index based on a given slice. The term "slice" is used to refer to an index of a CHn_MASK register in the set of CHn_MASK registers assigned to a certain master. Assuming the following partition scheme (i.MX8MP): { CHn_MASK4 } is assigned to MASTER0 { CHn_MASK3, CHn_MASK2 } is assigned to MASTER1 { CHn_MASK1, CHn_MASK0 } is assiged to MASTER2 CHn_MASK3 would be at slice (index) 0, CHn_MASK2 would be at slice 1, CHn_MASK1 would be at slice 0 and so on. To compute the CHn_MASK register index found at a given slice, `IRQSTEER_GetRegIndex()` uses a base index, which is either the lowest or the highest CHn_MASK register index in a master's partition (for instance, for MASTER1 the higher would be 3 and the lowest would be 2). For IRQ_STEER instances with an uneven number of CHn_MASK registers the base is the lowest index, while in the case of instances with an even number of CHn_MASK registers it's exactly the opposite. This is an issue because the software using this function might expect the base to either be the lowest or the highest index ALL THE TIME (since this affects the order in which the CHn_MASK register indexes are returned). As such, fix this problem by making the base the highest CHn_MASK register index. Signed-off-by: Laurentiu Mihalcea <[email protected]>
1 parent 4f863ba commit 40899ac

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mcux/mcux-sdk-ng/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ Patch List:
4545
- drivers/s3mu/fsl_s3mu.c: rename _BIT macro to avoid collision from util_macro.h in Zephyr
4646
- drivers/adc12/fsl_adc12.c: add guards to avoid compilation warnings when building
4747
with SDK clock control driver disabled.
48+
- drivers: irqsteer: adjust CHn_MASK index computation

mcux/mcux-sdk-ng/drivers/irqsteer/fsl_irqsteer.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,17 @@ uint32_t IRQSTEER_GetMasterIrqCount(IRQSTEER_Type *base, irqsteer_int_master_t i
171171
return count;
172172
}
173173

174-
static uint32_t IRQSTEER_GetRegIndex(irqsteer_int_master_t intMasterIndex, uint32_t slice)
174+
static uint32_t IRQSTEER_GetRegIndex(irqsteer_int_master_t intMasterIndex,
175+
uint32_t slice, uint32_t sliceNum)
175176
{
176177
uint32_t base = (uint32_t)FSL_FEATURE_IRQSTEER_CHn_MASK_COUNT - 1u - ((uint32_t)intMasterIndex * 2u);
177178

178179
if (0u != ((uint32_t)FSL_FEATURE_IRQSTEER_CHn_MASK_COUNT % 2u))
179180
{
180-
return base + slice;
181-
}
182-
else
183-
{
184-
return base - slice;
181+
base += sliceNum - 1;
185182
}
183+
184+
return base - slice;
186185
}
187186

188187
/*!
@@ -231,7 +230,7 @@ IRQn_Type IRQSTEER_GetMasterNextInterrupt(IRQSTEER_Type *base, irqsteer_int_mast
231230
bitOffset = 0;
232231

233232
/* compute the index of the register to be queried */
234-
regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i);
233+
regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i, sliceNum + 1);
235234

236235
/* get register's value */
237236
chanStatus = base->CHn_STATUS[regIndex];
@@ -261,7 +260,7 @@ uint64_t IRQSTEER_GetMasterInterruptsStatus(IRQSTEER_Type *base, irqsteer_int_ma
261260
sliceNum = IRQSTEER_GetMasterIrqCount(base, intMasterIndex) / 32u - 1u;
262261

263262
for (i = 0; i <= sliceNum; i++) {
264-
regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i);
263+
regIndex = IRQSTEER_GetRegIndex(intMasterIndex, i, sliceNum + 1);
265264

266265
chanStatus = base->CHn_STATUS[regIndex];
267266

0 commit comments

Comments
 (0)