All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control
@ 2015-01-21 11:18 Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-21 11:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter, dri-devel, Shobhit Kumar

Hi All
Please find modifed set of patches using regmap interface to accedd the PMIC 
registers. These patches implement a drm_panel as a platform driver for the
mfd_cell device declared in intel_soc_pmic_core.c. 

DRM is extended to provide a find panel by name in absence of OF. 

Backlight control is pending. For now I am doing Backlight Enable/Disable also
during panel/enable as this will at least save power.

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/i915: 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                   |  13 ++
 drivers/gpu/drm/i915/Makefile                  |   3 +
 drivers/gpu/drm/i915/intel-panel-crystalcove.c | 160 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.c               |  16 +++
 drivers/gpu/drm/i915/intel_dsi.h               |   6 +
 drivers/mfd/intel_soc_pmic_crc.c               |   3 +
 include/drm/drm_panel.h                        |   3 +
 8 files changed, 222 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/intel-panel-crystalcove.c

-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC v3 1/4] drm: Add support to find drm_panel by name
  2015-01-21 11:18 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
@ 2015-01-21 11:18 ` Shobhit Kumar
  2015-02-03 13:00   ` Thierry Reding
  2015-02-04 11:14   ` [PATCH] " Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic Shobhit Kumar
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-21 11:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter, dri-devel, Shobhit Kumar

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

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
 include/drm/drm_panel.h     |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index 2ef988e..e1cb8cf 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -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 *drm_find_panel_by_name(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(drm_find_panel_by_name);
+
 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
 MODULE_DESCRIPTION("DRM panel infrastructure");
 MODULE_LICENSE("GPL and additional rights");
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 1fbcc96..1ef9ff3 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -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 *drm_find_panel_by_name(const char *name);
+
 #endif
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic
  2015-01-21 11:18 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
@ 2015-01-21 11:18 ` Shobhit Kumar
  2015-02-03 13:05   ` Thierry Reding
  2015-01-21 11:18 ` [RFC v3 3/4] drm/i915: Add new panel driver based on " Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC Shobhit Kumar
  3 siblings, 1 reply; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-21 11:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter, dri-devel, Shobhit Kumar

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

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/mfd/intel_soc_pmic_crc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c
index c85e2ec..c8ccc24 100644
--- a/drivers/mfd/intel_soc_pmic_crc.c
+++ b/drivers/mfd/intel_soc_pmic_crc.c
@@ -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 = {
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic
  2015-01-21 11:18 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
  2015-01-21 11:18 ` [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic Shobhit Kumar
@ 2015-01-21 11:18 ` Shobhit Kumar
  2015-02-03 13:16   ` Thierry Reding
  2015-01-21 11:18 ` [RFC v3 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC Shobhit Kumar
  3 siblings, 1 reply; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-21 11:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter, dri-devel, 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.

v2: Addressed Jani's comments
    - Moved inside i915
    - Correct licensing
    - Remove unused stuff
    - Do not initialize prepare/unprepare as they are not needed as of now
    - Correct backlight off delay

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpu/drm/i915/Kconfig                   |  12 ++
 drivers/gpu/drm/i915/Makefile                  |   3 +
 drivers/gpu/drm/i915/intel-panel-crystalcove.c | 159 +++++++++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/intel-panel-crystalcove.c

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 4e39ab3..0510ef0 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -69,3 +69,15 @@ config DRM_I915_PRELIMINARY_HW_SUPPORT
 	  option changes the default for that module option.
 
 	  If in doubt, say "N".
+
+config DRM_I915_PANEL_CRYSTALCOVE_PMIC
+	bool "Enable drm panel for crystal cove pmic based control"
+	depends on DRM_I915
+	depends on DRM_PANEL
+	default n
+	help
+	  Choose this option if you have BYT-T based device with DSI panel. On
+	  BYT-T there a crystal cove PMIC which controls the PANEL EN/DISABLE
+	  signals.
+
+	  If in doubt, say "N".
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 1849ffa..cc2f10d 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -88,4 +88,7 @@ i915-y += i915_dma.o \
 
 obj-$(CONFIG_DRM_I915)  += i915.o
 
+# I915 DRM Panels
+obj-$(CONFIG_DRM_I915_PANEL_CRYSTALCOVE_PMIC)	+= intel-panel-crystalcove.o
+
 CFLAGS_i915_trace_points.o := -I$(src)
diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
new file mode 100644
index 0000000..a6aefa3
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * 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 <shobhit.kumar@intel.com>
+ */
+
+#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>
+#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;
+	bool enabled;
+
+	/* 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)
+		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);
+	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_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,
+	.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;
+
+	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 = retval;
+
+	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",
+	},
+};
+
+module_platform_driver(crystalcove_panel_driver);
+
+MODULE_AUTHOR("Shobhit Kumar <shobhit.kumar@linux.intel.com");
+MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
+MODULE_LICENSE("GPL and additional rights");
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [RFC v3 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC
  2015-01-21 11:18 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
                   ` (2 preceding siblings ...)
  2015-01-21 11:18 ` [RFC v3 3/4] drm/i915: Add new panel driver based on " Shobhit Kumar
@ 2015-01-21 11:18 ` Shobhit Kumar
  3 siblings, 0 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-21 11:18 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter, dri-devel, 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

v2: Adapt to panel find function name change in drm_panel

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpu/drm/i915/Kconfig                   |  1 +
 drivers/gpu/drm/i915/intel-panel-crystalcove.c |  1 +
 drivers/gpu/drm/i915/intel_dsi.c               | 16 ++++++++++++++++
 drivers/gpu/drm/i915/intel_dsi.h               |  6 ++++++
 4 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 0510ef0..bacbc06 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -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,
diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
index a6aefa3..0f129b2 100644
--- a/drivers/gpu/drm/i915/intel-panel-crystalcove.c
+++ b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
@@ -154,6 +154,7 @@ static struct platform_driver crystalcove_panel_driver = {
 
 module_platform_driver(crystalcove_panel_driver);
 
+MODULE_ALIAS();
 MODULE_AUTHOR("Shobhit Kumar <shobhit.kumar@linux.intel.com");
 MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
 MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 42b6d6f..6857d19 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -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 (dev_priv->vbt.dsi.config->pwm_blc == PPS_BLC_PMIC) {
+		intel_dsi->panel = drm_find_panel_by_name("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:
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index 8fe2064..4a9242d 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -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;
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [RFC v3 1/4] drm: Add support to find drm_panel by name
  2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
@ 2015-02-03 13:00   ` Thierry Reding
  2015-02-04 11:14   ` [PATCH] " Shobhit Kumar
  1 sibling, 0 replies; 14+ messages in thread
From: Thierry Reding @ 2015-02-03 13:00 UTC (permalink / raw)
  To: Shobhit Kumar; +Cc: Jani Nikula, Daniel Vetter, intel-gfx, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1905 bytes --]

On Wed, Jan 21, 2015 at 04:48:10PM +0530, Shobhit Kumar wrote:
> For scenarios where OF is not available, we can use panel identification by
> name.
> 
> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
> ---
>  drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
>  include/drm/drm_panel.h     |  3 +++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
> index 2ef988e..e1cb8cf 100644
> --- a/drivers/gpu/drm/drm_panel.c
> +++ b/drivers/gpu/drm/drm_panel.c
> @@ -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 *drm_find_panel_by_name(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(drm_find_panel_by_name);
> +
>  MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
>  MODULE_DESCRIPTION("DRM panel infrastructure");
>  MODULE_LICENSE("GPL and additional rights");
> diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
> index 1fbcc96..1ef9ff3 100644
> --- a/include/drm/drm_panel.h
> +++ b/include/drm/drm_panel.h
> @@ -74,6 +74,7 @@ struct drm_panel {
>  	struct drm_device *drm;
>  	struct drm_connector *connector;
>  	struct device *dev;
> +	char name[NAME_MAX];

I thought I had said this before, but I can't find any record, so here
goes again: NAME_MAX is a pretty large number and it increases the size
of this structure a lot. Why not use dev_name(dev) to do the matching?
Or if that doesn't work for some reason, allocate a string of the right
size, or use a static one.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic
  2015-01-21 11:18 ` [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic Shobhit Kumar
@ 2015-02-03 13:05   ` Thierry Reding
  2015-02-04  5:59     ` Shobhit Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Thierry Reding @ 2015-02-03 13:05 UTC (permalink / raw)
  To: Shobhit Kumar; +Cc: Jani Nikula, Daniel Vetter, intel-gfx, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1031 bytes --]

On Wed, Jan 21, 2015 at 04:48:11PM +0530, Shobhit Kumar wrote:
> On BYT-T configuration, panel enable/disable signals are routed through
> PMIC. Add a cell device for the same.
> 
> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
> ---
>  drivers/mfd/intel_soc_pmic_crc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c
> index c85e2ec..c8ccc24 100644
> --- a/drivers/mfd/intel_soc_pmic_crc.c
> +++ b/drivers/mfd/intel_soc_pmic_crc.c
> @@ -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 = {

This doesn't look at all right. A PMIC doesn't typically contain a panel
so this likely is a wrong description of the hardware. Is the datasheet
for the Crystal Cove PMIC available somewhere? Google doesn't turn any-
thing useful up.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic
  2015-01-21 11:18 ` [RFC v3 3/4] drm/i915: Add new panel driver based on " Shobhit Kumar
@ 2015-02-03 13:16   ` Thierry Reding
  2015-02-04  6:55     ` Shobhit Kumar
  2015-02-05  9:46     ` [Intel-gfx] " Daniel Vetter
  0 siblings, 2 replies; 14+ messages in thread
From: Thierry Reding @ 2015-02-03 13:16 UTC (permalink / raw)
  To: Shobhit Kumar; +Cc: Jani Nikula, Daniel Vetter, intel-gfx, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4672 bytes --]

On Wed, Jan 21, 2015 at 04:48:12PM +0530, Shobhit Kumar wrote:
> This driver provides support for the "crystal_cove_panel" cell device.
> On BYT-T pmic has to be used to enable/disable panel.
> 
> v2: Addressed Jani's comments
>     - Moved inside i915
>     - Correct licensing
>     - Remove unused stuff
>     - Do not initialize prepare/unprepare as they are not needed as of now
>     - Correct backlight off delay
> 
> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
> ---
>  drivers/gpu/drm/i915/Kconfig                   |  12 ++
>  drivers/gpu/drm/i915/Makefile                  |   3 +
>  drivers/gpu/drm/i915/intel-panel-crystalcove.c | 159 +++++++++++++++++++++++++
>  3 files changed, 174 insertions(+)
>  create mode 100644 drivers/gpu/drm/i915/intel-panel-crystalcove.c
> 
> diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
> index 4e39ab3..0510ef0 100644
> --- a/drivers/gpu/drm/i915/Kconfig
> +++ b/drivers/gpu/drm/i915/Kconfig
> @@ -69,3 +69,15 @@ config DRM_I915_PRELIMINARY_HW_SUPPORT
>  	  option changes the default for that module option.
>  
>  	  If in doubt, say "N".
> +
> +config DRM_I915_PANEL_CRYSTALCOVE_PMIC
> +	bool "Enable drm panel for crystal cove pmic based control"
> +	depends on DRM_I915
> +	depends on DRM_PANEL
> +	default n

n is the default default.

> diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
[...]
> +#define PMIC_PANEL_EN		0x52
> +#define PMIC_PWM_EN		0x51
> +#define PMIC_BKL_EN		0x4B
> +#define PMIC_PWM_LEVEL		0x4E

These look like they should be GPIOs/regulators and a PWM instead. So I
think you'd need to further split up the MFD device to accomodate for
this.

> +static inline struct crystalcove_panel *to_crystalcove_panel(struct drm_panel *panel)

Please wrap this so it doesn't cross the 80-character boundary.

> +static int crystalcove_panel_disable(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, 0x00);

A datasheet would be really good to determine whether this is the
correct place to write this. There are ->prepare() and ->unprepare()
callbacks that get the panel into a state where you can communicate
with it. This being a DSI panel I would assume that you need to enable
the panel to some degree so you can send DSI commands. So most likely
this enable "GPIO" should be set in ->unprepare().

> +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);

Similarly I'd expect this to go into ->prepare() to make sure that you
can communicate with the panel after ->prepare().

> +	/* Enable BKL as well */
> +	regmap_write(p->regmap, PMIC_BKL_EN, 0xFF);

Writing 0xff to an "enable" register seems weird. Again the datasheet
would help in determining the right thing to do here.

> +	regmap_write(p->regmap, PMIC_PWM_EN, 0x01);
> +	msleep(20);
> +	regmap_write(p->regmap, PMIC_PWM_LEVEL, 255);

This definitely looks like it should be a PWM driver. Also how do you
handle backlight brightness control? You only set things to either full
off or full on in this driver.

> +
> +	drm_panel_init(&panel->base);
> +	panel->base.dev = dev;
> +	panel->base.funcs = &crystalcove_panel_funcs;
> +
> +	drm_panel_add(&panel->base);

This function can theoretically fail, although it doesn't (at present),
so checking the error might be a good idea.

> +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",
> +	},
> +};
> +
> +module_platform_driver(crystalcove_panel_driver);

What's also weird here is that you claim this to be a DSI panel, yet you
use a platform driver. The right thing to do would be to instantiate the
device as mipi_dsi_device, with the DSI controller being the parent.

Thierry

[-- Attachment #1.2: Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic
  2015-02-03 13:05   ` Thierry Reding
@ 2015-02-04  5:59     ` Shobhit Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-02-04  5:59 UTC (permalink / raw)
  To: Thierry Reding, Shobhit Kumar
  Cc: Jani Nikula, Daniel Vetter, intel-gfx, dri-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/03/2015 06:35 PM, Thierry Reding wrote:
> On Wed, Jan 21, 2015 at 04:48:11PM +0530, Shobhit Kumar wrote:
>> On BYT-T configuration, panel enable/disable signals are routed
>> through PMIC. Add a cell device for the same.
>> 
>> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com> --- 
>> drivers/mfd/intel_soc_pmic_crc.c | 3 +++ 1 file changed, 3
>> insertions(+)
>> 
>> diff --git a/drivers/mfd/intel_soc_pmic_crc.c
>> b/drivers/mfd/intel_soc_pmic_crc.c index c85e2ec..c8ccc24 100644 
>> --- a/drivers/mfd/intel_soc_pmic_crc.c +++
>> b/drivers/mfd/intel_soc_pmic_crc.c @@ -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 = {
> 
> This doesn't look at all right. A PMIC doesn't typically contain a
> panel so this likely is a wrong description of the hardware. Is the
> datasheet for the Crystal Cove PMIC available somewhere? Google
> doesn't turn any- thing useful up.

Perhaps the naming makes it look like wrong, but only the Panel
En/Disable and Back light En/Disable/Control signals for any DSI
panels on this platform are routed through PMIC. Not sure if any spec
is available publicly.

Regards
Shobhit

> 
> Thierry
> 
> 
> 
> _______________________________________________ dri-devel mailing
> list dri-devel@lists.freedesktop.org 
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJU0bU7AAoJEHuQFv2//5KqGh8H/jbr2hjyhW8/omPC+vEgDHTr
f8Vh8bsgtEW8YQ89YVJJ8vvioBuhBvRDx8KrxS2122Om0KS4dlEgLBICELWy2Kaw
Lf25QfZlZ9+a/OeksJSL6uhwvOwDipUaUGTVSZCZHrUlCk+8YvkFqAEqB/Xv4d5Q
3vUr7OqzTp4hk1BNrZFoXNtal41EPvN8EGcnj/Zixfph1RQhJhpvxexpds2Aznz2
SEH5huOosuGI/rjfch89hvr6yI0UWhzi6i77e5/sN0QkCa07+0imNNDUx53IXmj4
2nXaPvf7myL8WuITYQ5Bj0DNgFkn+TgR1/2THNv3IQHqiofn3bBvsdQBR+5ttzY=
=reVa
-----END PGP SIGNATURE-----
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic
  2015-02-03 13:16   ` Thierry Reding
@ 2015-02-04  6:55     ` Shobhit Kumar
  2015-02-05  9:46     ` [Intel-gfx] " Daniel Vetter
  1 sibling, 0 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-02-04  6:55 UTC (permalink / raw)
  To: Thierry Reding, Shobhit Kumar
  Cc: Jani Nikula, Daniel Vetter, intel-gfx, dri-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/03/2015 06:46 PM, Thierry Reding wrote:
> On Wed, Jan 21, 2015 at 04:48:12PM +0530, Shobhit Kumar wrote:
>> This driver provides support for the "crystal_cove_panel" cell
>> device. On BYT-T pmic has to be used to enable/disable panel.
>> 
>> v2: Addressed Jani's comments - Moved inside i915 - Correct
>> licensing - Remove unused stuff - Do not initialize
>> prepare/unprepare as they are not needed as of now - Correct
>> backlight off delay
>> 
>> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com> --- 
>> drivers/gpu/drm/i915/Kconfig                   |  12 ++ 
>> drivers/gpu/drm/i915/Makefile                  |   3 + 
>> drivers/gpu/drm/i915/intel-panel-crystalcove.c | 159
>> +++++++++++++++++++++++++ 3 files changed, 174 insertions(+) 
>> create mode 100644
>> drivers/gpu/drm/i915/intel-panel-crystalcove.c
>> 
>> diff --git a/drivers/gpu/drm/i915/Kconfig
>> b/drivers/gpu/drm/i915/Kconfig index 4e39ab3..0510ef0 100644 ---
>> a/drivers/gpu/drm/i915/Kconfig +++
>> b/drivers/gpu/drm/i915/Kconfig @@ -69,3 +69,15 @@ config
>> DRM_I915_PRELIMINARY_HW_SUPPORT option changes the default for
>> that module option.
>> 
>> If in doubt, say "N". + +config DRM_I915_PANEL_CRYSTALCOVE_PMIC +
>> bool "Enable drm panel for crystal cove pmic based control" +
>> depends on DRM_I915 +	depends on DRM_PANEL +	default n
> 
> n is the default default.

Okay.

> 
>> diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c
>> b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
> [...]
>> +#define PMIC_PANEL_EN		0x52 +#define PMIC_PWM_EN		0x51 +#define
>> PMIC_BKL_EN		0x4B +#define PMIC_PWM_LEVEL		0x4E
> 
> These look like they should be GPIOs/regulators and a PWM instead.
> So I think you'd need to further split up the MFD device to
> accomodate for this.

Yes these are I2C addresses for the PWM and Panel control registers on
PMIC. The PMIC driver is a I2C slave device and all control for
Crystal cove is through i2c. Till now there is no situation where
either of the two PWM and Panel control are through interfaces other
than PMIC. Either both are through PMIC or none. With that in mind, I
think can have one common MFD device for PWM and Panel control. Also I
was planning to add Backlight control via backlight class driver in
this same panel driver.

> 
>> +static inline struct crystalcove_panel
>> *to_crystalcove_panel(struct drm_panel *panel)
> 
> Please wrap this so it doesn't cross the 80-character boundary.
> 
>> +static int crystalcove_panel_disable(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, 0x00);
> 
> A datasheet would be really good to determine whether this is the 
> correct place to write this. There are ->prepare() and
> ->unprepare() callbacks that get the panel into a state where you
> can communicate with it. This being a DSI panel I would assume that
> you need to enable the panel to some degree so you can send DSI
> commands. So most likely this enable "GPIO" should be set in
> ->unprepare().

This is just a mechanism to enable needed signals which are routed
through PMIC, I kept the logic as per enable and disable signals in
enable/disable. But yes actually it is preparing the panel to receive
DCS commands. I can move this into prepare/unprepare. In that case
there would be no need for any enable/disable callbacks.

> 
>> +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);
> 
> Similarly I'd expect this to go into ->prepare() to make sure that
> you can communicate with the panel after ->prepare().

Can do as I mentioned above.

> 
>> +	/* Enable BKL as well */ +	regmap_write(p->regmap, PMIC_BKL_EN,
>> 0xFF);
> 
> Writing 0xff to an "enable" register seems weird. Again the
> datasheet would help in determining the right thing to do here.

Actually, I think I made a mistake in naming the register. It is
actually the PWMCLKDIV which has to be programmed as per needed
divider. I will correct this. Spec is not available in public.

> 
>> +	regmap_write(p->regmap, PMIC_PWM_EN, 0x01); +	msleep(20); +
>> regmap_write(p->regmap, PMIC_PWM_LEVEL, 255);
> 
> This definitely looks like it should be a PWM driver. Also how do
> you handle backlight brightness control? You only set things to
> either full off or full on in this driver.

As of now I did just enable and disable to save power leakage during
Suspend/Resume. I am planning to add a backlight class driver as well
as pert of this itself. As I said this should be okay as either both
Panel and PWM control is thorough PMIC or none in our platforms as of now.

> 
>> + +	drm_panel_init(&panel->base); +	panel->base.dev = dev; +
>> panel->base.funcs = &crystalcove_panel_funcs; + +
>> drm_panel_add(&panel->base);
> 
> This function can theoretically fail, although it doesn't (at
> present), so checking the error might be a good idea.

Okay.

> 
>> +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", +	}, +}; + 
>> +module_platform_driver(crystalcove_panel_driver);
> 
> What's also weird here is that you claim this to be a DSI panel,
> yet you use a platform driver. The right thing to do would be to
> instantiate the device as mipi_dsi_device, with the DSI controller
> being the parent.

This is not a DSI panel driver but just to control the Panel
EN/Disbale signals and PWM on BYT platform with CRC PMIC.
mipi_dsi_device conversion for the actual DSI panel driver is recently
done on i915.

Regards
Shobhit

> 
> Thierry
> 
> 
> 
> _______________________________________________ dri-devel mailing
> list dri-devel@lists.freedesktop.org 
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJU0cJJAAoJEHuQFv2//5KqjBkH/35Md/V3bpdNzA0+hjrTy7ap
GPbApTUhyurYm32jAqQwtoVsYHl4Wysyv8lTxQnz+j1VcvWcq2e3a25j1Qo0ybbq
dZeDTr2r3X7Fgj+arFboLxEQSvIWLaT0ML+xaNorbsCaEGxXl/frX/fTCuWXeJet
VX1dII9UbTKtxV/Sc1lcXruL9O4pJSnH02tP+sXqev1gyPhm8EU2Wjz3MReUsvVh
roWnaYTUk7GS15ihuvD2mbm4+o5H8GD8wEP2F5telcKoD4C49HKFbmWVyXFKjHSe
kojntvgYAUGBQY2g6ytTk+nuE/56e3cIFSr27v8RwffWLw+VOWELT30gtKLF6ww=
=Jqac
-----END PGP SIGNATURE-----
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] drm: Add support to find drm_panel by name
  2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
  2015-02-03 13:00   ` Thierry Reding
@ 2015-02-04 11:14   ` Shobhit Kumar
  2015-02-04 14:01     ` shuang.he
  1 sibling, 1 reply; 14+ messages in thread
From: Shobhit Kumar @ 2015-02-04 11:14 UTC (permalink / raw)
  To: dri-devel
  Cc: Jani Nikula, Daniel Vetter, intel-gfx, Thierry Reding, Shobhit Kumar

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

v2: Use const char *name instead of name[NAME_MAX] (Thierry)

CC: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpu/drm/drm_panel.c | 18 ++++++++++++++++++
 include/drm/drm_panel.h     |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index 2ef988e..7b4f559 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -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 *drm_find_panel_by_name(const char *name)
+{
+	struct drm_panel *panel;
+
+	mutex_lock(&panel_lock);
+
+	list_for_each_entry(panel, &panel_list, list) {
+		if (panel->name && strcmp(panel->name, name) == 0) {
+			mutex_unlock(&panel_lock);
+			return panel;
+		}
+	}
+
+	mutex_unlock(&panel_lock);
+	return NULL;
+}
+EXPORT_SYMBOL(drm_find_panel_by_name);
+
 MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
 MODULE_DESCRIPTION("DRM panel infrastructure");
 MODULE_LICENSE("GPL and additional rights");
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index 1fbcc96..43b9004 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -74,6 +74,7 @@ struct drm_panel {
 	struct drm_device *drm;
 	struct drm_connector *connector;
 	struct device *dev;
+	const char *name;
 
 	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 *drm_find_panel_by_name(const char *name);
+
 #endif
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] drm: Add support to find drm_panel by name
  2015-02-04 11:14   ` [PATCH] " Shobhit Kumar
@ 2015-02-04 14:01     ` shuang.he
  0 siblings, 0 replies; 14+ messages in thread
From: shuang.he @ 2015-02-04 14:01 UTC (permalink / raw)
  To: shuang.he, ethan.gao, intel-gfx, shobhit.kumar

Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
Task id: 5711
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
PNV              +1                 282/283              283/283
ILK                 -1              316/319              315/319
SNB                                  322/346              322/346
IVB                 -2              382/384              380/384
BYT                                  296/296              296/296
HSW                                  425/428              425/428
BDW                                  318/333              318/333
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
 PNV  igt_gen3_render_linear_blits      CRASH(1, M23)PASS(2, M25M23)      PASS(1, M23)
*ILK  igt_kms_flip_rcs-flip-vs-panning-interruptible      PASS(2, M26)      DMESG_WARN(1, M26)
 IVB  igt_gem_pwrite_pread_snooped-pwrite-blt-cpu_mmap-performance      DMESG_WARN(2, M34)PASS(1, M21)      DMESG_WARN(1, M34)
*IVB  igt_gem_storedw_batches_loop_secure-dispatch      PASS(3, M21M34)      DMESG_WARN(1, M34)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Intel-gfx] [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic
  2015-02-03 13:16   ` Thierry Reding
  2015-02-04  6:55     ` Shobhit Kumar
@ 2015-02-05  9:46     ` Daniel Vetter
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2015-02-05  9:46 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jani Nikula, Shobhit Kumar, intel-gfx, dri-devel, Daniel Vetter

On Tue, Feb 03, 2015 at 02:16:53PM +0100, Thierry Reding wrote:
> On Wed, Jan 21, 2015 at 04:48:12PM +0530, Shobhit Kumar wrote:
> > diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
> [...]
> > +#define PMIC_PANEL_EN		0x52
> > +#define PMIC_PWM_EN		0x51
> > +#define PMIC_BKL_EN		0x4B
> > +#define PMIC_PWM_LEVEL		0x4E
> 
> These look like they should be GPIOs/regulators and a PWM instead. So I
> think you'd need to further split up the MFD device to accomodate for
> this.

I've had some extension discussion with Thierry on irc and I agree that
using gpio/pwm interfaces will suit better. In addition both gpio and pwm
subsystem already have magic register/lookup support (which works outside
of devicetree or the new acpi tables, which I didn't know). So we'll avoid
writing our own inter-module boilerplate.

Shobhit, Jani&I also chatted about this topic on irc and I think the rough
direction is hopefully clear now.

Just a quick mail here for the record so that the irc discussion won't get
lost.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic
  2015-01-27  9:31 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
@ 2015-01-27  9:31 ` Shobhit Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Shobhit Kumar @ 2015-01-27  9:31 UTC (permalink / raw)
  To: intel-gfx
  Cc: Samuel Ortiz, Jani Nikula, Shobhit Kumar, dri-devel,
	Thierry Reding, Daniel Vetter

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

v2: Addressed Jani's comments
    - Moved inside i915
    - Correct licensing
    - Remove unused stuff
    - Do not initialize prepare/unprepare as they are not needed as of now
    - Correct backlight off delay

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpu/drm/i915/Kconfig                   |  12 ++
 drivers/gpu/drm/i915/Makefile                  |   3 +
 drivers/gpu/drm/i915/intel-panel-crystalcove.c | 159 +++++++++++++++++++++++++
 3 files changed, 174 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/intel-panel-crystalcove.c

diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig
index 4e39ab3..0510ef0 100644
--- a/drivers/gpu/drm/i915/Kconfig
+++ b/drivers/gpu/drm/i915/Kconfig
@@ -69,3 +69,15 @@ config DRM_I915_PRELIMINARY_HW_SUPPORT
 	  option changes the default for that module option.
 
 	  If in doubt, say "N".
+
+config DRM_I915_PANEL_CRYSTALCOVE_PMIC
+	bool "Enable drm panel for crystal cove pmic based control"
+	depends on DRM_I915
+	depends on DRM_PANEL
+	default n
+	help
+	  Choose this option if you have BYT-T based device with DSI panel. On
+	  BYT-T there a crystal cove PMIC which controls the PANEL EN/DISABLE
+	  signals.
+
+	  If in doubt, say "N".
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 1849ffa..cc2f10d 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -88,4 +88,7 @@ i915-y += i915_dma.o \
 
 obj-$(CONFIG_DRM_I915)  += i915.o
 
+# I915 DRM Panels
+obj-$(CONFIG_DRM_I915_PANEL_CRYSTALCOVE_PMIC)	+= intel-panel-crystalcove.o
+
 CFLAGS_i915_trace_points.o := -I$(src)
diff --git a/drivers/gpu/drm/i915/intel-panel-crystalcove.c b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
new file mode 100644
index 0000000..a6aefa3
--- /dev/null
+++ b/drivers/gpu/drm/i915/intel-panel-crystalcove.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * 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 <shobhit.kumar@intel.com>
+ */
+
+#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>
+#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;
+	bool enabled;
+
+	/* 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)
+		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);
+	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_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,
+	.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;
+
+	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 = retval;
+
+	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",
+	},
+};
+
+module_platform_driver(crystalcove_panel_driver);
+
+MODULE_AUTHOR("Shobhit Kumar <shobhit.kumar@linux.intel.com");
+MODULE_DESCRIPTION("Intel Crystal Cove Panel Driver");
+MODULE_LICENSE("GPL and additional rights");
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-02-05  9:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-21 11:18 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
2015-01-21 11:18 ` [RFC v3 1/4] drm: Add support to find drm_panel by name Shobhit Kumar
2015-02-03 13:00   ` Thierry Reding
2015-02-04 11:14   ` [PATCH] " Shobhit Kumar
2015-02-04 14:01     ` shuang.he
2015-01-21 11:18 ` [RFC v3 2/4] mfd: Add a new cell device for panel controlled by crystal cove pmic Shobhit Kumar
2015-02-03 13:05   ` Thierry Reding
2015-02-04  5:59     ` Shobhit Kumar
2015-01-21 11:18 ` [RFC v3 3/4] drm/i915: Add new panel driver based on " Shobhit Kumar
2015-02-03 13:16   ` Thierry Reding
2015-02-04  6:55     ` Shobhit Kumar
2015-02-05  9:46     ` [Intel-gfx] " Daniel Vetter
2015-01-21 11:18 ` [RFC v3 4/4] drm/i915: Enable DSI panel enable/disable based on PMIC Shobhit Kumar
2015-01-27  9:31 [RFC v3 0/4] Crystal Cove PMIC based Panel and Backlight Control Shobhit Kumar
2015-01-27  9:31 ` [RFC v3 3/4] drm/i915: Add new panel driver based on crystal cove pmic Shobhit Kumar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.