From patchwork Wed Aug 19 09:50:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 42559 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7J9tKC8002333 for ; Wed, 19 Aug 2009 09:55:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751735AbZHSJzR (ORCPT ); Wed, 19 Aug 2009 05:55:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751550AbZHSJzQ (ORCPT ); Wed, 19 Aug 2009 05:55:16 -0400 Received: from rv-out-0506.google.com ([209.85.198.233]:23849 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751492AbZHSJzP (ORCPT ); Wed, 19 Aug 2009 05:55:15 -0400 Received: by rv-out-0506.google.com with SMTP id f6so1242893rvb.1 for ; Wed, 19 Aug 2009 02:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=jMqkXSUgIq13ibF3dwIA7NEB1fN7cPTrivWwC3uAGzA=; b=t1ENEpWCUqfPcWWYT6Fu3zIgkASIAFu/InSlvBfXcziOMjrz8hPx5pxpB9+cAmnNAG l4nrxta7t66YEWu494+8ORnzaZMPa+G7kvh5aKTd3XhdZjpUaAZSAapcfAygVaYaMunh z0AutwFwO25Yl608kpvSZi2mkEVQr97eKe6dk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=M19nX9aAL33nJ6tItvVh5i3Wk/gqQrQnzrIrvvAsMYjFUisLHjctI212oV1p3acW9Q Qs3h78TeVtJYgLTL0VyZn6R3CElM4bk7QNpVWHQxkoEIWqFYYxTsm8Qmd2M/OiTSvDF3 NGxosg87o33BHBEjuLoFrwi6UULWnqLx068zk= Received: by 10.140.188.15 with SMTP id l15mr1993159rvf.195.1250675716939; Wed, 19 Aug 2009 02:55:16 -0700 (PDT) Received: from rx1.opensource.se (210.5.32.202.bf.2iij.net [202.32.5.210]) by mx.google.com with ESMTPS id k2sm1951424rvb.13.2009.08.19.02.55.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Aug 2009 02:55:16 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org, shimoda.yoshihiro@renesas.com, linux-usb@vger.kernel.org, gregkh@suse.de Date: Wed, 19 Aug 2009 18:50:49 +0900 Message-Id: <20090819095049.11541.67276.sendpatchset@rx1.opensource.se> Subject: [PATCH] usb: add clock support to r8a66597 gadget driver Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm Add support for the clock framework to the r8a66597 gadget driver. This is needed to control the clock driving the USB block. Signed-off-by: Magnus Damm --- drivers/usb/gadget/r8a66597-udc.c | 37 ++++++++++++++++++++++++++++++++++--- drivers/usb/gadget/r8a66597-udc.h | 7 +++++++ 2 files changed, 41 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0002/drivers/usb/gadget/r8a66597-udc.c +++ work/drivers/usb/gadget/r8a66597-udc.c 2009-08-19 18:29:50.000000000 +0900 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1475,6 +1476,12 @@ static int __exit r8a66597_remove(struct iounmap((void *)r8a66597->reg); free_irq(platform_get_irq(pdev, 0), r8a66597); r8a66597_free_request(&r8a66597->ep[0].ep, r8a66597->ep0_req); +#ifdef CONFIG_HAVE_CLK + if (r8a66597->pdata->on_chip) { + clk_disable(r8a66597->clk); + clk_put(r8a66597->clk); + } +#endif kfree(r8a66597); return 0; } @@ -1485,6 +1492,9 @@ static void nop_completion(struct usb_ep static int __init r8a66597_probe(struct platform_device *pdev) { +#ifdef CONFIG_HAVE_CLK + char clk_name[8]; +#endif struct resource *res, *ires; int irq; void __iomem *reg = NULL; @@ -1545,13 +1555,27 @@ static int __init r8a66597_probe(struct r8a66597->bi_bufnum = R8A66597_BASE_BUFNUM; +#ifdef CONFIG_HAVE_CLK + if (r8a66597->pdata->on_chip) { + snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); + r8a66597->clk = clk_get(&pdev->dev, clk_name); + if (IS_ERR(r8a66597->clk)) { + dev_err(&pdev->dev, "cannot get clock \"%s\"\n", + clk_name); + ret = PTR_ERR(r8a66597->clk); + goto clean_up; + } + clk_enable(r8a66597->clk); + } +#endif + disable_controller(r8a66597); /* make sure controller is disabled */ ret = request_irq(irq, r8a66597_irq, IRQF_DISABLED | IRQF_SHARED, udc_name, r8a66597); if (ret < 0) { printk(KERN_ERR "request_irq error (%d)\n", ret); - goto clean_up; + goto clean_up2; } INIT_LIST_HEAD(&r8a66597->gadget.ep_list); @@ -1586,7 +1610,7 @@ static int __init r8a66597_probe(struct r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep, GFP_KERNEL); if (r8a66597->ep0_req == NULL) - goto clean_up2; + goto clean_up3; r8a66597->ep0_req->complete = nop_completion; init_controller(r8a66597); @@ -1594,8 +1618,15 @@ static int __init r8a66597_probe(struct dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); return 0; -clean_up2: +clean_up3: free_irq(irq, r8a66597); +clean_up2: +#ifdef CONFIG_HAVE_CLK + if (r8a66597->pdata->on_chip) { + clk_disable(r8a66597->clk); + clk_put(r8a66597->clk); + } +#endif clean_up: if (r8a66597) { if (r8a66597->ep0_req) --- 0002/drivers/usb/gadget/r8a66597-udc.h +++ work/drivers/usb/gadget/r8a66597-udc.h 2009-08-19 18:22:48.000000000 +0900 @@ -23,6 +23,10 @@ #ifndef __R8A66597_H__ #define __R8A66597_H__ +#ifdef CONFIG_HAVE_CLK +#include +#endif + #include #define R8A66597_MAX_SAMPLING 10 @@ -88,6 +92,9 @@ struct r8a66597 { spinlock_t lock; unsigned long reg; +#ifdef CONFIG_HAVE_CLK + struct clk *clk; +#endif struct r8a66597_platdata *pdata; struct usb_gadget gadget;