2022-09-23 15:16:33

by Quentin Schulz

[permalink] [raw]
Subject: [PATCH 2/2] gpio: rockchip: request GPIO mux to pinctrl when setting direction

From: Quentin Schulz <[email protected]>

Before the split of gpio and pinctrl sections in their own driver,
rockchip_set_mux was called in pinmux_ops.gpio_set_direction for
configuring a pin in its GPIO function.

This is essential for cases where pinctrl is "bypassed" by gpio
consumers otherwise the GPIO function is not configured for the pin and
it does not work. Such was the case for the sysfs/libgpiod userspace
GPIO handling.

Let's call pinctrl_gpio_direction_input/output when setting the
direction of a GPIO so that the pinctrl core requests from the rockchip
pinctrl driver to put the pin in its GPIO function.

Fixes: 9ce9a02039de ("pinctrl/rockchip: drop the gpio related codes")
Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio")
Cc: [email protected]
Signed-off-by: Quentin Schulz <[email protected]>
---
drivers/gpio/gpio-rockchip.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index bb50335239ac8..b83913e1ee49e 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -156,6 +156,12 @@ static int rockchip_gpio_set_direction(struct gpio_chip *chip,
unsigned long flags;
u32 data = input ? 0 : 1;

+
+ if (input)
+ pinctrl_gpio_direction_input(bank->pin_base + offset);
+ else
+ pinctrl_gpio_direction_output(bank->pin_base + offset);
+
raw_spin_lock_irqsave(&bank->slock, flags);
rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
raw_spin_unlock_irqrestore(&bank->slock, flags);
--
2.37.3


2022-09-23 18:59:42

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: rockchip: request GPIO mux to pinctrl when setting direction

Am Freitag, 23. September 2022, 16:51:41 CEST schrieb Quentin Schulz:
> From: Quentin Schulz <[email protected]>
>
> Before the split of gpio and pinctrl sections in their own driver,
> rockchip_set_mux was called in pinmux_ops.gpio_set_direction for
> configuring a pin in its GPIO function.
>
> This is essential for cases where pinctrl is "bypassed" by gpio
> consumers otherwise the GPIO function is not configured for the pin and
> it does not work. Such was the case for the sysfs/libgpiod userspace
> GPIO handling.
>
> Let's call pinctrl_gpio_direction_input/output when setting the
> direction of a GPIO so that the pinctrl core requests from the rockchip
> pinctrl driver to put the pin in its GPIO function.
>
> Fixes: 9ce9a02039de ("pinctrl/rockchip: drop the gpio related codes")
> Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio")
> Cc: [email protected]
> Signed-off-by: Quentin Schulz <[email protected]>

cool, thanks a lot for reimplementing this

Reviewed-by: Heiko Stuebner <[email protected]>


2022-09-30 05:16:01

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: rockchip: request GPIO mux to pinctrl when setting direction

Hi Quentin,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on linusw-pinctrl/devel brgl/gpio/for-next linus/master v6.0-rc7 next-20220927]
[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/Quentin-Schulz/fix-gpio-sysfs-libgpiod-for-rockchip/20220923-225404
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: m68k-randconfig-r014-20220925
compiler: m68k-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/cd1658c3e07a744075ac4c9cab165743daf266ff
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Quentin-Schulz/fix-gpio-sysfs-libgpiod-for-rockchip/20220923-225404
git checkout cd1658c3e07a744075ac4c9cab165743daf266ff
# 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=m68k SHELL=/bin/bash drivers/gpio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/gpio/gpio-rockchip.c: In function 'rockchip_gpio_set_direction':
>> drivers/gpio/gpio-rockchip.c:161:17: error: implicit declaration of function 'pinctrl_gpio_direction_input' [-Werror=implicit-function-declaration]
161 | pinctrl_gpio_direction_input(bank->pin_base + offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpio/gpio-rockchip.c:163:17: error: implicit declaration of function 'pinctrl_gpio_direction_output' [-Werror=implicit-function-declaration]
163 | pinctrl_gpio_direction_output(bank->pin_base + offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/pinctrl_gpio_direction_input +161 drivers/gpio/gpio-rockchip.c

151
152 static int rockchip_gpio_set_direction(struct gpio_chip *chip,
153 unsigned int offset, bool input)
154 {
155 struct rockchip_pin_bank *bank = gpiochip_get_data(chip);
156 unsigned long flags;
157 u32 data = input ? 0 : 1;
158
159
160 if (input)
> 161 pinctrl_gpio_direction_input(bank->pin_base + offset);
162 else
> 163 pinctrl_gpio_direction_output(bank->pin_base + offset);
164
165 raw_spin_lock_irqsave(&bank->slock, flags);
166 rockchip_gpio_writel_bit(bank, offset, data, bank->gpio_regs->port_ddr);
167 raw_spin_unlock_irqrestore(&bank->slock, flags);
168
169 return 0;
170 }
171

--
0-DAY CI Kernel Test Service
https://01.org/lkp


Attachments:
(No filename) (3.10 kB)
config (109.51 kB)
Download all attachments