|
47 | 47 | /**
|
48 | 48 | * struct sprd_pmic_eic - PMIC EIC controller
|
49 | 49 | * @chip: the gpio_chip structure.
|
50 |
| - * @intc: the irq_chip structure. |
51 | 50 | * @map: the regmap from the parent device.
|
52 | 51 | * @offset: the EIC controller's offset address of the PMIC.
|
53 | 52 | * @reg: the array to cache the EIC registers.
|
|
56 | 55 | */
|
57 | 56 | struct sprd_pmic_eic {
|
58 | 57 | struct gpio_chip chip;
|
59 |
| - struct irq_chip intc; |
60 | 58 | struct regmap *map;
|
61 | 59 | u32 offset;
|
62 | 60 | u8 reg[CACHE_NR_REGS];
|
@@ -151,15 +149,21 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *data)
|
151 | 149 | {
|
152 | 150 | struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
|
153 | 151 | struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
|
| 152 | + u32 offset = irqd_to_hwirq(data); |
154 | 153 |
|
155 | 154 | pmic_eic->reg[REG_IE] = 0;
|
156 | 155 | pmic_eic->reg[REG_TRIG] = 0;
|
| 156 | + |
| 157 | + gpiochip_disable_irq(chip, offset); |
157 | 158 | }
|
158 | 159 |
|
159 | 160 | static void sprd_pmic_eic_irq_unmask(struct irq_data *data)
|
160 | 161 | {
|
161 | 162 | struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
|
162 | 163 | struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
|
| 164 | + u32 offset = irqd_to_hwirq(data); |
| 165 | + |
| 166 | + gpiochip_enable_irq(chip, offset); |
163 | 167 |
|
164 | 168 | pmic_eic->reg[REG_IE] = 1;
|
165 | 169 | pmic_eic->reg[REG_TRIG] = 1;
|
@@ -292,6 +296,17 @@ static irqreturn_t sprd_pmic_eic_irq_handler(int irq, void *data)
|
292 | 296 | return IRQ_HANDLED;
|
293 | 297 | }
|
294 | 298 |
|
| 299 | +static const struct irq_chip pmic_eic_irq_chip = { |
| 300 | + .name = "sprd-pmic-eic", |
| 301 | + .irq_mask = sprd_pmic_eic_irq_mask, |
| 302 | + .irq_unmask = sprd_pmic_eic_irq_unmask, |
| 303 | + .irq_set_type = sprd_pmic_eic_irq_set_type, |
| 304 | + .irq_bus_lock = sprd_pmic_eic_bus_lock, |
| 305 | + .irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock, |
| 306 | + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, |
| 307 | + GPIOCHIP_IRQ_RESOURCE_HELPERS, |
| 308 | +}; |
| 309 | + |
295 | 310 | static int sprd_pmic_eic_probe(struct platform_device *pdev)
|
296 | 311 | {
|
297 | 312 | struct gpio_irq_chip *irq;
|
@@ -338,16 +353,8 @@ static int sprd_pmic_eic_probe(struct platform_device *pdev)
|
338 | 353 | pmic_eic->chip.set = sprd_pmic_eic_set;
|
339 | 354 | pmic_eic->chip.get = sprd_pmic_eic_get;
|
340 | 355 |
|
341 |
| - pmic_eic->intc.name = dev_name(&pdev->dev); |
342 |
| - pmic_eic->intc.irq_mask = sprd_pmic_eic_irq_mask; |
343 |
| - pmic_eic->intc.irq_unmask = sprd_pmic_eic_irq_unmask; |
344 |
| - pmic_eic->intc.irq_set_type = sprd_pmic_eic_irq_set_type; |
345 |
| - pmic_eic->intc.irq_bus_lock = sprd_pmic_eic_bus_lock; |
346 |
| - pmic_eic->intc.irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock; |
347 |
| - pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE; |
348 |
| - |
349 | 356 | irq = &pmic_eic->chip.irq;
|
350 |
| - irq->chip = &pmic_eic->intc; |
| 357 | + gpio_irq_chip_set_chip(irq, &pmic_eic_irq_chip); |
351 | 358 | irq->threaded = true;
|
352 | 359 |
|
353 | 360 | ret = devm_gpiochip_add_data(&pdev->dev, &pmic_eic->chip, pmic_eic);
|
|
0 commit comments