Commit Graph

8 Commits

Author SHA1 Message Date
Shaoqin Huang c23a7a7884 gpio: regmap: Add missing header(s)
Bugzilla: https://bugzilla.redhat.com/2183344

commit e79098ac29a41526a50a83ea77306c634a74e904
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Tue Feb 7 16:29:48 2023 +0200

    gpio: regmap: Add missing header(s)

    Do not imply that some of the generic headers may be always included.
    Instead, include explicitly what we are direct user of.

    While at it, split out the GPIO group of headers.

    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
2023-06-19 23:50:51 -04:00
Shaoqin Huang e01dadbc48 gpio: regmap: use new regmap_might_sleep()
Bugzilla: https://bugzilla.redhat.com/2183344

commit 297a44f664a8ac2139c25c51ba0064cc12a6f1e5
Author: Michael Walle <michael@walle.cc>
Date:   Thu Jan 5 16:06:03 2023 +0100

    gpio: regmap: use new regmap_might_sleep()

    Now that the regmap can be queried whether it might sleep, we can get
    rid of the conservative setting "can_sleep = true". New drivers which
    want to use gpio-regmap and can access the registers memory-mapped won't
    have the restriction that their consumers have to use the
    gpiod_*cansleep() variants anymore.

    Signed-off-by: Michael Walle <michael@walle.cc>
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
2023-06-19 23:50:49 -04:00
Shaoqin Huang 167844b521 gpio: regmap: Always set gpio_chip get_direction
Bugzilla: https://bugzilla.redhat.com/2183344

commit 8978277c229b9502aba4654b1d6ec59c819e82ea
Author: William Breathitt Gray <william.gray@linaro.org>
Date:   Tue Dec 27 09:09:39 2022 -0500

    gpio: regmap: Always set gpio_chip get_direction

    If you only have reg_dat_base set, then it is input-only; if you only
    have reg_set_base set, then it is output-only. Thus, we can always set
    gpio_chip get_direction to gpio_regmap_get_direction and return
    GPIO_LINE_DIRECTION_IN/GPIO_LINE_DIRECTION_OUT given the respective
    register base addresses configuration.

    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Michael Walle <michael@walle.cc>
    Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
2023-06-19 23:50:48 -04:00
Al Stone b05d33778e gpio: regmap: Switch to use fwnode instead of of_node
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071835
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
 support in the kernel for NXP i.MX8 platforms.  This set updates GPIO
 support.  It has been tested via simple boot tests and by using the
 kernel GPIO tools to verify pins are being identified and can be used.

commit f21ecad451c9b33d56165da61b0f5a9a535bfd3c
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Thu Dec 23 14:16:06 2021 +0200

    gpio: regmap: Switch to use fwnode instead of of_node

    GPIO library now accepts fwnode as a firmware node, so
    switch the driver to use it.

    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Michael Walle <michael@walle.cc>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    (cherry picked from commit f21ecad451c9b33d56165da61b0f5a9a535bfd3c)

Signed-off-by: Al Stone <ahs3@redhat.com>
2022-08-24 13:31:01 -06:00
Michael Walle 9b3c47f124 gpio: regmap: move drvdata to config data
Drop gpio_regmap_set_drvdata() and instead add it to the configuration
data passed to gpio_regmap_register().

gpio_regmap_set_drvdata() can't really be used in a race free way. This
is because the gpio_regmap object which is needed by _set_drvdata() is
returned by gpio_regmap_register(). On the other hand, the callbacks
which use the drvdata might already be called right after the
gpiochip_add() call in gpio_regmap_register(). Therefore, we have to
provide the drvdata early before we call gpiochip_add().

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2021-06-07 15:39:19 +02:00
Matti Vaittinen 40e568f9c8 gpio: gpio-regmap: Use devm_add_action_or_reset()
Slightly simplify the devm_gpio_regmap_register() by using the
devm_add_action_or_reset().

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2021-06-04 20:53:51 +02:00
Álvaro Fernández Rojas d46bf9ec45 gpio: regmap: set gpio_chip of_node
This is needed for properly registering GPIO regmap as a child of a regmap
pin controller.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20210324081923.20379-3-noltari@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2021-03-29 12:20:07 +02:00
Michael Walle ebe363197e gpio: add a reusable generic gpio_chip using regmap
There are quite a lot simple GPIO controller which are using regmap to
access the hardware. This driver tries to be a base to unify existing
code into one place. This won't cover everything but it should be a good
starting point.

It does not implement its own irq_chip because there is already a
generic one for regmap based devices. Instead, the irq_chip will be
instantiated in the parent driver and its irq domain will be associate
to this driver.

For now it consists of the usual registers, like set (and an optional
clear) data register, an input register and direction registers.
Out-of-the-box, it supports consecutive register mappings and mappings
where the registers have gaps between them with a linear mapping between
GPIO offset and bit position. For weirder mappings the user can register
its own .xlate().

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200528145845.31436-3-michael@walle.cc
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-06-03 10:48:37 +02:00