Commit c5ebba75 authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: use bitmasks for GSI IRQ values

There are seven GSI interrupt types that can be signaled by a single
GSI IRQ.  These are represented in a bitmask, and the gsi_irq_type_id
enumerated type defines what each bit position represents.

Similarly, the global and general GSI interrupt types each has a set
of conditions it signals, and both types have an enumerated type
that defines which bit that represents each condition.

When used, these enumerated values are passed as an argument to BIT()
in *all* cases.  So clean up the code a little bit by defining the
enumerated type values as one-bit masks rather than bit positions.

Rename gsi_general_id to be gsi_general_irq_id for consistency.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d86603e9
...@@ -191,12 +191,12 @@ static void gsi_irq_type_update(struct gsi *gsi, u32 val) ...@@ -191,12 +191,12 @@ static void gsi_irq_type_update(struct gsi *gsi, u32 val)
static void gsi_irq_type_enable(struct gsi *gsi, enum gsi_irq_type_id type_id) static void gsi_irq_type_enable(struct gsi *gsi, enum gsi_irq_type_id type_id)
{ {
gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | BIT(type_id)); gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | type_id);
} }
static void gsi_irq_type_disable(struct gsi *gsi, enum gsi_irq_type_id type_id) static void gsi_irq_type_disable(struct gsi *gsi, enum gsi_irq_type_id type_id)
{ {
gsi_irq_type_update(gsi, gsi->type_enabled_bitmap & ~BIT(type_id)); gsi_irq_type_update(gsi, gsi->type_enabled_bitmap & ~type_id);
} }
/* Event ring commands are performed one at a time. Their completion /* Event ring commands are performed one at a time. Their completion
...@@ -292,19 +292,19 @@ static void gsi_irq_enable(struct gsi *gsi) ...@@ -292,19 +292,19 @@ static void gsi_irq_enable(struct gsi *gsi)
/* Global interrupts include hardware error reports. Enable /* Global interrupts include hardware error reports. Enable
* that so we can at least report the error should it occur. * that so we can at least report the error should it occur.
*/ */
iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(ERROR_INT, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET);
gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | BIT(GSI_GLOB_EE)); gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | GSI_GLOB_EE);
/* General GSI interrupts are reported to all EEs; if they occur /* General GSI interrupts are reported to all EEs; if they occur
* they are unrecoverable (without reset). A breakpoint interrupt * they are unrecoverable (without reset). A breakpoint interrupt
* also exists, but we don't support that. We want to be notified * also exists, but we don't support that. We want to be notified
* of errors so we can report them, even if they can't be handled. * of errors so we can report them, even if they can't be handled.
*/ */
val = BIT(BUS_ERROR); val = BUS_ERROR;
val |= BIT(CMD_FIFO_OVRFLOW); val |= CMD_FIFO_OVRFLOW;
val |= BIT(MCS_STACK_OVRFLOW); val |= MCS_STACK_OVRFLOW;
iowrite32(val, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET); iowrite32(val, gsi->virt + GSI_CNTXT_GSI_IRQ_EN_OFFSET);
gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | BIT(GSI_GENERAL)); gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | GSI_GENERAL);
} }
/* Disable all GSI interrupt types */ /* Disable all GSI interrupt types */
...@@ -1195,15 +1195,15 @@ static void gsi_isr_glob_ee(struct gsi *gsi) ...@@ -1195,15 +1195,15 @@ static void gsi_isr_glob_ee(struct gsi *gsi)
val = ioread32(gsi->virt + GSI_CNTXT_GLOB_IRQ_STTS_OFFSET); val = ioread32(gsi->virt + GSI_CNTXT_GLOB_IRQ_STTS_OFFSET);
if (val & BIT(ERROR_INT)) if (val & ERROR_INT)
gsi_isr_glob_err(gsi); gsi_isr_glob_err(gsi);
iowrite32(val, gsi->virt + GSI_CNTXT_GLOB_IRQ_CLR_OFFSET); iowrite32(val, gsi->virt + GSI_CNTXT_GLOB_IRQ_CLR_OFFSET);
val &= ~BIT(ERROR_INT); val &= ~ERROR_INT;
if (val & BIT(GP_INT1)) { if (val & GP_INT1) {
val ^= BIT(GP_INT1); val ^= GP_INT1;
gsi_isr_gp_int1(gsi); gsi_isr_gp_int1(gsi);
} }
...@@ -1264,19 +1264,19 @@ static irqreturn_t gsi_isr(int irq, void *dev_id) ...@@ -1264,19 +1264,19 @@ static irqreturn_t gsi_isr(int irq, void *dev_id)
intr_mask ^= gsi_intr; intr_mask ^= gsi_intr;
switch (gsi_intr) { switch (gsi_intr) {
case BIT(GSI_CH_CTRL): case GSI_CH_CTRL:
gsi_isr_chan_ctrl(gsi); gsi_isr_chan_ctrl(gsi);
break; break;
case BIT(GSI_EV_CTRL): case GSI_EV_CTRL:
gsi_isr_evt_ctrl(gsi); gsi_isr_evt_ctrl(gsi);
break; break;
case BIT(GSI_GLOB_EE): case GSI_GLOB_EE:
gsi_isr_glob_ee(gsi); gsi_isr_glob_ee(gsi);
break; break;
case BIT(GSI_IEOB): case GSI_IEOB:
gsi_isr_ieob(gsi); gsi_isr_ieob(gsi);
break; break;
case BIT(GSI_GENERAL): case GSI_GENERAL:
gsi_isr_general(gsi); gsi_isr_general(gsi);
break; break;
default: default:
...@@ -1654,7 +1654,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, ...@@ -1654,7 +1654,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
* channel), and only from this function. So we enable the GP_INT1 * channel), and only from this function. So we enable the GP_INT1
* IRQ type here, and disable it again after the command completes. * IRQ type here, and disable it again after the command completes.
*/ */
val = BIT(ERROR_INT) | BIT(GP_INT1); val = ERROR_INT | GP_INT1;
iowrite32(val, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(val, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET);
/* First zero the result code field */ /* First zero the result code field */
...@@ -1672,7 +1672,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, ...@@ -1672,7 +1672,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
timeout = !gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val); timeout = !gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val);
/* Disable the GP_INT1 IRQ type again */ /* Disable the GP_INT1 IRQ type again */
iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(ERROR_INT, gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET);
if (!timeout) if (!timeout)
return gsi->result; return gsi->result;
......
...@@ -299,15 +299,25 @@ enum gsi_iram_size { ...@@ -299,15 +299,25 @@ enum gsi_iram_size {
#define GSI_CNTXT_TYPE_IRQ_MSK_OFFSET \ #define GSI_CNTXT_TYPE_IRQ_MSK_OFFSET \
(0x0001f088 + 0x4000 * GSI_EE_AP) (0x0001f088 + 0x4000 * GSI_EE_AP)
/* Values here are bit positions in the TYPE_IRQ and TYPE_IRQ_MSK registers */ /**
* enum gsi_irq_type_id: GSI IRQ types
* @GSI_CH_CTRL: Channel allocation, deallocation, etc.
* @GSI_EV_CTRL: Event ring allocation, deallocation, etc.
* @GSI_GLOB_EE: Global/general event
* @GSI_IEOB: Transfer (TRE) completion
* @GSI_INTER_EE_CH_CTRL: Remote-issued stop/reset (unused)
* @GSI_INTER_EE_EV_CTRL: Remote-issued event reset (unused)
* @GSI_GENERAL: General hardware event (bus error, etc.)
*/
enum gsi_irq_type_id { enum gsi_irq_type_id {
GSI_CH_CTRL = 0x0, /* channel allocation, etc. */ GSI_CH_CTRL = BIT(0),
GSI_EV_CTRL = 0x1, /* event ring allocation, etc. */ GSI_EV_CTRL = BIT(1),
GSI_GLOB_EE = 0x2, /* global/general event */ GSI_GLOB_EE = BIT(2),
GSI_IEOB = 0x3, /* TRE completion */ GSI_IEOB = BIT(3),
GSI_INTER_EE_CH_CTRL = 0x4, /* remote-issued stop/reset (unused) */ GSI_INTER_EE_CH_CTRL = BIT(4),
GSI_INTER_EE_EV_CTRL = 0x5, /* remote-issued event reset (unused) */ GSI_INTER_EE_EV_CTRL = BIT(5),
GSI_GENERAL = 0x6, /* general-purpose event */ GSI_GENERAL = BIT(6),
/* IRQ types 7-31 (and their bit values) are reserved */
}; };
#define GSI_CNTXT_SRC_CH_IRQ_OFFSET \ #define GSI_CNTXT_SRC_CH_IRQ_OFFSET \
...@@ -343,12 +353,14 @@ enum gsi_irq_type_id { ...@@ -343,12 +353,14 @@ enum gsi_irq_type_id {
(0x0001f108 + 0x4000 * GSI_EE_AP) (0x0001f108 + 0x4000 * GSI_EE_AP)
#define GSI_CNTXT_GLOB_IRQ_CLR_OFFSET \ #define GSI_CNTXT_GLOB_IRQ_CLR_OFFSET \
(0x0001f110 + 0x4000 * GSI_EE_AP) (0x0001f110 + 0x4000 * GSI_EE_AP)
/* Values here are bit positions in the GLOB_IRQ_* registers */
/** enum gsi_global_irq_id: Global GSI interrupt events */
enum gsi_global_irq_id { enum gsi_global_irq_id {
ERROR_INT = 0x0, ERROR_INT = BIT(0),
GP_INT1 = 0x1, GP_INT1 = BIT(1),
GP_INT2 = 0x2, GP_INT2 = BIT(2),
GP_INT3 = 0x3, GP_INT3 = BIT(3),
/* Global IRQ types 4-31 (and their bit values) are reserved */
}; };
#define GSI_CNTXT_GSI_IRQ_STTS_OFFSET \ #define GSI_CNTXT_GSI_IRQ_STTS_OFFSET \
...@@ -357,12 +369,14 @@ enum gsi_global_irq_id { ...@@ -357,12 +369,14 @@ enum gsi_global_irq_id {
(0x0001f120 + 0x4000 * GSI_EE_AP) (0x0001f120 + 0x4000 * GSI_EE_AP)
#define GSI_CNTXT_GSI_IRQ_CLR_OFFSET \ #define GSI_CNTXT_GSI_IRQ_CLR_OFFSET \
(0x0001f128 + 0x4000 * GSI_EE_AP) (0x0001f128 + 0x4000 * GSI_EE_AP)
/* Values here are bit positions in the (general) GSI_IRQ_* registers */
enum gsi_general_id { /** enum gsi_general_irq_id: GSI general IRQ conditions */
BREAK_POINT = 0x0, enum gsi_general_irq_id {
BUS_ERROR = 0x1, BREAK_POINT = BIT(0),
CMD_FIFO_OVRFLOW = 0x2, BUS_ERROR = BIT(1),
MCS_STACK_OVRFLOW = 0x3, CMD_FIFO_OVRFLOW = BIT(2),
MCS_STACK_OVRFLOW = BIT(3),
/* General IRQ types 4-31 (and their bit values) are reserved */
}; };
#define GSI_CNTXT_INTSET_OFFSET \ #define GSI_CNTXT_INTSET_OFFSET \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment