linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: "jay.xu@rock-chips.com" <jay.xu@rock-chips.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"linus.walleij" <linus.walleij@linaro.org>,
	linux-gpio <linux-gpio@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Heiko Stübner" <heiko@sntech.de>
Subject: Re: Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
Date: Thu, 22 Sep 2022 10:34:49 +0200	[thread overview]
Message-ID: <CAMRc=MdZVG8PC3_SmRYn54zTx-x_UfUxnRzhsLEaYEzDS=VjRA@mail.gmail.com> (raw)
In-Reply-To: <2022090115251208267537@rock-chips.com>

On Thu, Sep 1, 2022 at 9:25 AM jay.xu@rock-chips.com
<jay.xu@rock-chips.com> wrote:
>
> Hi Bart
>
> --------------
> jay.xu@rock-chips.com
> >On Thu, Sep 1, 2022 at 3:47 AM jay.xu@rock-chips.com
> ><jay.xu@rock-chips.com> wrote:
> >>
> >> Hi
> >>
> >> --------------
> >> jay.xu@rock-chips.com
> >> >On Wed, Aug 31, 2022 at 3:45 PM Andy Shevchenko
> >> ><andriy.shevchenko@linux.intel.com> wrote:
> >> >>
> >> >> GPIO library now accepts fwnode as a firmware node, so
> >> >> switch the driver to use it.
> >> >>
> >> >> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >> >> ---
> >> >> v2: fixed compilation errors (LKP), replace some OF calls (Bart)
> >> >>  drivers/gpio/gpio-rockchip.c       | 38 +++++++++++-------------------
> >> >>  drivers/pinctrl/pinctrl-rockchip.h |  2 --
> >> >>  2 files changed, 14 insertions(+), 26 deletions(-)
> >> >>
> >> >> diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
> >> >> index bb50335239ac..e8fa99fd4c80 100644
> >> >> --- a/drivers/gpio/gpio-rockchip.c
> >> >> +++ b/drivers/gpio/gpio-rockchip.c
> >> >> @@ -14,12 +14,11 @@
> >> >>  #include <linux/init.h>
> >> >>  #include <linux/interrupt.h>
> >> >>  #include <linux/io.h>
> >> >> +#include <linux/mod_devicetable.h>
> >> >>  #include <linux/module.h>
> >> >>  #include <linux/of.h>
> >> >> -#include <linux/of_address.h>
> >> >> -#include <linux/of_device.h>
> >> >> -#include <linux/of_irq.h>
> >> >>  #include <linux/pinctrl/pinconf-generic.h>
> >> >> +#include <linux/property.h>
> >> >>  #include <linux/regmap.h>
> >> >>
> >> >>  #include "../pinctrl/core.h"
> >> >> @@ -518,7 +517,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank)
> >> >>         struct irq_chip_generic *gc;
> >> >>         int ret;
> >> >>
> >> >> -       bank->domain = irq_domain_add_linear(bank->of_node, 32,
> >> >> +       bank->domain = irq_domain_create_linear(dev_fwnode(bank->dev), 32,
> >> >>                                         &irq_generic_chip_ops, NULL);
> >> >>         if (!bank->domain) {
> >> >>                 dev_warn(bank->dev, "could not init irq domain for bank %s\n",
> >> >> @@ -606,14 +605,10 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
> >> >>          * files which don't set the "gpio-ranges" property or systems that
> >> >>          * utilize ACPI the driver has to call gpiochip_add_pin_range().
> >> >>          */
> >> >> -       if (!of_property_read_bool(bank->of_node, "gpio-ranges")) {
> >> >> -               struct device_node *pctlnp = of_get_parent(bank->of_node);
> >> >> +       if (!device_property_read_bool(bank->dev, "gpio-ranges")) {
> >> >>                 struct pinctrl_dev *pctldev = NULL;
> >> >>
> >> >> -               if (!pctlnp)
> >> >> -                       return -ENODATA;
> >> >> -
> >> >> -               pctldev = of_pinctrl_get(pctlnp);
> >> >> +               pctldev = pinctrl_get(bank->dev->parent);
> >> >>                 if (!pctldev)
> >> >>                         return -ENODEV;
> >> >>
> >> >> @@ -641,23 +636,20 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
> >> >>
> >> >>  static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
> >> >>  {
> >> >> +       struct platform_device *pdev = to_platform_device(bank->dev);
> >> >> +       struct device_node *np = bank->dev->of_node;
> >> >>         struct resource res;
> >> >>         int id = 0;
> >> >>
> >> >> -       if (of_address_to_resource(bank->of_node, 0, &res)) {
> >> >> -               dev_err(bank->dev, "cannot find IO resource for bank\n");
> >> >> -               return -ENOENT;
> >> >> -       }
> >> >> -
> >> >> -       bank->reg_base = devm_ioremap_resource(bank->dev, &res);
> >> >> +       bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
> >> >>         if (IS_ERR(bank->reg_base))
> >> >>                 return PTR_ERR(bank->reg_base);
> >> >>
> >> >> -       bank->irq = irq_of_parse_and_map(bank->of_node, 0);
> >> >> +       bank->irq = platform_get_irq(pdev, 0);
> >> >>         if (!bank->irq)
> >> >>                 return -EINVAL;
> >> >>
> >> >> -       bank->clk = of_clk_get(bank->of_node, 0);
> >> >> +       bank->clk = of_clk_get(np, 0);
> >> >
> >> >Why did you stop above? Why not regular clk_get here?
> >> >
> >> >>         if (IS_ERR(bank->clk))
> >> >>                 return PTR_ERR(bank->clk);
> >> >>
> >> >> @@ -668,7 +660,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
> >> >>         if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
> >> >>                 bank->gpio_regs = &gpio_regs_v2;
> >> >>                 bank->gpio_type = GPIO_TYPE_V2;
> >> >> -               bank->db_clk = of_clk_get(bank->of_node, 1);
> >> >> +               bank->db_clk = of_clk_get(np, 1);
> >> >
> >> >Ah, the clocks don't have names in DT? That's unfortunate...
> >>
> >> The patch add 'clock-names' property for gpio dt node, after that, the driver can change to
> >> devm_clk_get(dev, "bus");
> >> devm_clk_get(dev, "db");
> >>
> >
> >We can't unfortunately, we need to remain compatible with existing DTs.
> >
> As said in the patch comment, the 'clock-names' is not 'required' since existing DTs
> Do the driver can try get by id first and then do a second try with legency way without id ?
>
> or other suggestion ?
>

No, it sounds good to me.

Bart

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  reply	other threads:[~2022-09-22  8:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 13:45 [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node Andy Shevchenko
2022-08-31 15:11 ` Bartosz Golaszewski
2022-08-31 19:03   ` Andy Shevchenko
2022-09-01  1:47   ` jay.xu
2022-09-01  7:08     ` Bartosz Golaszewski
2022-09-01  7:25       ` jay.xu
2022-09-22  8:34         ` Bartosz Golaszewski [this message]
2022-08-31 19:30 ` kernel test robot
2022-08-31 19:51 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMRc=MdZVG8PC3_SmRYn54zTx-x_UfUxnRzhsLEaYEzDS=VjRA@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=heiko@sntech.de \
    --cc=jay.xu@rock-chips.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).