All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework
@ 2013-08-02  8:33 ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:33 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Ludovic Desroches
  Cc: linux-usb, linux-kernel, linux-arm-kernel, Boris BREZILLON

Hello,

This patch series prepare the at91 SoCs transition to common clk framework.
This is done by adding a new clock (called usb clock or uclk) to at91_udc
driver. This clock will be used to configure the usb port clock rate.

Best Regards,

Boris

Changes since v2:
- split the patch in 2 parts:
    * add missing clk_put for existing clk (fclk and uclk)
    * add usb clock (uclk) support

Changes since v1:
- use IS_ENABLED(CONFIG_COMMON_CLK) to isolate new at91 clk support  

Boris BREZILLON (2):
  usb: gadget: at91_udc: add missing clk_put on fclk and iclk
  usb: gadget: at91_udc: add usb_clk for transition to common clk
    framework

 drivers/usb/gadget/at91_udc.c |   21 +++++++++++++++++++--
 drivers/usb/gadget/at91_udc.h |    2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 0/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework
@ 2013-08-02  8:33 ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This patch series prepare the at91 SoCs transition to common clk framework.
This is done by adding a new clock (called usb clock or uclk) to at91_udc
driver. This clock will be used to configure the usb port clock rate.

Best Regards,

Boris

Changes since v2:
- split the patch in 2 parts:
    * add missing clk_put for existing clk (fclk and uclk)
    * add usb clock (uclk) support

Changes since v1:
- use IS_ENABLED(CONFIG_COMMON_CLK) to isolate new at91 clk support  

Boris BREZILLON (2):
  usb: gadget: at91_udc: add missing clk_put on fclk and iclk
  usb: gadget: at91_udc: add usb_clk for transition to common clk
    framework

 drivers/usb/gadget/at91_udc.c |   21 +++++++++++++++++++--
 drivers/usb/gadget/at91_udc.h |    2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] usb: gadget: at91_udc: add missing clk_put on fclk and iclk
  2013-08-02  8:33 ` Boris BREZILLON
@ 2013-08-02  8:37   ` Boris BREZILLON
  -1 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:37 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Ludovic Desroches
  Cc: linux-usb, linux-kernel, linux-arm-kernel, Boris BREZILLON

This patch adds missing clk_put on fclk and iclk in case the probe function
fails after these clocks have been retrieved.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/usb/gadget/at91_udc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index fce8e4e..d145cb78 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1851,6 +1851,10 @@ fail3:
 fail2:
 	free_irq(udc->udp_irq, udc);
 fail1:
+	if (!IS_ERR(udc->fclk))
+		clk_put(udc->fclk);
+	if (!IS_ERR(udc->iclk))
+		clk_put(udc->iclk);
 	iounmap(udc->udp_baseaddr);
 fail0a:
 	if (cpu_is_at91rm9200())
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 1/2] usb: gadget: at91_udc: add missing clk_put on fclk and iclk
@ 2013-08-02  8:37   ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:37 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds missing clk_put on fclk and iclk in case the probe function
fails after these clocks have been retrieved.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/usb/gadget/at91_udc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index fce8e4e..d145cb78 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1851,6 +1851,10 @@ fail3:
 fail2:
 	free_irq(udc->udp_irq, udc);
 fail1:
+	if (!IS_ERR(udc->fclk))
+		clk_put(udc->fclk);
+	if (!IS_ERR(udc->iclk))
+		clk_put(udc->iclk);
 	iounmap(udc->udp_baseaddr);
 fail0a:
 	if (cpu_is_at91rm9200())
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework
  2013-08-02  8:33 ` Boris BREZILLON
@ 2013-08-02  8:37   ` Boris BREZILLON
  -1 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:37 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Nicolas Ferre,
	Jean-Christophe Plagniol-Villard, Ludovic Desroches
  Cc: linux-usb, linux-kernel, linux-arm-kernel, Boris BREZILLON

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 adds 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 it).

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/usb/gadget/at91_udc.c |   17 +++++++++++++++--
 drivers/usb/gadget/at91_udc.h |    2 +-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index d145cb78..5c7c8bb 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -870,6 +870,11 @@ static void clk_on(struct at91_udc *udc)
 	if (udc->clocked)
 		return;
 	udc->clocked = 1;
+
+	if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+		clk_set_rate(udc->uclk, 48000000);
+		clk_prepare_enable(udc->uclk);
+	}
 	clk_prepare_enable(udc->iclk);
 	clk_prepare_enable(udc->fclk);
 }
@@ -882,6 +887,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 (IS_ENABLED(CONFIG_COMMON_CLK))
+		clk_disable_unprepare(udc->uclk);
 }
 
 /*
@@ -1774,10 +1781,12 @@ static int at91udc_probe(struct platform_device *pdev)
 	/* get interface and function clocks */
 	udc->iclk = clk_get(dev, "udc_clk");
 	udc->fclk = clk_get(dev, "udpck");
-	if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) {
+	if (IS_ENABLED(CONFIG_COMMON_CLK))
+		udc->uclk = clk_get(dev, "usb_clk");
+	if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) ||
+	    (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) {
 		DBG("clocks missing\n");
 		retval = -ENODEV;
-		/* NOTE: we "know" here that refcounts on these are NOPs */
 		goto fail1;
 	}
 
@@ -1851,6 +1860,8 @@ fail3:
 fail2:
 	free_irq(udc->udp_irq, udc);
 fail1:
+	if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
+		clk_put(udc->uclk);
 	if (!IS_ERR(udc->fclk))
 		clk_put(udc->fclk);
 	if (!IS_ERR(udc->iclk))
@@ -1898,6 +1909,8 @@ static int __exit at91udc_remove(struct platform_device *pdev)
 
 	clk_put(udc->iclk);
 	clk_put(udc->fclk);
+	if (IS_ENABLED(CONFIG_COMMON_CLK))
+		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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3 2/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework
@ 2013-08-02  8:37   ` Boris BREZILLON
  0 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-08-02  8:37 UTC (permalink / raw)
  To: linux-arm-kernel

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 adds 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 it).

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
 drivers/usb/gadget/at91_udc.c |   17 +++++++++++++++--
 drivers/usb/gadget/at91_udc.h |    2 +-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index d145cb78..5c7c8bb 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -870,6 +870,11 @@ static void clk_on(struct at91_udc *udc)
 	if (udc->clocked)
 		return;
 	udc->clocked = 1;
+
+	if (IS_ENABLED(CONFIG_COMMON_CLK)) {
+		clk_set_rate(udc->uclk, 48000000);
+		clk_prepare_enable(udc->uclk);
+	}
 	clk_prepare_enable(udc->iclk);
 	clk_prepare_enable(udc->fclk);
 }
@@ -882,6 +887,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 (IS_ENABLED(CONFIG_COMMON_CLK))
+		clk_disable_unprepare(udc->uclk);
 }
 
 /*
@@ -1774,10 +1781,12 @@ static int at91udc_probe(struct platform_device *pdev)
 	/* get interface and function clocks */
 	udc->iclk = clk_get(dev, "udc_clk");
 	udc->fclk = clk_get(dev, "udpck");
-	if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) {
+	if (IS_ENABLED(CONFIG_COMMON_CLK))
+		udc->uclk = clk_get(dev, "usb_clk");
+	if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk) ||
+	    (IS_ENABLED(CONFIG_COMMON_CLK) && IS_ERR(udc->uclk))) {
 		DBG("clocks missing\n");
 		retval = -ENODEV;
-		/* NOTE: we "know" here that refcounts on these are NOPs */
 		goto fail1;
 	}
 
@@ -1851,6 +1860,8 @@ fail3:
 fail2:
 	free_irq(udc->udp_irq, udc);
 fail1:
+	if (IS_ENABLED(CONFIG_COMMON_CLK) && !IS_ERR(udc->uclk))
+		clk_put(udc->uclk);
 	if (!IS_ERR(udc->fclk))
 		clk_put(udc->fclk);
 	if (!IS_ERR(udc->iclk))
@@ -1898,6 +1909,8 @@ static int __exit at91udc_remove(struct platform_device *pdev)
 
 	clk_put(udc->iclk);
 	clk_put(udc->fclk);
+	if (IS_ENABLED(CONFIG_COMMON_CLK))
+		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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-02  8:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-02  8:33 [PATCH v3 0/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework Boris BREZILLON
2013-08-02  8:33 ` Boris BREZILLON
2013-08-02  8:37 ` [PATCH v3 1/2] usb: gadget: at91_udc: add missing clk_put on fclk and iclk Boris BREZILLON
2013-08-02  8:37   ` Boris BREZILLON
2013-08-02  8:37 ` [PATCH v3 2/2] usb: gadget: at91_udc: add usb_clk for transition to common clk framework Boris BREZILLON
2013-08-02  8:37   ` Boris BREZILLON

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.