summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-01-21 19:44:59 -0700
committerSimon Glass <sjg@chromium.org>2016-01-21 20:42:36 -0700
commitcd9c2070ea0712bd69e18236e8b52232fd27b02e (patch)
tree7724a3951261c66844780c96b0d3acb0e7adc765 /drivers
parentf563dc1d195aa7ca0ba1ce614031e9727fab1325 (diff)
downloadblackbird-obmc-uboot-cd9c2070ea0712bd69e18236e8b52232fd27b02e.tar.gz
blackbird-obmc-uboot-cd9c2070ea0712bd69e18236e8b52232fd27b02e.zip
video: panel: Add a simple panel driver
Most panels are very simple - they just have a power supply and a backlight. Add a driver which supports this and implements the enable_backlight() method. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/Makefile2
-rw-r--r--drivers/video/simple_panel.c99
2 files changed, 100 insertions, 1 deletions
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index d29280cee4..6658e96142 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -8,7 +8,7 @@
ifdef CONFIG_DM
obj-$(CONFIG_DISPLAY_PORT) += dp-uclass.o
obj-$(CONFIG_DM_VIDEO) += backlight-uclass.o
-obj-$(CONFIG_DM_VIDEO) += panel-uclass.o
+obj-$(CONFIG_DM_VIDEO) += panel-uclass.o simple_panel.o
obj-$(CONFIG_DM_VIDEO) += video-uclass.o vidconsole-uclass.o console_normal.o
obj-$(CONFIG_DM_VIDEO) += video_bmp.o
ifdef CONFIG_DM_VIDEO
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
new file mode 100644
index 0000000000..b161517674
--- /dev/null
+++ b/drivers/video/simple_panel.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2016 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <backlight.h>
+#include <dm.h>
+#include <panel.h>
+#include <asm/gpio.h>
+#include <power/regulator.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct simple_panel_priv {
+ struct udevice *reg;
+ struct udevice *backlight;
+ struct gpio_desc enable;
+};
+
+static int simple_panel_enable_backlight(struct udevice *dev)
+{
+ struct simple_panel_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ dm_gpio_set_value(&priv->enable, 1);
+ ret = backlight_enable(priv->backlight);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int simple_panel_ofdata_to_platdata(struct udevice *dev)
+{
+ struct simple_panel_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "power-supply", &priv->reg);
+ if (ret) {
+ debug("%s: Warning: cnnot get power supply: ret=%d\n",
+ __func__, ret);
+ if (ret != -ENOENT)
+ return ret;
+ }
+ ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+ "backlight", &priv->backlight);
+ if (ret) {
+ debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
+ return ret;
+ }
+ ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
+ GPIOD_IS_OUT);
+ if (ret) {
+ debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
+ __func__, ret);
+ if (ret != -ENOENT)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int simple_panel_probe(struct udevice *dev)
+{
+ struct simple_panel_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ if (priv->reg) {
+ debug("%s: Enable regulator '%s'\n", __func__, priv->reg->name);
+ ret = regulator_set_enable(priv->reg, true);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct panel_ops simple_panel_ops = {
+ .enable_backlight = simple_panel_enable_backlight,
+};
+
+static const struct udevice_id simple_panel_ids[] = {
+ { .compatible = "simple-panel" },
+ { }
+};
+
+U_BOOT_DRIVER(simple_panel) = {
+ .name = "simple_panel",
+ .id = UCLASS_PANEL,
+ .of_match = simple_panel_ids,
+ .ops = &simple_panel_ops,
+ .ofdata_to_platdata = simple_panel_ofdata_to_platdata,
+ .probe = simple_panel_probe,
+ .priv_auto_alloc_size = sizeof(struct simple_panel_priv),
+};
OpenPOWER on IntegriCloud