* [PATCH v2] gpio: dwapb: Add support for a bus clock
@ 2018-03-12 18:30 Phil Edworthy
2018-03-13 16:35 ` Andy Shevchenko
2018-03-27 11:32 ` Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Phil Edworthy @ 2018-03-12 18:30 UTC (permalink / raw)
To: Hoan Tran, Andy Shevchenko
Cc: Linus Walleij, Michel Pollet, linux-gpio, linux-kernel, Phil Edworthy
Enable an optional bus clock provided by DT.
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
v2:
- Fix include order.
- Use a clock name.
- Check errors from clk_prepare_enable()
- Add calls to enable/disable the clock in PM
---
drivers/gpio/gpio-dwapb.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index b0704a8..226977f 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -8,8 +8,9 @@
* All enquiries to support@picochip.com
*/
#include <linux/acpi.h>
-#include <linux/gpio/driver.h>
+#include <linux/clk.h>
#include <linux/err.h>
+#include <linux/gpio/driver.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -98,6 +99,7 @@ struct dwapb_gpio {
struct irq_domain *domain;
unsigned int flags;
struct reset_control *rst;
+ struct clk *clk;
};
static inline u32 gpio_reg_v2_convert(unsigned int offset)
@@ -670,6 +672,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
if (IS_ERR(gpio->regs))
return PTR_ERR(gpio->regs);
+ /* Optional bus clock */
+ gpio->clk = devm_clk_get(&pdev->dev, "bus");
+ if (!IS_ERR(gpio->clk)) {
+ err = clk_prepare_enable(gpio->clk);
+ if (err) {
+ dev_info(&pdev->dev, "Cannot enable clock\n");
+ return err;
+ }
+ }
+
gpio->flags = 0;
if (dev->of_node) {
const struct of_device_id *of_devid;
@@ -712,6 +724,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
dwapb_gpio_unregister(gpio);
dwapb_irq_teardown(gpio);
reset_control_assert(gpio->rst);
+ clk_disable_unprepare(gpio->clk);
return 0;
}
@@ -757,6 +770,8 @@ static int dwapb_gpio_suspend(struct device *dev)
}
spin_unlock_irqrestore(&gc->bgpio_lock, flags);
+ clk_disable_unprepare(gpio->clk);
+
return 0;
}
@@ -768,6 +783,9 @@ static int dwapb_gpio_resume(struct device *dev)
unsigned long flags;
int i;
+ if (!IS_ERR(gpio->clk))
+ clk_prepare_enable(gpio->clk);
+
spin_lock_irqsave(&gc->bgpio_lock, flags);
for (i = 0; i < gpio->nr_ports; i++) {
unsigned int offset;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gpio: dwapb: Add support for a bus clock
2018-03-12 18:30 [PATCH v2] gpio: dwapb: Add support for a bus clock Phil Edworthy
@ 2018-03-13 16:35 ` Andy Shevchenko
2018-03-13 16:42 ` Phil Edworthy
2018-03-27 11:32 ` Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2018-03-13 16:35 UTC (permalink / raw)
To: Phil Edworthy
Cc: Hoan Tran, Linus Walleij, Michel Pollet,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List
On Mon, Mar 12, 2018 at 8:30 PM, Phil Edworthy
<phil.edworthy@renesas.com> wrote:
> Enable an optional bus clock provided by DT.
FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
(Assuming it has been tested on clock-less cases)
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v2:
> - Fix include order.
> - Use a clock name.
> - Check errors from clk_prepare_enable()
> - Add calls to enable/disable the clock in PM
> ---
> drivers/gpio/gpio-dwapb.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index b0704a8..226977f 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -8,8 +8,9 @@
> * All enquiries to support@picochip.com
> */
> #include <linux/acpi.h>
> -#include <linux/gpio/driver.h>
> +#include <linux/clk.h>
> #include <linux/err.h>
> +#include <linux/gpio/driver.h>
> #include <linux/init.h>
> #include <linux/interrupt.h>
> #include <linux/io.h>
> @@ -98,6 +99,7 @@ struct dwapb_gpio {
> struct irq_domain *domain;
> unsigned int flags;
> struct reset_control *rst;
> + struct clk *clk;
> };
>
> static inline u32 gpio_reg_v2_convert(unsigned int offset)
> @@ -670,6 +672,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
> if (IS_ERR(gpio->regs))
> return PTR_ERR(gpio->regs);
>
> + /* Optional bus clock */
> + gpio->clk = devm_clk_get(&pdev->dev, "bus");
> + if (!IS_ERR(gpio->clk)) {
> + err = clk_prepare_enable(gpio->clk);
> + if (err) {
> + dev_info(&pdev->dev, "Cannot enable clock\n");
> + return err;
> + }
> + }
> +
> gpio->flags = 0;
> if (dev->of_node) {
> const struct of_device_id *of_devid;
> @@ -712,6 +724,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
> dwapb_gpio_unregister(gpio);
> dwapb_irq_teardown(gpio);
> reset_control_assert(gpio->rst);
> + clk_disable_unprepare(gpio->clk);
>
> return 0;
> }
> @@ -757,6 +770,8 @@ static int dwapb_gpio_suspend(struct device *dev)
> }
> spin_unlock_irqrestore(&gc->bgpio_lock, flags);
>
> + clk_disable_unprepare(gpio->clk);
> +
> return 0;
> }
>
> @@ -768,6 +783,9 @@ static int dwapb_gpio_resume(struct device *dev)
> unsigned long flags;
> int i;
>
> + if (!IS_ERR(gpio->clk))
> + clk_prepare_enable(gpio->clk);
> +
> spin_lock_irqsave(&gc->bgpio_lock, flags);
> for (i = 0; i < gpio->nr_ports; i++) {
> unsigned int offset;
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] gpio: dwapb: Add support for a bus clock
2018-03-13 16:35 ` Andy Shevchenko
@ 2018-03-13 16:42 ` Phil Edworthy
0 siblings, 0 replies; 4+ messages in thread
From: Phil Edworthy @ 2018-03-13 16:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Hoan Tran, Linus Walleij, Michel Pollet,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List
Hi Andy,
On 13 March 2018 16:36, Andy Shevchenko wrote:
> On Mon, Mar 12, 2018 at 8:30 PM, Phil Edworthy
> <phil.edworthy@renesas.com> wrote:
> > Enable an optional bus clock provided by DT.
>
> FWIW,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks!
> (Assuming it has been tested on clock-less cases)
I hacked together a test where the bus clock for the device I have
is always on, and the clock for this driver is not present in the DTB.
Whilst not ideal, it does test the clock-less case.
Thanks
Phil
> > Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> > ---
> > v2:
> > - Fix include order.
> > - Use a clock name.
> > - Check errors from clk_prepare_enable()
> > - Add calls to enable/disable the clock in PM
> > ---
> > drivers/gpio/gpio-dwapb.c | 20 +++++++++++++++++++-
> > 1 file changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> > index b0704a8..226977f 100644
> > --- a/drivers/gpio/gpio-dwapb.c
> > +++ b/drivers/gpio/gpio-dwapb.c
> > @@ -8,8 +8,9 @@
> > * All enquiries to support@picochip.com
> > */
> > #include <linux/acpi.h>
> > -#include <linux/gpio/driver.h>
> > +#include <linux/clk.h>
> > #include <linux/err.h>
> > +#include <linux/gpio/driver.h>
> > #include <linux/init.h>
> > #include <linux/interrupt.h>
> > #include <linux/io.h>
> > @@ -98,6 +99,7 @@ struct dwapb_gpio {
> > struct irq_domain *domain;
> > unsigned int flags;
> > struct reset_control *rst;
> > + struct clk *clk;
> > };
> >
> > static inline u32 gpio_reg_v2_convert(unsigned int offset) @@ -670,6
> > +672,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
> > if (IS_ERR(gpio->regs))
> > return PTR_ERR(gpio->regs);
> >
> > + /* Optional bus clock */
> > + gpio->clk = devm_clk_get(&pdev->dev, "bus");
> > + if (!IS_ERR(gpio->clk)) {
> > + err = clk_prepare_enable(gpio->clk);
> > + if (err) {
> > + dev_info(&pdev->dev, "Cannot enable clock\n");
> > + return err;
> > + }
> > + }
> > +
> > gpio->flags = 0;
> > if (dev->of_node) {
> > const struct of_device_id *of_devid; @@ -712,6 +724,7
> > @@ static int dwapb_gpio_remove(struct platform_device *pdev)
> > dwapb_gpio_unregister(gpio);
> > dwapb_irq_teardown(gpio);
> > reset_control_assert(gpio->rst);
> > + clk_disable_unprepare(gpio->clk);
> >
> > return 0;
> > }
> > @@ -757,6 +770,8 @@ static int dwapb_gpio_suspend(struct device *dev)
> > }
> > spin_unlock_irqrestore(&gc->bgpio_lock, flags);
> >
> > + clk_disable_unprepare(gpio->clk);
> > +
> > return 0;
> > }
> >
> > @@ -768,6 +783,9 @@ static int dwapb_gpio_resume(struct device *dev)
> > unsigned long flags;
> > int i;
> >
> > + if (!IS_ERR(gpio->clk))
> > + clk_prepare_enable(gpio->clk);
> > +
> > spin_lock_irqsave(&gc->bgpio_lock, flags);
> > for (i = 0; i < gpio->nr_ports; i++) {
> > unsigned int offset;
> > --
> > 2.7.4
> >
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] gpio: dwapb: Add support for a bus clock
2018-03-12 18:30 [PATCH v2] gpio: dwapb: Add support for a bus clock Phil Edworthy
2018-03-13 16:35 ` Andy Shevchenko
@ 2018-03-27 11:32 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-03-27 11:32 UTC (permalink / raw)
To: Phil Edworthy
Cc: Hoan Tran, Andy Shevchenko, Michel Pollet,
open list:GPIO SUBSYSTEM, linux-kernel
On Mon, Mar 12, 2018 at 7:30 PM, Phil Edworthy
<phil.edworthy@renesas.com> wrote:
> Enable an optional bus clock provided by DT.
>
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v2:
> - Fix include order.
> - Use a clock name.
> - Check errors from clk_prepare_enable()
> - Add calls to enable/disable the clock in PM
Patch applied with Andy's review tag.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-27 11:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 18:30 [PATCH v2] gpio: dwapb: Add support for a bus clock Phil Edworthy
2018-03-13 16:35 ` Andy Shevchenko
2018-03-13 16:42 ` Phil Edworthy
2018-03-27 11:32 ` Linus Walleij
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).