* [PATCH] usb: gadget: udc-xilinx: Add clock support
@ 2021-08-18 9:47 Shubhrajyoti Datta
2021-08-18 9:50 ` Shubhrajyoti Datta
2021-08-18 9:54 ` Felipe Balbi
0 siblings, 2 replies; 5+ messages in thread
From: Shubhrajyoti Datta @ 2021-08-18 9:47 UTC (permalink / raw)
To: linux-usb; +Cc: gregkh, michal.simek, git, Shubhrajyoti Datta
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>
---
drivers/usb/gadget/udc/udc-xilinx.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index fb4ffedd6f0d..30070a488c87 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,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 */
@@ -2147,6 +2170,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] 5+ messages in thread
* RE: [PATCH] usb: gadget: udc-xilinx: Add clock support
2021-08-18 9:47 [PATCH] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta
@ 2021-08-18 9:50 ` Shubhrajyoti Datta
2021-08-18 9:54 ` Felipe Balbi
1 sibling, 0 replies; 5+ messages in thread
From: Shubhrajyoti Datta @ 2021-08-18 9:50 UTC (permalink / raw)
To: Shubhrajyoti Datta, linux-usb; +Cc: gregkh, Michal Simek, git
> -----Original Message-----
> From: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> Sent: Wednesday, August 18, 2021 3:17 PM
> To: linux-usb@vger.kernel.org
> Cc: gregkh@linuxfoundation.org; Michal Simek <michals@xilinx.com>; git
> <git@xilinx.com>; Shubhrajyoti Datta <shubhraj@xilinx.com>
> Subject: [PATCH] usb: gadget: udc-xilinx: Add clock support
>
> 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>
> ---
Please ignore will resend
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: gadget: udc-xilinx: Add clock support
2021-08-18 9:47 [PATCH] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta
2021-08-18 9:50 ` Shubhrajyoti Datta
@ 2021-08-18 9:54 ` Felipe Balbi
2021-09-17 9:44 ` Shubhrajyoti Datta
1 sibling, 1 reply; 5+ messages in thread
From: Felipe Balbi @ 2021-08-18 9:54 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-usb, gregkh, michal.simek, git
Hi,
Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> writes:
> 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>
> ---
> drivers/usb/gadget/udc/udc-xilinx.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
> index fb4ffedd6f0d..30070a488c87 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,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;
should it be, though? Might be a good idea to add fixed-clock instances
to the boards still depending on clock framework. Maybe that can be done
over time, but worth considering anyhow.
--
balbi
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] usb: gadget: udc-xilinx: Add clock support
2021-08-18 9:54 ` Felipe Balbi
@ 2021-09-17 9:44 ` Shubhrajyoti Datta
2021-09-17 14:27 ` Felipe Balbi
0 siblings, 1 reply; 5+ messages in thread
From: Shubhrajyoti Datta @ 2021-09-17 9:44 UTC (permalink / raw)
To: Felipe Balbi; +Cc: linux-usb, gregkh, Michal Simek, git
> -----Original Message-----
> From: Felipe Balbi <balbi@kernel.org>
> Sent: Wednesday, August 18, 2021 3:24 PM
> To: Shubhrajyoti Datta <shubhraj@xilinx.com>
> Cc: linux-usb@vger.kernel.org; gregkh@linuxfoundation.org; Michal Simek
> <michals@xilinx.com>; git <git@xilinx.com>
> Subject: Re: [PATCH] usb: gadget: udc-xilinx: Add clock support
>
>
> Hi,
>
> Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> writes:
> > 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>
> > ---
> > drivers/usb/gadget/udc/udc-xilinx.c | 24 ++++++++++++++++++++++++
> > 1 file changed, 24 insertions(+)
> >
> > diff --git a/drivers/usb/gadget/udc/udc-xilinx.c
> > b/drivers/usb/gadget/udc/udc-xilinx.c
> > index fb4ffedd6f0d..30070a488c87 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,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;
>
> should it be, though? Might be a good idea to add fixed-clock instances to the
> boards still depending on clock framework. Maybe that can be done over time,
> but worth considering anyhow.
But for backward compatibility , I think it will be good to have the support instead of forcing the fixed-clock node.
>
> --
> balbi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: gadget: udc-xilinx: Add clock support
2021-09-17 9:44 ` Shubhrajyoti Datta
@ 2021-09-17 14:27 ` Felipe Balbi
0 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2021-09-17 14:27 UTC (permalink / raw)
To: Shubhrajyoti Datta; +Cc: linux-usb, gregkh, Michal Simek, git
Hi,
Shubhrajyoti Datta <shubhraj@xilinx.com> writes:
>> -----Original Message-----
>> From: Felipe Balbi <balbi@kernel.org>
>> Sent: Wednesday, August 18, 2021 3:24 PM
>> To: Shubhrajyoti Datta <shubhraj@xilinx.com>
>> Cc: linux-usb@vger.kernel.org; gregkh@linuxfoundation.org; Michal Simek
>> <michals@xilinx.com>; git <git@xilinx.com>
>> Subject: Re: [PATCH] usb: gadget: udc-xilinx: Add clock support
>>
>>
>> Hi,
>>
>> Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> writes:
>> > 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>
>> > ---
>> > drivers/usb/gadget/udc/udc-xilinx.c | 24 ++++++++++++++++++++++++
>> > 1 file changed, 24 insertions(+)
>> >
>> > diff --git a/drivers/usb/gadget/udc/udc-xilinx.c
>> > b/drivers/usb/gadget/udc/udc-xilinx.c
>> > index fb4ffedd6f0d..30070a488c87 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,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;
>>
>> should it be, though? Might be a good idea to add fixed-clock instances to the
>> boards still depending on clock framework. Maybe that can be done over time,
>> but worth considering anyhow.
>
> But for backward compatibility , I think it will be good to have the
> support instead of forcing the fixed-clock node.
you gotta explain that a little better. Care to do so?
--
balbi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-17 14:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 9:47 [PATCH] usb: gadget: udc-xilinx: Add clock support Shubhrajyoti Datta
2021-08-18 9:50 ` Shubhrajyoti Datta
2021-08-18 9:54 ` Felipe Balbi
2021-09-17 9:44 ` Shubhrajyoti Datta
2021-09-17 14:27 ` 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).