* [PATCHv2 1/2] gpio: xilinx: dt-binding: Add clock node @ 2016-11-09 5:09 Shubhrajyoti Datta 2016-11-09 5:09 ` [PATCHv2 2/2] gpio: xilinx: Add clock support Shubhrajyoti Datta 0 siblings, 1 reply; 6+ messages in thread From: Shubhrajyoti Datta @ 2016-11-09 5:09 UTC (permalink / raw) To: linux-gpio, devicetree Cc: soren.brinkmann, michal.simek, shubhrajyoti.datta, Shubhrajyoti Datta Add the clock node to the dt binding. Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> --- v2: Make clocks optional Add clock name .../devicetree/bindings/gpio/gpio-xilinx.txt | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt b/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt index 63bf4be..1372007 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-xilinx.txt @@ -25,12 +25,16 @@ Optional properties: - xlnx,dout-default-2 : as above but the second channel - xlnx,gpio2-width : as above but for the second channel - xlnx,tri-default-2 : as above but for the second channel +- clocks: Input clock specifier. Refer to common clock bindings. +- clock-names: Input clock name, should be s_axi_aclk. Example: gpio: gpio@40000000 { #gpio-cells = <2>; compatible = "xlnx,xps-gpio-1.00.a"; + clocks = <&clkc 15>; + clock-names = "s_axi_aclk"; gpio-controller ; interrupt-parent = <µblaze_0_intc>; interrupts = < 6 2 >; -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCHv2 2/2] gpio: xilinx: Add clock support 2016-11-09 5:09 [PATCHv2 1/2] gpio: xilinx: dt-binding: Add clock node Shubhrajyoti Datta @ 2016-11-09 5:09 ` Shubhrajyoti Datta [not found] ` <1478668191-26322-2-git-send-email-shubhrajyoti.datta-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Shubhrajyoti Datta @ 2016-11-09 5:09 UTC (permalink / raw) To: linux-gpio, devicetree Cc: soren.brinkmann, michal.simek, shubhrajyoti.datta, Shubhrajyoti Datta Add basic clock support for xilinx gpio. Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> --- v2 : no change drivers/gpio/gpio-xilinx.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 14b2a62..923cab8 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -13,6 +13,7 @@ */ #include <linux/bitops.h> +#include <linux/clk.h> #include <linux/init.h> #include <linux/errno.h> #include <linux/module.h> @@ -45,6 +46,7 @@ * @gpio_state: GPIO state shadow register * @gpio_dir: GPIO direction shadow register * @gpio_lock: Lock used for synchronization + * @clk: Clock resource for this controller */ struct xgpio_instance { struct of_mm_gpio_chip mmchip; @@ -52,6 +54,7 @@ struct xgpio_instance { u32 gpio_state[2]; u32 gpio_dir[2]; spinlock_t gpio_lock[2]; + struct clk *clk; }; static inline int xgpio_index(struct xgpio_instance *chip, int gpio) @@ -282,6 +285,7 @@ static int xgpio_remove(struct platform_device *pdev) struct xgpio_instance *chip = platform_get_drvdata(pdev); of_mm_gpiochip_remove(&chip->mmchip); + clk_disable_unprepare(chip->clk); return 0; } @@ -307,6 +311,23 @@ static int xgpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, chip); + /* Retrieve GPIO clock */ + chip->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(chip->clk)) { + if (PTR_ERR(chip->clk) == -ENOENT) { + dev_info(&pdev->dev, "No clocks found for clk\n"); + chip->clk = NULL; + } else { + dev_err(&pdev->dev, "axi clock error\n"); + return PTR_ERR(chip->clk); + } + } + status = clk_prepare_enable(chip->clk); + if (status) { + dev_err(&pdev->dev, "Unable to enable clock.\n"); + return status; + } + /* Update GPIO state shadow register with default value */ of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state[0]); @@ -362,6 +383,7 @@ static int xgpio_probe(struct platform_device *pdev) if (status) { pr_err("%s: error in probe function with status %d\n", np->full_name, status); + clk_disable_unprepare(chip->clk); return status; } -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1478668191-26322-2-git-send-email-shubhrajyoti.datta-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCHv2 2/2] gpio: xilinx: Add clock support [not found] ` <1478668191-26322-2-git-send-email-shubhrajyoti.datta-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org> @ 2016-11-09 6:27 ` Sören Brinkmann 2016-11-09 6:46 ` Shubhrajyoti Datta 0 siblings, 1 reply; 6+ messages in thread From: Sören Brinkmann @ 2016-11-09 6:27 UTC (permalink / raw) To: Shubhrajyoti Datta Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, michal.simek-gjFFaj9aHVfQT0dZR+AlfA, shubhrajyoti.datta-Re5JQEeQqe8AvxtiuMwx3w On Wed, 2016-11-09 at 10:39:51 +0530, Shubhrajyoti Datta wrote: > Add basic clock support for xilinx gpio. > > Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org> > --- > v2 : > no change > > drivers/gpio/gpio-xilinx.c | 22 ++++++++++++++++++++++ > 1 files changed, 22 insertions(+), 0 deletions(-) > > diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > index 14b2a62..923cab8 100644 > --- a/drivers/gpio/gpio-xilinx.c > +++ b/drivers/gpio/gpio-xilinx.c > @@ -13,6 +13,7 @@ > */ > > #include <linux/bitops.h> > +#include <linux/clk.h> > #include <linux/init.h> > #include <linux/errno.h> > #include <linux/module.h> > @@ -45,6 +46,7 @@ > * @gpio_state: GPIO state shadow register > * @gpio_dir: GPIO direction shadow register > * @gpio_lock: Lock used for synchronization > + * @clk: Clock resource for this controller > */ > struct xgpio_instance { > struct of_mm_gpio_chip mmchip; > @@ -52,6 +54,7 @@ struct xgpio_instance { > u32 gpio_state[2]; > u32 gpio_dir[2]; > spinlock_t gpio_lock[2]; > + struct clk *clk; > }; > > static inline int xgpio_index(struct xgpio_instance *chip, int gpio) > @@ -282,6 +285,7 @@ static int xgpio_remove(struct platform_device *pdev) > struct xgpio_instance *chip = platform_get_drvdata(pdev); > > of_mm_gpiochip_remove(&chip->mmchip); > + clk_disable_unprepare(chip->clk); > > return 0; > } > @@ -307,6 +311,23 @@ static int xgpio_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, chip); > > + /* Retrieve GPIO clock */ > + chip->clk = devm_clk_get(&pdev->dev, NULL); The driver should use the clock-name documented in the binding to do the clock lookup. > + if (IS_ERR(chip->clk)) { > + if (PTR_ERR(chip->clk) == -ENOENT) { > + dev_info(&pdev->dev, "No clocks found for clk\n"); This is pretty much just noise. The clocks property is optional. No need to be too verbose about that. It would be quite a lot of printing if every driver would report absent optional DT properties. Sören -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 2/2] gpio: xilinx: Add clock support 2016-11-09 6:27 ` Sören Brinkmann @ 2016-11-09 6:46 ` Shubhrajyoti Datta 2016-11-09 17:18 ` Sören Brinkmann 0 siblings, 1 reply; 6+ messages in thread From: Shubhrajyoti Datta @ 2016-11-09 6:46 UTC (permalink / raw) To: Sören Brinkmann Cc: Shubhrajyoti Datta, linux-gpio, devicetree, Michal Simek On Wed, Nov 9, 2016 at 11:57 AM, Sören Brinkmann <soren.brinkmann@xilinx.com> wrote: > On Wed, 2016-11-09 at 10:39:51 +0530, Shubhrajyoti Datta wrote: >> Add basic clock support for xilinx gpio. >> >> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> >> --- >> v2 : >> no change >> >> drivers/gpio/gpio-xilinx.c | 22 ++++++++++++++++++++++ >> 1 files changed, 22 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c >> index 14b2a62..923cab8 100644 >> --- a/drivers/gpio/gpio-xilinx.c >> +++ b/drivers/gpio/gpio-xilinx.c >> @@ -13,6 +13,7 @@ >> */ >> >> #include <linux/bitops.h> >> +#include <linux/clk.h> >> #include <linux/init.h> >> #include <linux/errno.h> >> #include <linux/module.h> >> @@ -45,6 +46,7 @@ >> * @gpio_state: GPIO state shadow register >> * @gpio_dir: GPIO direction shadow register >> * @gpio_lock: Lock used for synchronization >> + * @clk: Clock resource for this controller >> */ >> struct xgpio_instance { >> struct of_mm_gpio_chip mmchip; >> @@ -52,6 +54,7 @@ struct xgpio_instance { >> u32 gpio_state[2]; >> u32 gpio_dir[2]; >> spinlock_t gpio_lock[2]; >> + struct clk *clk; >> }; >> >> static inline int xgpio_index(struct xgpio_instance *chip, int gpio) >> @@ -282,6 +285,7 @@ static int xgpio_remove(struct platform_device *pdev) >> struct xgpio_instance *chip = platform_get_drvdata(pdev); >> >> of_mm_gpiochip_remove(&chip->mmchip); >> + clk_disable_unprepare(chip->clk); >> >> return 0; >> } >> @@ -307,6 +311,23 @@ static int xgpio_probe(struct platform_device *pdev) >> >> platform_set_drvdata(pdev, chip); >> >> + /* Retrieve GPIO clock */ >> + chip->clk = devm_clk_get(&pdev->dev, NULL); > > The driver should use the clock-name documented in the binding to do the > clock lookup. My idea was to keep the clk name optional since there is only one clock. Or do you think we should mandate the name if clk is provided. > >> + if (IS_ERR(chip->clk)) { >> + if (PTR_ERR(chip->clk) == -ENOENT) { >> + dev_info(&pdev->dev, "No clocks found for clk\n"); > > This is pretty much just noise. The clocks property is optional. No need > to be too verbose about that. It would be quite a lot of printing if > every driver would report absent optional DT properties. Ok will remove the print > > Sören ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 2/2] gpio: xilinx: Add clock support 2016-11-09 6:46 ` Shubhrajyoti Datta @ 2016-11-09 17:18 ` Sören Brinkmann 2016-11-10 6:08 ` Shubhrajyoti Datta 0 siblings, 1 reply; 6+ messages in thread From: Sören Brinkmann @ 2016-11-09 17:18 UTC (permalink / raw) To: Shubhrajyoti Datta Cc: Shubhrajyoti Datta, linux-gpio, devicetree, Michal Simek On Wed, 2016-11-09 at 12:16:58 +0530, Shubhrajyoti Datta wrote: > On Wed, Nov 9, 2016 at 11:57 AM, Sören Brinkmann > <soren.brinkmann@xilinx.com> wrote: > > On Wed, 2016-11-09 at 10:39:51 +0530, Shubhrajyoti Datta wrote: > >> Add basic clock support for xilinx gpio. > >> > >> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> > >> --- > >> v2 : > >> no change > >> > >> drivers/gpio/gpio-xilinx.c | 22 ++++++++++++++++++++++ > >> 1 files changed, 22 insertions(+), 0 deletions(-) > >> > >> diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c > >> index 14b2a62..923cab8 100644 > >> --- a/drivers/gpio/gpio-xilinx.c > >> +++ b/drivers/gpio/gpio-xilinx.c > >> @@ -13,6 +13,7 @@ > >> */ > >> > >> #include <linux/bitops.h> > >> +#include <linux/clk.h> > >> #include <linux/init.h> > >> #include <linux/errno.h> > >> #include <linux/module.h> > >> @@ -45,6 +46,7 @@ > >> * @gpio_state: GPIO state shadow register > >> * @gpio_dir: GPIO direction shadow register > >> * @gpio_lock: Lock used for synchronization > >> + * @clk: Clock resource for this controller > >> */ > >> struct xgpio_instance { > >> struct of_mm_gpio_chip mmchip; > >> @@ -52,6 +54,7 @@ struct xgpio_instance { > >> u32 gpio_state[2]; > >> u32 gpio_dir[2]; > >> spinlock_t gpio_lock[2]; > >> + struct clk *clk; > >> }; > >> > >> static inline int xgpio_index(struct xgpio_instance *chip, int gpio) > >> @@ -282,6 +285,7 @@ static int xgpio_remove(struct platform_device *pdev) > >> struct xgpio_instance *chip = platform_get_drvdata(pdev); > >> > >> of_mm_gpiochip_remove(&chip->mmchip); > >> + clk_disable_unprepare(chip->clk); > >> > >> return 0; > >> } > >> @@ -307,6 +311,23 @@ static int xgpio_probe(struct platform_device *pdev) > >> > >> platform_set_drvdata(pdev, chip); > >> > >> + /* Retrieve GPIO clock */ > >> + chip->clk = devm_clk_get(&pdev->dev, NULL); > > > > The driver should use the clock-name documented in the binding to do the > > clock lookup. > > My idea was to keep the clk name optional since there is only one clock. > Or do you think we should mandate the name if clk is provided. I'd make 'clock-names' mandatory if 'clocks' is present. That way there won't be any trouble if this IP ever consumed additional clocks in the future. Sören ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCHv2 2/2] gpio: xilinx: Add clock support 2016-11-09 17:18 ` Sören Brinkmann @ 2016-11-10 6:08 ` Shubhrajyoti Datta 0 siblings, 0 replies; 6+ messages in thread From: Shubhrajyoti Datta @ 2016-11-10 6:08 UTC (permalink / raw) To: Sören Brinkmann Cc: Shubhrajyoti Datta, linux-gpio-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, Michal Simek On Wed, Nov 9, 2016 at 10:48 PM, Sören Brinkmann <soren.brinkmann-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org> wrote: [...] >> >> My idea was to keep the clk name optional since there is only one clock. >> Or do you think we should mandate the name if clk is provided. > > I'd make 'clock-names' mandatory if 'clocks' is present. That way there > won't be any trouble if this IP ever consumed additional clocks in the > future. fixed that in v3. Thanks > > Sören -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-11-10 6:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-09 5:09 [PATCHv2 1/2] gpio: xilinx: dt-binding: Add clock node Shubhrajyoti Datta
2016-11-09 5:09 ` [PATCHv2 2/2] gpio: xilinx: Add clock support Shubhrajyoti Datta
[not found] ` <1478668191-26322-2-git-send-email-shubhrajyoti.datta-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2016-11-09 6:27 ` Sören Brinkmann
2016-11-09 6:46 ` Shubhrajyoti Datta
2016-11-09 17:18 ` Sören Brinkmann
2016-11-10 6:08 ` Shubhrajyoti Datta
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.