aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorThéo Lebrun <theo.lebrun@bootlin.com>2024-02-28 12:28:23 +0100
committerLinus Walleij <linus.walleij@linaro.org>2024-02-29 10:38:31 +0100
commit6ad679cfaeea9291e9dce3247e34656080fc1d29 (patch)
tree0e47b9c322e0b0642881560e036355bc8e055442 /drivers/gpio
parent3c30cc26df0a3fc50b1f3fe4fd3a9b19a1704d95 (diff)
downloadlinux-6ad679cfaeea9291e9dce3247e34656080fc1d29.tar.gz
gpio: nomadik: grab optional reset control and deassert it at probe
Fetch a reference to the optional shared reset control and deassert it if it exists. Optional because not all platforms that use this driver have a reset attached to the reset block. Shared because some platforms that use the reset (at least Mobileye EyeQ5) share the reset across banks. Do not keep a reference to the reset control as it is not needed afterwards; the driver does not handle suspend, does not use runtime PM, does not register a remove callback and does not support unbinding from sysfs (made explicit with suppress_bind_attrs). The operation is done in nmk_gpio_populate_chip(). This function is called by either gpio-nomadik or pinctrl-nomadik, whoever comes first. This is here for historic reasons and could probably be removed now; it seems gpio-ranges enforces the ordering to be pinctrl-first. It is not the topic of the present patch however. Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Link: https://lore.kernel.org/r/20240228-mbly-gpio-v2-25-3ba757474006@bootlin.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-nomadik.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 6adb3c4417d3e3..c9fd6631e0aa76 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -509,11 +509,13 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
{
struct nmk_gpio_chip *nmk_chip;
struct platform_device *gpio_pdev;
+ struct reset_control *reset;
struct device *gpio_dev;
struct gpio_chip *chip;
struct clk *clk;
void __iomem *base;
u32 id, ngpio;
+ int ret;
gpio_dev = bus_find_device_by_of_node(&platform_bus_type, np);
if (!gpio_dev) {
@@ -572,6 +574,24 @@ struct nmk_gpio_chip *nmk_gpio_populate_chip(struct device_node *np,
clk_prepare(clk);
nmk_chip->clk = clk;
+ reset = devm_reset_control_get_optional_shared(gpio_dev, NULL);
+ if (IS_ERR(reset)) {
+ dev_err(&pdev->dev, "failed getting reset control: %ld\n",
+ PTR_ERR(reset));
+ return ERR_CAST(reset);
+ }
+
+ /*
+ * Reset might be shared and asserts/deasserts calls are unbalanced. We
+ * only support sharing this reset with other gpio-nomadik devices that
+ * use this reset to ensure deassertion at probe.
+ */
+ ret = reset_control_deassert(reset);
+ if (ret) {
+ dev_err(&pdev->dev, "failed reset deassert: %d\n", ret);
+ return ERR_PTR(ret);
+ }
+
#ifdef CONFIG_PINCTRL_NOMADIK
BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips));
nmk_gpio_chips[id] = nmk_chip;
@@ -690,6 +710,7 @@ static struct platform_driver nmk_gpio_driver = {
.driver = {
.name = "nomadik-gpio",
.of_match_table = nmk_gpio_match,
+ .suppress_bind_attrs = true,
},
.probe = nmk_gpio_probe,
};