diff options
Diffstat (limited to 'drivers/usb/dwc3/host.c')
| -rw-r--r-- | drivers/usb/dwc3/host.c | 88 | 
1 files changed, 48 insertions, 40 deletions
| diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index f6533c68fed1..487f0ff6ae25 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -19,6 +19,39 @@  #include "core.h" +static int dwc3_host_get_irq(struct dwc3 *dwc) +{ +	struct platform_device	*dwc3_pdev = to_platform_device(dwc->dev); +	int irq; + +	irq = platform_get_irq_byname(dwc3_pdev, "host"); +	if (irq > 0) +		goto out; + +	if (irq == -EPROBE_DEFER) +		goto out; + +	irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); +	if (irq > 0) +		goto out; + +	if (irq == -EPROBE_DEFER) +		goto out; + +	irq = platform_get_irq(dwc3_pdev, 0); +	if (irq > 0) +		goto out; + +	if (irq != -EPROBE_DEFER) +		dev_err(dwc->dev, "missing host IRQ\n"); + +	if (!irq) +		irq = -EINVAL; + +out: +	return irq; +} +  int dwc3_host_init(struct dwc3 *dwc)  {  	struct property_entry	props[2]; @@ -27,39 +60,18 @@ int dwc3_host_init(struct dwc3 *dwc)  	struct resource		*res;  	struct platform_device	*dwc3_pdev = to_platform_device(dwc->dev); -	irq = platform_get_irq_byname(dwc3_pdev, "host"); -	if (irq == -EPROBE_DEFER) +	irq = dwc3_host_get_irq(dwc); +	if (irq < 0)  		return irq; -	if (irq <= 0) { -		irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3"); -		if (irq == -EPROBE_DEFER) -			return irq; - -		if (irq <= 0) { -			irq = platform_get_irq(dwc3_pdev, 0); -			if (irq <= 0) { -				if (irq != -EPROBE_DEFER) { -					dev_err(dwc->dev, -						"missing host IRQ\n"); -				} -				if (!irq) -					irq = -EINVAL; -				return irq; -			} else { -				res = platform_get_resource(dwc3_pdev, -							    IORESOURCE_IRQ, 0); -			} -		} else { -			res = platform_get_resource_byname(dwc3_pdev, -							   IORESOURCE_IRQ, -							   "dwc_usb3"); -		} - -	} else { +	res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, "host"); +	if (!res)  		res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ, -						   "host"); -	} +				"dwc_usb3"); +	if (!res) +		res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0); +	if (!res) +		return -ENOMEM;  	dwc->xhci_resources[1].start = irq;  	dwc->xhci_resources[1].end = irq; @@ -72,11 +84,7 @@ int dwc3_host_init(struct dwc3 *dwc)  		return -ENOMEM;  	} -	dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); -  	xhci->dev.parent	= dwc->dev; -	xhci->dev.dma_mask	= dwc->dev->dma_mask; -	xhci->dev.dma_parms	= dwc->dev->dma_parms;  	dwc->xhci = xhci; @@ -99,9 +107,9 @@ int dwc3_host_init(struct dwc3 *dwc)  	}  	phy_create_lookup(dwc->usb2_generic_phy, "usb2-phy", -			  dev_name(&xhci->dev)); +			  dev_name(dwc->dev));  	phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy", -			  dev_name(&xhci->dev)); +			  dev_name(dwc->dev));  	ret = platform_device_add(xhci);  	if (ret) { @@ -112,9 +120,9 @@ int dwc3_host_init(struct dwc3 *dwc)  	return 0;  err2:  	phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy", -			  dev_name(&xhci->dev)); +			  dev_name(dwc->dev));  	phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy", -			  dev_name(&xhci->dev)); +			  dev_name(dwc->dev));  err1:  	platform_device_put(xhci);  	return ret; @@ -123,8 +131,8 @@ err1:  void dwc3_host_exit(struct dwc3 *dwc)  {  	phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy", -			  dev_name(&dwc->xhci->dev)); +			  dev_name(dwc->dev));  	phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy", -			  dev_name(&dwc->xhci->dev)); +			  dev_name(dwc->dev));  	platform_device_unregister(dwc->xhci);  } |