From patchwork Tue Apr 16 06:04:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: manjunath.goudar@linaro.org X-Patchwork-Id: 16141 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 101352395D for ; Tue, 16 Apr 2013 06:10:30 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id k5sf220365ggn.0 for ; Mon, 15 Apr 2013 23:09:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=XOZVDtbZIWD1nswDsdsPL/0W1wKM1WqpZTGCXGK9GMQ=; b=j5FPEAR3MabQk5ByRlaEr7t5R0Mar06DltnZto+RpsJ8UOjPzpcr6ka8SKdWr5nS7m VSqF6EUU37pgC9UwaPMjODuLVY38HOPKNsjMTe6ccCMjTrk/v6fc7FQ05H7UtuTtNwwG Ql8Is4C8wI50U3dQ2NIUiBAyzVuOKYKVfVnRI33J5amoGBlhpvxYuQDFKaGBncupgqe+ +ct1q1pFiM4kBosjI6g+8RQ65IIoHgXKPbOvczIXnR+0aArBrV/0R3DQmRKCQoPFdnbb K/6hWtiUh4LlXxNloB9red8B4QcTqk4VwGuQ+iOOBxU32OunEwX2g/QNTCHyilg33ntk 4D5g== X-Received: by 10.236.102.200 with SMTP id d48mr502227yhg.3.1366092597800; Mon, 15 Apr 2013 23:09:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.130.100 with SMTP id od4ls140280qeb.27.gmail; Mon, 15 Apr 2013 23:09:57 -0700 (PDT) X-Received: by 10.52.35.110 with SMTP id g14mr464721vdj.61.1366092597563; Mon, 15 Apr 2013 23:09:57 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id b4si370552vdw.109.2013.04.15.23.09.57 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 23:09:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hx10so105382vcb.0 for ; Mon, 15 Apr 2013 23:09:57 -0700 (PDT) X-Received: by 10.58.84.164 with SMTP id a4mr577901vez.9.1366092286172; Mon, 15 Apr 2013 23:04:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp8530veb; Mon, 15 Apr 2013 23:04:45 -0700 (PDT) X-Received: by 10.68.135.231 with SMTP id pv7mr1136369pbb.108.1366092285132; Mon, 15 Apr 2013 23:04:45 -0700 (PDT) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id fd8si1294749pad.336.2013.04.15.23.04.44 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 23:04:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.44 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id bi5so158384pad.17 for ; Mon, 15 Apr 2013 23:04:44 -0700 (PDT) X-Received: by 10.66.226.171 with SMTP id rt11mr1637533pac.131.1366092284623; Mon, 15 Apr 2013 23:04:44 -0700 (PDT) Received: from manjunath-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPS id ra9sm1252434pab.16.2013.04.15.23.04.41 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 23:04:43 -0700 (PDT) From: manjunath.goudar@linaro.org To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org Subject: [REF PATCH 1/2] USB: OHCI: prepare to make ohci-hcd a library module Date: Tue, 16 Apr 2013 11:34:27 +0530 Message-Id: <516ce9fb.c98b420a.1599.5b38@mx.google.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366092268-4458-1-git-send-email-y> References: <1366092268-4458-1-git-send-email-y> X-Gm-Message-State: ALoCoQk6ghbhTSylbrkt+duOgY0BwbHklwUzV6FUor4O6d8SGm8yTYdABN5lepHbkim9HdWwZaKR X-Original-Sender: manjunath.goudar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Manjunath Goudar This patch prepares ohci-hcd for being split up into a core library and separate platform driver modules. A generic ohci_hc_driver structure is created, containing all the "standard" values, and a new mechanism is added whereby a driver module can specify a set of overrides to those values. In addition the ohci_init(),ohci_restart(),ohci_hcd_init(),ohci_run() ohci_stop(), ohci_suspend() and ohci_resume() routines need to be EXPORTed for use by the drivers. Signed-off-by: Manjunath Goudar Cc: Arnd Bergmann Cc: Greg KH Cc: Alan Stern Cc: linux-usb@vger.kernel.org --- drivers/usb/host/ohci-hcd.c | 90 +++++++++++++++++++++++++++++++++++-------- drivers/usb/host/ohci-mem.c | 3 +- drivers/usb/host/ohci.h | 34 ++++++++++++++++ 3 files changed, 110 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 9e6de95..073917c 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -79,12 +79,6 @@ static const char hcd_name [] = "ohci_hcd"; #include "pci-quirks.h" static void ohci_dump (struct ohci_hcd *ohci, int verbose); -static int ohci_init (struct ohci_hcd *ohci); -static void ohci_stop (struct usb_hcd *hcd); - -#if defined(CONFIG_PM) || defined(CONFIG_PCI) -static int ohci_restart (struct ohci_hcd *ohci); -#endif #ifdef CONFIG_PCI static void sb800_prefetch(struct ohci_hcd *ohci, int on); @@ -520,7 +514,7 @@ done: /* init memory, and kick BIOS/SMM off */ -static int ohci_init (struct ohci_hcd *ohci) +int ohci_init(struct ohci_hcd *ohci) { int ret; struct usb_hcd *hcd = ohci_to_hcd(ohci); @@ -590,6 +584,7 @@ static int ohci_init (struct ohci_hcd *ohci) return ret; } +EXPORT_SYMBOL_GPL(ohci_init); /*-------------------------------------------------------------------------*/ @@ -597,7 +592,7 @@ static int ohci_init (struct ohci_hcd *ohci) * resets USB and controller * enable interrupts */ -static int ohci_run (struct ohci_hcd *ohci) +int ohci_run(struct ohci_hcd *ohci) { u32 mask, val; int first = ohci->fminterval == 0; @@ -767,6 +762,7 @@ retry: return 0; } +EXPORT_SYMBOL_GPL(ohci_run); /*-------------------------------------------------------------------------*/ @@ -914,7 +910,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) /*-------------------------------------------------------------------------*/ -static void ohci_stop (struct usb_hcd *hcd) +void ohci_stop(struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); @@ -943,13 +939,13 @@ static void ohci_stop (struct usb_hcd *hcd) ohci->hcca_dma = 0; } } - +EXPORT_SYMBOL_GPL(ohci_stop); /*-------------------------------------------------------------------------*/ #if defined(CONFIG_PM) || defined(CONFIG_PCI) /* must not be called from interrupt context */ -static int ohci_restart (struct ohci_hcd *ohci) +int ohci_restart(struct ohci_hcd *ohci) { int temp; int i; @@ -1008,12 +1004,12 @@ static int ohci_restart (struct ohci_hcd *ohci) ohci_dbg(ohci, "restart complete\n"); return 0; } - +EXPORT_SYMBOL_GPL(ohci_restart); #endif #ifdef CONFIG_PM -static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) +int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); unsigned long flags; @@ -1031,9 +1027,9 @@ static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) return 0; } +EXPORT_SYMBOL_GPL(ohci_suspend); - -static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated) +int ohci_resume(struct usb_hcd *hcd, bool hibernated) { struct ohci_hcd *ohci = hcd_to_ohci(hcd); int port; @@ -1081,11 +1077,73 @@ static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated) return 0; } - +EXPORT_SYMBOL_GPL(ohci_resume); #endif /*-------------------------------------------------------------------------*/ +/* + * Generic structure: This gets copied for platform drivers so that + * individual entries can be overridden as needed. + */ + +static const struct hc_driver ohci_hc_driver = { + .description = hcd_name, + .product_desc = "OHCI Host Controller", + .hcd_priv_size = sizeof(struct ohci_hcd), + + /* + * generic hardware linkage + */ + .irq = ohci_irq, + .flags = HCD_MEMORY | HCD_USB11, + + /* + * basic lifecycle operations + */ + .start = ohci_run, + .stop = ohci_stop, + .shutdown = ohci_shutdown, + + /* + * managing i/o requests and associated device resources + */ + .urb_enqueue = ohci_urb_enqueue, + .urb_dequeue = ohci_urb_dequeue, + .endpoint_disable = ohci_endpoint_disable, + + /* + * scheduling support + */ + .get_frame_number = ohci_get_frame, + + /* + * root hub support + */ + .hub_status_data = ohci_hub_status_data, + .hub_control = ohci_hub_control, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, + .start_port_reset = ohci_start_port_reset, +}; + +void ohci_init_driver(struct hc_driver *drv, + const struct ohci_driver_overrides *over) +{ + /* Copy the generic table to drv and then apply the overrides */ + *drv = ohci_hc_driver; + + drv->product_desc = over->product_desc; + drv->hcd_priv_size += over->extra_priv_size; + if (over->reset) + drv->reset = over->reset; + if (over->start) + drv->start = over->start; +} +EXPORT_SYMBOL_GPL(ohci_init_driver); + +/*-------------------------------------------------------------------------*/ + MODULE_AUTHOR (DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE ("GPL"); diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index 2f20d3d..1a4dede 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c @@ -23,12 +23,13 @@ /*-------------------------------------------------------------------------*/ -static void ohci_hcd_init (struct ohci_hcd *ohci) +void ohci_hcd_init (struct ohci_hcd *ohci) { ohci->next_statechange = jiffies; spin_lock_init (&ohci->lock); INIT_LIST_HEAD (&ohci->pending); } +EXPORT_SYMBOL_GPL(ohci_hcd_init); /*-------------------------------------------------------------------------*/ diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index d329914..c7adb9c 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -718,3 +718,37 @@ static inline u32 roothub_status (struct ohci_hcd *hc) { return ohci_readl (hc, &hc->regs->roothub.status); } static inline u32 roothub_portstatus (struct ohci_hcd *hc, int i) { return read_roothub (hc, portstatus [i], 0xffe0fce0); } + +/* Declarations of things exported for use by ohci platform drivers */ + +struct ohci_driver_overrides { + const char *product_desc; + size_t extra_priv_size; + int (*reset)(struct usb_hcd *hcd); + int (*start)(struct usb_hcd *hcd); +}; + +extern void ohci_init_driver(struct hc_driver *drv, + const struct ohci_driver_overrides *over); +extern int ohci_init (struct ohci_hcd *ohci); +extern void ohci_stop (struct usb_hcd *hcd); +extern void ohci_hcd_init (struct ohci_hcd *ohci); +extern int ohci_run (struct ohci_hcd *ohci); + +#if defined(CONFIG_PM) || defined(CONFIG_PCI) +extern int ohci_restart (struct ohci_hcd *ohci); +#endif + +#ifdef CONFIG_PM +extern int ohci_suspend(struct usb_hcd *hcd, bool do_wakeup); +extern int ohci_resume(struct usb_hcd *hcd, bool hibernated); +#else +static inline void ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) +{ + return; +} +static inline int ohci_resume(struct usb_hcd *hcd, bool hibernated) +{ + return; +} +#endif