diff options
-rw-r--r-- | drivers/base/platform.c | 7 | ||||
-rw-r--r-- | drivers/of/irq.c | 26 | ||||
-rw-r--r-- | drivers/of/platform.c | 4 | ||||
-rw-r--r-- | include/linux/of_irq.h | 5 |
4 files changed, 40 insertions, 2 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index e714709704e4..5b47210889e0 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/string.h> | 13 | #include <linux/string.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
16 | #include <linux/of_irq.h> | ||
16 | #include <linux/module.h> | 17 | #include <linux/module.h> |
17 | #include <linux/init.h> | 18 | #include <linux/init.h> |
18 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
@@ -87,7 +88,11 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) | |||
87 | return -ENXIO; | 88 | return -ENXIO; |
88 | return dev->archdata.irqs[num]; | 89 | return dev->archdata.irqs[num]; |
89 | #else | 90 | #else |
90 | struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num); | 91 | struct resource *r; |
92 | if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) | ||
93 | return of_irq_get(dev->dev.of_node, num); | ||
94 | |||
95 | r = platform_get_resource(dev, IORESOURCE_IRQ, num); | ||
91 | 96 | ||
92 | return r ? r->start : -ENXIO; | 97 | return r ? r->start : -ENXIO; |
93 | #endif | 98 | #endif |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index e2e4c548a42f..5aeb89411350 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
@@ -380,6 +380,32 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) | |||
380 | EXPORT_SYMBOL_GPL(of_irq_to_resource); | 380 | EXPORT_SYMBOL_GPL(of_irq_to_resource); |
381 | 381 | ||
382 | /** | 382 | /** |
383 | * of_irq_get - Decode a node's IRQ and return it as a Linux irq number | ||
384 | * @dev: pointer to device tree node | ||
385 | * @index: zero-based index of the irq | ||
386 | * | ||
387 | * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain | ||
388 | * is not yet created. | ||
389 | * | ||
390 | */ | ||
391 | int of_irq_get(struct device_node *dev, int index) | ||
392 | { | ||
393 | int rc; | ||
394 | struct of_phandle_args oirq; | ||
395 | struct irq_domain *domain; | ||
396 | |||
397 | rc = of_irq_parse_one(dev, index, &oirq); | ||
398 | if (rc) | ||
399 | return rc; | ||
400 | |||
401 | domain = irq_find_host(oirq.np); | ||
402 | if (!domain) | ||
403 | return -EPROBE_DEFER; | ||
404 | |||
405 | return irq_create_of_mapping(&oirq); | ||
406 | } | ||
407 | |||
408 | /** | ||
383 | * of_irq_count - Count the number of IRQs a node uses | 409 | * of_irq_count - Count the number of IRQs a node uses |
384 | * @dev: pointer to device tree node | 410 | * @dev: pointer to device tree node |
385 | */ | 411 | */ |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 404d1daebefa..bd47fbc53dc9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -168,7 +168,9 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
168 | rc = of_address_to_resource(np, i, res); | 168 | rc = of_address_to_resource(np, i, res); |
169 | WARN_ON(rc); | 169 | WARN_ON(rc); |
170 | } | 170 | } |
171 | WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq); | 171 | if (of_irq_to_resource_table(np, res, num_irq) != num_irq) |
172 | pr_debug("not all legacy IRQ resources mapped for %s\n", | ||
173 | np->name); | ||
172 | } | 174 | } |
173 | 175 | ||
174 | dev->dev.of_node = of_node_get(np); | 176 | dev->dev.of_node = of_node_get(np); |
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 3f23b4472c31..6404253d810d 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h | |||
@@ -44,11 +44,16 @@ extern void of_irq_init(const struct of_device_id *matches); | |||
44 | 44 | ||
45 | #ifdef CONFIG_OF_IRQ | 45 | #ifdef CONFIG_OF_IRQ |
46 | extern int of_irq_count(struct device_node *dev); | 46 | extern int of_irq_count(struct device_node *dev); |
47 | extern int of_irq_get(struct device_node *dev, int index); | ||
47 | #else | 48 | #else |
48 | static inline int of_irq_count(struct device_node *dev) | 49 | static inline int of_irq_count(struct device_node *dev) |
49 | { | 50 | { |
50 | return 0; | 51 | return 0; |
51 | } | 52 | } |
53 | static inline int of_irq_get(struct device_node *dev, int index) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
52 | #endif | 57 | #endif |
53 | 58 | ||
54 | #if defined(CONFIG_OF) | 59 | #if defined(CONFIG_OF) |