linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] usb: gadget: Add clock support
@ 2021-09-28  5:27 Shubhrajyoti Datta
  2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
  2021-09-28  5:27 ` [PATCH v4 2/2] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta
  0 siblings, 2 replies; 7+ messages in thread
From: Shubhrajyoti Datta @ 2021-09-28  5:27 UTC (permalink / raw)
  To: devicetree, linux-usb; +Cc: git-dev, Shubhrajyoti Datta

Add clock support to udc xilinx.

v2:
Add the clock binding
v3:
Add a warn print
v4:
Update the clock binding

Shubhrajyoti Datta (2):
  dt-binding: usb: xilinx: Add clocking node
  usb: gadget: udc-xilinx: Add clock support

 .../devicetree/bindings/usb/xlnx,usb2.yaml    |  6 +++++
 drivers/usb/gadget/udc/udc-xilinx.c           | 25 +++++++++++++++++++
 2 files changed, 31 insertions(+)

-- 
2.25.1


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

* [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node
  2021-09-28  5:27 [PATCH v4 0/2] usb: gadget: Add clock support Shubhrajyoti Datta
@ 2021-09-28  5:27 ` Shubhrajyoti Datta
  2021-09-29 22:50   ` Rob Herring
                     ` (2 more replies)
  2021-09-28  5:27 ` [PATCH v4 2/2] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta
  1 sibling, 3 replies; 7+ messages in thread
From: Shubhrajyoti Datta @ 2021-09-28  5:27 UTC (permalink / raw)
  To: devicetree, linux-usb; +Cc: git-dev, Shubhrajyoti Datta

Add a clocking node for xilinx udc.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
---
v3:
update clock description and names

 Documentation/devicetree/bindings/usb/xlnx,usb2.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/xlnx,usb2.yaml b/Documentation/devicetree/bindings/usb/xlnx,usb2.yaml
index b8acc415eaf1..04c123c7252a 100644
--- a/Documentation/devicetree/bindings/usb/xlnx,usb2.yaml
+++ b/Documentation/devicetree/bindings/usb/xlnx,usb2.yaml
@@ -24,6 +24,12 @@ properties:
       If present, hardware has dma capability.
     type: boolean
 
+  clocks:
+    minItems: 1
+
+  clock-names:
+    const: s_axi_aclk
+
 required:
   - compatible
   - reg
-- 
2.25.1


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

* [PATCH v4 2/2] usb: gadget: udc-xilinx: Add clock support
  2021-09-28  5:27 [PATCH v4 0/2] usb: gadget: Add clock support Shubhrajyoti Datta
  2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
@ 2021-09-28  5:27 ` Shubhrajyoti Datta
  1 sibling, 0 replies; 7+ messages in thread
From: Shubhrajyoti Datta @ 2021-09-28  5:27 UTC (permalink / raw)
  To: devicetree, linux-usb; +Cc: git-dev, Shubhrajyoti Datta, Felipe Balbi

Currently the driver depends on the  bootloader to enable the clocks.
Add support for clocking. The patch enables the clock at  probe and
disables them at remove.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
---
v3:
Add dev_warn

 drivers/usb/gadget/udc/udc-xilinx.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index fb4ffedd6f0d..f5ca670776a3 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -11,6 +11,7 @@
  * USB peripheral controller (at91_udc.c).
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
@@ -171,6 +172,7 @@ struct xusb_ep {
  * @addr: the usb device base address
  * @lock: instance of spinlock
  * @dma_enabled: flag indicating whether the dma is included in the system
+ * @clk: pointer to struct clk
  * @read_fn: function pointer to read device registers
  * @write_fn: function pointer to write to device registers
  */
@@ -188,6 +190,7 @@ struct xusb_udc {
 	void __iomem *addr;
 	spinlock_t lock;
 	bool dma_enabled;
+	struct clk *clk;
 
 	unsigned int (*read_fn)(void __iomem *);
 	void (*write_fn)(void __iomem *, u32, u32);
@@ -2092,6 +2095,27 @@ static int xudc_probe(struct platform_device *pdev)
 	udc->gadget.ep0 = &udc->ep[XUSB_EP_NUMBER_ZERO].ep_usb;
 	udc->gadget.name = driver_name;
 
+	udc->clk = devm_clk_get(&pdev->dev, "s_axi_aclk");
+	if (IS_ERR(udc->clk)) {
+		if (PTR_ERR(udc->clk) != -ENOENT) {
+			ret = PTR_ERR(udc->clk);
+			goto fail;
+		}
+
+		/*
+		 * Clock framework support is optional, continue on,
+		 * anyways if we don't find a matching clock
+		 */
+		dev_warn(&pdev->dev, "s_axi_aclk clock property is not found\n");
+		udc->clk = NULL;
+	}
+
+	ret = clk_prepare_enable(udc->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Unable to enable clock.\n");
+		return ret;
+	}
+
 	spin_lock_init(&udc->lock);
 
 	/* Check for IP endianness */
@@ -2147,6 +2171,7 @@ static int xudc_remove(struct platform_device *pdev)
 	struct xusb_udc *udc = platform_get_drvdata(pdev);
 
 	usb_del_gadget_udc(&udc->gadget);
+	clk_disable_unprepare(udc->clk);
 
 	return 0;
 }
-- 
2.25.1


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

* Re: [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node
  2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
@ 2021-09-29 22:50   ` Rob Herring
  2021-10-05 10:55   ` Greg KH
  2021-10-08 19:32   ` Rob Herring
  2 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2021-09-29 22:50 UTC (permalink / raw)
  To: Shubhrajyoti Datta; +Cc: linux-usb, git-dev, devicetree

On Tue, 28 Sep 2021 10:57:10 +0530, Shubhrajyoti Datta wrote:
> Add a clocking node for xilinx udc.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v3:
> update clock description and names
> 
>  Documentation/devicetree/bindings/usb/xlnx,usb2.yaml | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node
  2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
  2021-09-29 22:50   ` Rob Herring
@ 2021-10-05 10:55   ` Greg KH
  2021-10-05 10:59     ` Michal Simek
  2021-10-08 19:32   ` Rob Herring
  2 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2021-10-05 10:55 UTC (permalink / raw)
  To: Shubhrajyoti Datta; +Cc: devicetree, linux-usb, git-dev

On Tue, Sep 28, 2021 at 10:57:10AM +0530, Shubhrajyoti Datta wrote:
> Add a clocking node for xilinx udc.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v3:
> update clock description and names
> 
>  Documentation/devicetree/bindings/usb/xlnx,usb2.yaml | 6 ++++++

This file is not in my tree, where does it come from?

thanks,

greg k-h

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

* Re: [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node
  2021-10-05 10:55   ` Greg KH
@ 2021-10-05 10:59     ` Michal Simek
  0 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2021-10-05 10:59 UTC (permalink / raw)
  To: Greg KH, Shubhrajyoti Datta; +Cc: devicetree, linux-usb, git-dev



On 10/5/21 12:55 PM, Greg KH wrote:
> On Tue, Sep 28, 2021 at 10:57:10AM +0530, Shubhrajyoti Datta wrote:
>> Add a clocking node for xilinx udc.
>>
>> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>> ---
>> v3:
>> update clock description and names
>>
>>  Documentation/devicetree/bindings/usb/xlnx,usb2.yaml | 6 ++++++
> 
> This file is not in my tree, where does it come from?

In linux-next I see that Rob has applied it to his tree as commit
ecc4103f32e9 ("dt-binding: usb: xilinx: Convert binding to YAML")

Thanks,
Michal

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

* Re: [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node
  2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
  2021-09-29 22:50   ` Rob Herring
  2021-10-05 10:55   ` Greg KH
@ 2021-10-08 19:32   ` Rob Herring
  2 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2021-10-08 19:32 UTC (permalink / raw)
  To: Shubhrajyoti Datta; +Cc: devicetree, linux-usb, git-dev

On Tue, 28 Sep 2021 10:57:10 +0530, Shubhrajyoti Datta wrote:
> Add a clocking node for xilinx udc.
> 
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> v3:
> update clock description and names
> 
>  Documentation/devicetree/bindings/usb/xlnx,usb2.yaml | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

Since I picked up the conversion, applied. Thanks!

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

end of thread, other threads:[~2021-10-08 19:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28  5:27 [PATCH v4 0/2] usb: gadget: Add clock support Shubhrajyoti Datta
2021-09-28  5:27 ` [PATCH v4 1/2] dt-binding: usb: xilinx: Add clocking node Shubhrajyoti Datta
2021-09-29 22:50   ` Rob Herring
2021-10-05 10:55   ` Greg KH
2021-10-05 10:59     ` Michal Simek
2021-10-08 19:32   ` Rob Herring
2021-09-28  5:27 ` [PATCH v4 2/2] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).