* [PATCH] usb: gadget: udc-xilinx: Add clock support
@ 2018-04-03 6:28 shubhrajyoti.datta
2018-04-09 7:40 ` Felipe Balbi
0 siblings, 1 reply; 2+ messages in thread
From: shubhrajyoti.datta @ 2018-04-03 6:28 UTC (permalink / raw)
To: linux-usb
Cc: shubhrajyoti.datta, devicetree, gregkh, michal.simek, balbi,
Shubhrajyoti Datta
From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
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>
---
.../devicetree/bindings/usb/udc-xilinx.txt | 4 ++++
drivers/usb/gadget/udc/udc-xilinx.c | 23 ++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/udc-xilinx.txt b/Documentation/devicetree/bindings/usb/udc-xilinx.txt
index 47b4e39..da2fedc 100644
--- a/Documentation/devicetree/bindings/usb/udc-xilinx.txt
+++ b/Documentation/devicetree/bindings/usb/udc-xilinx.txt
@@ -8,6 +8,10 @@ Required properties:
controller
- xlnx,has-builtin-dma : if DMA is included
+Optional properties:
+- clock-names : should be "s_axi_aclk"
+- clocks : Input clock specifier. Refer to common clock bindings.
+
Example:
axi-usb2-device@42e00000 {
compatible = "xlnx,usb2-device-4.00.a";
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index 6407e43..8e81171 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>
@@ -188,6 +189,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);
@@ -2094,6 +2096,26 @@ 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
+ */
+ 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 */
@@ -2149,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.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: udc-xilinx: Add clock support
2018-04-03 6:28 [PATCH] usb: gadget: udc-xilinx: Add clock support shubhrajyoti.datta
@ 2018-04-09 7:40 ` Felipe Balbi
0 siblings, 0 replies; 2+ messages in thread
From: Felipe Balbi @ 2018-04-09 7:40 UTC (permalink / raw)
To: shubhrajyoti.datta, linux-usb
Cc: devicetree, gregkh, michal.simek, Shubhrajyoti Datta
[-- Attachment #1: Type: text/plain, Size: 506 bytes --]
Hi,
shubhrajyoti.datta@gmail.com writes:
> From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
>
> 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>
which platform uses this? Isn't zynq using the chipidea core? Why don't
you switch this board to the generic chipidea driver instead?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-09 7:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 6:28 [PATCH] usb: gadget: udc-xilinx: Add clock support shubhrajyoti.datta
2018-04-09 7:40 ` Felipe Balbi
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).