Message ID | 20220308061935.2441447-3-jay.xu@rock-chips.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | gpio-before-pinctrl | expand |
On Wed, Mar 9, 2022 at 1:06 AM Jianqun Xu <jay.xu@rock-chips.com> wrote: > > Get the irq of gpio controller with fwnode apis, support for both dt > node and acpi. DT ACPI ... > - Stray change. > +#include <linux/acpi.h> Probably you wanted property.h. > #include <linux/bitops.h> > #include <linux/clk.h> > #include <linux/device.h> > @@ -639,10 +639,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) > { > int id = 0; > > - bank->irq = irq_of_parse_and_map(bank->of_node, 0); > - if (!bank->irq) > - return -EINVAL; > - > bank->clk = of_clk_get(bank->of_node, 0); > if (IS_ERR(bank->clk)) > return PTR_ERR(bank->clk); > @@ -668,6 +664,24 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) > return 0; > } ... > + if (np) > + irq = irq_of_parse_and_map(np, 0); > + else if (has_acpi_companion(dev)) > + irq = platform_get_irq_optional(to_platform_device(dev), 0); Why can't this work for the DT case?
Hi Andy Shevchenko -------------- jay.xu@rock-chips.com >On Wed, Mar 9, 2022 at 1:06 AM Jianqun Xu <jay.xu@rock-chips.com> wrote: >> >> Get the irq of gpio controller with fwnode apis, support for both dt >> node and acpi. > >DT >ACPI > ok, i will fix it in next patchset >... > >> - > >Stray change. > >> +#include <linux/acpi.h> > >Probably you wanted property.h. for this patch maybe property.h, for later acpi support, the acpi.h will be need > >> #include <linux/bitops.h> >> #include <linux/clk.h> >> #include <linux/device.h> >> @@ -639,10 +639,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) >> { >> int id = 0; >> >> - bank->irq = irq_of_parse_and_map(bank->of_node, 0); >> - if (!bank->irq) >> - return -EINVAL; >> - >> bank->clk = of_clk_get(bank->of_node, 0); >> if (IS_ERR(bank->clk)) >> return PTR_ERR(bank->clk); >> @@ -668,6 +664,24 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) >> return 0; >> } > >... > >> + if (np) >> + irq = irq_of_parse_and_map(np, 0); >> + else if (has_acpi_companion(dev)) >> + irq = platform_get_irq_optional(to_platform_device(dev), 0); > >Why can't this work for the DT case? try to keep same for dt case, ok i will modify to common usage > >-- >With Best Regards, >Andy Shevchenko
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c index b67038572285..3703c3d71809 100644 --- a/drivers/gpio/gpio-rockchip.c +++ b/drivers/gpio/gpio-rockchip.c @@ -5,7 +5,7 @@ * * Copyright (c) 2021 Rockchip Electronics Co. Ltd. */ - +#include <linux/acpi.h> #include <linux/bitops.h> #include <linux/clk.h> #include <linux/device.h> @@ -639,10 +639,6 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) { int id = 0; - bank->irq = irq_of_parse_and_map(bank->of_node, 0); - if (!bank->irq) - return -EINVAL; - bank->clk = of_clk_get(bank->of_node, 0); if (IS_ERR(bank->clk)) return PTR_ERR(bank->clk); @@ -668,6 +664,24 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank) return 0; } +static int rockchip_gpio_get_irq(struct rockchip_pin_bank *bank) +{ + struct device *dev = bank->dev; + struct fwnode_handle *fwnode = dev_fwnode(dev); + struct device_node *np = NULL; + int irq = 0; + + if (fwnode_property_read_bool(fwnode, "interrupt-controller")) + np = to_of_node(fwnode); + + if (np) + irq = irq_of_parse_and_map(np, 0); + else if (has_acpi_companion(dev)) + irq = platform_get_irq_optional(to_platform_device(dev), 0); + + return irq; +} + static struct rockchip_pin_bank * rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id) { @@ -721,6 +735,10 @@ static int rockchip_gpio_probe(struct platform_device *pdev) if (IS_ERR(bank->reg_base)) return PTR_ERR(bank->reg_base); + bank->irq = rockchip_gpio_get_irq(bank); + if (bank->irq < 0) + return bank->irq; + ret = rockchip_get_bank_data(bank); if (ret) return ret;
Get the irq of gpio controller with fwnode apis, support for both dt node and acpi. Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> --- drivers/gpio/gpio-rockchip.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)