rockchip pinctrl for acpi
Subsystems (3)
v2 cover rockchip pinctrl for acpi
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device api
Jianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data by device_get_match_data
drivers/pinctrl/pinctrl-rockchip.c | 62 +++++++++++++++++++++--------- drivers/pinctrl/pinctrl-rockchip.h | 2 +- 2 files changed, 45 insertions(+), 19 deletions(-)
Signature · 4 lines
v2: - add a second patch to support acpi 2.25.1
PATCH v2 1/2 pinctrl: rockchip: find gpiochip by name from gpio module
Currently the pinctrl device acts as parent for the gpio devices for rockchip platform, the pinctrl driver probes first and then populate the gpio platform lastly.
This patch makes the pinctrl to populate gpio platform firstly and then do probe after gpio probed successfully. And get gpiochips througth a find function by the gpio label.
---
v2 RESEND:
- first version RESEND
drivers/pinctrl/pinctrl-rockchip.c | 48 +++++++++++++++++++++++------- drivers/pinctrl/pinctrl-rockchip.h | 2 +- 2 files changed, 38 insertions(+), 12 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +37 -11
@@ -2726,7 +2726,7 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, {struct rockchip_pinctrl *info =pinctrl_dev_get_drvdata (pctldev);struct rockchip_pin_bank *bank =pin_to_bank (info, pin); -struct gpio_chip *gpio = &bank->gpio_chip; +struct gpio_chip *gpio = bank->gpio_chip;enum pin_config_param param;u32 arg;int i;
@@ -2832,7 +2832,7 @@ static int rockchip_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, {struct rockchip_pinctrl *info =pinctrl_dev_get_drvdata (pctldev);struct rockchip_pin_bank *bank =pin_to_bank (info, pin); -struct gpio_chip *gpio = &bank->gpio_chip; +struct gpio_chip *gpio = bank->gpio_chip;enum pin_config_param param =pinconf_to_config_param (*config);u16 arg;int rc;
@@ -3289,18 +3289,29 @@ static int __maybe_unused rockchip_pinctrl_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend, rockchip_pinctrl_resume); +static int gpiochip_match_name (struct gpio_chip *gc,void *data) +{ +const char *name = data; + +return !strcmp (gc->label, name); +} +static int rockchip_pinctrl_probe (struct platform_device *pdev) { -struct rockchip_pinctrl *info;struct device *dev = &pdev->dev; -struct device_node *np = dev->of_node, *node; +struct fwnode_handle *fwnode =dev_fwnode (dev); +struct rockchip_pinctrl *info;struct rockchip_pin_ctrl *ctrl; +struct device_node *np, *node;struct resource *res;void __iomem *base; -int ret; +int ret, i; -if (!dev->of_node) -return dev_err_probe (dev, -ENODEV ,"device tree node not found\n" ); +if (is_of_node (fwnode)) { + ret =of_platform_populate (np,NULL ,NULL ,NULL ); +if (ret) +return dev_err_probe (dev, ret,"failed to register gpio device\n" ); + } info =devm_kzalloc (dev,sizeof (*info),GFP_KERNEL );if (!info)
@@ -3358,11 +3369,26 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)if (ret)return ret; -platform_set_drvdata (pdev, info); +for (i =0 ; i < ctrl->nr_banks; i++) { +struct gpio_chip *gc; +struct rockchip_pin_bank *bank = &ctrl->pin_banks[i]; - ret =of_platform_populate (np,NULL ,NULL , &pdev->dev); -if (ret) -return dev_err_probe (dev, ret,"failed to register gpio device\n" ); + gc =gpiochip_find ((void *)ctrl->pin_banks[i].name, gpiochip_match_name); +if (!gc) { +dev_err (dev,"fail to find gpiochip\n" ); +return ret; + } + + ret =gpiochip_add_pin_range (gc,dev_name (dev),0 , gc->base, gc->ngpio); +if (ret) { +dev_err (dev,"fail to add pin range\n" ); +return ret; + } + bank->gpio_chip = gc; + } + +platform_set_drvdata (pdev, info); +dev_info (dev,"probed %pfw\n" , fwnode);return 0 ; }
drivers/pinctrl/pinctrl-rockchip.h +1 -1
@@ -330,7 +330,7 @@ struct rockchip_pin_bank {struct device_node *of_node;struct rockchip_pinctrl *drvdata;struct irq_domain *domain; -struct gpio_chip gpio_chip; +struct gpio_chip *gpio_chip;struct pinctrl_gpio_range grange;raw_spinlock_t slock;const struct rockchip_gpio_regs *gpio_regs;
Signature · 1 line
2.25.1
PATCH v2 2/2 pinctrl: rockchip: get match data by device_get_match_data
In reply to Jianqun XuThis patch fixes to use device_get_match_data to get match data, instead of of_match_node to adapt for the acpi.
---
v2 RESEND:
- use fwnode instead of of node
- add a second patch to this serail
drivers/pinctrl/pinctrl-rockchip.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/pinctrl-rockchip.c +8 -8
@@ -3033,11 +3033,15 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, struct rockchip_pinctrl *info) {struct device *dev = &pdev->dev; -struct device_node *np = dev->of_node; -struct device_node *child; +struct fwnode_handle *fwnode =dev_fwnode (dev); +struct device_node *np, *child;int ret;int i; +if (!is_of_node (fwnode)) +return 0 ; + + np =to_of_node (fwnode);rockchip_pinctrl_child_count (info, np);dev_dbg (dev,"nfunctions = %d\n" , info->nfunctions);
@@ -3129,15 +3133,11 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data( struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct device_node *node = dev->of_node; -const struct of_device_id *match;struct rockchip_pin_ctrl *ctrl;struct rockchip_pin_bank *bank;int grf_offs, pmu_offs, drv_grf_offs, drv_pmu_offs, i, j; - match =of_match_node (rockchip_pinctrl_dt_match, node); - ctrl = (struct rockchip_pin_ctrl *)match->data; - + ctrl = (struct rockchip_pin_ctrl *)device_get_match_data (&pdev->dev); grf_offs = ctrl->grf_mux_offset; pmu_offs = ctrl->pmu_mux_offset; drv_pmu_offs = ctrl->pmu_drv_offset;
@@ -3308,7 +3308,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)int ret, i;if (is_of_node (fwnode)) { - ret =of_platform_populate (np,NULL ,NULL ,NULL ); + ret =of_platform_populate (to_of_node (fwnode),NULL ,NULL ,NULL );if (ret)return dev_err_probe (dev, ret,"failed to register gpio device\n" ); }
Signature · 1 line
2.25.1
Quoted 8 lines · Jianqun Xu
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device apiJianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data bydevice_get_match_data
These look OK to me but I would feel better if Heiko or Andy ACK:ed them so I give them a few more days to comment.
Yours,
Linus Walleij
Heiko Stuebner
maintainerAm Dienstag, 20. September 2022, 11:26:26 CEST schrieb Linus Walleij:
Quoted 7 lines · Jianqun Xu
Quoted 6 lines
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device api
Quoted 6 lines
Quoted 3 lines
Jianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data bydevice_get_match_dataThese look OK to me but I would feel better if Heiko or Andy ACK:ed them so I give them a few more days to comment.
Right now I'm actually quite confused as I seem to have a bunch of pinctrl/gpio-acpi patchsets of varying lengths in my inbox.
There is a "v2", a "v8", a 20-patchset without version. It's all quite confusing.
Heiko
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Quoted 12 lines · Heiko Stuebner
Am Dienstag, 20. September 2022, 11:26:26 CEST schrieb Linus Walleij:
Quoted 11 lines · Jianqun Xu
Quoted 9 lines
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device apiJianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data bydevice_get_match_data
Quoted 8 lines
Quoted 2 lines
These look OK to me but I would feel better if Heiko or Andy ACK:ed them so I give them a few more days to comment.
Right now I'm actually quite confused as I seem to have a bunch of pinctrl/gpio-acpi patchsets of varying lengths in my inbox.
There is a "v2", a "v8", a 20-patchset without version. It's all quite confusing.
With the LKP complains on top of almost each series...
That's why I stopped considering them seriously (like some RFC is going on) and no more reviewing.
I can suggest the author to create a branch on a public tree and collect all series together (like topic branches that are merged one-by-one to the main topic branch) and start again.
Signature · 9 lines
With Best Regards, Andy Shevchenko _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Hi heiko
--------------
[email protected]
Quoted 12 lines
Am Dienstag, 20. September 2022, 11:26:26 CEST schrieb Linus Walleij:
Quoted 11 lines · Jianqun Xu
Quoted 9 lines
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device apiJianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data bydevice_get_match_data
Quoted 9 lines
Quoted 2 lines
These look OK to me but I would feel better if Heiko or Andy ACK:ed them so I give them a few more days to comment.
Right now I'm actually quite confused as I seem to have a bunch of pinctrl/gpio-acpi patchsets of varying lengths in my inbox.
There is a "v2", a "v8", a 20-patchset without version. It's all quite confusing.
From v2 to v8, I summit fixes in one patch, and them sugguested by Andy, I try to separate them into small patches 20-patchset.
The heart change is
current
1. pinctrl register first
2. gpiochip register and find pinctrl device to add pin range
this patch fix to
1. gpiochip register itself
2. pinctrl register and find all gpiochips and add pin range
Please help to review directly to 20-patchset, I will add some suggested-by and acked-by later
Quoted 4 lines
Heiko
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Heiko Stuebner
maintainerHi Jay,
Am Freitag, 23. September 2022, 12:35:36 CEST schrieb [email protected]:
Quoted 34 lines
Hi heiko
--------------
[email protected]Quoted 12 lines
Am Dienstag, 20. September 2022, 11:26:26 CEST schrieb Linus Walleij:
Quoted 11 lines · Jianqun Xu
Quoted 9 lines
These patch fixes to support acpi by:
1. populate gpio platform before pinctrl to probe
2. get gpiochip by finding from gpiochip list
3. get match data by device apiJianqun Xu (2):
pinctrl: rockchip: find gpiochip by name from gpio module
pinctrl: rockchip: get match data bydevice_get_match_dataQuoted 9 lines
Quoted 2 lines
These look OK to me but I would feel better if Heiko or Andy ACK:ed them so I give them a few more days to comment.
Right now I'm actually quite confused as I seem to have a bunch of pinctrl/gpio-acpi patchsets of varying lengths in my inbox.
There is a "v2", a "v8", a 20-patchset without version. It's all quite confusing.
From v2 to v8, I summit fixes in one patch, and them sugguested by Andy, I try to separate them into small patches 20-patchset.
The heart change is
current
1. pinctrl register first
2. gpiochip register and find pinctrl device to add pin range
Quoted 5 lines
this patch fix to
1. gpiochip register itself
2. pinctrl register and find all gpiochips and add pin rangePlease help to review directly to 20-patchset, I will add some suggested-by and acked-by later
ok, I'll drop all the other acpi/pinctrl/gpio sets and move to the 20-patch-series.
Thanks for the clarification
Heiko
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip