diff options
author | Srinivas Neeli <srinivas.neeli@xilinx.com> | 2020-11-12 20:12:22 +0300 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2020-11-18 02:59:37 +0300 |
commit | 65bbe531b54668099783cd687e674b9587c7e56e (patch) | |
tree | b38ac3002dfa1dac19a258c2fa36821fe459336c /drivers/gpio | |
parent | 700a2b53bdc9c3b3f7241626eaf9a81b04c7593d (diff) | |
download | linux-65bbe531b54668099783cd687e674b9587c7e56e.tar.xz |
gpio: gpio-xilinx: Add clock support
Adds clock support to the Xilinx GPIO driver.
Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/1605201148-4508-4-git-send-email-srinivas.neeli@xilinx.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-xilinx.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index a28aa5b2bc0f..5327457586d7 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -6,6 +6,7 @@ */ #include <linux/bitops.h> +#include <linux/clk.h> #include <linux/errno.h> #include <linux/gpio/driver.h> #include <linux/init.h> @@ -38,6 +39,7 @@ * @gpio_state: GPIO state shadow register * @gpio_dir: GPIO direction shadow register * @gpio_lock: Lock used for synchronization + * @clk: clock resource for this driver */ struct xgpio_instance { struct gpio_chip gc; @@ -46,6 +48,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) @@ -334,11 +337,25 @@ static int xgpio_probe(struct platform_device *pdev) return PTR_ERR(chip->regs); } + chip->clk = devm_clk_get_optional(&pdev->dev, NULL); + if (IS_ERR(chip->clk)) { + if (PTR_ERR(chip->clk) != -EPROBE_DEFER) + dev_dbg(&pdev->dev, "Input clock not found\n"); + return PTR_ERR(chip->clk); + } + + status = clk_prepare_enable(chip->clk); + if (status < 0) { + dev_err(&pdev->dev, "Failed to prepare clk\n"); + return status; + } + xgpio_save_regs(chip); status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); if (status) { dev_err(&pdev->dev, "failed to add GPIO chip\n"); + clk_disable_unprepare(chip->clk); return status; } |