From: "Heiko Stübner" <heiko@sntech.de>
To: linus.walleij@linaro.org, Jianqun Xu <jay.xu@rock-chips.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rockchip@lists.infradead.org,
Jianqun Xu <jay.xu@rock-chips.com>
Subject: Re: [PATCH 6/6] pinctrl: rockchip: populate platform device for rockchip gpio
Date: Sun, 06 Sep 2020 12:20:31 +0200 [thread overview]
Message-ID: <76163126.riIkUvEO9g@diego> (raw)
In-Reply-To: <20200831085021.7288-1-jay.xu@rock-chips.com>
Hi Jianqun,
Am Montag, 31. August 2020, 10:50:21 CEST schrieb Jianqun Xu:
> Register both gpio driver and device as part of driver model, so that
> the '-gpio'/'-gpios' dependency in dts can be correctly handled by
> of_devlink/of_fwlink.
>
> Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
[...]
> -static int rockchip_gpiolib_unregister(struct platform_device *pdev,
> - struct rockchip_pinctrl *info)
> -{
> - struct rockchip_pin_ctrl *ctrl = info->ctrl;
> - struct rockchip_pin_bank *bank = ctrl->pin_banks;
> - int i;
> + pctldev = info->pctl_dev;
> + if (!pctldev)
> + return -ENODEV;
>
> - for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
> - if (!bank->valid)
> - continue;
> - gpiochip_remove(&bank->gpio_chip);
> + ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0, gc->base, gc->ngpio);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to add pin range\n");
> + gpiochip_remove(&bank->gpio_chip);
> + return ret;
> + }
> }
>
> return 0;
> @@ -3752,6 +3734,46 @@ 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 rockchip_gpio_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct device *parent = pdev->dev.parent;
> + struct rockchip_pinctrl *info = dev_get_drvdata(parent);
> + struct rockchip_pin_ctrl *ctrl = info ? (info->ctrl) : NULL;
> + struct rockchip_pin_bank *bank;
> + int ret, i;
> +
> + if (!info || !ctrl)
> + return -EINVAL;
> +
> + if (!of_find_property(np, "gpio-controller", NULL))
> + return -ENODEV;
> +
> + bank = ctrl->pin_banks;
> + for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
> + if (!strcmp(bank->name, np->name)) {
> + bank->of_node = np;
> +
> + if (!rockchip_get_bank_data(bank, info))
> + bank->valid = true;
> +
> + break;
> + }
> + }
> +
> + bank->of_node = pdev->dev.of_node;
> +
> + ret = rockchip_gpiolib_register(pdev, bank);
> + if (ret)
> + return ret;
> +
> + ret = rockchip_interrupts_register(pdev, bank);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> static int rockchip_pinctrl_probe(struct platform_device *pdev)
> {
> struct rockchip_pinctrl *info;
> @@ -3823,18 +3845,20 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
> return PTR_ERR(info->regmap_pmu);
> }
>
> - ret = rockchip_gpiolib_register(pdev, info);
> - if (ret)
> - return ret;
> -
> ret = rockchip_pinctrl_register(pdev, info);
> if (ret) {
> - rockchip_gpiolib_unregister(pdev, info);
> + dev_err(&pdev->dev, "failed to register pinctrl device\n");
> return ret;
> }
>
> platform_set_drvdata(pdev, info);
>
> + ret = of_platform_populate(np, rockchip_bank_match, NULL, dev);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to register gpio device\n");
> + return ret;
> + }
> +
> return 0;
> }
>
> @@ -4254,6 +4278,14 @@ static const struct of_device_id rockchip_pinctrl_dt_match[] = {
> {},
> };
>
> +static struct platform_driver rockchip_gpio_driver = {
> + .probe = rockchip_gpio_probe,
> + .driver = {
> + .name = "rockchip-gpio",
> + .of_match_table = rockchip_bank_match,
> + },
> +};
> +
> static struct platform_driver rockchip_pinctrl_driver = {
> .probe = rockchip_pinctrl_probe,
> .driver = {
> @@ -4265,7 +4297,9 @@ static struct platform_driver rockchip_pinctrl_driver = {
>
> static int __init rockchip_pinctrl_drv_register(void)
> {
> - return platform_driver_register(&rockchip_pinctrl_driver);
> + platform_driver_register(&rockchip_pinctrl_driver);
> +
> + return platform_driver_register(&rockchip_gpio_driver);
> }
> postcore_initcall(rockchip_pinctrl_drv_register);
This also seems to miss the whole unloading of module paths?
I'd expect a gpiochip_remove etc in some _remove function and
of course a platform_driver_unregister.
Heiko
next prev parent reply other threads:[~2020-09-06 10:20 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 8:47 [PATCH 0/6] rockchip-pinctrl fixes for GKI Jianqun Xu
2020-08-31 8:47 ` [PATCH 1/6] pinctrl: rockchip: make driver be tristate module Jianqun Xu
2020-09-01 10:13 ` kernel test robot
2020-09-05 21:51 ` Heiko Stübner
2020-09-05 22:01 ` Heiko Stübner
2020-09-05 22:23 ` Heiko Stübner
2020-08-31 8:47 ` [PATCH 2/6] pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq Jianqun Xu
2020-09-05 21:54 ` Heiko Stübner
2020-08-31 8:47 ` [PATCH 3/6] pinctrl: rockchip: create irq mapping in gpio_to_irq Jianqun Xu
2020-09-05 22:03 ` Heiko Stübner
2020-08-31 8:47 ` [PATCH 4/6] pinctrl: rockchip: do not set gpio if bank invalid Jianqun Xu
2020-09-05 22:09 ` Heiko Stübner
2020-08-31 8:50 ` [PATCH 5/6] pinctrl: rockchip: fix crash caused by invalid gpio bank Jianqun Xu
2020-09-05 22:14 ` Heiko Stübner
2020-08-31 8:50 ` [PATCH 6/6] pinctrl: rockchip: populate platform device for rockchip gpio Jianqun Xu
2020-09-06 10:20 ` Heiko Stübner [this message]
2020-09-07 2:59 ` [PATCH v2 0/5] rockchip-pinctrl fixes for GKI Jianqun Xu
2020-09-07 2:59 ` [PATCH 1/5] pinctrl: rockchip: depend on OF Jianqun Xu
2020-09-07 2:59 ` [PATCH 2/5] pinctrl: rockchip: make driver be tristate module Jianqun Xu
2020-09-07 11:35 ` kernel test robot
2020-09-12 11:41 ` Heiko Stübner
2020-09-14 0:38 ` [PATCH 2/2] " Jianqun Xu
2020-09-20 22:14 ` Heiko Stübner
2020-09-20 22:18 ` Heiko Stübner
2020-09-29 13:21 ` Linus Walleij
2020-10-13 6:40 ` jay.xu
2020-09-07 2:59 ` [PATCH 3/5] pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq Jianqun Xu
2020-09-07 2:59 ` [PATCH 4/5] pinctrl: rockchip: create irq mapping in gpio_to_irq Jianqun Xu
2020-09-07 3:38 ` [PATCH 5/5] pinctrl: rockchip: populate platform device for rockchip gpio Jianqun Xu
2020-09-08 2:19 ` [PATCH] " Jianqun Xu
2020-09-20 22:16 ` Heiko Stübner
2020-09-12 11:35 ` [PATCH v2 0/5] rockchip-pinctrl fixes for GKI Linus Walleij
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=76163126.riIkUvEO9g@diego \
--to=heiko@sntech.de \
--cc=jay.xu@rock-chips.com \
--cc=linus.walleij@linaro.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).