mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
of/irq: create interrupts-extended property
The standard interrupts property in device tree can only handle interrupts coming from a single interrupt parent. If a device is wired to multiple interrupt controllers, then it needs to be attached to a node with an interrupt-map property to demux the interrupt specifiers which is confusing. It would be a lot easier if there was a form of the interrupts property that allows for a separate interrupt phandle for each interrupt specifier. This patch does exactly that by creating a new interrupts-extended property which reuses the phandle+arguments pattern used by GPIOs and other core bindings. Signed-off-by: Grant Likely <[email protected]> Acked-by: Tony Lindgren <[email protected]> Acked-by: Kumar Gala <[email protected]> [grant.likely: removed versatile platform hunks into separate patch] Cc: Rob Herring <[email protected]>
This commit is contained in:
parent
f27446c3ad
commit
79d9701559
4 changed files with 120 additions and 11 deletions
|
|
@ -292,17 +292,23 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
|
|||
if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
|
||||
return of_irq_parse_oldworld(device, index, out_irq);
|
||||
|
||||
/* Get the reg property (if any) */
|
||||
addr = of_get_property(device, "reg", NULL);
|
||||
|
||||
/* Get the interrupts property */
|
||||
intspec = of_get_property(device, "interrupts", &intlen);
|
||||
if (intspec == NULL)
|
||||
return -EINVAL;
|
||||
if (intspec == NULL) {
|
||||
/* Try the new-style interrupts-extended */
|
||||
res = of_parse_phandle_with_args(device, "interrupts-extended",
|
||||
"#interrupt-cells", index, out_irq);
|
||||
if (res)
|
||||
return -EINVAL;
|
||||
return of_irq_parse_raw(addr, out_irq);
|
||||
}
|
||||
intlen /= sizeof(*intspec);
|
||||
|
||||
pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen);
|
||||
|
||||
/* Get the reg property (if any) */
|
||||
addr = of_get_property(device, "reg", NULL);
|
||||
|
||||
/* Look for the interrupt parent. */
|
||||
p = of_irq_find_parent(device);
|
||||
if (p == NULL)
|
||||
|
|
|
|||
|
|
@ -231,6 +231,75 @@ static void __init of_selftest_parse_interrupts(void)
|
|||
of_node_put(np);
|
||||
}
|
||||
|
||||
static void __init of_selftest_parse_interrupts_extended(void)
|
||||
{
|
||||
struct device_node *np;
|
||||
struct of_phandle_args args;
|
||||
int i, rc;
|
||||
|
||||
np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0");
|
||||
if (!np) {
|
||||
pr_err("missing testcase data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < 7; i++) {
|
||||
bool passed = true;
|
||||
rc = of_irq_parse_one(np, i, &args);
|
||||
|
||||
/* Test the values from tests-phandle.dtsi */
|
||||
switch (i) {
|
||||
case 0:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 1);
|
||||
passed &= (args.args[0] == 1);
|
||||
break;
|
||||
case 1:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 3);
|
||||
passed &= (args.args[0] == 2);
|
||||
passed &= (args.args[1] == 3);
|
||||
passed &= (args.args[2] == 4);
|
||||
break;
|
||||
case 2:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 2);
|
||||
passed &= (args.args[0] == 5);
|
||||
passed &= (args.args[1] == 6);
|
||||
break;
|
||||
case 3:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 1);
|
||||
passed &= (args.args[0] == 9);
|
||||
break;
|
||||
case 4:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 3);
|
||||
passed &= (args.args[0] == 10);
|
||||
passed &= (args.args[1] == 11);
|
||||
passed &= (args.args[2] == 12);
|
||||
break;
|
||||
case 5:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 2);
|
||||
passed &= (args.args[0] == 13);
|
||||
passed &= (args.args[1] == 14);
|
||||
break;
|
||||
case 6:
|
||||
passed &= !rc;
|
||||
passed &= (args.args_count == 1);
|
||||
passed &= (args.args[0] == 15);
|
||||
break;
|
||||
default:
|
||||
passed = false;
|
||||
}
|
||||
|
||||
selftest(passed, "index %i - data error on node %s rc=%i\n",
|
||||
i, args.np->full_name, rc);
|
||||
}
|
||||
of_node_put(np);
|
||||
}
|
||||
|
||||
static int __init of_selftest(void)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
|
@ -246,6 +315,7 @@ static int __init of_selftest(void)
|
|||
of_selftest_parse_phandle_with_args();
|
||||
of_selftest_property_match_string();
|
||||
of_selftest_parse_interrupts();
|
||||
of_selftest_parse_interrupts_extended();
|
||||
pr_info("end of selftest - %i passed, %i failed\n",
|
||||
selftest_results.passed, selftest_results.failed);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue