Message ID | 1605201148-4508-4-git-send-email-srinivas.neeli@xilinx.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | gpio-xilinx: Update on xilinx gpio driver | expand |
On Thu, Nov 12, 2020 at 6:13 PM Srinivas Neeli <srinivas.neeli@xilinx.com> wrote: > Adds clock support to the Xilinx GPIO driver. > > Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com> (...) > + 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); > + } You can now use return dev_err_probe(dev, ret, "failed to get clock\n"); to avoid all the comparing with -EPROBE_DEFER. Yours, Linus Walleij
On Wed, Nov 18, 2020 at 12:53 AM Linus Walleij <linus.walleij@linaro.org> wrote: > On Thu, Nov 12, 2020 at 6:13 PM Srinivas Neeli > <srinivas.neeli@xilinx.com> wrote: > > > Adds clock support to the Xilinx GPIO driver. > > > > Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com> > > (...) > > + 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); > > + } > > You can now use return dev_err_probe(dev, ret, "failed to get clock\n"); > to avoid all the comparing with -EPROBE_DEFER. Patch applied anyways, this can be done separately. Yours, Linus Walleij
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 17a8a8f90d84..99d603bfb6f0 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) @@ -333,11 +336,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; }
Adds clock support to the Xilinx GPIO driver. Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com> --- Chnages in V3: -Created separate patch for Clock changes. --- drivers/gpio/gpio-xilinx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)