2020-10-13 11:56:02

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH v3 0/3] rockchip-pinctrl fixes

These patches are required by GKI.

Jianqun Xu (3):
pinctrl: rockchip: make driver be tristate module
pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq
pinctrl: rockchip: create irq mapping in gpio_to_irq

drivers/pinctrl/Kconfig | 2 +-
drivers/pinctrl/pinctrl-rockchip.c | 43 +++++++++++++++++++-----------
2 files changed, 28 insertions(+), 17 deletions(-)

--
2.17.1




2020-10-13 11:56:05

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH v3 2/3] pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq

There need to enable pclk_gpio when do irq_create_mapping, since it will
do access to gpio controller.

Reviewed-by: Heiko Stuebner <[email protected]>
Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/pinctrl/pinctrl-rockchip.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 927d132d6716..a2f361aa6d05 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -3157,7 +3157,9 @@ static int rockchip_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
if (!bank->domain)
return -ENXIO;

+ clk_enable(bank->clk);
virq = irq_create_mapping(bank->domain, offset);
+ clk_disable(bank->clk);

return (virq) ? : -ENXIO;
}
--
2.17.1



2020-10-13 11:56:11

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH v3 3/3] pinctrl: rockchip: create irq mapping in gpio_to_irq

Remove totally irq mappings create in probe, the gpio irq mapping will
be created when do
gpio_to_irq ->
rockchip_gpio_to_irq ->
irq_create_mapping

This patch can speed up system boot on, also abandon many unused irq
mappings' create.

Reviewed-by: Heiko Stuebner <[email protected]>
Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/pinctrl/pinctrl-rockchip.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index a2f361aa6d05..70dc03af5699 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -3198,7 +3198,7 @@ static void rockchip_irq_demux(struct irq_desc *desc)

irq = __ffs(pend);
pend &= ~BIT(irq);
- virq = irq_linear_revmap(bank->domain, irq);
+ virq = irq_find_mapping(bank->domain, irq);

if (!virq) {
dev_err(bank->drvdata->dev, "unmapped irq %d\n", irq);
@@ -3377,7 +3377,7 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
struct irq_chip_generic *gc;
int ret;
- int i, j;
+ int i;

for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
if (!bank->valid) {
@@ -3404,7 +3404,7 @@ static int rockchip_interrupts_register(struct platform_device *pdev,

ret = irq_alloc_domain_generic_chips(bank->domain, 32, 1,
"rockchip_gpio_irq", handle_level_irq,
- clr, 0, IRQ_GC_INIT_MASK_CACHE);
+ clr, 0, 0);
if (ret) {
dev_err(&pdev->dev, "could not alloc generic chips for bank %s\n",
bank->name);
@@ -3413,14 +3413,6 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
continue;
}

- /*
- * Linux assumes that all interrupts start out disabled/masked.
- * Our driver only uses the concept of masked and always keeps
- * things enabled, so for us that's all masked and all enabled.
- */
- writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTMASK);
- writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTEN);
-
gc = irq_get_domain_generic_chip(bank->domain, 0);
gc->reg_base = bank->reg_base;
gc->private = bank;
@@ -3437,13 +3429,17 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type;
gc->wake_enabled = IRQ_MSK(bank->nr_pins);

+ /*
+ * Linux assumes that all interrupts start out disabled/masked.
+ * Our driver only uses the concept of masked and always keeps
+ * things enabled, so for us that's all masked and all enabled.
+ */
+ writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTMASK);
+ writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTEN);
+ gc->mask_cache = 0xffffffff;
+
irq_set_chained_handler_and_data(bank->irq,
rockchip_irq_demux, bank);
-
- /* map the gpio irqs here, when the clock is still running */
- for (j = 0 ; j < 32 ; j++)
- irq_create_mapping(bank->domain, j);
-
clk_disable(bank->clk);
}

--
2.17.1



2020-10-13 11:56:18

by Jianqun Xu

[permalink] [raw]
Subject: [PATCH v3 1/3] pinctrl: rockchip: make driver be tristate module

Make pinctrl-rockchip driver to be tristate module, support to build as
a module, this is useful for GKI.

Reviewed-by: Heiko Stuebner <[email protected]>
Signed-off-by: Jianqun Xu <[email protected]>
---
drivers/pinctrl/Kconfig | 2 +-
drivers/pinctrl/pinctrl-rockchip.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 815095326e2d..bc9774c1ae8d 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -207,7 +207,7 @@ config PINCTRL_OXNAS
select MFD_SYSCON

config PINCTRL_ROCKCHIP
- bool
+ tristate "Rockchip gpio and pinctrl driver"
depends on OF
select PINMUX
select GENERIC_PINCONF
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 0401c1da79dd..927d132d6716 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -16,10 +16,12 @@
*/

#include <linux/init.h>
+#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/bitops.h>
#include <linux/gpio/driver.h>
+#include <linux/of_device.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/pinctrl/machine.h>
@@ -4258,3 +4260,14 @@ static int __init rockchip_pinctrl_drv_register(void)
return platform_driver_register(&rockchip_pinctrl_driver);
}
postcore_initcall(rockchip_pinctrl_drv_register);
+
+static void __exit rockchip_pinctrl_drv_unregister(void)
+{
+ platform_driver_unregister(&rockchip_pinctrl_driver);
+}
+module_exit(rockchip_pinctrl_drv_unregister);
+
+MODULE_DESCRIPTION("ROCKCHIP Pin Controller Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:pinctrl-rockchip");
+MODULE_DEVICE_TABLE(of, rockchip_pinctrl_dt_match);
--
2.17.1



2020-10-13 18:25:07

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] rockchip-pinctrl fixes

Hi Jianqun,

Am Dienstag, 13. Oktober 2020, 08:37:28 CEST schrieb Jianqun Xu:
> These patches are required by GKI.
>
> Jianqun Xu (3):
> pinctrl: rockchip: make driver be tristate module
> pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq
> pinctrl: rockchip: create irq mapping in gpio_to_irq

looks good to go as fixes.

What happenend to the "populate platform device for rockchip gpio"
patch though - more out of cursiosity.

Heiko


2020-10-14 08:08:15

by Kever Yang

[permalink] [raw]
Subject: Re: [PATCH v3 2/3] pinctrl: rockchip: enable gp io pclk for rockchip_gpio_to_irq【请注意,邮件由linux-rockchip-bounces+kever.yang=rock-chips.com@lists.infradead.org代发】


On 2020/10/13 下午2:37, Jianqun Xu wrote:
> There need to enable pclk_gpio when do irq_create_mapping, since it will
> do access to gpio controller.
>
> Reviewed-by: Heiko Stuebner <[email protected]>
> Signed-off-by: Jianqun Xu <[email protected]>
> ---
> drivers/pinctrl/pinctrl-rockchip.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 927d132d6716..a2f361aa6d05 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -3157,7 +3157,9 @@ static int rockchip_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
> if (!bank->domain)
> return -ENXIO;
>
> + clk_enable(bank->clk);
> virq = irq_create_mapping(bank->domain, offset);
> + clk_disable(bank->clk);
>
> return (virq) ? : -ENXIO;
> }


Looks good to me,

Reviewed-by: Kever Yang<[email protected]>

Thanks,
- Kever



2020-10-14 08:08:21

by Kever Yang

[permalink] [raw]
Subject: Re: [PATCH v3 1/3] pinctrl: rockchip: make driv er be tristate module【请注意,邮件由lin [email protected] radead.org代发】


On 2020/10/13 下午2:37, Jianqun Xu wrote:
> Make pinctrl-rockchip driver to be tristate module, support to build as
> a module, this is useful for GKI.
>
> Reviewed-by: Heiko Stuebner <[email protected]>
> Signed-off-by: Jianqun Xu <[email protected]>
> ---
> drivers/pinctrl/Kconfig | 2 +-
> drivers/pinctrl/pinctrl-rockchip.c | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
> index 815095326e2d..bc9774c1ae8d 100644
> --- a/drivers/pinctrl/Kconfig
> +++ b/drivers/pinctrl/Kconfig
> @@ -207,7 +207,7 @@ config PINCTRL_OXNAS
> select MFD_SYSCON
>
> config PINCTRL_ROCKCHIP
> - bool
> + tristate "Rockchip gpio and pinctrl driver"
> depends on OF
> select PINMUX
> select GENERIC_PINCONF
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 0401c1da79dd..927d132d6716 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -16,10 +16,12 @@
> */
>
> #include <linux/init.h>
> +#include <linux/module.h>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/bitops.h>
> #include <linux/gpio/driver.h>
> +#include <linux/of_device.h>
> #include <linux/of_address.h>
> #include <linux/of_irq.h>
> #include <linux/pinctrl/machine.h>
> @@ -4258,3 +4260,14 @@ static int __init rockchip_pinctrl_drv_register(void)
> return platform_driver_register(&rockchip_pinctrl_driver);
> }
> postcore_initcall(rockchip_pinctrl_drv_register);
> +
> +static void __exit rockchip_pinctrl_drv_unregister(void)
> +{
> + platform_driver_unregister(&rockchip_pinctrl_driver);
> +}
> +module_exit(rockchip_pinctrl_drv_unregister);
> +
> +MODULE_DESCRIPTION("ROCKCHIP Pin Controller Driver");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:pinctrl-rockchip");
> +MODULE_DEVICE_TABLE(of, rockchip_pinctrl_dt_match);

Looks good to me,

Reviewed-by: Kever Yang<[email protected]>

Thanks,
- Kever



2020-10-14 08:11:23

by Kever Yang

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] pinctrl: rockchip: create ir q mapping in gpio_to_irq【请注意,邮件由 linux-rockchip-bounces+kever.yang=rock-chips.com@lists. infradead.org代发】


On 2020/10/13 下午2:37, Jianqun Xu wrote:
> Remove totally irq mappings create in probe, the gpio irq mapping will
> be created when do
> gpio_to_irq ->
> rockchip_gpio_to_irq ->
> irq_create_mapping
>
> This patch can speed up system boot on, also abandon many unused irq
> mappings' create.
>
> Reviewed-by: Heiko Stuebner <[email protected]>
> Signed-off-by: Jianqun Xu <[email protected]>
> ---
> drivers/pinctrl/pinctrl-rockchip.c | 28 ++++++++++++----------------
> 1 file changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index a2f361aa6d05..70dc03af5699 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -3198,7 +3198,7 @@ static void rockchip_irq_demux(struct irq_desc *desc)
>
> irq = __ffs(pend);
> pend &= ~BIT(irq);
> - virq = irq_linear_revmap(bank->domain, irq);
> + virq = irq_find_mapping(bank->domain, irq);
>
> if (!virq) {
> dev_err(bank->drvdata->dev, "unmapped irq %d\n", irq);
> @@ -3377,7 +3377,7 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
> unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
> struct irq_chip_generic *gc;
> int ret;
> - int i, j;
> + int i;
>
> for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
> if (!bank->valid) {
> @@ -3404,7 +3404,7 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
>
> ret = irq_alloc_domain_generic_chips(bank->domain, 32, 1,
> "rockchip_gpio_irq", handle_level_irq,
> - clr, 0, IRQ_GC_INIT_MASK_CACHE);
> + clr, 0, 0);
> if (ret) {
> dev_err(&pdev->dev, "could not alloc generic chips for bank %s\n",
> bank->name);
> @@ -3413,14 +3413,6 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
> continue;
> }
>
> - /*
> - * Linux assumes that all interrupts start out disabled/masked.
> - * Our driver only uses the concept of masked and always keeps
> - * things enabled, so for us that's all masked and all enabled.
> - */
> - writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTMASK);
> - writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTEN);
> -
> gc = irq_get_domain_generic_chip(bank->domain, 0);
> gc->reg_base = bank->reg_base;
> gc->private = bank;
> @@ -3437,13 +3429,17 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
> gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type;
> gc->wake_enabled = IRQ_MSK(bank->nr_pins);
>
> + /*
> + * Linux assumes that all interrupts start out disabled/masked.
> + * Our driver only uses the concept of masked and always keeps
> + * things enabled, so for us that's all masked and all enabled.
> + */
> + writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTMASK);
> + writel_relaxed(0xffffffff, bank->reg_base + GPIO_INTEN);
> + gc->mask_cache = 0xffffffff;
> +
> irq_set_chained_handler_and_data(bank->irq,
> rockchip_irq_demux, bank);
> -
> - /* map the gpio irqs here, when the clock is still running */
> - for (j = 0 ; j < 32 ; j++)
> - irq_create_mapping(bank->domain, j);
> -
> clk_disable(bank->clk);
> }
>

Looks good to me,

Reviewed-by: Kever Yang<[email protected]>

Thanks,
- Kever



2020-10-28 23:04:11

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] rockchip-pinctrl fixes

On Tue, Oct 13, 2020 at 10:22 AM Heiko Stübner <[email protected]> wrote:

> > Jianqun Xu (3):
> > pinctrl: rockchip: make driver be tristate module
> > pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq
> > pinctrl: rockchip: create irq mapping in gpio_to_irq
>
> looks good to go as fixes.

I record that as Acked-by :)

Yours,
Linus Walleij

2020-10-29 00:57:08

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] rockchip-pinctrl fixes

On Wed, Oct 28, 2020 at 4:55 PM Linus Walleij <[email protected]> wrote:
> On Tue, Oct 13, 2020 at 10:22 AM Heiko Stübner <[email protected]> wrote:
>
> > > Jianqun Xu (3):
> > > pinctrl: rockchip: make driver be tristate module
> > > pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq
> > > pinctrl: rockchip: create irq mapping in gpio_to_irq
> >
> > looks good to go as fixes.
>
> I record that as Acked-by :)

Aha they are already reviewed-by in the patches. OK then,
sorry for the confusion.

Yours,
Linus Walleij

2020-10-29 10:00:42

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] rockchip-pinctrl fixes

On Tue, Oct 13, 2020 at 8:37 AM Jianqun Xu <[email protected]> wrote:

> These patches are required by GKI.
>
> Jianqun Xu (3):
> pinctrl: rockchip: make driver be tristate module
> pinctrl: rockchip: enable gpio pclk for rockchip_gpio_to_irq
> pinctrl: rockchip: create irq mapping in gpio_to_irq

Patches applied for fixes.

Yours,
Linus Walleij