Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'irq/gpio-immutable' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into intel/pinctrl

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

+293 -90
+142 -33
Documentation/driver-api/gpio/driver.rst
··· 417 417 If you do this, the additional irq_chip will be set up by gpiolib at the 418 418 same time as setting up the rest of the GPIO functionality. The following 419 419 is a typical example of a chained cascaded interrupt handler using 420 - the gpio_irq_chip: 420 + the gpio_irq_chip. Note how the mask/unmask (or disable/enable) functions 421 + call into the core gpiolib code: 421 422 422 423 .. code-block:: c 423 424 424 - /* Typical state container with dynamic irqchip */ 425 + /* Typical state container */ 425 426 struct my_gpio { 426 427 struct gpio_chip gc; 427 - struct irq_chip irq; 428 + }; 429 + 430 + static void my_gpio_mask_irq(struct irq_data *d) 431 + { 432 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 433 + 434 + /* 435 + * Perform any necessary action to mask the interrupt, 436 + * and then call into the core code to synchronise the 437 + * state. 438 + */ 439 + 440 + gpiochip_disable_irq(gc, d->hwirq); 441 + } 442 + 443 + static void my_gpio_unmask_irq(struct irq_data *d) 444 + { 445 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 446 + 447 + gpiochip_enable_irq(gc, d->hwirq); 448 + 449 + /* 450 + * Perform any necessary action to unmask the interrupt, 451 + * after having called into the core code to synchronise 452 + * the state. 453 + */ 454 + } 455 + 456 + /* 457 + * Statically populate the irqchip. Note that it is made const 458 + * (further indicated by the IRQCHIP_IMMUTABLE flag), and that 459 + * the GPIOCHIP_IRQ_RESOURCE_HELPER macro adds some extra 460 + * callbacks to the structure. 461 + */ 462 + static const struct irq_chip my_gpio_irq_chip = { 463 + .name = "my_gpio_irq", 464 + .irq_ack = my_gpio_ack_irq, 465 + .irq_mask = my_gpio_mask_irq, 466 + .irq_unmask = my_gpio_unmask_irq, 467 + .irq_set_type = my_gpio_set_irq_type, 468 + .flags = IRQCHIP_IMMUTABLE, 469 + /* Provide the gpio resource callbacks */ 470 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 428 471 }; 429 472 430 473 int irq; /* from platform etc */ 431 474 struct my_gpio *g; 432 475 struct gpio_irq_chip *girq; 433 476 434 - /* Set up the irqchip dynamically */ 435 - g->irq.name = "my_gpio_irq"; 436 - g->irq.irq_ack = my_gpio_ack_irq; 437 - g->irq.irq_mask = my_gpio_mask_irq; 438 - g->irq.irq_unmask = my_gpio_unmask_irq; 439 - g->irq.irq_set_type = my_gpio_set_irq_type; 440 - 441 477 /* Get a pointer to the gpio_irq_chip */ 442 478 girq = &g->gc.irq; 443 - girq->chip = &g->irq; 479 + gpio_irq_chip_set_chip(girq, &my_gpio_irq_chip); 444 480 girq->parent_handler = ftgpio_gpio_irq_handler; 445 481 girq->num_parents = 1; 446 482 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), ··· 494 458 495 459 .. code-block:: c 496 460 497 - /* Typical state container with dynamic irqchip */ 461 + /* Typical state container */ 498 462 struct my_gpio { 499 463 struct gpio_chip gc; 500 - struct irq_chip irq; 464 + }; 465 + 466 + static void my_gpio_mask_irq(struct irq_data *d) 467 + { 468 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 469 + 470 + /* 471 + * Perform any necessary action to mask the interrupt, 472 + * and then call into the core code to synchronise the 473 + * state. 474 + */ 475 + 476 + gpiochip_disable_irq(gc, d->hwirq); 477 + } 478 + 479 + static void my_gpio_unmask_irq(struct irq_data *d) 480 + { 481 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 482 + 483 + gpiochip_enable_irq(gc, d->hwirq); 484 + 485 + /* 486 + * Perform any necessary action to unmask the interrupt, 487 + * after having called into the core code to synchronise 488 + * the state. 489 + */ 490 + } 491 + 492 + /* 493 + * Statically populate the irqchip. Note that it is made const 494 + * (further indicated by the IRQCHIP_IMMUTABLE flag), and that 495 + * the GPIOCHIP_IRQ_RESOURCE_HELPER macro adds some extra 496 + * callbacks to the structure. 497 + */ 498 + static const struct irq_chip my_gpio_irq_chip = { 499 + .name = "my_gpio_irq", 500 + .irq_ack = my_gpio_ack_irq, 501 + .irq_mask = my_gpio_mask_irq, 502 + .irq_unmask = my_gpio_unmask_irq, 503 + .irq_set_type = my_gpio_set_irq_type, 504 + .flags = IRQCHIP_IMMUTABLE, 505 + /* Provide the gpio resource callbacks */ 506 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 501 507 }; 502 508 503 509 int irq; /* from platform etc */ 504 510 struct my_gpio *g; 505 511 struct gpio_irq_chip *girq; 506 - 507 - /* Set up the irqchip dynamically */ 508 - g->irq.name = "my_gpio_irq"; 509 - g->irq.irq_ack = my_gpio_ack_irq; 510 - g->irq.irq_mask = my_gpio_mask_irq; 511 - g->irq.irq_unmask = my_gpio_unmask_irq; 512 - g->irq.irq_set_type = my_gpio_set_irq_type; 513 512 514 513 ret = devm_request_threaded_irq(dev, irq, NULL, 515 514 irq_thread_fn, IRQF_ONESHOT, "my-chip", g); ··· 553 482 554 483 /* Get a pointer to the gpio_irq_chip */ 555 484 girq = &g->gc.irq; 556 - girq->chip = &g->irq; 485 + gpio_irq_chip_set_chip(girq, &my_gpio_irq_chip); 557 486 /* This will let us handle the parent IRQ in the driver */ 558 487 girq->parent_handler = NULL; 559 488 girq->num_parents = 0; ··· 571 500 /* Typical state container with dynamic irqchip */ 572 501 struct my_gpio { 573 502 struct gpio_chip gc; 574 - struct irq_chip irq; 575 503 struct fwnode_handle *fwnode; 576 504 }; 577 505 578 - int irq; /* from platform etc */ 506 + static void my_gpio_mask_irq(struct irq_data *d) 507 + { 508 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 509 + 510 + /* 511 + * Perform any necessary action to mask the interrupt, 512 + * and then call into the core code to synchronise the 513 + * state. 514 + */ 515 + 516 + gpiochip_disable_irq(gc, d->hwirq); 517 + irq_mask_mask_parent(d); 518 + } 519 + 520 + static void my_gpio_unmask_irq(struct irq_data *d) 521 + { 522 + struct gpio_chip *gc = irq_desc_get_handler_data(d); 523 + 524 + gpiochip_enable_irq(gc, d->hwirq); 525 + 526 + /* 527 + * Perform any necessary action to unmask the interrupt, 528 + * after having called into the core code to synchronise 529 + * the state. 530 + */ 531 + 532 + irq_mask_unmask_parent(d); 533 + } 534 + 535 + /* 536 + * Statically populate the irqchip. Note that it is made const 537 + * (further indicated by the IRQCHIP_IMMUTABLE flag), and that 538 + * the GPIOCHIP_IRQ_RESOURCE_HELPER macro adds some extra 539 + * callbacks to the structure. 540 + */ 541 + static const struct irq_chip my_gpio_irq_chip = { 542 + .name = "my_gpio_irq", 543 + .irq_ack = my_gpio_ack_irq, 544 + .irq_mask = my_gpio_mask_irq, 545 + .irq_unmask = my_gpio_unmask_irq, 546 + .irq_set_type = my_gpio_set_irq_type, 547 + .flags = IRQCHIP_IMMUTABLE, 548 + /* Provide the gpio resource callbacks */ 549 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 550 + }; 551 + 579 552 struct my_gpio *g; 580 553 struct gpio_irq_chip *girq; 581 554 582 - /* Set up the irqchip dynamically */ 583 - g->irq.name = "my_gpio_irq"; 584 - g->irq.irq_ack = my_gpio_ack_irq; 585 - g->irq.irq_mask = my_gpio_mask_irq; 586 - g->irq.irq_unmask = my_gpio_unmask_irq; 587 - g->irq.irq_set_type = my_gpio_set_irq_type; 588 - 589 555 /* Get a pointer to the gpio_irq_chip */ 590 556 girq = &g->gc.irq; 591 - girq->chip = &g->irq; 557 + gpio_irq_chip_set_chip(girq, &my_gpio_irq_chip); 592 558 girq->default_type = IRQ_TYPE_NONE; 593 559 girq->handler = handle_bad_irq; 594 560 girq->fwnode = g->fwnode; ··· 713 605 typically be called in the .irq_disable() and .irq_enable() callbacks from the 714 606 irqchip. 715 607 716 - When using the gpiolib irqchip helpers, these callbacks are automatically 717 - assigned. 608 + When IRQCHIP_IMMUTABLE is not advertised by the irqchip, these callbacks 609 + are automatically assigned. This behaviour is deprecated and on its way 610 + to be removed from the kernel. 718 611 719 612 720 613 Real-Time compliance for GPIO IRQ chips
+19
drivers/gpio/TODO
··· 178 178 for debugging and hacking and to expose all lines without the 179 179 need of any exporting. Also provide ample ammunition to shoot 180 180 oneself in the foot, because this is debugfs after all. 181 + 182 + 183 + Moving over to immutable irq_chip structures 184 + 185 + Most of the gpio chips implementing interrupt support rely on gpiolib 186 + intercepting some of the irq_chip callbacks, preventing the structures 187 + from being made read-only and forcing duplication of structures that 188 + should otherwise be unique. 189 + 190 + The solution is to call into the gpiolib code when needed (resource 191 + management, enable/disable or unmask/mask callbacks), and to let the 192 + core code know about that by exposing a flag (IRQCHIP_IMMUTABLE) in 193 + the irq_chip structure. The irq_chip structure can then be made unique 194 + and const. 195 + 196 + A small number of drivers have been converted (pl061, tegra186, msm, 197 + amd, apple), and can be used as examples of how to proceed with this 198 + conversion. Note that drivers using the generic irqchip framework 199 + cannot be converted yet, but watch this space!
+23 -9
drivers/gpio/gpio-pl061.c
··· 52 52 53 53 void __iomem *base; 54 54 struct gpio_chip gc; 55 - struct irq_chip irq_chip; 56 55 int parent_irq; 57 56 58 57 #ifdef CONFIG_PM ··· 240 241 gpioie = readb(pl061->base + GPIOIE) & ~mask; 241 242 writeb(gpioie, pl061->base + GPIOIE); 242 243 raw_spin_unlock(&pl061->lock); 244 + 245 + gpiochip_disable_irq(gc, d->hwirq); 243 246 } 244 247 245 248 static void pl061_irq_unmask(struct irq_data *d) ··· 250 249 struct pl061 *pl061 = gpiochip_get_data(gc); 251 250 u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); 252 251 u8 gpioie; 252 + 253 + gpiochip_enable_irq(gc, d->hwirq); 253 254 254 255 raw_spin_lock(&pl061->lock); 255 256 gpioie = readb(pl061->base + GPIOIE) | mask; ··· 286 283 return irq_set_irq_wake(pl061->parent_irq, state); 287 284 } 288 285 286 + static void pl061_irq_print_chip(struct irq_data *data, struct seq_file *p) 287 + { 288 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 289 + 290 + seq_printf(p, dev_name(gc->parent)); 291 + } 292 + 293 + static const struct irq_chip pl061_irq_chip = { 294 + .irq_ack = pl061_irq_ack, 295 + .irq_mask = pl061_irq_mask, 296 + .irq_unmask = pl061_irq_unmask, 297 + .irq_set_type = pl061_irq_type, 298 + .irq_set_wake = pl061_irq_set_wake, 299 + .irq_print_chip = pl061_irq_print_chip, 300 + .flags = IRQCHIP_IMMUTABLE, 301 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 302 + }; 303 + 289 304 static int pl061_probe(struct amba_device *adev, const struct amba_id *id) 290 305 { 291 306 struct device *dev = &adev->dev; ··· 336 315 /* 337 316 * irq_chip support 338 317 */ 339 - pl061->irq_chip.name = dev_name(dev); 340 - pl061->irq_chip.irq_ack = pl061_irq_ack; 341 - pl061->irq_chip.irq_mask = pl061_irq_mask; 342 - pl061->irq_chip.irq_unmask = pl061_irq_unmask; 343 - pl061->irq_chip.irq_set_type = pl061_irq_type; 344 - pl061->irq_chip.irq_set_wake = pl061_irq_set_wake; 345 - 346 318 writeb(0, pl061->base + GPIOIE); /* disable irqs */ 347 319 irq = adev->irq[0]; 348 320 if (!irq) ··· 343 329 pl061->parent_irq = irq; 344 330 345 331 girq = &pl061->gc.irq; 346 - girq->chip = &pl061->irq_chip; 332 + gpio_irq_chip_set_chip(girq, &pl061_irq_chip); 347 333 girq->parent_handler = pl061_irq_handler; 348 334 girq->num_parents = 1; 349 335 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
+23 -9
drivers/gpio/gpio-tegra186.c
··· 80 80 81 81 struct tegra_gpio { 82 82 struct gpio_chip gpio; 83 - struct irq_chip intc; 84 83 unsigned int num_irq; 85 84 unsigned int *irq; 86 85 ··· 371 372 value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG); 372 373 value &= ~TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT; 373 374 writel(value, base + TEGRA186_GPIO_ENABLE_CONFIG); 375 + 376 + gpiochip_disable_irq(&gpio->gpio, data->hwirq); 374 377 } 375 378 376 379 static void tegra186_irq_unmask(struct irq_data *data) ··· 385 384 base = tegra186_gpio_get_base(gpio, data->hwirq); 386 385 if (WARN_ON(base == NULL)) 387 386 return; 387 + 388 + gpiochip_enable_irq(&gpio->gpio, data->hwirq); 388 389 389 390 value = readl(base + TEGRA186_GPIO_ENABLE_CONFIG); 390 391 value |= TEGRA186_GPIO_ENABLE_CONFIG_INTERRUPT; ··· 458 455 459 456 return 0; 460 457 } 458 + 459 + static void tegra186_irq_print_chip(struct irq_data *data, struct seq_file *p) 460 + { 461 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 462 + 463 + seq_printf(p, dev_name(gc->parent)); 464 + } 465 + 466 + static const struct irq_chip tegra186_gpio_irq_chip = { 467 + .irq_ack = tegra186_irq_ack, 468 + .irq_mask = tegra186_irq_mask, 469 + .irq_unmask = tegra186_irq_unmask, 470 + .irq_set_type = tegra186_irq_set_type, 471 + .irq_set_wake = tegra186_irq_set_wake, 472 + .irq_print_chip = tegra186_irq_print_chip, 473 + .flags = IRQCHIP_IMMUTABLE, 474 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 475 + }; 461 476 462 477 static void tegra186_gpio_irq(struct irq_desc *desc) 463 478 { ··· 781 760 gpio->gpio.of_xlate = tegra186_gpio_of_xlate; 782 761 #endif /* CONFIG_OF_GPIO */ 783 762 784 - gpio->intc.name = dev_name(&pdev->dev); 785 - gpio->intc.irq_ack = tegra186_irq_ack; 786 - gpio->intc.irq_mask = tegra186_irq_mask; 787 - gpio->intc.irq_unmask = tegra186_irq_unmask; 788 - gpio->intc.irq_set_type = tegra186_irq_set_type; 789 - gpio->intc.irq_set_wake = tegra186_irq_set_wake; 790 - 791 763 irq = &gpio->gpio.irq; 792 - irq->chip = &gpio->intc; 764 + gpio_irq_chip_set_chip(irq, &tegra186_gpio_irq_chip); 793 765 irq->fwnode = of_node_to_fwnode(pdev->dev.of_node); 794 766 irq->child_to_parent_hwirq = tegra186_gpio_child_to_parent_hwirq; 795 767 irq->populate_parent_alloc_arg = tegra186_gpio_populate_parent_fwspec;
+10 -3
drivers/gpio/gpiolib.c
··· 1423 1423 return irq_create_mapping(domain, offset); 1424 1424 } 1425 1425 1426 - static int gpiochip_irq_reqres(struct irq_data *d) 1426 + int gpiochip_irq_reqres(struct irq_data *d) 1427 1427 { 1428 1428 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1429 1429 1430 1430 return gpiochip_reqres_irq(gc, d->hwirq); 1431 1431 } 1432 + EXPORT_SYMBOL(gpiochip_irq_reqres); 1432 1433 1433 - static void gpiochip_irq_relres(struct irq_data *d) 1434 + void gpiochip_irq_relres(struct irq_data *d) 1434 1435 { 1435 1436 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1436 1437 1437 1438 gpiochip_relres_irq(gc, d->hwirq); 1438 1439 } 1440 + EXPORT_SYMBOL(gpiochip_irq_relres); 1439 1441 1440 1442 static void gpiochip_irq_mask(struct irq_data *d) 1441 1443 { ··· 1476 1474 static void gpiochip_set_irq_hooks(struct gpio_chip *gc) 1477 1475 { 1478 1476 struct irq_chip *irqchip = gc->irq.chip; 1477 + 1478 + if (irqchip->flags & IRQCHIP_IMMUTABLE) 1479 + return; 1480 + 1481 + chip_warn(gc, "not an immutable chip, please consider fixing it!\n"); 1479 1482 1480 1483 if (!irqchip->irq_request_resources && 1481 1484 !irqchip->irq_release_resources) { ··· 1640 1633 irq_domain_remove(gc->irq.domain); 1641 1634 } 1642 1635 1643 - if (irqchip) { 1636 + if (irqchip && !(irqchip->flags & IRQCHIP_IMMUTABLE)) { 1644 1637 if (irqchip->irq_request_resources == gpiochip_irq_reqres) { 1645 1638 irqchip->irq_request_resources = NULL; 1646 1639 irqchip->irq_release_resources = NULL;
+8 -3
drivers/pinctrl/pinctrl-amd.c
··· 387 387 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 388 388 struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 389 389 390 + gpiochip_enable_irq(gc, d->hwirq); 391 + 390 392 raw_spin_lock_irqsave(&gpio_dev->lock, flags); 391 393 pin_reg = readl(gpio_dev->base + (d->hwirq)*4); 392 394 pin_reg |= BIT(INTERRUPT_ENABLE_OFF); ··· 410 408 pin_reg &= ~BIT(INTERRUPT_MASK_OFF); 411 409 writel(pin_reg, gpio_dev->base + (d->hwirq)*4); 412 410 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 411 + 412 + gpiochip_disable_irq(gc, d->hwirq); 413 413 } 414 414 415 415 static void amd_gpio_irq_mask(struct irq_data *d) ··· 581 577 */ 582 578 } 583 579 584 - static struct irq_chip amd_gpio_irqchip = { 580 + static const struct irq_chip amd_gpio_irqchip = { 585 581 .name = "amd_gpio", 586 582 .irq_ack = amd_irq_ack, 587 583 .irq_enable = amd_gpio_irq_enable, ··· 597 593 * the wake event. Otherwise the wake event will never clear and 598 594 * prevent the system from suspending. 599 595 */ 600 - .flags = IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND, 596 + .flags = IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND | IRQCHIP_IMMUTABLE, 597 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 601 598 }; 602 599 603 600 #define PIN_IRQ_PENDING (BIT(INTERRUPT_STS_OFF) | BIT(WAKE_STS_OFF)) ··· 1031 1026 amd_gpio_irq_init(gpio_dev); 1032 1027 1033 1028 girq = &gpio_dev->gc.irq; 1034 - girq->chip = &amd_gpio_irqchip; 1029 + gpio_irq_chip_set_chip(girq, &amd_gpio_irqchip); 1035 1030 /* This will let us handle the parent IRQ in the driver */ 1036 1031 girq->parent_handler = NULL; 1037 1032 girq->num_parents = 0;
+16 -13
drivers/pinctrl/pinctrl-apple-gpio.c
··· 36 36 37 37 struct pinctrl_desc pinctrl_desc; 38 38 struct gpio_chip gpio_chip; 39 - struct irq_chip irq_chip; 40 39 u8 irqgrps[]; 41 40 }; 42 41 ··· 274 275 275 276 static void apple_gpio_irq_mask(struct irq_data *data) 276 277 { 277 - struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data)); 278 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 279 + struct apple_gpio_pinctrl *pctl = gpiochip_get_data(gc); 278 280 279 281 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE, 280 282 FIELD_PREP(REG_GPIOx_MODE, REG_GPIOx_IN_IRQ_OFF)); 283 + gpiochip_disable_irq(gc, data->hwirq); 281 284 } 282 285 283 286 static void apple_gpio_irq_unmask(struct irq_data *data) 284 287 { 285 - struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data)); 288 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 289 + struct apple_gpio_pinctrl *pctl = gpiochip_get_data(gc); 286 290 unsigned int irqtype = apple_gpio_irq_type(irqd_get_trigger_type(data)); 287 291 292 + gpiochip_enable_irq(gc, data->hwirq); 288 293 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE, 289 294 FIELD_PREP(REG_GPIOx_MODE, irqtype)); 290 295 } ··· 346 343 chained_irq_exit(chip, desc); 347 344 } 348 345 349 - static struct irq_chip apple_gpio_irqchip = { 350 - .name = "Apple-GPIO", 351 - .irq_startup = apple_gpio_irq_startup, 352 - .irq_ack = apple_gpio_irq_ack, 353 - .irq_mask = apple_gpio_irq_mask, 354 - .irq_unmask = apple_gpio_irq_unmask, 355 - .irq_set_type = apple_gpio_irq_set_type, 346 + static const struct irq_chip apple_gpio_irqchip = { 347 + .name = "Apple-GPIO", 348 + .irq_startup = apple_gpio_irq_startup, 349 + .irq_ack = apple_gpio_irq_ack, 350 + .irq_mask = apple_gpio_irq_mask, 351 + .irq_unmask = apple_gpio_irq_unmask, 352 + .irq_set_type = apple_gpio_irq_set_type, 353 + .flags = IRQCHIP_IMMUTABLE, 354 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 356 355 }; 357 356 358 357 /* Probe & register */ ··· 364 359 struct gpio_irq_chip *girq = &pctl->gpio_chip.irq; 365 360 void **irq_data = NULL; 366 361 int ret; 367 - 368 - pctl->irq_chip = apple_gpio_irqchip; 369 362 370 363 pctl->gpio_chip.label = dev_name(pctl->dev); 371 364 pctl->gpio_chip.request = gpiochip_generic_request; ··· 380 377 if (girq->num_parents) { 381 378 int i; 382 379 383 - girq->chip = &pctl->irq_chip; 380 + gpio_irq_chip_set_chip(girq, &apple_gpio_irqchip); 384 381 girq->parent_handler = apple_gpio_irq_handler; 385 382 386 383 girq->parents = kmalloc_array(girq->num_parents,
+33 -20
drivers/pinctrl/qcom/pinctrl-msm.c
··· 42 42 * @chip: gpiochip handle. 43 43 * @desc: pin controller descriptor 44 44 * @restart_nb: restart notifier block. 45 - * @irq_chip: irq chip information 46 45 * @irq: parent irq for the TLMM irq_chip. 47 46 * @intr_target_use_scm: route irq to application cpu using scm calls 48 47 * @lock: Spinlock to protect register resources as well ··· 62 63 struct pinctrl_desc desc; 63 64 struct notifier_block restart_nb; 64 65 65 - struct irq_chip irq_chip; 66 66 int irq; 67 67 68 68 bool intr_target_use_scm; ··· 866 868 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 867 869 struct msm_pinctrl *pctrl = gpiochip_get_data(gc); 868 870 871 + gpiochip_enable_irq(gc, d->hwirq); 872 + 869 873 if (d->parent_data) 870 874 irq_chip_enable_parent(d); 871 875 ··· 885 885 886 886 if (!test_bit(d->hwirq, pctrl->skip_wake_irqs)) 887 887 msm_gpio_irq_mask(d); 888 + 889 + gpiochip_disable_irq(gc, d->hwirq); 888 890 } 889 891 890 892 /** ··· 958 956 msm_gpio_update_dual_edge_pos(pctrl, g, d); 959 957 960 958 raw_spin_unlock_irqrestore(&pctrl->lock, flags); 959 + } 960 + 961 + static void msm_gpio_irq_eoi(struct irq_data *d) 962 + { 963 + d = d->parent_data; 964 + 965 + if (d) 966 + d->chip->irq_eoi(d); 961 967 } 962 968 963 969 static bool msm_gpio_needs_dual_edge_parent_workaround(struct irq_data *d, ··· 1265 1255 return device_property_count_u16(pctrl->dev, "gpios") > 0; 1266 1256 } 1267 1257 1258 + static const struct irq_chip msm_gpio_irq_chip = { 1259 + .name = "msmgpio", 1260 + .irq_enable = msm_gpio_irq_enable, 1261 + .irq_disable = msm_gpio_irq_disable, 1262 + .irq_mask = msm_gpio_irq_mask, 1263 + .irq_unmask = msm_gpio_irq_unmask, 1264 + .irq_ack = msm_gpio_irq_ack, 1265 + .irq_eoi = msm_gpio_irq_eoi, 1266 + .irq_set_type = msm_gpio_irq_set_type, 1267 + .irq_set_wake = msm_gpio_irq_set_wake, 1268 + .irq_request_resources = msm_gpio_irq_reqres, 1269 + .irq_release_resources = msm_gpio_irq_relres, 1270 + .irq_set_affinity = msm_gpio_irq_set_affinity, 1271 + .irq_set_vcpu_affinity = msm_gpio_irq_set_vcpu_affinity, 1272 + .flags = (IRQCHIP_MASK_ON_SUSPEND | 1273 + IRQCHIP_SET_TYPE_MASKED | 1274 + IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND | 1275 + IRQCHIP_IMMUTABLE), 1276 + }; 1277 + 1268 1278 static int msm_gpio_init(struct msm_pinctrl *pctrl) 1269 1279 { 1270 1280 struct gpio_chip *chip; ··· 1306 1276 if (msm_gpio_needs_valid_mask(pctrl)) 1307 1277 chip->init_valid_mask = msm_gpio_init_valid_mask; 1308 1278 1309 - pctrl->irq_chip.name = "msmgpio"; 1310 - pctrl->irq_chip.irq_enable = msm_gpio_irq_enable; 1311 - pctrl->irq_chip.irq_disable = msm_gpio_irq_disable; 1312 - pctrl->irq_chip.irq_mask = msm_gpio_irq_mask; 1313 - pctrl->irq_chip.irq_unmask = msm_gpio_irq_unmask; 1314 - pctrl->irq_chip.irq_ack = msm_gpio_irq_ack; 1315 - pctrl->irq_chip.irq_set_type = msm_gpio_irq_set_type; 1316 - pctrl->irq_chip.irq_set_wake = msm_gpio_irq_set_wake; 1317 - pctrl->irq_chip.irq_request_resources = msm_gpio_irq_reqres; 1318 - pctrl->irq_chip.irq_release_resources = msm_gpio_irq_relres; 1319 - pctrl->irq_chip.irq_set_affinity = msm_gpio_irq_set_affinity; 1320 - pctrl->irq_chip.irq_set_vcpu_affinity = msm_gpio_irq_set_vcpu_affinity; 1321 - pctrl->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND | 1322 - IRQCHIP_SET_TYPE_MASKED | 1323 - IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND; 1324 - 1325 1279 np = of_parse_phandle(pctrl->dev->of_node, "wakeup-parent", 0); 1326 1280 if (np) { 1327 1281 chip->irq.parent_domain = irq_find_matching_host(np, ··· 1314 1300 if (!chip->irq.parent_domain) 1315 1301 return -EPROBE_DEFER; 1316 1302 chip->irq.child_to_parent_hwirq = msm_gpio_wakeirq; 1317 - pctrl->irq_chip.irq_eoi = irq_chip_eoi_parent; 1318 1303 /* 1319 1304 * Let's skip handling the GPIOs, if the parent irqchip 1320 1305 * is handling the direct connect IRQ of the GPIO. ··· 1326 1313 } 1327 1314 1328 1315 girq = &chip->irq; 1329 - girq->chip = &pctrl->irq_chip; 1316 + gpio_irq_chip_set_chip(girq, &msm_gpio_irq_chip); 1330 1317 girq->parent_handler = msm_gpio_irq_handler; 1331 1318 girq->fwnode = pctrl->dev->fwnode; 1332 1319 girq->num_parents = 1;
+16
include/linux/gpio/driver.h
··· 579 579 void gpiochip_disable_irq(struct gpio_chip *gc, unsigned int offset); 580 580 void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset); 581 581 582 + /* irq_data versions of the above */ 583 + int gpiochip_irq_reqres(struct irq_data *data); 584 + void gpiochip_irq_relres(struct irq_data *data); 585 + 586 + /* Paste this in your irq_chip structure */ 587 + #define GPIOCHIP_IRQ_RESOURCE_HELPERS \ 588 + .irq_request_resources = gpiochip_irq_reqres, \ 589 + .irq_release_resources = gpiochip_irq_relres 590 + 591 + static inline void gpio_irq_chip_set_chip(struct gpio_irq_chip *girq, 592 + const struct irq_chip *chip) 593 + { 594 + /* Yes, dropping const is ugly, but it isn't like we have a choice */ 595 + girq->chip = (struct irq_chip *)chip; 596 + } 597 + 582 598 /* Line status inquiry for drivers */ 583 599 bool gpiochip_line_is_open_drain(struct gpio_chip *gc, unsigned int offset); 584 600 bool gpiochip_line_is_open_source(struct gpio_chip *gc, unsigned int offset);
+2
include/linux/irq.h
··· 569 569 * IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND: Invokes __enable_irq()/__disable_irq() for wake irqs 570 570 * in the suspend path if they are in disabled state 571 571 * IRQCHIP_AFFINITY_PRE_STARTUP: Default affinity update before startup 572 + * IRQCHIP_IMMUTABLE: Don't ever change anything in this chip 572 573 */ 573 574 enum { 574 575 IRQCHIP_SET_TYPE_MASKED = (1 << 0), ··· 583 582 IRQCHIP_SUPPORTS_NMI = (1 << 8), 584 583 IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND = (1 << 9), 585 584 IRQCHIP_AFFINITY_PRE_STARTUP = (1 << 10), 585 + IRQCHIP_IMMUTABLE = (1 << 11), 586 586 }; 587 587 588 588 #include <linux/irqdesc.h>
+1
kernel/irq/debugfs.c
··· 58 58 BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI), 59 59 BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI), 60 60 BIT_MASK_DESCR(IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND), 61 + BIT_MASK_DESCR(IRQCHIP_IMMUTABLE), 61 62 }; 62 63 63 64 static void