mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Boris BREZILLON <b.brezillon@overkiz.com>
To: Nicolas Ferre <nicolas.ferre@atmel.com>,
	Ludovic Desroches <ludovic.desroches@atmel.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	Boris BREZILLON <b.brezillon@overkiz.com>
Subject: [PATCH v3 7/7] usb: gadget: at91_udc: add usb_clk for transition to common clk framework
Date: Tue, 16 Jul 2013 17:25:10 +0200	[thread overview]
Message-ID: <1373988310-24734-1-git-send-email-b.brezillon@overkiz.com> (raw)
In-Reply-To: <1373986995-23899-1-git-send-email-b.brezillon@overkiz.com>

The AT91 PMC (Power Management Controller) provides an USB clock used by
USB Full Speed host (ohci) and USB Full Speed device (udc).
The usb drivers (ohci and udc) must configure this clock to 48Mhz.
This configuration was formely done in mach-at91/clock.c, but this
implementation will be removed when moving to common clk framework.

This patch add support for usb clock retrieval and configuration, and is
backward compatible with the current at91 clk implementation (if usb clk
is not found, it does not configure/enable the usb clk).

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/usb/gadget/at91_udc.c |   12 ++++++++++++
 drivers/usb/gadget/at91_udc.h |    2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index fce8e4e..1306a02 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -870,6 +870,10 @@ static void clk_on(struct at91_udc *udc)
 	if (udc->clocked)
 		return;
 	udc->clocked = 1;
+	if (udc->uclk) {
+		clk_set_rate(udc->uclk, 48000000);
+		clk_prepare_enable(udc->uclk);
+	}
 	clk_prepare_enable(udc->iclk);
 	clk_prepare_enable(udc->fclk);
 }
@@ -882,6 +886,8 @@ static void clk_off(struct at91_udc *udc)
 	udc->gadget.speed = USB_SPEED_UNKNOWN;
 	clk_disable_unprepare(udc->fclk);
 	clk_disable_unprepare(udc->iclk);
+	if (udc->uclk)
+		clk_disable_unprepare(udc->uclk);
 }
 
 /*
@@ -1781,6 +1787,10 @@ static int at91udc_probe(struct platform_device *pdev)
 		goto fail1;
 	}
 
+	udc->uclk = clk_get(dev, "usb_clk");
+	if (IS_ERR(udc->uclk))
+		udc->uclk = NULL;
+
 	/* don't do anything until we have both gadget driver and VBUS */
 	retval = clk_prepare_enable(udc->iclk);
 	if (retval)
@@ -1894,6 +1904,8 @@ static int __exit at91udc_remove(struct platform_device *pdev)
 
 	clk_put(udc->iclk);
 	clk_put(udc->fclk);
+	if (udc->uclk)
+		clk_put(udc->uclk);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index e647d1c..0175246 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -126,7 +126,7 @@ struct at91_udc {
 	unsigned			active_suspend:1;
 	u8				addr;
 	struct at91_udc_data		board;
-	struct clk			*iclk, *fclk;
+	struct clk			*iclk, *fclk, *uclk;
 	struct platform_device		*pdev;
 	struct proc_dir_entry		*pde;
 	void __iomem			*udp_baseaddr;
-- 
1.7.9.5


      parent reply	other threads:[~2013-07-16 15:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 15:03 [PATCH v3 0/7] ARM: at91: prepare " Boris BREZILLON
2013-07-16 15:05 ` [PATCH v3 1/7] ARM: at91/tc/clocksource: replace clk_enable/disable with clk_prepare_enable/disable_unprepare Boris BREZILLON
2013-07-16 15:48   ` Daniel Lezcano
2013-07-16 15:06 ` [PATCH v3 2/7] mmc: atmel-mci: prepare clk before calling enable Boris BREZILLON
2013-07-16 15:13   ` Thomas Petazzoni
2013-07-16 15:49     ` boris brezillon
2013-07-16 17:13   ` Russell King - ARM Linux
2013-07-16 15:08 ` [PATCH v3 3/7] at91/avr32/atmel_lcdfb: " Boris BREZILLON
2013-07-16 15:10 ` [PATCH v3 4/7] USB: gadget: atmel_usba: " Boris BREZILLON
2013-07-16 15:16 ` [PATCH v3 5/7] spi: atmel: " Boris BREZILLON
2013-07-17  8:10   ` Mark Brown
2013-07-16 15:22 ` [PATCH v3 6/7] USB: ohci-at91: add usb_clk for transition to common clk framework Boris BREZILLON
2013-07-16 16:48   ` Alan Stern
2013-07-16 17:08     ` boris brezillon
2013-07-16 18:47       ` Alan Stern
2013-07-16 19:06         ` boris brezillon
2013-07-16 17:07   ` Russell King - ARM Linux
2013-07-17 15:33   ` Alan Stern
2013-07-17 15:45     ` boris brezillon
2013-07-17 16:17       ` Alan Stern
2013-07-16 15:25 ` Boris BREZILLON [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373988310-24734-1-git-send-email-b.brezillon@overkiz.com \
    --to=b.brezillon@overkiz.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=ludovic.desroches@atmel.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®