···1111#include <linux/irq.h>1212#include <linux/irqdomain.h>1313#include <linux/irqchip.h>1414+#include <linux/of_irq.h>1415#include <linux/platform_device.h>1516#include <linux/bitops.h>1617/* Include that go away with DT transition */···307306{308307 unsigned long flags;309308 struct device *dev = &pdev->dev;309309+ struct device_node *np = dev->of_node;310310 struct irq_domain *parent;311311 struct resource *res;312312 struct ixp4xx_gpio *g;···384382 * from IRQCHIP_DECLARE(), then use of_node_to_fwnode() to get385383 * the fwnode. For now we need this boardfile style code.386384 */387387- parent = ixp4xx_get_irq_domain();388388- g->fwnode = irq_domain_alloc_fwnode(g->base);389389- if (!g->fwnode) {390390- dev_err(dev, "no domain base\n");391391- return -ENODEV;385385+ if (np) {386386+ struct device_node *irq_parent;387387+388388+ irq_parent = of_irq_find_parent(np);389389+ if (!irq_parent) {390390+ dev_err(dev, "no IRQ parent node\n");391391+ return -ENODEV;392392+ }393393+ parent = irq_find_host(irq_parent);394394+ if (!parent) {395395+ dev_err(dev, "no IRQ parent domain\n");396396+ return -ENODEV;397397+ }398398+ g->fwnode = of_node_to_fwnode(np);399399+ } else {400400+ parent = ixp4xx_get_irq_domain();401401+ g->fwnode = irq_domain_alloc_fwnode(g->base);402402+ if (!g->fwnode) {403403+ dev_err(dev, "no domain base\n");404404+ return -ENODEV;405405+ }392406 }393407 g->domain = irq_domain_create_hierarchy(parent,394408 IRQ_DOMAIN_FLAG_HIERARCHY,···422404 * After adding OF support, this is no longer needed: irqs423405 * will be allocated for the respective fwnodes.424406 */425425- for (i = 0; i < ARRAY_SIZE(ixp4xx_gpiomap); i++) {426426- const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i];427427- struct irq_fwspec fwspec;407407+ if (!np) {408408+ for (i = 0; i < ARRAY_SIZE(ixp4xx_gpiomap); i++) {409409+ const struct ixp4xx_gpio_map *map = &ixp4xx_gpiomap[i];410410+ struct irq_fwspec fwspec;428411429429- fwspec.fwnode = g->fwnode;430430- /* This is the hwirq for the GPIO line side of things */431431- fwspec.param[0] = map->gpio_offset;432432- fwspec.param[1] = IRQ_TYPE_EDGE_RISING;433433- fwspec.param_count = 2;434434- ret = __irq_domain_alloc_irqs(g->domain,435435- -1, /* just pick something */436436- 1,437437- NUMA_NO_NODE,438438- &fwspec,439439- false,440440- NULL);441441- if (ret < 0) {442442- irq_domain_free_fwnode(g->fwnode);443443- dev_err(dev,444444- "can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n",445445- map->gpio_offset, map->parent_hwirq, ret);446446- return ret;412412+ fwspec.fwnode = g->fwnode;413413+ /* This is the hwirq for the GPIO line side of things */414414+ fwspec.param[0] = map->gpio_offset;415415+ fwspec.param[1] = IRQ_TYPE_EDGE_RISING;416416+ fwspec.param_count = 2;417417+ ret = __irq_domain_alloc_irqs(g->domain,418418+ -1, /* just pick something */419419+ 1,420420+ NUMA_NO_NODE,421421+ &fwspec,422422+ false,423423+ NULL);424424+ if (ret < 0) {425425+ irq_domain_free_fwnode(g->fwnode);426426+ dev_err(dev,427427+ "can not allocate irq for GPIO line %d parent hwirq %d in hierarchy domain: %d\n",428428+ map->gpio_offset, map->parent_hwirq,429429+ ret);430430+ return ret;431431+ }447432 }448433 }449434···456435 return 0;457436}458437438438+static const struct of_device_id ixp4xx_gpio_of_match[] = {439439+ {440440+ .compatible = "intel,ixp4xx-gpio",441441+ },442442+ {},443443+};444444+445445+459446static struct platform_driver ixp4xx_gpio_driver = {460447 .driver = {461448 .name = "ixp4xx-gpio",449449+ .of_match_table = of_match_ptr(ixp4xx_gpio_of_match),462450 },463451 .probe = ixp4xx_gpio_probe,464452};