Skip to content

Commit ffbe2fe

Browse files
tmlindgregkh
authored andcommitted
usb: musb: omap2430: Fix probe regression for missing resources
Probe for omap2430 glue layer is now broken for interrupt resources in all cases. Commit 2390710 ("partially Revert "usb: musb: Set the DT node on the child device"") broke probing for SoCs using ti-sysc interconnect target module as the dt node is not found. Commit a1a2b71 ("of/platform: Drop static setup of IRQ resource from DT core") caused omap3 to fail with error "-ENXIO: IRQ mc not found" as the IRQ resources are no longer automatically populated from devicetree. Let's fix the issues by calling device_set_of_node_from_dev() only if the SoC has been updated to probe with ti-sysc. And for legacy SoCs, let's populate the resources manually as needed. Note that once we have updated the SoCs to probe with proper devicetree data in all cases, this is no longer needed. But doing that requires patching both devicetree and SoC code, so let's fix the probe issues first. Fixes: a1a2b71 ("of/platform: Drop static setup of IRQ resource from DT core") Fixes: 2390710 ("partially Revert "usb: musb: Set the DT node on the child device"") Cc: H. Nikolaus Schaller <[email protected]> Reported-by: Sicelo Mhlongo <[email protected]> Tested-by: Sicelo Mhlongo <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 53a256e commit ffbe2fe

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

drivers/usb/musb/omap2430.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/list.h>
1616
#include <linux/io.h>
1717
#include <linux/of.h>
18+
#include <linux/of_irq.h>
1819
#include <linux/platform_device.h>
1920
#include <linux/dma-mapping.h>
2021
#include <linux/pm_runtime.h>
@@ -310,6 +311,7 @@ static int omap2430_probe(struct platform_device *pdev)
310311
struct device_node *control_node;
311312
struct platform_device *control_pdev;
312313
int ret = -ENOMEM, val;
314+
bool populate_irqs = false;
313315

314316
if (!np)
315317
return -ENODEV;
@@ -328,6 +330,18 @@ static int omap2430_probe(struct platform_device *pdev)
328330
musb->dev.dma_mask = &omap2430_dmamask;
329331
musb->dev.coherent_dma_mask = omap2430_dmamask;
330332

333+
/*
334+
* Legacy SoCs using omap_device get confused if node is moved
335+
* because of interconnect properties mixed into the node.
336+
*/
337+
if (of_get_property(np, "ti,hwmods", NULL)) {
338+
dev_warn(&pdev->dev, "please update to probe with ti-sysc\n");
339+
populate_irqs = true;
340+
} else {
341+
device_set_of_node_from_dev(&musb->dev, &pdev->dev);
342+
}
343+
of_node_put(np);
344+
331345
glue->dev = &pdev->dev;
332346
glue->musb = musb;
333347
glue->status = MUSB_UNKNOWN;
@@ -389,6 +403,46 @@ static int omap2430_probe(struct platform_device *pdev)
389403
goto err2;
390404
}
391405

406+
if (populate_irqs) {
407+
struct resource musb_res[3];
408+
struct resource *res;
409+
int i = 0;
410+
411+
memset(musb_res, 0, sizeof(*musb_res) * ARRAY_SIZE(musb_res));
412+
413+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
414+
if (!res)
415+
goto err2;
416+
417+
musb_res[i].start = res->start;
418+
musb_res[i].end = res->end;
419+
musb_res[i].flags = res->flags;
420+
musb_res[i].name = res->name;
421+
i++;
422+
423+
ret = of_irq_get_byname(np, "mc");
424+
if (ret > 0) {
425+
musb_res[i].start = ret;
426+
musb_res[i].flags = IORESOURCE_IRQ;
427+
musb_res[i].name = "mc";
428+
i++;
429+
}
430+
431+
ret = of_irq_get_byname(np, "dma");
432+
if (ret > 0) {
433+
musb_res[i].start = ret;
434+
musb_res[i].flags = IORESOURCE_IRQ;
435+
musb_res[i].name = "dma";
436+
i++;
437+
}
438+
439+
ret = platform_device_add_resources(musb, musb_res, i);
440+
if (ret) {
441+
dev_err(&pdev->dev, "failed to add IRQ resources\n");
442+
goto err2;
443+
}
444+
}
445+
392446
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
393447
if (ret) {
394448
dev_err(&pdev->dev, "failed to add platform_data\n");

0 commit comments

Comments
 (0)