Skip to contentSkip to conversation

Crystal Cove PMIC based Panel and Backlight Control

RFC Superseded Shobhit Kumar 6 participants 18 messages Jan 2, 2015 – Jan 16, 2015

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Crystal Cove PMIC based Panel and Backlight Control

Hi All
Please find modifed set of patches. Sending as a separate thread as initial patches were a crude implementation to trigger discussion, but these have been tested and also do not need intel_soc_pmic_writeb/readb functionaly, but uses the regmap interface as suggested by Jacob.

These patches implement a drm_panel as a platform driver for the mfd_cell device declared in intel_soc_pmic_core.c.

Still there are opens, where I need closure -
1. Added a new drm_panel, but how to find the panel in lack of OF info. For now added a drm_panel function to find panel by name.
2. Backlight also needs similar pmic based control. Is it okay to add a backlight class driver also as part of this panel driver ?

For now I am doing Backlight Enable/Disable also during panel/enable as this will at least save power. Backlight control will need a backlight class driver.

Regards
Shobhit

Shobhit Kumar (4):
drm: Add support to find drm_panel by name
mfd: Add a new cell device for panel controlled by crystal cove pmic drm/panel: Add new panel driver based on crystal cove pmic drm/i915: Enable DSI panel enable/disable based on PMIC

 drivers/gpu/drm/drm_panel.c                |  18 +++
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/intel_dsi.c           |  16 +++
 drivers/gpu/drm/i915/intel_dsi.h           |   6 +
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   1 +
 drivers/gpu/drm/panel/Kconfig              |   7 ++
 drivers/gpu/drm/panel/Makefile             |   1 +
 drivers/gpu/drm/panel/panel-crystalcove.c  | 191 +++++++++++++++++++++++++++++
 drivers/mfd/intel_soc_pmic_crc.c           |   3 +
 include/drm/drm_panel.h                    |   3 +
 10 files changed, 247 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-crystalcove.c
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC v2 1/4 drm: Add support to find drm_panel by name

For scenarios where OF is not available, we can use panel identification by name.

---
 drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
 include/drm/drm_panel.h     |  3 +++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_panel.c +18 -0
index 2ef988e..773ebd6 100644
@@ -95,6 +95,24 @@ struct drm_panel *of_drm_find_panel(struct device_node *np)
 EXPORT_SYMBOL(of_drm_find_panel);
 #endif
 
+struct drm_panel *name_drm_find_panel(const char *name)
+{
+	struct drm_panel *panel;
+
+	mutex_lock(&panel_lock);
+
+	list_for_each_entry(panel, &panel_list, list) {
+		if (strcmp(panel->name, name) == 0) {
+			mutex_unlock(&panel_lock);
+			return panel;
+		}
+	}
+
+	mutex_unlock(&panel_lock);
+	return NULL;
+}
+EXPORT_SYMBOL(name_drm_find_panel);
+
 MODULE_AUTHOR("Thierry Reding <[email protected]>");
 MODULE_DESCRIPTION("DRM panel infrastructure");
 MODULE_LICENSE("GPL and additional rights");
include/drm/drm_panel.h +3 -0
index 1fbcc96..b120b5d 100644
@@ -74,6 +74,7 @@ struct drm_panel {
 	struct drm_device *drm;
 	struct drm_connector *connector;
 	struct device *dev;
+	char name[NAME_MAX];
 
 	const struct drm_panel_funcs *funcs;
 
@@ -137,4 +138,6 @@ static inline struct drm_panel *of_drm_find_panel(struct device_node *np)
 }
 #endif
 
+struct drm_panel *name_drm_find_panel(const char *name);
+
 #endif
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [RFC v2 1/4] drm: Add support to find drm_panel by name

Quoted 24 lines · Shobhit Kumar

For scenarios where OF is not available, we can use panel identification by name.

---
 drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
 include/drm/drm_panel.h     |  3 +++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_panel.c +7 -0
index 2ef988e..773ebd6 100644
@@ -95,6 +95,24 @@ struct drm_panel *of_drm_find_panel(struct device_node *np)
 EXPORT_SYMBOL(of_drm_find_panel);
 #endif
 
+struct drm_panel *name_drm_find_panel(const char *name)
+{
+	struct drm_panel *panel;
+
+	mutex_lock(&panel_lock);
+
+	list_for_each_entry(panel, &panel_list, list) {

drivers/gpu/drm/drm_panel.c struct drm_panel *of_drm_find_panel(struct device_node *np) · line 114

Quoted 10 lines
drivers/gpu/drm/drm_panel.c +10 -0
+		if (strcmp(panel->name, name) == 0) {
+			mutex_unlock(&panel_lock);
+			return panel;
+		}
+	}
+
+	mutex_unlock(&panel_lock);
+	return NULL;
+}
+EXPORT_SYMBOL(name_drm_find_panel);

This patch needs to be sent to drm-devel.

The name should probably be something like drm_find_panel_by_name.

I have a slightly uneasy feeling about handing out drm_panel pointers (both from here and of_drm_find_panel) without refcounting. If the panel driver gets removed, whoever called the find functions will have a dangling pointer. I supposed this will be discussed on drm-devel.

BR,
Jani.

Quoted 26 lines
drivers/gpu/drm/drm_panel.c +1 -0
+
 MODULE_AUTHOR("Thierry Reding <[email protected]>");
 MODULE_DESCRIPTION("DRM panel infrastructure");
 MODULE_LICENSE("GPL and additional rights");
include/drm/drm_panel.h +3 -0
index 1fbcc96..b120b5d 100644
@@ -74,6 +74,7 @@ struct drm_panel {
 	struct drm_device *drm;
 	struct drm_connector *connector;
 	struct device *dev;
+	char name[NAME_MAX];
 
 	const struct drm_panel_funcs *funcs;
 
@@ -137,4 +138,6 @@ static inline struct drm_panel *of_drm_find_panel(struct device_node *np)
 }
 #endif
 
+struct drm_panel *name_drm_find_panel(const char *name);
+
 #endif
Signature · 1 line
1.9.1
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [RFC v2 1/4] drm: Add support to find drm_panel by name

Quoted 38 lines · Jani Nikula
Quoted 24 lines · Shobhit Kumar

For scenarios where OF is not available, we can use panel identification by name.

---
  drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
  include/drm/drm_panel.h     |  3 +++
  2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_panel.c +7 -0
index 2ef988e..773ebd6 100644
@@ -95,6 +95,24 @@ struct drm_panel *of_drm_find_panel(struct device_node *np)
  EXPORT_SYMBOL(of_drm_find_panel);
  #endif
 
+struct drm_panel *name_drm_find_panel(const char *name)
+{
+	struct drm_panel *panel;
+
+	mutex_lock(&panel_lock);
+
+	list_for_each_entry(panel, &panel_list, list) {

drivers/gpu/drm/drm_panel.c struct drm_panel *of_drm_find_panel(struct device_node *np) · line 114

Quoted 10 lines
drivers/gpu/drm/drm_panel.c +10 -0
+		if (strcmp(panel->name, name) == 0) {
+			mutex_unlock(&panel_lock);
+			return panel;
+		}
+	}
+
+	mutex_unlock(&panel_lock);
+	return NULL;
+}
+EXPORT_SYMBOL(name_drm_find_panel);

This patch needs to be sent to drm-devel.

Quoted 6 lines

The name should probably be something like drm_find_panel_by_name.

I have a slightly uneasy feeling about handing out drm_panel pointers (both from here and of_drm_find_panel) without refcounting. If the panel driver gets removed, whoever called the find functions will have a dangling pointer. I supposed this will be discussed on drm-devel.

Right its a valid point. I Will post the updated patch there and see what all comes up.

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [Intel-gfx] [RFC v2 1/4] drm: Add support to find drm_panel by name

In reply to Jani Nikula
Quoted 4 lines · Jani Nikula

I have a slightly uneasy feeling about handing out drm_panel pointers (both from here and of_drm_find_panel) without refcounting. If the panel driver gets removed, whoever called the find functions will have a dangling pointer. I supposed this will be discussed on drm-devel.

There's been some discussion already about exactly this problem (but with drm bridges) with Thierry and some other people. Cc'ed them all hopefully. Especially when the panel/bridge is a separate driver there's imo indeed an issue.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [Intel-gfx] [RFC v2 1/4] drm: Add support to find drm_panel by name

Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Jani Nikula

I have a slightly uneasy feeling about handing out drm_panel pointers (both from here and of_drm_find_panel) without refcounting. If the panel driver gets removed, whoever called the find functions will have a dangling pointer. I supposed this will be discussed on drm-devel.

refcounting does not seems to me a good solution, drm_panel is exposed by device driver and device driver can be unbound unconditionally at any time. This problem affects many frameworks not only drm_panel.

I work on resource tracking framework which tries to solve the problem in a generic way[1].

[1]: https://lkml.org/lkml/2014/12/10/342

Regards
Andrzej

Quoted 5 lines

There's been some discussion already about exactly this problem (but with drm bridges) with Thierry and some other people. Cc'ed them all hopefully. Especially when the panel/bridge is a separate driver there's imo indeed an issue.
-Daniel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [Intel-gfx] [RFC v2 1/4] drm: Add support to find drm_panel by name

In reply to Daniel Vetter
Quoted 10 lines · Daniel Vetter
Quoted 4 lines · Jani Nikula

I have a slightly uneasy feeling about handing out drm_panel pointers (both from here and of_drm_find_panel) without refcounting. If the panel driver gets removed, whoever called the find functions will have a dangling pointer. I supposed this will be discussed on drm-devel.

There's been some discussion already about exactly this problem (but with drm bridges) with Thierry and some other people. Cc'ed them all hopefully. Especially when the panel/bridge is a separate driver there's imo indeed an issue.

I posted patches some time ago to create a generic registry to do the actual ref-counting[0]. It didn't seem to be very well received by Greg for the core, so perhaps we could test-drive it in DRM first for panels and bridges and once it's matured a bit it could still be promoted to the driver core, or maybe lib/.

The difficult part about it is that while reference counting gives you the benefit of keeping a valid pointer around, you may still want to have a method of getting notified of the panel going away. I've thought a bit about that and I think we could probably integrate that into the registry, since that will notice anyway.

Thierry

[0]: http://www.spinics.net/linux/lists/kernel/msg1859333.html

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

RFC v2 2/4 mfd: Add a new cell device for panel controlled by crystal cove pmic

In reply to Shobhit Kumar

On BYT-T configuration, panel enable/disable signals are routed through PMIC. Add a cell device for the same.

---
 drivers/mfd/intel_soc_pmic_crc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mfd/intel_soc_pmic_crc.c +3 -0
index c85e2ec..c8ccc24 100644
@@ -109,6 +109,9 @@ static struct mfd_cell crystal_cove_dev[] = {
 	{
 		.name = "crystal_cove_pmic",
 	},
+	{
+		.name = "crystal_cove_panel",
+	},
 };
 
 static struct regmap_config crystal_cove_regmap_config = {
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

RFC v2 3/4 drm/panel: Add new panel driver based on crystal cove pmic

In reply to Shobhit Kumar

This driver provides support for the "crystal_cove_panel" cell device. On BYT-T pmic has to be used to enable/disable panel.

---
 drivers/gpu/drm/panel/Kconfig             |   7 ++
 drivers/gpu/drm/panel/Makefile            |   1 +
 drivers/gpu/drm/panel/panel-crystalcove.c | 191 ++++++++++++++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-crystalcove.c
drivers/gpu/drm/panel/Kconfig +7 -0
index 024e98e..d813bd1 100644
@@ -40,4 +40,11 @@ config DRM_PANEL_SHARP_LQ101R1SX01
 	  To compile this driver as a module, choose M here: the module
 	  will be called panel-sharp-lq101r1sx01.
 
+config DRM_PANEL_CRYSTALCOVE
+	tristate "Crystalcove PMIC controlled panel"
+	depends on INTEL_SOC_PMIC
+	help
+	  Say Y here if you want to enable support for DSI panel and backlight
+	  control using crystalcove pmic. This is used for BYT CR configurations
+
 endmenu
drivers/gpu/drm/panel/Makefile +1 -0
index 4b2a043..c05824e 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
 obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
 obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
+obj-$(CONFIG_DRM_PANEL_CRYSTALCOVE) += panel-crystalcove.o
drivers/gpu/drm/panel/panel-crystalcove.c new file +191 -0

191 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 3/4
#9 lore raw

Re: [RFC v2 3/4] drm/panel: Add new panel driver based on crystal cove pmic

Quoted 2 lines · Shobhit Kumar

This driver provides support for the "crystal_cove_panel" cell device. On BYT-T pmic has to be used to enable/disable panel.

This needs to be sent to dri-devel.

With the comments below addressed, and with the disclaimer that I have no idea about the pmic registers or required sleeps, this is

Quoted 14 lines
---
 drivers/gpu/drm/panel/Kconfig             |   7 ++
 drivers/gpu/drm/panel/Makefile            |   1 +
 drivers/gpu/drm/panel/panel-crystalcove.c | 191 ++++++++++++++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-crystalcove.c
drivers/gpu/drm/panel/Kconfig +0 -0
index 024e98e..d813bd1 100644

drivers/gpu/drm/panel/Kconfig config DRM_PANEL_SHARP_LQ101R1SX01 · line 45

Quoted 6 lines
drivers/gpu/drm/panel/Kconfig +3 -0
@@ -40,4 +40,11 @@ config DRM_PANEL_SHARP_LQ101R1SX01
 	  To compile this driver as a module, choose M here: the module
 	  will be called panel-sharp-lq101r1sx01.
 
+config DRM_PANEL_CRYSTALCOVE
+	tristate "Crystalcove PMIC controlled panel"
+	depends on INTEL_SOC_PMIC

INTEL_SOC_PMIC is still a bool (and requires I2C=y), and IMO should be fixed to support tristate. Or are there fundamental reasons this can't be done?

Quoted 20 lines
drivers/gpu/drm/panel/Kconfig +4 -0
+	help
+	  Say Y here if you want to enable support for DSI panel and backlight
+	  control using crystalcove pmic. This is used for BYT CR configurations
+
 endmenu
drivers/gpu/drm/panel/Makefile +1 -0
index 4b2a043..c05824e 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
 obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
 obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
+obj-$(CONFIG_DRM_PANEL_CRYSTALCOVE) += panel-crystalcove.o
drivers/gpu/drm/panel/panel-crystalcove.c new file +0 -0
new file mode 100644
index 0000000..22f7ff5

drivers/gpu/drm/panel/panel-crystalcove.c line 2

Quoted 2 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +2 -0
@@ -0,0 +1,191 @@
+/*
+ * Copyright © 2006-2014 Intel Corporation

2006?!

Quoted 29 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +29 -0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *	Shobhit Kumar <[email protected]>
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+#include <linux/mfd/intel_soc_pmic.h>
+#include <linux/platform_device.h>

drivers/gpu/drm/panel/panel-crystalcove.c line 41

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+#include <linux/regmap.h>
+
+#define PMIC_PANEL_EN		0x52
+#define PMIC_PWM_EN		0x51
+#define PMIC_BKL_EN		0x4B
+#define PMIC_PWM_LEVEL		0x4E
+
+struct crystalcove_panel {
+	struct drm_panel base;
+	char name[NAME_MAX];

Unused.

drivers/gpu/drm/panel/panel-crystalcove.c line 45

Quoted 4 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +4 -0
+	bool prepared;
+	bool enabled;
+
+	struct mutex lock;

Unused.

Quoted 15 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +15 -0
+
+	/* crystal cove pmic regmap */
+	struct regmap *regmap;
+};
+
+static inline struct crystalcove_panel *to_crystalcove_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct crystalcove_panel, base);
+}
+
+static int crystalcove_panel_disable(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (!p->enabled)

drivers/gpu/drm/panel/panel-crystalcove.c line 70

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+		return 0;
+
+	DRM_DEBUG_KMS("\n");
+
+	/* invoke the pmic driver */
+	regmap_write(p->regmap, PMIC_PANEL_EN, 0x00);
+
+	/* Disable backlight as well */
+	regmap_write(p->regmap, PMIC_PWM_LEVEL, 0);
+	msleep(20);

Seems like a long delay.

Quoted 23 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +23 -0
+	regmap_write(p->regmap, PMIC_PWM_EN, 0x00);
+	regmap_write(p->regmap, PMIC_BKL_EN, 0x7F);
+
+	p->enabled = false;
+
+	return 0;
+}
+
+static int crystalcove_panel_unprepare(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (!p->prepared)
+		return 0;
+
+	/* Nothing needed */
+	p->prepared = false;
+
+	return 0;
+}
+
+static int crystalcove_panel_prepare(struct drm_panel *panel)
+{

drivers/gpu/drm/panel/panel-crystalcove.c line 103

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (p->prepared)
+		return 0;
+
+	/* Nothing needed */
+	p->prepared = true;
+
+	return 0;
+}

If you don't need prepare/unprepare, you can just leave them out altogether. It's easy to add them if you need them later.

Quoted 41 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +41 -0
+
+static int crystalcove_panel_enable(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (p->enabled)
+		return 0;
+
+	DRM_DEBUG_KMS("\n");
+
+	/* invoke the pmic driver */
+	regmap_write(p->regmap, PMIC_PANEL_EN, 0x01);
+
+	/* Enable BKL as well */
+	regmap_write(p->regmap, PMIC_BKL_EN, 0xFF);
+	regmap_write(p->regmap, PMIC_PWM_EN, 0x01);
+	msleep(20);
+	regmap_write(p->regmap, PMIC_PWM_LEVEL, 255);
+
+	p->enabled = true;
+
+	return 0;
+}
+
+static const struct drm_panel_funcs crystalcove_panel_funcs = {
+	.disable = crystalcove_panel_disable,
+	.unprepare = crystalcove_panel_unprepare,
+	.prepare = crystalcove_panel_prepare,
+	.enable = crystalcove_panel_enable,
+};
+
+static int crystalcove_panel_probe(struct platform_device *pdev)
+{
+	struct crystalcove_panel *panel;
+	int retval;
+	struct device *dev = pdev->dev.parent;
+	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+	panel = devm_kzalloc(&pdev->dev, sizeof(*panel), GFP_KERNEL);
+	if (!panel)
+		return -ENOMEM;

drivers/gpu/drm/panel/panel-crystalcove.c line 154

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+
+	DRM_DEBUG_KMS("\n");
+
+	platform_set_drvdata(pdev, panel);
+
+	strcpy(panel->base.name, "crystal_cove_panel");
+	panel->regmap = pmic->regmap;
+
+	regmap_read(panel->regmap, PMIC_PANEL_EN, &retval);
+	panel->enabled = panel->prepared = retval ? true : false;

For bools you can just assign retval, or if you want to emphasis it's a bool you can use !!retval.

Quoted 27 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +27 -0
+
+	drm_panel_init(&panel->base);
+	panel->base.dev = dev;
+	panel->base.funcs = &crystalcove_panel_funcs;
+
+	drm_panel_add(&panel->base);
+
+	return 0;
+}
+
+static int crystalcove_panel_remove(struct platform_device *pdev)
+{
+	struct crystalcove_panel *panel = platform_get_drvdata(pdev);
+
+	DRM_DEBUG_KMS("\n");
+
+	drm_panel_detach(&panel->base);
+	drm_panel_remove(&panel->base);
+
+	crystalcove_panel_disable(&panel->base);
+
+	return 0;
+}
+
+static struct platform_driver crystalcove_panel_driver = {
+	.probe = crystalcove_panel_probe,
+	.remove = crystalcove_panel_remove,

drivers/gpu/drm/panel/panel-crystalcove.c line 191

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+	.driver = {
+		.name = "crystal_cove_panel",
+	},
+};
+
+module_platform_driver(crystalcove_panel_driver);
+
+MODULE_AUTHOR("Shobhit Kumar <[email protected]");
+MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
+MODULE_LICENSE("GPL v2");

This conflicts with the copyright header of the file.

Quoted 3 lines
Signature · 1 line
1.9.1
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

Re: [RFC v2 3/4] drm/panel: Add new panel driver based on crystal cove pmic

Quoted 5 lines · Jani Nikula
Quoted 2 lines · Shobhit Kumar

This driver provides support for the "crystal_cove_panel" cell device. On BYT-T pmic has to be used to enable/disable panel.

This needs to be sent to dri-devel.

Will do for the updated patch after addressing all your comments.

Quoted 23 lines

With the comments below addressed, and with the disclaimer that I have no idea about the pmic registers or required sleeps, this is

Quoted 17 lines
---
  drivers/gpu/drm/panel/Kconfig             |   7 ++
  drivers/gpu/drm/panel/Makefile            |   1 +
  drivers/gpu/drm/panel/panel-crystalcove.c | 191 ++++++++++++++++++++++++++++++
  3 files changed, 199 insertions(+)

create mode 100644 drivers/gpu/drm/panel/panel-crystalcove.c

drivers/gpu/drm/panel/Kconfig +0 -0
index 024e98e..d813bd1 100644
@@ -40,4 +40,11 @@ config DRM_PANEL_SHARP_LQ101R1SX01
  	  To compile this driver as a module, choose M here: the module
  	  will be called panel-sharp-lq101r1sx01.
 
Quoted 7 lines

drivers/gpu/drm/panel/Kconfig config DRM_PANEL_SHARP_LQ101R1SX01 · line 45

Quoted 3 lines
drivers/gpu/drm/panel/Kconfig +3 -0
+config DRM_PANEL_CRYSTALCOVE
+	tristate "Crystalcove PMIC controlled panel"
+	depends on INTEL_SOC_PMIC

INTEL_SOC_PMIC is still a bool (and requires I2C=y), and IMO should be fixed to support tristate. Or are there fundamental reasons this can't be done?

Jacob, can you answer this one for the PMIC driver. This has come up multiple times earlier also in some discussions.

Quoted 226 lines
Quoted 21 lines
drivers/gpu/drm/panel/Kconfig +4 -0
+	help
+	  Say Y here if you want to enable support for DSI panel and backlight
+	  control using crystalcove pmic. This is used for BYT CR configurations
+
  endmenu
drivers/gpu/drm/panel/Makefile +1 -0
index 4b2a043..c05824e 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
  obj-$(CONFIG_DRM_PANEL_LD9040) += panel-ld9040.o
  obj-$(CONFIG_DRM_PANEL_S6E8AA0) += panel-s6e8aa0.o
  obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
+obj-$(CONFIG_DRM_PANEL_CRYSTALCOVE) += panel-crystalcove.o
drivers/gpu/drm/panel/panel-crystalcove.c new file +0 -0
new file mode 100644
index 0000000..22f7ff5

drivers/gpu/drm/panel/panel-crystalcove.c line 2

Quoted 2 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +2 -0
@@ -0,0 +1,191 @@
+/*
+ * Copyright © 2006-2014 Intel Corporation

2006?!

Quoted 29 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +29 -0
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *	Shobhit Kumar <[email protected]>
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_panel.h>
+#include <linux/mfd/intel_soc_pmic.h>
+#include <linux/platform_device.h>

drivers/gpu/drm/panel/panel-crystalcove.c line 41

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+#include <linux/regmap.h>
+
+#define PMIC_PANEL_EN		0x52
+#define PMIC_PWM_EN		0x51
+#define PMIC_BKL_EN		0x4B
+#define PMIC_PWM_LEVEL		0x4E
+
+struct crystalcove_panel {
+	struct drm_panel base;
+	char name[NAME_MAX];

Unused.

drivers/gpu/drm/panel/panel-crystalcove.c line 45

Quoted 4 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +4 -0
+	bool prepared;
+	bool enabled;
+
+	struct mutex lock;

Unused.

Quoted 15 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +15 -0
+
+	/* crystal cove pmic regmap */
+	struct regmap *regmap;
+};
+
+static inline struct crystalcove_panel *to_crystalcove_panel(struct drm_panel *panel)
+{
+	return container_of(panel, struct crystalcove_panel, base);
+}
+
+static int crystalcove_panel_disable(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (!p->enabled)

drivers/gpu/drm/panel/panel-crystalcove.c line 70

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+		return 0;
+
+	DRM_DEBUG_KMS("\n");
+
+	/* invoke the pmic driver */
+	regmap_write(p->regmap, PMIC_PANEL_EN, 0x00);
+
+	/* Disable backlight as well */
+	regmap_write(p->regmap, PMIC_PWM_LEVEL, 0);
+	msleep(20);

Seems like a long delay.

Quoted 23 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +23 -0
+	regmap_write(p->regmap, PMIC_PWM_EN, 0x00);
+	regmap_write(p->regmap, PMIC_BKL_EN, 0x7F);
+
+	p->enabled = false;
+
+	return 0;
+}
+
+static int crystalcove_panel_unprepare(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (!p->prepared)
+		return 0;
+
+	/* Nothing needed */
+	p->prepared = false;
+
+	return 0;
+}
+
+static int crystalcove_panel_prepare(struct drm_panel *panel)
+{

drivers/gpu/drm/panel/panel-crystalcove.c line 103

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (p->prepared)
+		return 0;
+
+	/* Nothing needed */
+	p->prepared = true;
+
+	return 0;
+}

If you don't need prepare/unprepare, you can just leave them out altogether. It's easy to add them if you need them later.

Quoted 41 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +41 -0
+
+static int crystalcove_panel_enable(struct drm_panel *panel)
+{
+	struct crystalcove_panel *p = to_crystalcove_panel(panel);
+
+	if (p->enabled)
+		return 0;
+
+	DRM_DEBUG_KMS("\n");
+
+	/* invoke the pmic driver */
+	regmap_write(p->regmap, PMIC_PANEL_EN, 0x01);
+
+	/* Enable BKL as well */
+	regmap_write(p->regmap, PMIC_BKL_EN, 0xFF);
+	regmap_write(p->regmap, PMIC_PWM_EN, 0x01);
+	msleep(20);
+	regmap_write(p->regmap, PMIC_PWM_LEVEL, 255);
+
+	p->enabled = true;
+
+	return 0;
+}
+
+static const struct drm_panel_funcs crystalcove_panel_funcs = {
+	.disable = crystalcove_panel_disable,
+	.unprepare = crystalcove_panel_unprepare,
+	.prepare = crystalcove_panel_prepare,
+	.enable = crystalcove_panel_enable,
+};
+
+static int crystalcove_panel_probe(struct platform_device *pdev)
+{
+	struct crystalcove_panel *panel;
+	int retval;
+	struct device *dev = pdev->dev.parent;
+	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+	panel = devm_kzalloc(&pdev->dev, sizeof(*panel), GFP_KERNEL);
+	if (!panel)
+		return -ENOMEM;

drivers/gpu/drm/panel/panel-crystalcove.c line 154

Quoted 10 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +10 -0
+
+	DRM_DEBUG_KMS("\n");
+
+	platform_set_drvdata(pdev, panel);
+
+	strcpy(panel->base.name, "crystal_cove_panel");
+	panel->regmap = pmic->regmap;
+
+	regmap_read(panel->regmap, PMIC_PANEL_EN, &retval);
+	panel->enabled = panel->prepared = retval ? true : false;

For bools you can just assign retval, or if you want to emphasis it's a bool you can use !!retval.

Quoted 31 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +31 -0
+
+	drm_panel_init(&panel->base);
+	panel->base.dev = dev;
+	panel->base.funcs = &crystalcove_panel_funcs;
+
+	drm_panel_add(&panel->base);
+
+	return 0;
+}
+
+static int crystalcove_panel_remove(struct platform_device *pdev)
+{
+	struct crystalcove_panel *panel = platform_get_drvdata(pdev);
+
+	DRM_DEBUG_KMS("\n");
+
+	drm_panel_detach(&panel->base);
+	drm_panel_remove(&panel->base);
+
+	crystalcove_panel_disable(&panel->base);
+
+	return 0;
+}
+
+static struct platform_driver crystalcove_panel_driver = {
+	.probe = crystalcove_panel_probe,
+	.remove = crystalcove_panel_remove,
+	.driver = {
+		.name = "crystal_cove_panel",
+	},
+};
Quoted 14 lines

drivers/gpu/drm/panel/panel-crystalcove.c line 191

Quoted 6 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +6 -0
+
+module_platform_driver(crystalcove_panel_driver);
+
+MODULE_AUTHOR("Shobhit Kumar <[email protected]");
+MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
+MODULE_LICENSE("GPL v2");

This conflicts with the copyright header of the file.

Quoted 3 lines

--
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

Re: [RFC v2 3/4] drm/panel: Add new panel driver based on crystal cove pmic

Quoted 8 lines · Shobhit
Quoted 5 lines · Jani Nikula
Quoted 2 lines · Shobhit Kumar

This driver provides support for the "crystal_cove_panel" cell device. On BYT-T pmic has to be used to enable/disable panel.

This needs to be sent to dri-devel.

Will do for the updated patch after addressing all your comments.

Also do we really need to make it as part of drm. How about keeping this internal to i915 as most likely no one else other than i915 will use it ?

Quoted 11 lines
Quoted 10 lines

With the comments below addressed, and with the disclaimer that I have no idea about the pmic registers or required sleeps, this is

Quoted 3 lines

---

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/panel/panel-crystalcove.c line 191

Quoted 5 lines
drivers/gpu/drm/panel/panel-crystalcove.c new file +5 -0
+module_platform_driver(crystalcove_panel_driver);
+
+MODULE_AUTHOR("Shobhit Kumar <[email protected]");
+MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
+MODULE_LICENSE("GPL v2");

This conflicts with the copyright header of the file.

I have seen drivers in kernel header both with Copyright and GPL V2. Example - "drivers/gpu/drm/panel/panel-s6e8aa0.c"

I can change to MODULE_LICENSE("GPL and additional rights");

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

RFC v2 4/4 drm/i915: Enable DSI panel enable/disable based on PMIC

In reply to Shobhit Kumar

This allows for proper PPS during enable/disable of BYT-T platforms where these signals are routed through PMIC. Needs DRM_PANEL to be selected by default as well

---
 drivers/gpu/drm/i915/Kconfig               |  1 +
 drivers/gpu/drm/i915/intel_dsi.c           | 16 ++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.h           |  6 ++++++
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |  1 +
 4 files changed, 24 insertions(+)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab3..3210dbb 100644
@@ -18,6 +18,7 @@ config DRM_I915
 	select INPUT if ACPI
 	select ACPI_VIDEO if ACPI
 	select ACPI_BUTTON if ACPI
+	select DRM_PANEL
 	help
 	  Choose this option if you have a system that has "Intel Graphics
 	  Media Accelerator" or "HD Graphics" integrated graphics,
drivers/gpu/drm/i915/intel_dsi.c +16 -0
index 42b6d6f..431e7cb 100644
@@ -26,6 +26,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_panel.h>
 #include <drm/i915_drm.h>
 #include <linux/slab.h>
 #include "i915_drv.h"
@@ -230,6 +231,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
 	DRM_DEBUG_KMS("\n");
 
+	drm_panel_enable(intel_dsi->panel);
+
 	/* Disable DPOunit clock gating, can stall pipe
 	 * and we need DPLL REFA always enabled */
 	tmp = I915_READ(DPLL(pipe));
@@ -392,6 +395,8 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
 	msleep(intel_dsi->panel_off_delay);
 	msleep(intel_dsi->panel_pwr_cycle_delay);
+
+	drm_panel_disable(intel_dsi->panel);
 }
 
 static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
@@ -896,6 +901,17 @@ void intel_dsi_init(struct drm_device *dev)
 	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
+	/* Initialize the PMIC based drm_panel if available on the platform */
+	if (intel_dsi->pps_blc == PPS_BLC_PMIC) {
+		intel_dsi->panel = name_drm_find_panel("crystal_cove_panel");
+		if (!intel_dsi->panel) {
+			DRM_ERROR("PMIC Panel control will not work !!\n");
+			return;
+		}
+
+		drm_panel_attach(intel_dsi->panel, connector);
+	}
+
 	return;
 
 err:
drivers/gpu/drm/i915/intel_dsi.h +6 -0
index 8fe2064..4a9242d 100644
@@ -33,6 +33,9 @@
 #define DSI_DUAL_LINK_FRONT_BACK	1
 #define DSI_DUAL_LINK_PIXEL_ALT		2
 
+#define PPS_BLC_PMIC	0
+#define PPS_BLC_SOC	1
+
 struct intel_dsi_device {
 	unsigned int panel_id;
 	const char *name;
@@ -83,6 +86,8 @@ struct intel_dsi {
 
 	struct intel_connector *attached_connector;
 
+	struct drm_panel *panel;
+
 	/* bit mask of ports being driven */
 	u16 ports;
 
@@ -116,6 +121,7 @@ struct intel_dsi {
 	u32 dphy_reg;
 	u32 video_frmt_cfg_bits;
 	u16 lp_byte_clk;
+	u8 pps_blc;
 
 	/* timeouts in byte clocks */
 	u16 lp_rx_timeout;
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
index 5493aef..0612d33 100644
@@ -297,6 +297,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
 	intel_dsi->pixel_format = mipi_config->videomode_color_format << 7;
 	intel_dsi->dual_link = mipi_config->dual_link;
 	intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
+	intel_dsi->pps_blc = mipi_config->pwm_blc;
 
 	if (intel_dsi->dual_link)
 		intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [RFC v2 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC

Quoted 46 lines · Shobhit Kumar

This allows for proper PPS during enable/disable of BYT-T platforms where these signals are routed through PMIC. Needs DRM_PANEL to be selected by default as well

---
 drivers/gpu/drm/i915/Kconfig               |  1 +
 drivers/gpu/drm/i915/intel_dsi.c           | 16 ++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.h           |  6 ++++++
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |  1 +
 4 files changed, 24 insertions(+)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab3..3210dbb 100644
@@ -18,6 +18,7 @@ config DRM_I915
 	select INPUT if ACPI
 	select ACPI_VIDEO if ACPI
 	select ACPI_BUTTON if ACPI
+	select DRM_PANEL
 	help
 	  Choose this option if you have a system that has "Intel Graphics
 	  Media Accelerator" or "HD Graphics" integrated graphics,
drivers/gpu/drm/i915/intel_dsi.c +3 -0
index 42b6d6f..431e7cb 100644
@@ -26,6 +26,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_panel.h>
 #include <drm/i915_drm.h>
 #include <linux/slab.h>
 #include "i915_drv.h"
@@ -230,6 +231,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
 	DRM_DEBUG_KMS("\n");
 
+	drm_panel_enable(intel_dsi->panel);
+
 	/* Disable DPOunit clock gating, can stall pipe
 	 * and we need DPLL REFA always enabled */
 	tmp = I915_READ(DPLL(pipe));

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_post_disable(struct intel_encoder *encoder) · line 400

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -0
@@ -392,6 +395,8 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
 	msleep(intel_dsi->panel_off_delay);
 	msleep(intel_dsi->panel_pwr_cycle_delay);
+
+	drm_panel_disable(intel_dsi->panel);
 }

As I explained in a private mail, I intend to convert all of our panel driver callbacks to the drm_panel model. So we'd have two sets of drm_panel_* hooks sprinkled here, one for handling the panel power and the other for the generic vbt panel driver. An alternative would be to have the vbt panel driver handle this internally, but I don't really know which one is better. In any case this has a fairly small footprint so it's easy to change one way or another.

Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi.c +1 -0
 static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
@@ -896,6 +901,17 @@ void intel_dsi_init(struct drm_device *dev)
 	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
+	/* Initialize the PMIC based drm_panel if available on the platform */

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 914

Quoted 10 lines
drivers/gpu/drm/i915/intel_dsi.c +10 -0
+	if (intel_dsi->pps_blc == PPS_BLC_PMIC) {
+		intel_dsi->panel = name_drm_find_panel("crystal_cove_panel");
+		if (!intel_dsi->panel) {
+			DRM_ERROR("PMIC Panel control will not work !!\n");
+			return;
+		}
+
+		drm_panel_attach(intel_dsi->panel, connector);
+	}
+

I think there's an init order problem here. If the panel driver hasn't been registered yet this will fail. I don't know what the answer to that should be.

Quoted 39 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -0
 	return;
 
 err:
drivers/gpu/drm/i915/intel_dsi.h +6 -0
index 8fe2064..4a9242d 100644
@@ -33,6 +33,9 @@
 #define DSI_DUAL_LINK_FRONT_BACK	1
 #define DSI_DUAL_LINK_PIXEL_ALT		2
 
+#define PPS_BLC_PMIC	0
+#define PPS_BLC_SOC	1
+
 struct intel_dsi_device {
 	unsigned int panel_id;
 	const char *name;
@@ -83,6 +86,8 @@ struct intel_dsi {
 
 	struct intel_connector *attached_connector;
 
+	struct drm_panel *panel;
+
 	/* bit mask of ports being driven */
 	u16 ports;
 
@@ -116,6 +121,7 @@ struct intel_dsi {
 	u32 dphy_reg;
 	u32 video_frmt_cfg_bits;
 	u16 lp_byte_clk;
+	u8 pps_blc;
 
 	/* timeouts in byte clocks */
 	u16 lp_rx_timeout;
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
index 5493aef..0612d33 100644

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static bool generic_init(struct intel_dsi_device *dsi) · line 300

Quoted 4 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
@@ -297,6 +297,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
 	intel_dsi->pixel_format = mipi_config->videomode_color_format << 7;
 	intel_dsi->dual_link = mipi_config->dual_link;
 	intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
+	intel_dsi->pps_blc = mipi_config->pwm_blc;

If the drm_panel for crystal cove is going to be like in this patch, I think this part belongs in intel_dsi.c.

Quoted 6 lines
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +0 -0
 	if (intel_dsi->dual_link)
 		intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
Signature · 1 line
1.9.1
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [RFC v2 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC

Quoted 48 lines · Jani Nikula
Quoted 47 lines · Shobhit Kumar

This allows for proper PPS during enable/disable of BYT-T platforms where these signals are routed through PMIC. Needs DRM_PANEL to be selected by default as well

---
  drivers/gpu/drm/i915/Kconfig               |  1 +
  drivers/gpu/drm/i915/intel_dsi.c           | 16 ++++++++++++++++
  drivers/gpu/drm/i915/intel_dsi.h           |  6 ++++++
  drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |  1 +
  4 files changed, 24 insertions(+)
drivers/gpu/drm/i915/Kconfig +1 -0
index 4e39ab3..3210dbb 100644
@@ -18,6 +18,7 @@ config DRM_I915
  	select INPUT if ACPI
  	select ACPI_VIDEO if ACPI
  	select ACPI_BUTTON if ACPI
+	select DRM_PANEL
  	help
  	  Choose this option if you have a system that has "Intel Graphics
  	  Media Accelerator" or "HD Graphics" integrated graphics,
drivers/gpu/drm/i915/intel_dsi.c +3 -0
index 42b6d6f..431e7cb 100644
@@ -26,6 +26,7 @@
  #include <drm/drmP.h>
  #include <drm/drm_crtc.h>
  #include <drm/drm_edid.h>
+#include <drm/drm_panel.h>
  #include <drm/i915_drm.h>
  #include <linux/slab.h>
  #include "i915_drv.h"
@@ -230,6 +231,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
  	DRM_DEBUG_KMS("\n");
 
+	drm_panel_enable(intel_dsi->panel);
+
  	/* Disable DPOunit clock gating, can stall pipe
  	 * and we need DPLL REFA always enabled */
  	tmp = I915_READ(DPLL(pipe));
@@ -392,6 +395,8 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_dsi.c static void intel_dsi_post_disable(struct intel_encoder *encoder) · line 400

Quoted 5 lines
drivers/gpu/drm/i915/intel_dsi.c +2 -0
  	msleep(intel_dsi->panel_off_delay);
  	msleep(intel_dsi->panel_pwr_cycle_delay);
+
+	drm_panel_disable(intel_dsi->panel);
  }

As I explained in a private mail, I intend to convert all of our panel driver callbacks to the drm_panel model. So we'd have two sets of drm_panel_* hooks sprinkled here, one for handling the panel power and the other for the generic vbt panel driver. An alternative would be to have the vbt panel driver handle this internally, but I don't really know which one is better. In any case this has a fairly small footprint so it's easy to change one way or another.

PMIC based control is something unique for current platforms (BYT/CHT) and all future platforms will go with SoC based control. Given that, I think we should not put this is VBT panel driver and keep separate.

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -0
  static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
@@ -896,6 +901,17 @@ void intel_dsi_init(struct drm_device *dev)
  	fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
Quoted 15 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 914

Quoted 11 lines
drivers/gpu/drm/i915/intel_dsi.c +11 -0
+	/* Initialize the PMIC based drm_panel if available on the platform */
+	if (intel_dsi->pps_blc == PPS_BLC_PMIC) {
+		intel_dsi->panel = name_drm_find_panel("crystal_cove_panel");
+		if (!intel_dsi->panel) {
+			DRM_ERROR("PMIC Panel control will not work !!\n");
+			return;
+		}
+
+		drm_panel_attach(intel_dsi->panel, connector);
+	}
+

I think there's an init order problem here. If the panel driver hasn't been registered yet this will fail. I don't know what the answer to that should be.

Agree and for my testing I made both PMIC and This panel driver as in-built and i915 as module. I was hoping for some answer !!

Quoted 33 lines
Quoted 33 lines
drivers/gpu/drm/i915/intel_dsi.c +0 -0
  	return;
 
  err:
drivers/gpu/drm/i915/intel_dsi.h +6 -0
index 8fe2064..4a9242d 100644
@@ -33,6 +33,9 @@
  #define DSI_DUAL_LINK_FRONT_BACK	1
  #define DSI_DUAL_LINK_PIXEL_ALT		2
 
+#define PPS_BLC_PMIC	0
+#define PPS_BLC_SOC	1
+
  struct intel_dsi_device {
  	unsigned int panel_id;
  	const char *name;
@@ -83,6 +86,8 @@ struct intel_dsi {
 
  	struct intel_connector *attached_connector;
 
+	struct drm_panel *panel;
+
  	/* bit mask of ports being driven */
  	u16 ports;
 
@@ -116,6 +121,7 @@ struct intel_dsi {
  	u32 dphy_reg;
  	u32 video_frmt_cfg_bits;
  	u16 lp_byte_clk;
+	u8 pps_blc;
 
Quoted 14 lines

drivers/gpu/drm/i915/intel_dsi_panel_vbt.c static bool generic_init(struct intel_dsi_device *dsi) · line 300

Quoted 11 lines
drivers/gpu/drm/i915/intel_dsi.h +0 -0
  	/* timeouts in byte clocks */
  	u16 lp_rx_timeout;
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c +1 -0
index 5493aef..0612d33 100644
@@ -297,6 +297,7 @@ static bool generic_init(struct intel_dsi_device *dsi)
  	intel_dsi->pixel_format = mipi_config->videomode_color_format << 7;
  	intel_dsi->dual_link = mipi_config->dual_link;
  	intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
+	intel_dsi->pps_blc = mipi_config->pwm_blc;

If the drm_panel for crystal cove is going to be like in this patch, I think this part belongs in intel_dsi.c.

If you are suggesting check mipi_config->pwm_blc directly in intel_dsi, that can be done. Was just abstracting all VBT fields in generic VBT based panel driver

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw

Re: [RFC v2 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC

Quoted 23 lines · Shobhit
Quoted 7 lines
Quoted 7 lines

static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,

drivers/gpu/drm/i915/intel_dsi.c +0 -0
@@ -896,6 +901,17 @@ void intel_dsi_init(struct drm_device *dev)
  fixed_mode->type |= DRM_MODE_TYPE_PREFERRED;
  intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 
Quoted 15 lines

drivers/gpu/drm/i915/intel_dsi.c void intel_dsi_init(struct drm_device *dev) · line 914

Quoted 11 lines
drivers/gpu/drm/i915/intel_dsi.c +11 -0
+ /* Initialize the PMIC based drm_panel if available on the platform */
+ if (intel_dsi->pps_blc == PPS_BLC_PMIC) {
+ intel_dsi->panel = name_drm_find_panel("crystal_cove_panel");
+ if (!intel_dsi->panel) {
+ DRM_ERROR("PMIC Panel control will not work !!\n");
+ return;
+ }
+
+ drm_panel_attach(intel_dsi->panel, connector);
+ }
+

I think there's an init order problem here. If the panel driver hasn't been registered yet this will fail. I don't know what the answer to that should be.

Quoted 2 lines

Agree and for my testing I made both PMIC and This panel driver as in-built and i915 as module. I was hoping for some answer !!

The answer is to use the component framework and delayed probing. Afaik there's unfortunately not yet any ready-made integration with drm panel/bridge yet since this is all very much in flux. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw
In reply to Shobhit Kumar
Quoted 6 lines · Shobhit Kumar

Hi All
Please find modifed set of patches. Sending as a separate thread as initial patches were a crude implementation to trigger discussion, but these have been tested and also do not need intel_soc_pmic_writeb/readb functionaly, but uses the regmap interface as suggested by Jacob.

Quoted 9 lines

These patches implement a drm_panel as a platform driver for the mfd_cell device declared in intel_soc_pmic_core.c.

Still there are opens, where I need closure -
1. Added a new drm_panel, but how to find the panel in lack of OF info. For now added a drm_panel function to find panel by name.
2. Backlight also needs similar pmic based control. Is it okay to add a backlight class driver also as part of this panel driver ?

Are there any suggestions/comments for the approach/opens in this patch set ?

Regards
Shobhit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw
In reply to Shobhit Kumar
Quoted 6 lines · Shobhit Kumar

Hi All
Please find modifed set of patches. Sending as a separate thread as initial patches were a crude implementation to trigger discussion, but these have been tested and also do not need intel_soc_pmic_writeb/readb functionaly, but uses the regmap interface as suggested by Jacob.

Quoted 6 lines

These patches implement a drm_panel as a platform driver for the mfd_cell device declared in intel_soc_pmic_core.c.

Still there are opens, where I need closure -
1. Added a new drm_panel, but how to find the panel in lack of OF info. For now added a drm_panel function to find panel by name.

I don't have an answer.

Quoted 2 lines

2. Backlight also needs similar pmic based control. Is it okay to add a backlight class driver also as part of this panel driver ?

Is it fathomable you have designs with pmic panel enable/disable but soc pwm backlight control? If yes, I think you need to separate the two. If they always go together, I think you can keep them together.

BR,
Jani.

Quoted 29 lines

For now I am doing Backlight Enable/Disable also during panel/enable as this will at least save power. Backlight control will need a backlight class driver.

Regards
Shobhit

Shobhit Kumar (4):
drm: Add support to find drm_panel by name
mfd: Add a new cell device for panel controlled by crystal cove pmic drm/panel: Add new panel driver based on crystal cove pmic drm/i915: Enable DSI panel enable/disable based on PMIC

 drivers/gpu/drm/drm_panel.c                |  18 +++
 drivers/gpu/drm/i915/Kconfig               |   1 +
 drivers/gpu/drm/i915/intel_dsi.c           |  16 +++
 drivers/gpu/drm/i915/intel_dsi.h           |   6 +
 drivers/gpu/drm/i915/intel_dsi_panel_vbt.c |   1 +
 drivers/gpu/drm/panel/Kconfig              |   7 ++
 drivers/gpu/drm/panel/Makefile             |   1 +
 drivers/gpu/drm/panel/panel-crystalcove.c  | 191 +++++++++++++++++++++++++++++
 drivers/mfd/intel_soc_pmic_crc.c           |   3 +
 include/drm/drm_panel.h                    |   3 +
 10 files changed, 247 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-crystalcove.c
Signature · 1 line
1.9.1
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx