From patchwork Fri Mar 15 20:11:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 15387 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8E4D34C13C7 for ; Fri, 15 Mar 2013 20:11:34 +0000 (UTC) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by fiordland.canonical.com (Postfix) with ESMTP id 0F578A1864D for ; Fri, 15 Mar 2013 20:11:33 +0000 (UTC) Received: by mail-vc0-f182.google.com with SMTP id ht11so1552019vcb.41 for ; Fri, 15 Mar 2013 13:11:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id:x-provags-id:x-gm-message-state; bh=uCD0wgXaL4nbAq7lMsw/F4Dugv9dpCToarPuWS6uqPE=; b=ClonkPkgN/V6iFN38EDmtb6R1/zFiJu07SCKOu0t2t4qC0eAefjgOJ/3Hj4+HYHGZr PujvRXr8/3yJZK8c7OlSvG4zu7foQr3VAZipYtsjTbd4RR1zd/hjWcTetMpqWdaAWpHF 3DMxpfB4nS2hCfbAoU5XAssfpCOw7zF13E4z0VEro7zO9zI4fEtfFm60WUNHESBwFHMb UFa1BHOTKALYwAgOQRpwclrkXEdNGM+fILqp+j9lY3qyIHZ8pJt/64qMgRhOLLj/mFkF rJvfAVd7LIZnyTbdnLjZuXx5KO/r3me01KpF3+uRIM88ITu3cyK/jLhK7lIVS8hP181J K32g== X-Received: by 10.52.177.163 with SMTP id cr3mr7643378vdc.94.1363378293416; Fri, 15 Mar 2013 13:11:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp137081veb; Fri, 15 Mar 2013 13:11:32 -0700 (PDT) X-Received: by 10.14.207.73 with SMTP id m49mr21725060eeo.24.1363378292033; Fri, 15 Mar 2013 13:11:32 -0700 (PDT) Received: from moutng.kundenserver.de (moutng.kundenserver.de. [212.227.17.10]) by mx.google.com with ESMTPS id f9si13671934eep.189.2013.03.15.13.11.31 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Mar 2013 13:11:32 -0700 (PDT) Received-SPF: neutral (google.com: 212.227.17.10 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) client-ip=212.227.17.10; Authentication-Results: mx.google.com; spf=neutral (google.com: 212.227.17.10 is neither permitted nor denied by best guess record for domain of arnd@arndb.de) smtp.mail=arnd@arndb.de Received: from klappe2.localnet (HSI-KBW-46-223-90-92.hsi.kabel-badenwuerttemberg.de [46.223.90.92]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0LtUuK-1Ui40b3Nm0-011Aur; Fri, 15 Mar 2013 21:11:30 +0100 From: Arnd Bergmann To: Alan Stern Subject: Re: [RFC] USB: EHCI: hot-fix OMAP and Orion multiplatform config Date: Fri, 15 Mar 2013 20:11:26 +0000 User-Agent: KMail/1.12.2 (Linux/3.8.0-8-generic; KDE/4.3.2; x86_64; ; ) Cc: Manjunath Goudar , USB list , linux-arm-kernel@lists.infradead.org, patches@linaro.org, "Greg Kroah-Hartman" , Roger Quadros , Andrew Lunn , Jason Cooper , Alexey Charkov References: In-Reply-To: MIME-Version: 1.0 Message-Id: <201303152011.26414.arnd@arndb.de> X-Provags-ID: V02:K0:LAjT4jgFoBKT9Pd6/RIi/BoPhp2GLmaS6jp5iR2fzne mp9z8OJdusRbFjPlruMo3i+sd0rdluprKjBT+WKilUQT+kAyz9 vv7rc3mWxAIFBrwgrMA8+KMDNULS/5EbkHPQPmpWPGPlaneiLZ FtEjFyjTYby1FcjumY5/RecUFK77XixMu/QP4XfJbm3SUn+JHE /3y23ThTLEJG9IuTRgN4YISzeUhKtFe2KEW70QYfGw+ocF8CsI OdT7gI3x2MXsbRTDX2NSQzRTDbibE9BFqEhk3l8gRMYHgQ2cZc ASZdJxASRQ3nCFMuorVCRrI5V4muGLYU8GwIQ6h70zvhmXQ9+y 67Nl+nAN/MKpj4z7RguE= X-Gm-Message-State: ALoCoQkYS1kNTnH942/So9oJZtfWLqPR39jb8mIJvUfTH3oZHr+WLzBzTB+Beu7OMCf+8Ya1Acb/ On Friday 15 March 2013, Alan Stern wrote: > On Fri, 15 Mar 2013, Arnd Bergmann wrote: > > @@ -89,12 +90,17 @@ static int ehci_platform_probe(struct platform_device *dev) > > return -ENXIO; > > } > > > > - if (pdata->power_on) { > > + if (pdata && pdata->power_on) { > > err = pdata->power_on(dev); > > if (err < 0) > > return err; > > } > > Instead of adding these tests for non-NULL pdata all over the place, > you could define a static structure with default settings and store a > pointer to it if pdata wasn't set initially. Yes, good idea. Here is a new version. Maybe Alexey or Tony can verify if that works for them on wm8850. That should be independent of the decision into which kernel to merge this patch. Arnd 8<------ >From 016f7ecd1bce61c18d621acf746776491cc8487e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 15 Feb 2013 23:12:28 +0100 Subject: [PATCH] USB: EHCI: DT support for generic bus glue This lets us use the ehci-generic driver on platforms without special requirements for their ehci controllers. In particular, this is true for the vt8500/wm8x50 platforms, which currently have a separate driver that causes problems with multiplatform configurations. Signed-off-by: Arnd Bergmann Cc: Tony Prisk Cc: Alexey Charkov Cc: Alan Stern Acked-by: Alan Stern --- drivers/usb/host/ehci-hcd.c | 5 -- drivers/usb/host/ehci-platform.c | 25 +++-- drivers/usb/host/ehci-vt8500.c | 150 ------------------------------- 3 files changed, 19 insertions(+), 161 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index c750d71..9dfcef6 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1292,11 +1292,6 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER ehci_octeon_driver #endif -#ifdef CONFIG_ARCH_VT8500 -#include "ehci-vt8500.c" -#define PLATFORM_DRIVER vt8500_ehci_driver -#endif - #ifdef CONFIG_PLAT_SPEAR #include "ehci-spear.c" #define PLATFORM_DRIVER spear_ehci_hcd_driver diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index ca75063..e7777af 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -18,11 +18,13 @@ * * Licensed under the GNU/GPL. See COPYING for details. */ +#include #include #include #include #include #include +#include #include #include #include @@ -62,22 +64,26 @@ static const struct ehci_driver_overrides platform_overrides __initdata = { .reset = ehci_platform_reset, }; +static struct usb_ehci_pdata ehci_platform_defaults; + static int ehci_platform_probe(struct platform_device *dev) { struct usb_hcd *hcd; struct resource *res_mem; - struct usb_ehci_pdata *pdata = dev->dev.platform_data; + struct usb_ehci_pdata *pdata; int irq; int err = -ENOMEM; - if (!pdata) { - WARN_ON(1); - return -ENODEV; - } - if (usb_disabled()) return -ENODEV; + if (!dev->dev.platform_data) { + dev->dev.platform_data = &ehci_platform_defaults; + dev->dev.dma_mask = &dev->dev.coherent_dma_mask; + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + } + pdata = dev->dev.platform_data; + irq = platform_get_irq(dev, 0); if (irq < 0) { dev_err(&dev->dev, "no irq provided"); @@ -183,6 +189,12 @@ static int ehci_platform_resume(struct device *dev) #define ehci_platform_resume NULL #endif /* CONFIG_PM */ +static const struct of_device_id vt8500_ehci_ids[] = { + { .compatible = "via,vt8500-ehci", }, + { .compatible = "wm,prizm-ehci", }, + {} +}; + static const struct platform_device_id ehci_platform_table[] = { { "ehci-platform", 0 }, { } @@ -203,6 +215,7 @@ static struct platform_driver ehci_platform_driver = { .owner = THIS_MODULE, .name = "ehci-platform", .pm = &ehci_platform_pm_ops, + .of_match_table = of_match_ptr(vt8500_ehci_ids), } }; diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c deleted file mode 100644 index 7ecf709..0000000 --- a/drivers/usb/host/ehci-vt8500.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * drivers/usb/host/ehci-vt8500.c - * - * Copyright (C) 2010 Alexey Charkov - * - * Based on ehci-au1xxx.c - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include - -static const struct hc_driver vt8500_ehci_hc_driver = { - .description = hcd_name, - .product_desc = "VT8500 EHCI", - .hcd_priv_size = sizeof(struct ehci_hcd), - - /* - * generic hardware linkage - */ - .irq = ehci_irq, - .flags = HCD_MEMORY | HCD_USB2, - - /* - * basic lifecycle operations - */ - .reset = ehci_setup, - .start = ehci_run, - .stop = ehci_stop, - .shutdown = ehci_shutdown, - - /* - * managing i/o requests and associated device resources - */ - .urb_enqueue = ehci_urb_enqueue, - .urb_dequeue = ehci_urb_dequeue, - .endpoint_disable = ehci_endpoint_disable, - .endpoint_reset = ehci_endpoint_reset, - - /* - * scheduling support - */ - .get_frame_number = ehci_get_frame, - - /* - * root hub support - */ - .hub_status_data = ehci_hub_status_data, - .hub_control = ehci_hub_control, - .bus_suspend = ehci_bus_suspend, - .bus_resume = ehci_bus_resume, - .relinquish_port = ehci_relinquish_port, - .port_handed_over = ehci_port_handed_over, - - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, -}; - -static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32); - -static int vt8500_ehci_drv_probe(struct platform_device *pdev) -{ - struct usb_hcd *hcd; - struct ehci_hcd *ehci; - struct resource *res; - int ret; - - if (usb_disabled()) - return -ENODEV; - - /* - * Right now device-tree probed devices don't get dma_mask set. - * Since shared usb code relies on it, set it here for now. - * Once we have dma capability bindings this can go away. - */ - if (!pdev->dev.dma_mask) - pdev->dev.dma_mask = &vt8500_ehci_dma_mask; - - if (pdev->resource[1].flags != IORESOURCE_IRQ) { - pr_debug("resource[1] is not IORESOURCE_IRQ"); - return -ENOMEM; - } - hcd = usb_create_hcd(&vt8500_ehci_hc_driver, &pdev->dev, "VT8500"); - if (!hcd) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd->rsrc_start = res->start; - hcd->rsrc_len = resource_size(res); - - hcd->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(hcd->regs)) { - ret = PTR_ERR(hcd->regs); - goto err1; - } - - ehci = hcd_to_ehci(hcd); - ehci->caps = hcd->regs; - - ret = usb_add_hcd(hcd, pdev->resource[1].start, - IRQF_SHARED); - if (ret == 0) { - platform_set_drvdata(pdev, hcd); - return ret; - } - -err1: - usb_put_hcd(hcd); - return ret; -} - -static int vt8500_ehci_drv_remove(struct platform_device *pdev) -{ - struct usb_hcd *hcd = platform_get_drvdata(pdev); - - usb_remove_hcd(hcd); - usb_put_hcd(hcd); - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static const struct of_device_id vt8500_ehci_ids[] = { - { .compatible = "via,vt8500-ehci", }, - { .compatible = "wm,prizm-ehci", }, - {} -}; - -static struct platform_driver vt8500_ehci_driver = { - .probe = vt8500_ehci_drv_probe, - .remove = vt8500_ehci_drv_remove, - .shutdown = usb_hcd_platform_shutdown, - .driver = { - .name = "vt8500-ehci", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(vt8500_ehci_ids), - } -}; - -MODULE_ALIAS("platform:vt8500-ehci"); -MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);