diff options
author | Phil Edworthy <phil.edworthy@renesas.com> | 2018-03-12 14:30:56 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2018-03-27 09:18:19 -0400 |
commit | e6bf37736f6495fb87ce5525d1f6fd2adce307f1 (patch) | |
tree | a6abee670fbfc56abc02ede30b8e4a9d2fac69cb | |
parent | 13b5319e92a94036ce2131f76510e108428daec8 (diff) |
gpio: dwapb: Add support for a bus clock
Enable an optional bus clock provided by DT.
Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-dwapb.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index b0704a883513..226977f78482 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c | |||
@@ -8,8 +8,9 @@ | |||
8 | * All enquiries to support@picochip.com | 8 | * All enquiries to support@picochip.com |
9 | */ | 9 | */ |
10 | #include <linux/acpi.h> | 10 | #include <linux/acpi.h> |
11 | #include <linux/gpio/driver.h> | 11 | #include <linux/clk.h> |
12 | #include <linux/err.h> | 12 | #include <linux/err.h> |
13 | #include <linux/gpio/driver.h> | ||
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
14 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
15 | #include <linux/io.h> | 16 | #include <linux/io.h> |
@@ -98,6 +99,7 @@ struct dwapb_gpio { | |||
98 | struct irq_domain *domain; | 99 | struct irq_domain *domain; |
99 | unsigned int flags; | 100 | unsigned int flags; |
100 | struct reset_control *rst; | 101 | struct reset_control *rst; |
102 | struct clk *clk; | ||
101 | }; | 103 | }; |
102 | 104 | ||
103 | static inline u32 gpio_reg_v2_convert(unsigned int offset) | 105 | static inline u32 gpio_reg_v2_convert(unsigned int offset) |
@@ -670,6 +672,16 @@ static int dwapb_gpio_probe(struct platform_device *pdev) | |||
670 | if (IS_ERR(gpio->regs)) | 672 | if (IS_ERR(gpio->regs)) |
671 | return PTR_ERR(gpio->regs); | 673 | return PTR_ERR(gpio->regs); |
672 | 674 | ||
675 | /* Optional bus clock */ | ||
676 | gpio->clk = devm_clk_get(&pdev->dev, "bus"); | ||
677 | if (!IS_ERR(gpio->clk)) { | ||
678 | err = clk_prepare_enable(gpio->clk); | ||
679 | if (err) { | ||
680 | dev_info(&pdev->dev, "Cannot enable clock\n"); | ||
681 | return err; | ||
682 | } | ||
683 | } | ||
684 | |||
673 | gpio->flags = 0; | 685 | gpio->flags = 0; |
674 | if (dev->of_node) { | 686 | if (dev->of_node) { |
675 | const struct of_device_id *of_devid; | 687 | const struct of_device_id *of_devid; |
@@ -712,6 +724,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev) | |||
712 | dwapb_gpio_unregister(gpio); | 724 | dwapb_gpio_unregister(gpio); |
713 | dwapb_irq_teardown(gpio); | 725 | dwapb_irq_teardown(gpio); |
714 | reset_control_assert(gpio->rst); | 726 | reset_control_assert(gpio->rst); |
727 | clk_disable_unprepare(gpio->clk); | ||
715 | 728 | ||
716 | return 0; | 729 | return 0; |
717 | } | 730 | } |
@@ -757,6 +770,8 @@ static int dwapb_gpio_suspend(struct device *dev) | |||
757 | } | 770 | } |
758 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); | 771 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); |
759 | 772 | ||
773 | clk_disable_unprepare(gpio->clk); | ||
774 | |||
760 | return 0; | 775 | return 0; |
761 | } | 776 | } |
762 | 777 | ||
@@ -768,6 +783,9 @@ static int dwapb_gpio_resume(struct device *dev) | |||
768 | unsigned long flags; | 783 | unsigned long flags; |
769 | int i; | 784 | int i; |
770 | 785 | ||
786 | if (!IS_ERR(gpio->clk)) | ||
787 | clk_prepare_enable(gpio->clk); | ||
788 | |||
771 | spin_lock_irqsave(&gc->bgpio_lock, flags); | 789 | spin_lock_irqsave(&gc->bgpio_lock, flags); |
772 | for (i = 0; i < gpio->nr_ports; i++) { | 790 | for (i = 0; i < gpio->nr_ports; i++) { |
773 | unsigned int offset; | 791 | unsigned int offset; |