From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932523AbcHIMhq (ORCPT ); Tue, 9 Aug 2016 08:37:46 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:41063 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932446AbcHIMhm (ORCPT ); Tue, 9 Aug 2016 08:37:42 -0400 From: Paul Burton To: , Ralf Baechle CC: Paul Burton , Greg Kroah-Hartman , Alan Stern , , Subject: [PATCH 06/20] usb: host: ehci-sead3: Support probing using device tree Date: Tue, 9 Aug 2016 13:35:31 +0100 Message-ID: <20160809123546.10190-7-paul.burton@imgtec.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160809123546.10190-1-paul.burton@imgtec.com> References: <20160809123546.10190-1-paul.burton@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.100.200.230] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce support for probing the SEAD3 EHCI driver using device tree. Signed-off-by: Paul Burton --- drivers/usb/host/ehci-sead3.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c index 3d86cc2..05db1ae 100644 --- a/drivers/usb/host/ehci-sead3.c +++ b/drivers/usb/host/ehci-sead3.c @@ -20,6 +20,7 @@ */ #include +#include #include static int ehci_sead3_setup(struct usb_hcd *hcd) @@ -96,15 +97,25 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev) { struct usb_hcd *hcd; struct resource *res; - int ret; + int ret, irq; if (usb_disabled()) return -ENODEV; - if (pdev->resource[1].flags != IORESOURCE_IRQ) { - pr_debug("resource[1] is not IORESOURCE_IRQ"); - return -ENOMEM; + if (pdev->dev.of_node) { + irq = irq_of_parse_and_map(pdev->dev.of_node, 0); + if (!irq) { + dev_err(&pdev->dev, "failed to map IRQ\n"); + return -ENODEV; + } + } else { + if (pdev->resource[1].flags != IORESOURCE_IRQ) { + pr_debug("resource[1] is not IORESOURCE_IRQ"); + return -ENOMEM; + } + irq = pdev->resource[1].start; } + hcd = usb_create_hcd(&ehci_sead3_hc_driver, &pdev->dev, "SEAD-3"); if (!hcd) return -ENOMEM; @@ -121,8 +132,7 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev) /* Root hub has integrated TT. */ hcd->has_tt = 1; - ret = usb_add_hcd(hcd, pdev->resource[1].start, - IRQF_SHARED); + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret == 0) { platform_set_drvdata(pdev, hcd); device_wakeup_enable(hcd->self.controller); @@ -172,12 +182,19 @@ static const struct dev_pm_ops sead3_ehci_pmops = { #define SEAD3_EHCI_PMOPS NULL #endif +static const struct of_device_id sead3_ehci_of_match[] = { + { .compatible = "mti,sead3-ehci" }, + {}, +}; +MODULE_DEVICE_TABLE(of, sead3_ehci_of_match); + static struct platform_driver ehci_hcd_sead3_driver = { .probe = ehci_hcd_sead3_drv_probe, .remove = ehci_hcd_sead3_drv_remove, .shutdown = usb_hcd_platform_shutdown, .driver = { .name = "sead3-ehci", + .of_match_table = sead3_ehci_of_match, .pm = SEAD3_EHCI_PMOPS, } }; -- 2.9.2