39
39
40
40
#define GNR_CFG_DW_HOSTSW_MODE BIT(27)
41
41
#define GNR_CFG_DW_RX_MASK GENMASK(23, 22)
42
+ #define GNR_CFG_DW_INTSEL_MASK GENMASK(21, 14)
42
43
#define GNR_CFG_DW_RX_DISABLE FIELD_PREP(GNR_CFG_DW_RX_MASK, 2)
43
44
#define GNR_CFG_DW_RX_EDGE FIELD_PREP(GNR_CFG_DW_RX_MASK, 1)
44
45
#define GNR_CFG_DW_RX_LEVEL FIELD_PREP(GNR_CFG_DW_RX_MASK, 0)
@@ -227,10 +228,18 @@ static void gnr_gpio_irq_unmask(struct irq_data *d)
227
228
static int gnr_gpio_irq_set_type (struct irq_data * d , unsigned int type )
228
229
{
229
230
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
230
- irq_hw_number_t pin = irqd_to_hwirq (d );
231
- u32 mask = GNR_CFG_DW_RX_MASK ;
231
+ struct gnr_gpio * priv = gpiochip_get_data (gc );
232
+ irq_hw_number_t hwirq = irqd_to_hwirq (d );
233
+ u32 reg ;
232
234
u32 set ;
233
235
236
+ /* Allow interrupts only if Interrupt Select field is non-zero */
237
+ reg = readl (gnr_gpio_get_padcfg_addr (priv , hwirq ));
238
+ if (!(reg & GNR_CFG_DW_INTSEL_MASK )) {
239
+ dev_dbg (gc -> parent , "GPIO %lu cannot be used as IRQ" , hwirq );
240
+ return - EPERM ;
241
+ }
242
+
234
243
/* Falling edge and level low triggers not supported by the GPIO controller */
235
244
switch (type ) {
236
245
case IRQ_TYPE_NONE :
@@ -248,7 +257,7 @@ static int gnr_gpio_irq_set_type(struct irq_data *d, unsigned int type)
248
257
return - EINVAL ;
249
258
}
250
259
251
- return gnr_gpio_configure_line (gc , pin , mask , set );
260
+ return gnr_gpio_configure_line (gc , hwirq , GNR_CFG_DW_RX_MASK , set );
252
261
}
253
262
254
263
static const struct irq_chip gnr_gpio_irq_chip = {
0 commit comments