From: Quentin Schulz quentin.schulz@theobroma-systems.com
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: stable@vger.kernel.org Signed-off-by: Quentin Schulz quentin.schulz@theobroma-systems.com --- 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);
Am Freitag, 23. September 2022, 16:51:41 CEST schrieb Quentin Schulz:
From: Quentin Schulz quentin.schulz@theobroma-systems.com
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: stable@vger.kernel.org Signed-off-by: Quentin Schulz quentin.schulz@theobroma-systems.com
cool, thanks a lot for reimplementing this
Reviewed-by: Heiko Stuebner heiko@sntech.de
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... 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/cd1658c3e07a744075ac4c9cab1657... 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 lkp@intel.com
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
linux-stable-mirror@lists.linaro.org