Commit Graph

14 Commits

Author SHA1 Message Date
Jianqun Xu cc165ba48a gpio: rockchip: add support for rk3588
Add V2.1 rockchip gpio controller type, which is part of the
RK3588 SoC.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
2022-07-19 09:57:13 +02:00
Caleb Connolly 7ff1135781 gpio/rockchip: handle deferring input-enable pinconfs
Add support for deferred PIN_CONFIG_INPUT_ENABLE handling.

Signed-off-by: Caleb Connolly <kc@postmarketos.org>
Acked-by: Bartosz Golaszewski <brgl@bgdev.pl>
Link: https://lore.kernel.org/r/20220328005005.72492-4-kc@postmarketos.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2022-04-22 22:56:46 +02:00
Caleb Connolly 8ce5ef6454 pinctrl/rockchip: support deferring other gpio params
Add support for deferring other params like PIN_CONFIG_INPUT_ENABLE.
This will be used to add support for PIN_CONFIG_INPUT_ENABLE to the
driver.

Fixes: e7165b1dff ("pinctrl/rockchip: add a queue for deferred pin output settings on probe")
Fixes: 59dd178e1d ("gpio/rockchip: fetch deferred output settings on probe")
Signed-off-by: Caleb Connolly <kc@postmarketos.org>
Link: https://lore.kernel.org/r/20220328005005.72492-2-kc@postmarketos.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2022-04-22 22:55:41 +02:00
Samuel Holland 7920af5c82 gpio: rockchip: Reset int_bothedge when changing trigger
With v2 hardware, an IRQ can be configured to trigger on both edges via
a bit in the int_bothedge register. Currently, the driver sets this bit
when changing the trigger type to IRQ_TYPE_EDGE_BOTH, but fails to reset
this bit if the trigger type is later changed to something else. This
causes spurious IRQs, and when using gpio-keys with wakeup-event-action
set to EV_ACT_(DE)ASSERTED, those IRQs translate into spurious wakeups.

Fixes: 3bcbd1a85b ("gpio/rockchip: support next version gpio controller")
Reported-by: Guillaume Savaton <guillaume@baierouge.fr>
Tested-by: Guillaume Savaton <guillaume@baierouge.fr>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2022-02-16 15:52:22 +01:00
Andy Shevchenko 448cf90513 gpio: Get rid of duplicate of_node assignment in the drivers
GPIO library does copy the of_node from the parent device of
the GPIO chip, there is no need to repeat this in the individual
drivers. Remove these assignment all at once.

For the details one may look into the of_gpio_dev_init() implementation.

While at it, remove duplicate parent device assignment where it is the case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-By: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-12-17 17:39:35 +01:00
John Keeping adc8b4bf2a gpio: rockchip: lock GPIOs used as interrupts
Use the standard gpiochip request/release resource functions so that any
GPIOs used as interrupts are properly locked.  This allows libgpiod to
correctly show these GPIOs as in-use.

Signed-off-by: John Keeping <john@metanate.com>
Tested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-12-03 15:59:10 +01:00
Linus Torvalds a4e6f95a89 Pin control fixes for v5.15:
- Fix wakeup interrupts in the AMD driver affecting AMD laptops.
 
 - Fix parent irqspec translation in the Qualcomm SPMI GPIO driver.
 
 - Fix deferred probe handling in the Rockchip driver, this is a
   stopgap solution while we look for something more elegant.
 
 - Add PM suspend callbacks to the Qualcomm SC7280 driver.
 
 - Some minor doc fix (should have come in earlier, sorry)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEElDRnuGcz/wPCXQWMQRCzN7AZXXMFAmFTkc4ACgkQQRCzN7AZ
 XXNfYA//fE2S4iV3d8Vj5rO03jtUSDdPRKg0TGFmL44pz+HPkIz+lRMbeEqjjEzi
 G1Rm4GNyifiS01jh3DSa3aS0JhdvOyVD7J2Hih2WEVYvMxi+ZUfdcuGgfwD1xFmO
 Haweg9vEYBlAtW1NcJPHH4YxN+qBwgrW41cnMOGxR4IB/sNGNoDdAdxJaXfwno08
 Ku+5PgIQif6YVb45WFgzDD6TF+khXClw2oqlNu7iO9TJ4zVP5I9of10bmhpPzfhW
 SoT2ySoxvBZqV71y6vtmc9X58nxyMRCFSWMVhCeQRcFnYRywpBpbLgP99y3xBxOn
 tYrseBXmguCe/tCqlld3BmHFwHkVC6vzURB9sEYL1Ea+xhQ3bnI4swMrt2UB2KAE
 UIWYw1nq6p8hMEGdsr042+9S8W6HNJGrfFs7YcFFmEuL7wJ4DtStNXkNWvXbXTs0
 +w0XoUbA1IjOzfycJguU1J9pZSZopd0xOL9aTmJGYC1zNUUvPOYGM9NknbHr50mH
 mhTJYyRUCi2QDWUV7SforTdnRwkaZiW1j+wggOw1rO5pEt3orBgZQ/cPeMBYV+FR
 lHiKtAHBoXMq0a93zukGyD4iH0CPnefiHWhvrfq+Md/Q91fJvAw6cTRIOYSz6XW3
 XGGvRN+xj0kk+vo+o5dyDgnZewKK8nVUBwGyiG2gzA2FNYZKVEQ=
 =Gel/
 -----END PGP SIGNATURE-----

Merge tag 'pinctrl-v5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Pull pin control fixes from Linus Walleij:
 "Some few pin control fixes for the v5.15 kernel cycle. The most
  critical is the AMD fixes.

   - Fix wakeup interrupts in the AMD driver affecting AMD laptops.

   - Fix parent irqspec translation in the Qualcomm SPMI GPIO driver.

   - Fix deferred probe handling in the Rockchip driver, this is a
     stopgap solution while we look for something more elegant.

   - Add PM suspend callbacks to the Qualcomm SC7280 driver.

   - Some minor doc fix (should have come in earlier, sorry)"

* tag 'pinctrl-v5.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
  pinctrl: qcom: sc7280: Add PM suspend callbacks
  gpio/rockchip: fetch deferred output settings on probe
  pinctrl/rockchip: add a queue for deferred pin output settings on probe
  pinctrl: qcom: spmi-gpio: correct parent irqspec translation
  pinctrl: amd: Handle wake-up interrupt
  pinctrl: amd: Add irq field data
  pinctrl: core: Remove duplicated word from devm_pinctrl_unregister()
2021-09-28 16:10:42 -07:00
Heiko Stuebner b22a4705e2 gpio/rockchip: fix get_direction value handling
The function uses the newly introduced rockchip_gpio_readl_bit()
which directly returns the actual value of the requeste bit.
So using the existing bit-wise check for the bit inside the value
will always return 0.

Fix this by dropping the bit manipulation on the result.

Fixes: 3bcbd1a85b ("gpio/rockchip: support next version gpio controller")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-09-22 11:31:52 +02:00
Heiko Stuebner 0f562b7de9 gpio/rockchip: extended debounce support is only available on v2
The gpio driver runs into issues on v1 gpio blocks, as the db_clk
and the whole extended debounce support is only ever defined on v2.
So checking for the IS_ERR on the db_clk is not enough, as it will
be NULL on v1.

Fix this by adding the needed condition for v2 first before checking
the existence of the db_clk.

This caused my rk3288-veyron-pinky to enter a reboot loop when it
tried to enable the power-key as adc-key device.

Fixes: 3bcbd1a85b ("gpio/rockchip: support next version gpio controller")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2021-09-22 11:31:43 +02:00
Heiko Stuebner 59dd178e1d gpio/rockchip: fetch deferred output settings on probe
Fetch the output settings the pinctrl driver may have created
for pinctrl hogs and set the relevant pins as requested.

Fixes: 9ce9a02039 ("pinctrl/rockchip: drop the gpio related codes")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20210913224926.1260726-5-heiko@sntech.de
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-09-18 01:36:35 +02:00
Jianqun Xu 93103f6eb0 gpio/rockchip: drop irq_gc_lock/irq_gc_unlock for irq set type
There has spin lock for irq set type already, so drop irq_gc_lock and
irq_gc_unlock.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Link: https://lore.kernel.org/r/20210816012135.1119234-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-08-17 01:01:50 +02:00
Jianqun Xu 3bcbd1a85b gpio/rockchip: support next version gpio controller
The next version gpio controller on SoCs like rk3568 have more write
mask bits for registers.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Link: https://lore.kernel.org/r/20210816012123.1119179-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-08-17 01:01:50 +02:00
Jianqun Xu ff96a8c21c gpio/rockchip: use struct rockchip_gpio_regs for gpio controller
Store register offsets in the struct rockchip_gpio_regs, this patch
prepare for the driver update for new gpio controller.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Link: https://lore.kernel.org/r/20210816012111.1119125-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-08-17 01:01:49 +02:00
Jianqun Xu 936ee2675e gpio/rockchip: add driver for rockchip gpio
This patch add support for rockchip gpio controller, which is supported
in pinctrl driver in the past.

With this patch, the pinctrl-rockchip driver will drop gpio related
codes and populate platform driver to gpio-rockchip.

Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Link: https://lore.kernel.org/r/20210816012053.1119069-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-08-17 01:01:49 +02:00