drm/i915/dsi: Extract common soc_gpio_set_value() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 3 Nov 2023 20:18:26 +0000 (22:18 +0200)
committerJani Nikula <jani.nikula@intel.com>
Wed, 22 Nov 2023 17:12:54 +0000 (19:12 +0200)
Extract a common soc_gpio_set_value() helper that may be used by a few
SoCs.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231103201831.1037416-12-andriy.shevchenko@linux.intel.com
drivers/gpu/drm/i915/display/intel_dsi_vbt.c

index 0f9da0168a7b456be9499ef25594cce374b5e195..9847a92fdfc3de3f56ac81a094b453fdccc2837f 100644 (file)
@@ -243,6 +243,31 @@ static const u8 *mipi_exec_delay(struct intel_dsi *intel_dsi, const u8 *data)
        return data;
 }
 
+static void soc_gpio_set_value(struct intel_connector *connector, const char *con_id,
+                              u8 gpio_index, bool value)
+{
+       struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
+       /* XXX: this table is a quick ugly hack. */
+       static struct gpio_desc *soc_gpio_table[U8_MAX + 1];
+       struct gpio_desc *gpio_desc = soc_gpio_table[gpio_index];
+
+       if (gpio_desc) {
+               gpiod_set_value(gpio_desc, value);
+       } else {
+               gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
+                                                con_id, gpio_index,
+                                                value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
+               if (IS_ERR(gpio_desc)) {
+                       drm_err(&dev_priv->drm,
+                               "GPIO index %u request failed (%pe)\n",
+                               gpio_index, gpio_desc);
+                       return;
+               }
+
+               soc_gpio_table[gpio_index] = gpio_desc;
+       }
+}
+
 static void vlv_gpio_set_value(struct intel_connector *connector,
                               u8 gpio_source, u8 gpio_index, bool value)
 {
@@ -348,26 +373,7 @@ static void chv_gpio_set_value(struct intel_connector *connector,
 static void bxt_gpio_set_value(struct intel_connector *connector,
                               u8 gpio_index, bool value)
 {
-       struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
-       /* XXX: this table is a quick ugly hack. */
-       static struct gpio_desc *bxt_gpio_table[U8_MAX + 1];
-       struct gpio_desc *gpio_desc = bxt_gpio_table[gpio_index];
-
-       if (!gpio_desc) {
-               gpio_desc = devm_gpiod_get_index(dev_priv->drm.dev,
-                                                NULL, gpio_index,
-                                                value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
-               if (IS_ERR_OR_NULL(gpio_desc)) {
-                       drm_err(&dev_priv->drm,
-                               "GPIO index %u request failed (%ld)\n",
-                               gpio_index, PTR_ERR(gpio_desc));
-                       return;
-               }
-
-               bxt_gpio_table[gpio_index] = gpio_desc;
-       }
-
-       gpiod_set_value(gpio_desc, value);
+       soc_gpio_set_value(connector, NULL, gpio_index, value);
 }
 
 enum {