* [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
@ 2022-08-31 13:45 Andy Shevchenko
2022-08-31 15:11 ` Bartosz Golaszewski
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-08-31 13:45 UTC (permalink / raw)
To: Linus Walleij, Jianqun Xu, linux-gpio, linux-arm-kernel,
linux-rockchip, linux-kernel
Cc: Bartosz Golaszewski, Heiko Stuebner, Andy Shevchenko
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);
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);
if (IS_ERR(bank->db_clk)) {
dev_err(bank->dev, "cannot find debounce clk\n");
clk_disable_unprepare(bank->clk);
@@ -705,17 +697,16 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
- struct device_node *pctlnp = of_get_parent(np);
struct pinctrl_dev *pctldev = NULL;
struct rockchip_pin_bank *bank = NULL;
struct rockchip_pin_deferred *cfg;
static int gpio;
int id, ret;
- if (!np || !pctlnp)
+ if (!dev->parent)
return -ENODEV;
- pctldev = of_pinctrl_get(pctlnp);
+ pctldev = pinctrl_get(dev->parent);
if (!pctldev)
return -EPROBE_DEFER;
@@ -728,7 +719,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
return -EINVAL;
bank->dev = dev;
- bank->of_node = np;
raw_spin_lock_init(&bank->slock);
@@ -776,7 +766,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
mutex_unlock(&bank->deferred_lock);
platform_set_drvdata(pdev, bank);
- dev_info(dev, "probed %pOF\n", np);
+ dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
return 0;
}
diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
index 4759f336941e..37a0501bcc03 100644
--- a/drivers/pinctrl/pinctrl-rockchip.h
+++ b/drivers/pinctrl/pinctrl-rockchip.h
@@ -299,7 +299,6 @@ struct rockchip_drv {
* @drv: array describing the 4 drive strength sources of the bank
* @pull_type: array describing the 4 pull type sources of the bank
* @valid: is all necessary information present
- * @of_node: dt node of this bank
* @drvdata: common pinctrl basedata
* @domain: irqdomain of the gpio bank
* @gpio_chip: gpiolib chip
@@ -327,7 +326,6 @@ struct rockchip_pin_bank {
struct rockchip_drv drv[4];
enum rockchip_pin_pull_type pull_type[4];
bool valid;
- struct device_node *of_node;
struct rockchip_pinctrl *drvdata;
struct irq_domain *domain;
struct gpio_chip gpio_chip;
--
2.35.1
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
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-08-31 19:30 ` kernel test robot
2022-08-31 19:51 ` kernel test robot
2 siblings, 2 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2022-08-31 15:11 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, Jianqun Xu, open list:GPIO SUBSYSTEM, Linux ARM,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stuebner
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...
Bart
> if (IS_ERR(bank->db_clk)) {
> dev_err(bank->dev, "cannot find debounce clk\n");
> clk_disable_unprepare(bank->clk);
> @@ -705,17 +697,16 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct device_node *np = dev->of_node;
> - struct device_node *pctlnp = of_get_parent(np);
> struct pinctrl_dev *pctldev = NULL;
> struct rockchip_pin_bank *bank = NULL;
> struct rockchip_pin_deferred *cfg;
> static int gpio;
> int id, ret;
>
> - if (!np || !pctlnp)
> + if (!dev->parent)
> return -ENODEV;
>
> - pctldev = of_pinctrl_get(pctlnp);
> + pctldev = pinctrl_get(dev->parent);
> if (!pctldev)
> return -EPROBE_DEFER;
>
> @@ -728,7 +719,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> return -EINVAL;
>
> bank->dev = dev;
> - bank->of_node = np;
>
> raw_spin_lock_init(&bank->slock);
>
> @@ -776,7 +766,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> mutex_unlock(&bank->deferred_lock);
>
> platform_set_drvdata(pdev, bank);
> - dev_info(dev, "probed %pOF\n", np);
> + dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
>
> return 0;
> }
> diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
> index 4759f336941e..37a0501bcc03 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.h
> +++ b/drivers/pinctrl/pinctrl-rockchip.h
> @@ -299,7 +299,6 @@ struct rockchip_drv {
> * @drv: array describing the 4 drive strength sources of the bank
> * @pull_type: array describing the 4 pull type sources of the bank
> * @valid: is all necessary information present
> - * @of_node: dt node of this bank
> * @drvdata: common pinctrl basedata
> * @domain: irqdomain of the gpio bank
> * @gpio_chip: gpiolib chip
> @@ -327,7 +326,6 @@ struct rockchip_pin_bank {
> struct rockchip_drv drv[4];
> enum rockchip_pin_pull_type pull_type[4];
> bool valid;
> - struct device_node *of_node;
> struct rockchip_pinctrl *drvdata;
> struct irq_domain *domain;
> struct gpio_chip gpio_chip;
> --
> 2.35.1
>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
2022-08-31 15:11 ` Bartosz Golaszewski
@ 2022-08-31 19:03 ` Andy Shevchenko
2022-09-01 1:47 ` jay.xu
1 sibling, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2022-08-31 19:03 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Jianqun Xu, open list:GPIO SUBSYSTEM, Linux ARM,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stuebner
On Wed, Aug 31, 2022 at 05:11:36PM +0200, Bartosz Golaszewski wrote:
> On Wed, Aug 31, 2022 at 3:45 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
...
> > - 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?
Indices... And there is no non-OF API for that.
> > 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...
Yeah...
--
With Best Regards,
Andy Shevchenko
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
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:30 ` kernel test robot
2022-08-31 19:51 ` kernel test robot
2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-08-31 19:30 UTC (permalink / raw)
To: Andy Shevchenko, Linus Walleij, Jianqun Xu, linux-gpio,
linux-arm-kernel, linux-rockchip, linux-kernel
Cc: kbuild-all, Bartosz Golaszewski, Heiko Stuebner, Andy Shevchenko
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on rockchip/for-next]
[also build test ERROR on linus/master v6.0-rc3 next-20220831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpio-rockchip-Switch-to-use-fwnode-instead-of-of_node/20220831-214721
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: loongarch-buildonly-randconfig-r003-20220830 (https://download.01.org/0day-ci/archive/20220901/202209010347.s5HFnZfF-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1adf1d7efa2837b148a47d10749922358e6f1b8f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/gpio-rockchip-Switch-to-use-fwnode-instead-of-of_node/20220831-214721
git checkout 1adf1d7efa2837b148a47d10749922358e6f1b8f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash drivers/gpio/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpiolib_register':
>> drivers/gpio/gpio-rockchip.c:611:27: error: implicit declaration of function 'pinctrl_get'; did you mean 'of_pinctrl_get'? [-Werror=implicit-function-declaration]
611 | pctldev = pinctrl_get(bank->dev->parent);
| ^~~~~~~~~~~
| of_pinctrl_get
>> drivers/gpio/gpio-rockchip.c:611:25: warning: assignment to 'struct pinctrl_dev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
611 | pctldev = pinctrl_get(bank->dev->parent);
| ^
drivers/gpio/gpio-rockchip.c: In function 'rockchip_get_bank_data':
drivers/gpio/gpio-rockchip.c:639:40: error: implicit declaration of function 'to_platform_device' [-Werror=implicit-function-declaration]
639 | struct platform_device *pdev = to_platform_device(bank->dev);
| ^~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:639:40: warning: initialization of 'struct platform_device *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/gpio/gpio-rockchip.c:644:26: error: implicit declaration of function 'devm_platform_ioremap_resource'; did you mean 'devm_ioremap_resource'? [-Werror=implicit-function-declaration]
644 | bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| devm_ioremap_resource
drivers/gpio/gpio-rockchip.c:644:24: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
644 | bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
| ^
drivers/gpio/gpio-rockchip.c:648:21: error: implicit declaration of function 'platform_get_irq'; did you mean 'platform_notify'? [-Werror=implicit-function-declaration]
648 | bank->irq = platform_get_irq(pdev, 0);
| ^~~~~~~~~~~~~~~~
| platform_notify
drivers/gpio/gpio-rockchip.c:641:25: warning: unused variable 'res' [-Wunused-variable]
641 | struct resource res;
| ^~~
drivers/gpio/gpio-rockchip.c: At top level:
drivers/gpio/gpio-rockchip.c:696:39: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
696 | static int rockchip_gpio_probe(struct platform_device *pdev)
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpio_probe':
drivers/gpio/gpio-rockchip.c:698:35: error: invalid use of undefined type 'struct platform_device'
698 | struct device *dev = &pdev->dev;
| ^~
drivers/gpio/gpio-rockchip.c:709:17: warning: assignment to 'struct pinctrl_dev *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
709 | pctldev = pinctrl_get(dev->parent);
| ^
drivers/gpio/gpio-rockchip.c:768:9: error: implicit declaration of function 'platform_set_drvdata' [-Werror=implicit-function-declaration]
768 | platform_set_drvdata(pdev, bank);
| ^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c: At top level:
drivers/gpio/gpio-rockchip.c:774:40: warning: 'struct platform_device' declared inside parameter list will not be visible outside of this definition or declaration
774 | static int rockchip_gpio_remove(struct platform_device *pdev)
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpio_remove':
drivers/gpio/gpio-rockchip.c:776:42: error: implicit declaration of function 'platform_get_drvdata' [-Werror=implicit-function-declaration]
776 | struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
| ^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:776:42: warning: initialization of 'struct rockchip_pin_bank *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
drivers/gpio/gpio-rockchip.c: At top level:
drivers/gpio/gpio-rockchip.c:790:15: error: variable 'rockchip_gpio_driver' has initializer but incomplete type
790 | static struct platform_driver rockchip_gpio_driver = {
| ^~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:791:10: error: 'struct platform_driver' has no member named 'probe'
791 | .probe = rockchip_gpio_probe,
| ^~~~~
drivers/gpio/gpio-rockchip.c:791:27: warning: excess elements in struct initializer
791 | .probe = rockchip_gpio_probe,
| ^~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:791:27: note: (near initialization for 'rockchip_gpio_driver')
drivers/gpio/gpio-rockchip.c:792:10: error: 'struct platform_driver' has no member named 'remove'
792 | .remove = rockchip_gpio_remove,
| ^~~~~~
drivers/gpio/gpio-rockchip.c:792:27: warning: excess elements in struct initializer
792 | .remove = rockchip_gpio_remove,
| ^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c:792:27: note: (near initialization for 'rockchip_gpio_driver')
drivers/gpio/gpio-rockchip.c:793:10: error: 'struct platform_driver' has no member named 'driver'
793 | .driver = {
| ^~~~~~
drivers/gpio/gpio-rockchip.c:793:27: error: extra brace group at end of initializer
793 | .driver = {
| ^
drivers/gpio/gpio-rockchip.c:793:27: note: (near initialization for 'rockchip_gpio_driver')
drivers/gpio/gpio-rockchip.c:793:27: warning: excess elements in struct initializer
drivers/gpio/gpio-rockchip.c:793:27: note: (near initialization for 'rockchip_gpio_driver')
drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpio_init':
drivers/gpio/gpio-rockchip.c:801:16: error: implicit declaration of function 'platform_driver_register' [-Werror=implicit-function-declaration]
801 | return platform_driver_register(&rockchip_gpio_driver);
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpio_exit':
drivers/gpio/gpio-rockchip.c:807:9: error: implicit declaration of function 'platform_driver_unregister'; did you mean 'driver_unregister'? [-Werror=implicit-function-declaration]
807 | platform_driver_unregister(&rockchip_gpio_driver);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| driver_unregister
drivers/gpio/gpio-rockchip.c: At top level:
drivers/gpio/gpio-rockchip.c:790:31: error: storage size of 'rockchip_gpio_driver' isn't known
790 | static struct platform_driver rockchip_gpio_driver = {
| ^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PCI_LOONGSON
Depends on [n]: PCI [=y] && (MACH_LOONGSON64 [=y] || COMPILE_TEST [=y]) && (OF [=y] || ACPI [=y]) && PCI_QUIRKS [=n]
Selected by [y]:
- LOONGARCH [=y]
vim +611 drivers/gpio/gpio-rockchip.c
577
578 static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
579 {
580 struct gpio_chip *gc;
581 int ret;
582
583 bank->gpio_chip = rockchip_gpiolib_chip;
584
585 gc = &bank->gpio_chip;
586 gc->base = bank->pin_base;
587 gc->ngpio = bank->nr_pins;
588 gc->label = bank->name;
589 gc->parent = bank->dev;
590
591 ret = gpiochip_add_data(gc, bank);
592 if (ret) {
593 dev_err(bank->dev, "failed to add gpiochip %s, %d\n",
594 gc->label, ret);
595 return ret;
596 }
597
598 /*
599 * For DeviceTree-supported systems, the gpio core checks the
600 * pinctrl's device node for the "gpio-ranges" property.
601 * If it is present, it takes care of adding the pin ranges
602 * for the driver. In this case the driver can skip ahead.
603 *
604 * In order to remain compatible with older, existing DeviceTree
605 * files which don't set the "gpio-ranges" property or systems that
606 * utilize ACPI the driver has to call gpiochip_add_pin_range().
607 */
608 if (!device_property_read_bool(bank->dev, "gpio-ranges")) {
609 struct pinctrl_dev *pctldev = NULL;
610
> 611 pctldev = pinctrl_get(bank->dev->parent);
612 if (!pctldev)
613 return -ENODEV;
614
615 ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0,
616 gc->base, gc->ngpio);
617 if (ret) {
618 dev_err(bank->dev, "Failed to add pin range\n");
619 goto fail;
620 }
621 }
622
623 ret = rockchip_interrupts_register(bank);
624 if (ret) {
625 dev_err(bank->dev, "failed to register interrupt, %d\n", ret);
626 goto fail;
627 }
628
629 return 0;
630
631 fail:
632 gpiochip_remove(&bank->gpio_chip);
633
634 return ret;
635 }
636
--
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
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:30 ` kernel test robot
@ 2022-08-31 19:51 ` kernel test robot
2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2022-08-31 19:51 UTC (permalink / raw)
To: Andy Shevchenko, Linus Walleij, Jianqun Xu, linux-gpio,
linux-arm-kernel, linux-rockchip, linux-kernel
Cc: llvm, kbuild-all, Bartosz Golaszewski, Heiko Stuebner, Andy Shevchenko
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on rockchip/for-next]
[also build test ERROR on linus/master v6.0-rc3 next-20220831]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/gpio-rockchip-Switch-to-use-fwnode-instead-of-of_node/20220831-214721
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm-randconfig-r036-20220830 (https://download.01.org/0day-ci/archive/20220901/202209010355.qwMuqR06-lkp@intel.com/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 1c66bacd6cde1f37d6ac96c45b389666a1334ec0)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/1adf1d7efa2837b148a47d10749922358e6f1b8f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/gpio-rockchip-Switch-to-use-fwnode-instead-of-of_node/20220831-214721
git checkout 1adf1d7efa2837b148a47d10749922358e6f1b8f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/gpio/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All error/warnings (new ones prefixed by >>):
>> drivers/gpio/gpio-rockchip.c:611:11: error: incompatible pointer types assigning to 'struct pinctrl_dev *' from 'struct pinctrl *' [-Werror,-Wincompatible-pointer-types]
pctldev = pinctrl_get(bank->dev->parent);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:639:33: error: call to undeclared function 'to_platform_device'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct platform_device *pdev = to_platform_device(bank->dev);
^
>> drivers/gpio/gpio-rockchip.c:639:26: error: incompatible integer to pointer conversion initializing 'struct platform_device *' with an expression of type 'int' [-Wint-conversion]
struct platform_device *pdev = to_platform_device(bank->dev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:644:19: error: call to undeclared function 'devm_platform_ioremap_resource'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
^
drivers/gpio/gpio-rockchip.c:644:19: note: did you mean 'devm_ioremap_resource'?
include/linux/device.h:235:15: note: 'devm_ioremap_resource' declared here
void __iomem *devm_ioremap_resource(struct device *dev,
^
>> drivers/gpio/gpio-rockchip.c:644:17: error: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:648:14: error: call to undeclared function 'platform_get_irq'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
bank->irq = platform_get_irq(pdev, 0);
^
drivers/gpio/gpio-rockchip.c:641:18: warning: unused variable 'res' [-Wunused-variable]
struct resource res;
^
>> drivers/gpio/gpio-rockchip.c:696:39: warning: declaration of 'struct platform_device' will not be visible outside of this function [-Wvisibility]
static int rockchip_gpio_probe(struct platform_device *pdev)
^
>> drivers/gpio/gpio-rockchip.c:698:28: error: incomplete definition of type 'struct platform_device'
struct device *dev = &pdev->dev;
~~~~^
drivers/gpio/gpio-rockchip.c:696:39: note: forward declaration of 'struct platform_device'
static int rockchip_gpio_probe(struct platform_device *pdev)
^
drivers/gpio/gpio-rockchip.c:709:10: error: incompatible pointer types assigning to 'struct pinctrl_dev *' from 'struct pinctrl *' [-Werror,-Wincompatible-pointer-types]
pctldev = pinctrl_get(dev->parent);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:768:2: error: call to undeclared function 'platform_set_drvdata'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
platform_set_drvdata(pdev, bank);
^
drivers/gpio/gpio-rockchip.c:774:40: warning: declaration of 'struct platform_device' will not be visible outside of this function [-Wvisibility]
static int rockchip_gpio_remove(struct platform_device *pdev)
^
>> drivers/gpio/gpio-rockchip.c:776:35: error: call to undeclared function 'platform_get_drvdata'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
^
>> drivers/gpio/gpio-rockchip.c:776:28: error: incompatible integer to pointer conversion initializing 'struct rockchip_pin_bank *' with an expression of type 'int' [-Wint-conversion]
struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:790:31: error: variable has incomplete type 'struct platform_driver'
static struct platform_driver rockchip_gpio_driver = {
^
drivers/gpio/gpio-rockchip.c:790:15: note: forward declaration of 'struct platform_driver'
static struct platform_driver rockchip_gpio_driver = {
^
>> drivers/gpio/gpio-rockchip.c:801:9: error: call to undeclared function 'platform_driver_register'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
return platform_driver_register(&rockchip_gpio_driver);
^
>> drivers/gpio/gpio-rockchip.c:807:2: error: call to undeclared function 'platform_driver_unregister'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
platform_driver_unregister(&rockchip_gpio_driver);
^
3 warnings and 14 errors generated.
vim +611 drivers/gpio/gpio-rockchip.c
577
578 static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
579 {
580 struct gpio_chip *gc;
581 int ret;
582
583 bank->gpio_chip = rockchip_gpiolib_chip;
584
585 gc = &bank->gpio_chip;
586 gc->base = bank->pin_base;
587 gc->ngpio = bank->nr_pins;
588 gc->label = bank->name;
589 gc->parent = bank->dev;
590
591 ret = gpiochip_add_data(gc, bank);
592 if (ret) {
593 dev_err(bank->dev, "failed to add gpiochip %s, %d\n",
594 gc->label, ret);
595 return ret;
596 }
597
598 /*
599 * For DeviceTree-supported systems, the gpio core checks the
600 * pinctrl's device node for the "gpio-ranges" property.
601 * If it is present, it takes care of adding the pin ranges
602 * for the driver. In this case the driver can skip ahead.
603 *
604 * In order to remain compatible with older, existing DeviceTree
605 * files which don't set the "gpio-ranges" property or systems that
606 * utilize ACPI the driver has to call gpiochip_add_pin_range().
607 */
608 if (!device_property_read_bool(bank->dev, "gpio-ranges")) {
609 struct pinctrl_dev *pctldev = NULL;
610
> 611 pctldev = pinctrl_get(bank->dev->parent);
612 if (!pctldev)
613 return -ENODEV;
614
615 ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0,
616 gc->base, gc->ngpio);
617 if (ret) {
618 dev_err(bank->dev, "Failed to add pin range\n");
619 goto fail;
620 }
621 }
622
623 ret = rockchip_interrupts_register(bank);
624 if (ret) {
625 dev_err(bank->dev, "failed to register interrupt, %d\n", ret);
626 goto fail;
627 }
628
629 return 0;
630
631 fail:
632 gpiochip_remove(&bank->gpio_chip);
633
634 return ret;
635 }
636
637 static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
638 {
> 639 struct platform_device *pdev = to_platform_device(bank->dev);
640 struct device_node *np = bank->dev->of_node;
641 struct resource res;
642 int id = 0;
643
> 644 bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
645 if (IS_ERR(bank->reg_base))
646 return PTR_ERR(bank->reg_base);
647
> 648 bank->irq = platform_get_irq(pdev, 0);
649 if (!bank->irq)
650 return -EINVAL;
651
652 bank->clk = of_clk_get(np, 0);
653 if (IS_ERR(bank->clk))
654 return PTR_ERR(bank->clk);
655
656 clk_prepare_enable(bank->clk);
657 id = readl(bank->reg_base + gpio_regs_v2.version_id);
658
659 /* If not gpio v2, that is default to v1. */
660 if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
661 bank->gpio_regs = &gpio_regs_v2;
662 bank->gpio_type = GPIO_TYPE_V2;
663 bank->db_clk = of_clk_get(np, 1);
664 if (IS_ERR(bank->db_clk)) {
665 dev_err(bank->dev, "cannot find debounce clk\n");
666 clk_disable_unprepare(bank->clk);
667 return -EINVAL;
668 }
669 } else {
670 bank->gpio_regs = &gpio_regs_v1;
671 bank->gpio_type = GPIO_TYPE_V1;
672 }
673
674 return 0;
675 }
676
677 static struct rockchip_pin_bank *
678 rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id)
679 {
680 struct rockchip_pinctrl *info;
681 struct rockchip_pin_bank *bank;
682 int i, found = 0;
683
684 info = pinctrl_dev_get_drvdata(pctldev);
685 bank = info->ctrl->pin_banks;
686 for (i = 0; i < info->ctrl->nr_banks; i++, bank++) {
687 if (bank->bank_num == id) {
688 found = 1;
689 break;
690 }
691 }
692
693 return found ? bank : NULL;
694 }
695
> 696 static int rockchip_gpio_probe(struct platform_device *pdev)
697 {
> 698 struct device *dev = &pdev->dev;
699 struct device_node *np = dev->of_node;
700 struct pinctrl_dev *pctldev = NULL;
701 struct rockchip_pin_bank *bank = NULL;
702 struct rockchip_pin_deferred *cfg;
703 static int gpio;
704 int id, ret;
705
706 if (!dev->parent)
707 return -ENODEV;
708
709 pctldev = pinctrl_get(dev->parent);
710 if (!pctldev)
711 return -EPROBE_DEFER;
712
713 id = of_alias_get_id(np, "gpio");
714 if (id < 0)
715 id = gpio++;
716
717 bank = rockchip_gpio_find_bank(pctldev, id);
718 if (!bank)
719 return -EINVAL;
720
721 bank->dev = dev;
722
723 raw_spin_lock_init(&bank->slock);
724
725 ret = rockchip_get_bank_data(bank);
726 if (ret)
727 return ret;
728
729 /*
730 * Prevent clashes with a deferred output setting
731 * being added right at this moment.
732 */
733 mutex_lock(&bank->deferred_lock);
734
735 ret = rockchip_gpiolib_register(bank);
736 if (ret) {
737 clk_disable_unprepare(bank->clk);
738 mutex_unlock(&bank->deferred_lock);
739 return ret;
740 }
741
742 while (!list_empty(&bank->deferred_pins)) {
743 cfg = list_first_entry(&bank->deferred_pins,
744 struct rockchip_pin_deferred, head);
745 list_del(&cfg->head);
746
747 switch (cfg->param) {
748 case PIN_CONFIG_OUTPUT:
749 ret = rockchip_gpio_direction_output(&bank->gpio_chip, cfg->pin, cfg->arg);
750 if (ret)
751 dev_warn(dev, "setting output pin %u to %u failed\n", cfg->pin,
752 cfg->arg);
753 break;
754 case PIN_CONFIG_INPUT_ENABLE:
755 ret = rockchip_gpio_direction_input(&bank->gpio_chip, cfg->pin);
756 if (ret)
757 dev_warn(dev, "setting input pin %u failed\n", cfg->pin);
758 break;
759 default:
760 dev_warn(dev, "unknown deferred config param %d\n", cfg->param);
761 break;
762 }
763 kfree(cfg);
764 }
765
766 mutex_unlock(&bank->deferred_lock);
767
> 768 platform_set_drvdata(pdev, bank);
769 dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
770
771 return 0;
772 }
773
774 static int rockchip_gpio_remove(struct platform_device *pdev)
775 {
> 776 struct rockchip_pin_bank *bank = platform_get_drvdata(pdev);
777
778 clk_disable_unprepare(bank->clk);
779 gpiochip_remove(&bank->gpio_chip);
780
781 return 0;
782 }
783
784 static const struct of_device_id rockchip_gpio_match[] = {
785 { .compatible = "rockchip,gpio-bank", },
786 { .compatible = "rockchip,rk3188-gpio-bank0" },
787 { },
788 };
789
> 790 static struct platform_driver rockchip_gpio_driver = {
791 .probe = rockchip_gpio_probe,
792 .remove = rockchip_gpio_remove,
793 .driver = {
794 .name = "rockchip-gpio",
795 .of_match_table = rockchip_gpio_match,
796 },
797 };
798
799 static int __init rockchip_gpio_init(void)
800 {
> 801 return platform_driver_register(&rockchip_gpio_driver);
802 }
803 postcore_initcall(rockchip_gpio_init);
804
805 static void __exit rockchip_gpio_exit(void)
806 {
> 807 platform_driver_unregister(&rockchip_gpio_driver);
808 }
809 module_exit(rockchip_gpio_exit);
810
--
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
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
1 sibling, 1 reply; 9+ messages in thread
From: jay.xu @ 2022-09-01 1:47 UTC (permalink / raw)
To: Bartosz Golaszewski, Andy Shevchenko
Cc: linus.walleij, linux-gpio, linux-arm-kernel,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stübner
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");
https://patchwork.kernel.org/project/linux-rockchip/patch/20220901013101.2634480-2-jay.xu@rock-chips.com
>
>Bart
>
>> if (IS_ERR(bank->db_clk)) {
>> dev_err(bank->dev, "cannot find debounce clk\n");
>> clk_disable_unprepare(bank->clk);
>> @@ -705,17 +697,16 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> {
>> struct device *dev = &pdev->dev;
>> struct device_node *np = dev->of_node;
>> - struct device_node *pctlnp = of_get_parent(np);
>> struct pinctrl_dev *pctldev = NULL;
>> struct rockchip_pin_bank *bank = NULL;
>> struct rockchip_pin_deferred *cfg;
>> static int gpio;
>> int id, ret;
>>
>> - if (!np || !pctlnp)
>> + if (!dev->parent)
>> return -ENODEV;
>>
>> - pctldev = of_pinctrl_get(pctlnp);
>> + pctldev = pinctrl_get(dev->parent);
>> if (!pctldev)
>> return -EPROBE_DEFER;
>>
>> @@ -728,7 +719,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> return -EINVAL;
>>
>> bank->dev = dev;
>> - bank->of_node = np;
>>
>> raw_spin_lock_init(&bank->slock);
>>
>> @@ -776,7 +766,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> mutex_unlock(&bank->deferred_lock);
>>
>> platform_set_drvdata(pdev, bank);
>> - dev_info(dev, "probed %pOF\n", np);
>> + dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
>>
>> return 0;
>> }
>> diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
>> index 4759f336941e..37a0501bcc03 100644
>> --- a/drivers/pinctrl/pinctrl-rockchip.h
>> +++ b/drivers/pinctrl/pinctrl-rockchip.h
>> @@ -299,7 +299,6 @@ struct rockchip_drv {
>> * @drv: array describing the 4 drive strength sources of the bank
>> * @pull_type: array describing the 4 pull type sources of the bank
>> * @valid: is all necessary information present
>> - * @of_node: dt node of this bank
>> * @drvdata: common pinctrl basedata
>> * @domain: irqdomain of the gpio bank
>> * @gpio_chip: gpiolib chip
>> @@ -327,7 +326,6 @@ struct rockchip_pin_bank {
>> struct rockchip_drv drv[4];
>> enum rockchip_pin_pull_type pull_type[4];
>> bool valid;
>> - struct device_node *of_node;
>> struct rockchip_pinctrl *drvdata;
>> struct irq_domain *domain;
>> struct gpio_chip gpio_chip;
>> --
>> 2.35.1
>>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
2022-09-01 1:47 ` jay.xu
@ 2022-09-01 7:08 ` Bartosz Golaszewski
2022-09-01 7:25 ` jay.xu
0 siblings, 1 reply; 9+ messages in thread
From: Bartosz Golaszewski @ 2022-09-01 7:08 UTC (permalink / raw)
To: jay.xu
Cc: Andy Shevchenko, linus.walleij, linux-gpio, linux-arm-kernel,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stübner
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.
Bart
> https://patchwork.kernel.org/project/linux-rockchip/patch/20220901013101.2634480-2-jay.xu@rock-chips.com
>
> >
> >Bart
> >
> >> if (IS_ERR(bank->db_clk)) {
> >> dev_err(bank->dev, "cannot find debounce clk\n");
> >> clk_disable_unprepare(bank->clk);
> >> @@ -705,17 +697,16 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> >> {
> >> struct device *dev = &pdev->dev;
> >> struct device_node *np = dev->of_node;
> >> - struct device_node *pctlnp = of_get_parent(np);
> >> struct pinctrl_dev *pctldev = NULL;
> >> struct rockchip_pin_bank *bank = NULL;
> >> struct rockchip_pin_deferred *cfg;
> >> static int gpio;
> >> int id, ret;
> >>
> >> - if (!np || !pctlnp)
> >> + if (!dev->parent)
> >> return -ENODEV;
> >>
> >> - pctldev = of_pinctrl_get(pctlnp);
> >> + pctldev = pinctrl_get(dev->parent);
> >> if (!pctldev)
> >> return -EPROBE_DEFER;
> >>
> >> @@ -728,7 +719,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> >> return -EINVAL;
> >>
> >> bank->dev = dev;
> >> - bank->of_node = np;
> >>
> >> raw_spin_lock_init(&bank->slock);
> >>
> >> @@ -776,7 +766,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
> >> mutex_unlock(&bank->deferred_lock);
> >>
> >> platform_set_drvdata(pdev, bank);
> >> - dev_info(dev, "probed %pOF\n", np);
> >> + dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
> >>
> >> return 0;
> >> }
> >> diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
> >> index 4759f336941e..37a0501bcc03 100644
> >> --- a/drivers/pinctrl/pinctrl-rockchip.h
> >> +++ b/drivers/pinctrl/pinctrl-rockchip.h
> >> @@ -299,7 +299,6 @@ struct rockchip_drv {
> >> * @drv: array describing the 4 drive strength sources of the bank
> >> * @pull_type: array describing the 4 pull type sources of the bank
> >> * @valid: is all necessary information present
> >> - * @of_node: dt node of this bank
> >> * @drvdata: common pinctrl basedata
> >> * @domain: irqdomain of the gpio bank
> >> * @gpio_chip: gpiolib chip
> >> @@ -327,7 +326,6 @@ struct rockchip_pin_bank {
> >> struct rockchip_drv drv[4];
> >> enum rockchip_pin_pull_type pull_type[4];
> >> bool valid;
> >> - struct device_node *of_node;
> >> struct rockchip_pinctrl *drvdata;
> >> struct irq_domain *domain;
> >> struct gpio_chip gpio_chip;
> >> --
> >> 2.35.1
> >>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
2022-09-01 7:08 ` Bartosz Golaszewski
@ 2022-09-01 7:25 ` jay.xu
2022-09-22 8:34 ` Bartosz Golaszewski
0 siblings, 1 reply; 9+ messages in thread
From: jay.xu @ 2022-09-01 7:25 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Andy Shevchenko, linus.walleij, linux-gpio, linux-arm-kernel,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stübner
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 ?
>Bart
>
>> https://patchwork.kernel.org/project/linux-rockchip/patch/20220901013101.2634480-2-jay.xu@rock-chips.com
>>
>> >
>> >Bart
>> >
>> >> if (IS_ERR(bank->db_clk)) {
>> >> dev_err(bank->dev, "cannot find debounce clk\n");
>> >> clk_disable_unprepare(bank->clk);
>> >> @@ -705,17 +697,16 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> >> {
>> >> struct device *dev = &pdev->dev;
>> >> struct device_node *np = dev->of_node;
>> >> - struct device_node *pctlnp = of_get_parent(np);
>> >> struct pinctrl_dev *pctldev = NULL;
>> >> struct rockchip_pin_bank *bank = NULL;
>> >> struct rockchip_pin_deferred *cfg;
>> >> static int gpio;
>> >> int id, ret;
>> >>
>> >> - if (!np || !pctlnp)
>> >> + if (!dev->parent)
>> >> return -ENODEV;
>> >>
>> >> - pctldev = of_pinctrl_get(pctlnp);
>> >> + pctldev = pinctrl_get(dev->parent);
>> >> if (!pctldev)
>> >> return -EPROBE_DEFER;
>> >>
>> >> @@ -728,7 +719,6 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> >> return -EINVAL;
>> >>
>> >> bank->dev = dev;
>> >> - bank->of_node = np;
>> >>
>> >> raw_spin_lock_init(&bank->slock);
>> >>
>> >> @@ -776,7 +766,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
>> >> mutex_unlock(&bank->deferred_lock);
>> >>
>> >> platform_set_drvdata(pdev, bank);
>> >> - dev_info(dev, "probed %pOF\n", np);
>> >> + dev_info(dev, "probed %pfw\n", dev_fwnode(dev));
>> >>
>> >> return 0;
>> >> }
>> >> diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
>> >> index 4759f336941e..37a0501bcc03 100644
>> >> --- a/drivers/pinctrl/pinctrl-rockchip.h
>> >> +++ b/drivers/pinctrl/pinctrl-rockchip.h
>> >> @@ -299,7 +299,6 @@ struct rockchip_drv {
>> >> * @drv: array describing the 4 drive strength sources of the bank
>> >> * @pull_type: array describing the 4 pull type sources of the bank
>> >> * @valid: is all necessary information present
>> >> - * @of_node: dt node of this bank
>> >> * @drvdata: common pinctrl basedata
>> >> * @domain: irqdomain of the gpio bank
>> >> * @gpio_chip: gpiolib chip
>> >> @@ -327,7 +326,6 @@ struct rockchip_pin_bank {
>> >> struct rockchip_drv drv[4];
>> >> enum rockchip_pin_pull_type pull_type[4];
>> >> bool valid;
>> >> - struct device_node *of_node;
>> >> struct rockchip_pinctrl *drvdata;
>> >> struct irq_domain *domain;
>> >> struct gpio_chip gpio_chip;
>> >> --
>> >> 2.35.1
>> >>
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH v2 1/1] gpio: rockchip: Switch to use fwnode instead of of_node
2022-09-01 7:25 ` jay.xu
@ 2022-09-22 8:34 ` Bartosz Golaszewski
0 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2022-09-22 8:34 UTC (permalink / raw)
To: jay.xu
Cc: Andy Shevchenko, linus.walleij, linux-gpio, linux-arm-kernel,
open list:ARM/Rockchip SoC...,
Linux Kernel Mailing List, Heiko Stübner
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-22 8:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-08-31 19:30 ` kernel test robot
2022-08-31 19:51 ` kernel test robot
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).