@@ -52,6 +52,12 @@ config OF_VIDEOMODE
help
helper to get videomodes from the devicetree
+config OF_DISPLAY_ENABLE_GPIO
+ bool "Support for enabling a panel via GPIO from the devicetree"
+ depends on OF
+ help
+ helper to turning on a panel via gpio from the devicetree
+
config HDMI
bool
@@ -176,3 +176,4 @@ obj-$(CONFIG_DISPLAY_TIMING) += display_timing.o
obj-$(CONFIG_OF_DISPLAY_TIMING) += of_display_timing.o
obj-$(CONFIG_VIDEOMODE) += videomode.o
obj-$(CONFIG_OF_VIDEOMODE) += of_videomode.o
+obj-$(CONFIG_OF_DISPLAY_ENABLE_GPIO) += of_display_enable_gpio.o
new file mode 100644
@@ -0,0 +1,43 @@
+/*
+ * generic helper for enabling a panel via GPIO from the devicetree
+ *
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <linux/export.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+
+int of_get_display_gpio_enable(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ int panel_enable, ret;
+ enum of_gpio_flags flags;
+
+ panel_enable = of_get_named_gpio_flags(np, "panel-enable-gpios", 0,
+ &flags);
+
+ if (gpio_is_valid(panel_enable)) {
+ unsigned long f = GPIOF_OUT_INIT_HIGH;
+ if (flags == OF_GPIO_ACTIVE_LOW)
+ f = GPIOF_OUT_INIT_LOW;
+ ret = devm_gpio_request_one(&pdev->dev, panel_enable, f,
+ "panel-enable");
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request gpio %d: %d\n",
+ panel_enable, ret);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(of_get_display_gpio_enable);
new file mode 100644
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#ifndef __LINUX_OF_DISPLAY_GPIO_H
+#define __LINUX_OF_DISPLAY_GPIO_H
+
+int of_get_display_gpio_enable(struct platform_device *pdev);
+
+#endif