Merge tag 'gpio-omap-descriptors-v6.5' of git://git.kernel.org/pub/scm/linux/kernel...
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 31 May 2023 15:01:34 +0000 (17:01 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 31 May 2023 15:01:34 +0000 (17:01 +0200)
This removes all usage of global GPIO numbers from
arch/arm/mach-omap[12].

The patches have been reviewed and tested by everyone
who showed interest which was one person that tested
on OSK1 and Nokia 770, and we smoked out the bugs and
also addressed all review comments.

Any remaining problems can certainly be fixed in-tree.

1  2 
drivers/gpio/gpio-twl4030.c

index 3708ed2314e879855cf6788cc513d841c540b6aa,446599ac234a9d4b38858b8a92b1d3ceb516031a..bcd692229c7c73c51cffab353d78b63e1fc2151d
@@@ -492,9 -490,30 +490,18 @@@ static struct twl4030_gpio_platform_dat
        return omap_twl_info;
  }
  
 -/* Cannot use as gpio_twl4030_probe() calls us */
 -static int gpio_twl4030_remove(struct platform_device *pdev)
 -{
 -      struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev);
 -
 -      gpiochip_remove(&priv->gpio_chip);
 -
 -      /* REVISIT no support yet for deregistering all the IRQs */
 -      WARN_ON(!is_module());
 -      return 0;
 -}
 -
+ /* Called from the registered devm action */
+ static void gpio_twl4030_power_off_action(void *data)
+ {
+       struct gpio_desc *d = data;
+       gpiod_unexport(d);
+       gpiochip_free_own_desc(d);
+ }
  static int gpio_twl4030_probe(struct platform_device *pdev)
  {
-       struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
+       struct twl4030_gpio_platform_data *pdata;
        struct device_node *node = pdev->dev.of_node;
        struct gpio_twl4030_priv *priv;
        int ret, irq_base;
@@@ -569,19 -586,38 +574,35 @@@ no_irqs
        if (ret < 0) {
                dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret);
                priv->gpio_chip.ngpio = 0;
 -              gpio_twl4030_remove(pdev);
 -              goto out;
 +              return ret;
        }
  
-       if (pdata->setup) {
-               int status;
+       /*
+        * Special quirk for the OMAP3 to hog and export a WLAN power
+        * GPIO.
+        */
+       if (IS_ENABLED(CONFIG_ARCH_OMAP3) &&
+           of_machine_is_compatible("compulab,omap3-sbc-t3730")) {
+               struct gpio_desc *d;
+               d = gpiochip_request_own_desc(&priv->gpio_chip,
+                                                2, "wlan pwr",
+                                                GPIO_ACTIVE_HIGH,
+                                                GPIOD_OUT_HIGH);
+               if (IS_ERR(d))
+                       return dev_err_probe(&pdev->dev, PTR_ERR(d),
+                                            "unable to hog wlan pwr GPIO\n");
+               gpiod_export(d, 0);
+               ret = devm_add_action_or_reset(&pdev->dev, gpio_twl4030_power_off_action, d);
+               if (ret)
+                       return dev_err_probe(&pdev->dev, ret,
+                                            "failed to install power off handler\n");
  
-               status = pdata->setup(&pdev->dev, priv->gpio_chip.base,
-                                     TWL4030_GPIO_MAX);
-               if (status)
-                       dev_dbg(&pdev->dev, "setup --> %d\n", status);
        }
  
 -      platform_set_drvdata(pdev, priv);
 -out:
 -      return ret;
 +      return 0;
  }
  
  static const struct of_device_id twl_gpio_match[] = {