@@ -1120,41 +1120,6 @@ static int byt_gpio_request(struct gpio_chip *chip, unsigned int offset)
1120
1120
return 0 ;
1121
1121
}
1122
1122
1123
- static int byt_irq_type (struct irq_data * d , unsigned type )
1124
- {
1125
- struct byt_gpio * vg = gpiochip_get_data (irq_data_get_irq_chip_data (d ));
1126
- u32 offset = irqd_to_hwirq (d );
1127
- u32 value ;
1128
- unsigned long flags ;
1129
- void __iomem * reg = byt_gpio_reg (vg , offset , BYT_CONF0_REG );
1130
-
1131
- if (offset >= vg -> chip .ngpio )
1132
- return - EINVAL ;
1133
-
1134
- raw_spin_lock_irqsave (& vg -> lock , flags );
1135
- value = readl (reg );
1136
-
1137
- WARN (value & BYT_DIRECT_IRQ_EN ,
1138
- "Bad pad config for io mode, force direct_irq_en bit clearing" );
1139
-
1140
- /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
1141
- * are used to indicate high and low level triggering
1142
- */
1143
- value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG |
1144
- BYT_TRIG_LVL );
1145
-
1146
- writel (value , reg );
1147
-
1148
- if (type & IRQ_TYPE_EDGE_BOTH )
1149
- irq_set_handler_locked (d , handle_edge_irq );
1150
- else if (type & IRQ_TYPE_LEVEL_MASK )
1151
- irq_set_handler_locked (d , handle_level_irq );
1152
-
1153
- raw_spin_unlock_irqrestore (& vg -> lock , flags );
1154
-
1155
- return 0 ;
1156
- }
1157
-
1158
1123
static void byt_get_pull_strength (u32 reg , u16 * strength )
1159
1124
{
1160
1125
switch (reg & BYT_PULL_STR_MASK ) {
@@ -1565,12 +1530,23 @@ static void byt_irq_ack(struct irq_data *d)
1565
1530
unsigned offset = irqd_to_hwirq (d );
1566
1531
void __iomem * reg ;
1567
1532
1568
- raw_spin_lock (& vg -> lock );
1569
1533
reg = byt_gpio_reg (vg , offset , BYT_INT_STAT_REG );
1534
+ if (!reg )
1535
+ return ;
1536
+
1537
+ raw_spin_lock (& vg -> lock );
1570
1538
writel (BIT (offset % 32 ), reg );
1571
1539
raw_spin_unlock (& vg -> lock );
1572
1540
}
1573
1541
1542
+ static void byt_irq_mask (struct irq_data * d )
1543
+ {
1544
+ struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
1545
+ struct byt_gpio * vg = gpiochip_get_data (gc );
1546
+
1547
+ byt_gpio_clear_triggering (vg , irqd_to_hwirq (d ));
1548
+ }
1549
+
1574
1550
static void byt_irq_unmask (struct irq_data * d )
1575
1551
{
1576
1552
struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
@@ -1581,6 +1557,8 @@ static void byt_irq_unmask(struct irq_data *d)
1581
1557
u32 value ;
1582
1558
1583
1559
reg = byt_gpio_reg (vg , offset , BYT_CONF0_REG );
1560
+ if (!reg )
1561
+ return ;
1584
1562
1585
1563
raw_spin_lock_irqsave (& vg -> lock , flags );
1586
1564
value = readl (reg );
@@ -1606,21 +1584,48 @@ static void byt_irq_unmask(struct irq_data *d)
1606
1584
raw_spin_unlock_irqrestore (& vg -> lock , flags );
1607
1585
}
1608
1586
1609
- static void byt_irq_mask (struct irq_data * d )
1587
+ static int byt_irq_type (struct irq_data * d , unsigned int type )
1610
1588
{
1611
- struct gpio_chip * gc = irq_data_get_irq_chip_data (d );
1612
- struct byt_gpio * vg = gpiochip_get_data (gc );
1589
+ struct byt_gpio * vg = gpiochip_get_data (irq_data_get_irq_chip_data (d ));
1590
+ u32 offset = irqd_to_hwirq (d );
1591
+ u32 value ;
1592
+ unsigned long flags ;
1593
+ void __iomem * reg = byt_gpio_reg (vg , offset , BYT_CONF0_REG );
1613
1594
1614
- byt_gpio_clear_triggering (vg , irqd_to_hwirq (d ));
1595
+ if (!reg || offset >= vg -> chip .ngpio )
1596
+ return - EINVAL ;
1597
+
1598
+ raw_spin_lock_irqsave (& vg -> lock , flags );
1599
+ value = readl (reg );
1600
+
1601
+ WARN (value & BYT_DIRECT_IRQ_EN ,
1602
+ "Bad pad config for io mode, force direct_irq_en bit clearing" );
1603
+
1604
+ /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
1605
+ * are used to indicate high and low level triggering
1606
+ */
1607
+ value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG |
1608
+ BYT_TRIG_LVL );
1609
+
1610
+ writel (value , reg );
1611
+
1612
+ if (type & IRQ_TYPE_EDGE_BOTH )
1613
+ irq_set_handler_locked (d , handle_edge_irq );
1614
+ else if (type & IRQ_TYPE_LEVEL_MASK )
1615
+ irq_set_handler_locked (d , handle_level_irq );
1616
+
1617
+ raw_spin_unlock_irqrestore (& vg -> lock , flags );
1618
+
1619
+ return 0 ;
1615
1620
}
1616
1621
1617
1622
static struct irq_chip byt_irqchip = {
1618
- .name = "BYT-GPIO" ,
1619
- .irq_ack = byt_irq_ack ,
1620
- .irq_mask = byt_irq_mask ,
1621
- .irq_unmask = byt_irq_unmask ,
1622
- .irq_set_type = byt_irq_type ,
1623
- .flags = IRQCHIP_SKIP_SET_WAKE ,
1623
+ .name = "BYT-GPIO" ,
1624
+ .irq_ack = byt_irq_ack ,
1625
+ .irq_mask = byt_irq_mask ,
1626
+ .irq_unmask = byt_irq_unmask ,
1627
+ .irq_set_type = byt_irq_type ,
1628
+ .flags = IRQCHIP_SKIP_SET_WAKE ,
1624
1629
};
1625
1630
1626
1631
static void byt_gpio_irq_init_hw (struct byt_gpio * vg )
0 commit comments