drivers/usb/ehci-fsl: Fix interrupt setup in host mode.
Subsystems (2)
RFC PATCH 1/1 drivers/usb/ehci-fsl: Fix interrupt setup in host mode.
In patch a1a2b7125e1079 (Drop static setup of IRQ resource from DT core) we stopped platform_get_resource() from returning the IRQ, as all drivers were supposed to have switched to platform_get_irq() Unfortunately the Freescale EHCI driver in host mode got missed. Fix it. Also fix allocation of resources to work with current kernel.
Reported-by Christian Zigotzky <[email protected]> Signed-off-by Darren Stevens <[email protected]>
---
Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely correct fix though. Contains code by Rob Herring (in fsl-mph-dr-of.c)
drivers/usb/host/ehci-fsl.c +1 -0
@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/fsl_devices.h> #include <linux/of_platform.h> +#include <linux/of_address.h> #include <linux/io.h> #include "ehci.h"
@@ -46,9 +47,10 @@ static struct hc_driver __read_mostly
fsl_ehci_hc_driver; */
static int fsl_ehci_drv_probe(struct platform_device *pdev) {
+ struct device_node *dn = pdev->dev.of_node;
struct fsl_usb2_platform_data *pdata; struct usb_hcd *hcd;
- struct resource *res;
+ struct resource res;
int irq;
int retval;
u32 tmp;
@@ -76,14 +78,10 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) return -ENODEV;
}
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res) {
- dev_err(&pdev->dev,
- "Found HC with no IRQ. Check %s setup!\n",
- dev_name(&pdev->dev));
- return -ENODEV;
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ return irq;
}
- irq = res->start;
hcd = __usb_create_hcd(&fsl_ehci_hc_driver, pdev->dev.parent,
&pdev->dev, dev_name(&pdev->dev), NULL);
@@ -92,15 +90,21 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) goto err1;
}
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+ platform_set_drvdata(pdev, hcd);
+ pdev->dev.platform_data = pdata;
+
+ tmp = of_address_to_resource(dn, 0, &res);
+ if (tmp)
+ return tmp;
+
+ hcd->regs = devm_ioremap_resource(&pdev->dev, &res);
if (IS_ERR(hcd->regs)) {
retval = PTR_ERR(hcd->regs);
goto err2;
}
- hcd->rsrc_start = res->start;
- hcd->rsrc_len = resource_size(res);
+ hcd->rsrc_start = res.start;
+ hcd->rsrc_len = resource_size(&res);
pdata->regs = hcd->regs;
(quoted diff) +0 -0
b/drivers/usb/host/fsl-mph-dr-of.c index 44a7e58..766e4ab 100644
drivers/usb/host/fsl-mph-dr-of.c +0 -0
@@ -80,8 +80,6 @@ static struct platform_device
*fsl_usb2_device_register( const char *name, int id)
{
struct platform_device *pdev;
- const struct resource *res = ofdev->resource;
- unsigned int num = ofdev->num_resources;
int retval;
pdev = platform_device_alloc(name, id);
@@ -106,11 +104,8 @@ static struct platform_device *fsl_usb2_device_register( if (retval)
goto error;
- if (num) {
- retval = platform_device_add_resources(pdev, res, num);
- if (retval)
- goto error;
- }
+ pdev->dev.of_node = ofdev->dev.of_node;
+ pdev->dev.of_node_reused = true;
retval = platform_device_add(pdev);
if (retval)
Greg KH
maintainerQuoted 7 lines · Darren Stevens
In patch
a1a2b7125e1079(Drop static setup of IRQ resource from DT core) we stoppedplatform_get_resource()from returning the IRQ, as all drivers were supposed to have switched toplatform_get_irq()Unfortunately the Freescale EHCI driver in host mode got missed. Fix it. Also fix allocation of resources to work with current kernel.Fixes a1a2b7125e1079 (Drop static setup of IRQ resource from DT core)
Nit, please put a space after the :.
Also not that many characters are needed, as you can see in our documentation, this is the proper format:
Quoted 34 lines
Reported-by Christian Zigotzky <[email protected]> Signed-off-by Darren Stevens <[email protected]>
---
Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely correct fix though. Contains code by Rob Herring (infsl-mph-dr-of.c)drivers/usb/host/ehci-fsl.c +1
-0@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/fsl_devices.h> #include <linux/of_platform.h> +#include <linux/of_address.h> #include <linux/io.h> #include "ehci.h" @@ -46,9 +47,10 @@ static struct hc_driver __read_mostly
fsl_ehci_hc_driver; */
static intfsl_ehci_drv_probe(struct platform_device *pdev){drivers/usb/host/ehci-fsl.c +2
-1+struct device_node *dn = pdev->dev.of_node;struct fsl_usb2_platform_data *pdata;struct usb_hcd *hcd; -struct resource *res; +struct resource res;int irq;int retval;u32 tmp;@@ -76,14 +78,10 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) return -ENODEV; }
drivers/usb/host/ehci-fsl.c static int fsl_ehci_drv_probe(struct · line 84
Quoted 10 lines
drivers/usb/host/ehci-fsl.c +3
-6- res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (!res) { -dev_err (&pdev->dev, -"Found HC with no IRQ. Check %s setup!\n" , -dev_name (&pdev->dev)); -return -ENODEV ; + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +return irq; }
Did you run checkpatch on this? Coding style is not correct :(
thanks,
greg k-h
Quoted 6 lines · Darren Stevens
In patch
a1a2b7125e1079(Drop static setup of IRQ resource from DT core) we stoppedplatform_get_resource()from returning the IRQ, as all drivers were supposed to have switched toplatform_get_irq()Unfortunately the Freescale EHCI driver in host mode got missed. Fix it. Also fix allocation of resources to work with current kernel.
Quoted 6 lines
Fixes a1a2b7125e1079 (Drop static setup of IRQ resource from DT core)Reported-by Christian Zigotzky <[email protected]> Signed-off-by Darren Stevens <[email protected]>
---
Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely correct fix though. Contains code by Rob Herring (infsl-mph-dr-of.c)
It looks like this driver is used on some arm/arm64 boards:
$ git grep -l fsl-usb2-dr arch/arm*/boot/dts arch/arm/boot/dts/ls1021a.dtsi arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi
Which is for the "Layerscape-1012A family SoC".
Have we heard of any bug reports from users of those boards? Is it wired up differently or otherwise immune to the problem?
I've added the Layerscape maintainers to Cc.
cheers
Quoted 27 lines
(quoted diff) +0
-0
b/drivers/usb/host/fsl-mph-dr-of.cindex 44a7e58..766e4ab 100644drivers/usb/host/fsl-mph-dr-of.c +2
-7@@ -80,8 +80,6 @@ static struct platform_device *fsl_usb2_device_register( const char *name, int id) {struct platform_device *pdev; -const struct resource *res = ofdev->resource; -unsigned int num = ofdev->num_resources;int retval; pdev =platform_device_alloc (name, id);@@ -106,11 +104,8 @@ static struct platform_device *fsl_usb2_device_register( if (retval) goto error; - if (num) { - retval = platform_device_add_resources(pdev, res, num); - if (retval) - goto error; - } + pdev->dev.of_node = ofdev->dev.of_node; + pdev->dev.of_node_reused = true; retval = platform_device_add(pdev);if (retval)
Quoted 39 lines · Darren Stevens
In patch
a1a2b7125e1079(Drop static setup of IRQ resource from DT core) we stoppedplatform_get_resource()from returning the IRQ, as all drivers were supposed to have switched toplatform_get_irq()Unfortunately the Freescale EHCI driver in host mode got missed. Fix it. Also fix allocation of resources to work with current kernel.Fixes a1a2b7125e1079 (Drop static setup of IRQ resource from DT core)Reported-by Christian Zigotzky <[email protected]> Signed-off-by Darren Stevens <[email protected]>
---
Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely correct fix though. Contains code by Rob Herring (infsl-mph-dr-of.c)drivers/usb/host/ehci-fsl.c +1
-0@@ -23,6 +23,7 @@#include <linux/platform_device.h> #include <linux/fsl_devices.h> #include <linux/of_platform.h> +#include <linux/of_address.h> #include <linux/io.h> #include "ehci.h" @@ -46,9 +47,10 @@ static struct hc_driver __read_mostly
fsl_ehci_hc_driver; */
static intfsl_ehci_drv_probe(struct platform_device *pdev){drivers/usb/host/ehci-fsl.c +2
-1+struct device_node *dn = pdev->dev.of_node;struct fsl_usb2_platform_data *pdata;struct usb_hcd *hcd; -struct resource *res; +struct resource res;int irq;int retval;u32 tmp;
drivers/usb/host/ehci-fsl.c static int fsl_ehci_drv_probe(struct · line 79
Quoted 4 lines
drivers/usb/host/ehci-fsl.c +0
-1@@ -76,14 +78,10 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) return -ENODEV; } - res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );
Ah, this was the part I was missing...
Quoted 14 lines
drivers/usb/host/ehci-fsl.c +3
-6-if (!res) { -dev_err (&pdev->dev, -"Found HC with no IRQ. Check %s setup!\n" , -dev_name (&pdev->dev)); -return -ENODEV ; + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) { +return irq; } - irq = res->start; hcd =__usb_create_hcd (&fsl_ehci_hc_driver, pdev->dev.parent, &pdev->dev,dev_name (&pdev->dev),NULL );
drivers/usb/host/ehci-fsl.c static int fsl_ehci_drv_probe(struct · line 96
Quoted 9 lines
drivers/usb/host/ehci-fsl.c +4
-2@@ -92,15 +90,21 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) goto err1; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - hcd->regs =devm_ioremap_resource (&pdev->dev, res); +platform_set_drvdata (pdev, hcd); + pdev->dev.platform_data = pdata; + + tmp =of_address_to_resource (dn,0 , &res);
There's no need to change this. platform_get_resource() still works for IORESOURCE_MEM.
Plus, drivers shouldn't use of_address_to_resource().
Quoted 43 lines
drivers/usb/host/ehci-fsl.c +6
-2+if (tmp) +return tmp; + + hcd->regs =devm_ioremap_resource (&pdev->dev, &res);if (IS_ERR (hcd->regs)) { retval =PTR_ERR (hcd->regs); goto err2; } - hcd->rsrc_start = res->start; - hcd->rsrc_len =resource_size (res); + hcd->rsrc_start = res.start; + hcd->rsrc_len =resource_size (&res); pdata->regs = hcd->regs;(quoted diff) +0
-0
b/drivers/usb/host/fsl-mph-dr-of.cindex 44a7e58..766e4ab 100644drivers/usb/host/fsl-mph-dr-of.c +2
-7@@ -80,8 +80,6 @@ static struct platform_device *fsl_usb2_device_register( const char *name, int id) {struct platform_device *pdev; -const struct resource *res = ofdev->resource; -unsigned int num = ofdev->num_resources;int retval; pdev =platform_device_alloc (name, id);@@ -106,11 +104,8 @@ static struct platform_device *fsl_usb2_device_register( if (retval) goto error; - if (num) { - retval = platform_device_add_resources(pdev, res, num); - if (retval) - goto error; - } + pdev->dev.of_node = ofdev->dev.of_node; + pdev->dev.of_node_reused = true; retval = platform_device_add(pdev);if (retval)