All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] seperate panel power control from panel prepare/unprepare
@ 2021-11-16  9:49 ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

Changes since v2:
 - Panel driver panel-boe-tv101wum-nl6.c provides the power sequence apis.
 - The apis are called before dsi poweron and after dsi poweroff.

Changes since v1:
 - Fix null point when dsi next bridge isn't a panel.
 - "dsi mmsys reset" is implement by
   https://patchwork.kernel.org/project/linux-mediatek/list/?series=515355

Jitao Shi (2):
  drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid
    leakage
  drm/mediatek: control panel's power before MIPI LP11

 drivers/gpu/drm/mediatek/mtk_dsi.c             | 28 ++++++--
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 3 files changed, 116 insertions(+), 28 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

-- 
2.12.5


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

* [PATCH v3 0/2] seperate panel power control from panel prepare/unprepare
@ 2021-11-16  9:49 ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

Changes since v2:
 - Panel driver panel-boe-tv101wum-nl6.c provides the power sequence apis.
 - The apis are called before dsi poweron and after dsi poweroff.

Changes since v1:
 - Fix null point when dsi next bridge isn't a panel.
 - "dsi mmsys reset" is implement by
   https://patchwork.kernel.org/project/linux-mediatek/list/?series=515355

Jitao Shi (2):
  drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid
    leakage
  drm/mediatek: control panel's power before MIPI LP11

 drivers/gpu/drm/mediatek/mtk_dsi.c             | 28 ++++++--
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 3 files changed, 116 insertions(+), 28 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

-- 
2.12.5


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH v3 0/2] seperate panel power control from panel prepare/unprepare
@ 2021-11-16  9:49 ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: Jitao Shi, huijuan.xie, stonea168, xinlei.li, shuijing.li,
	linux-mediatek, liangxu.xu

Changes since v2:
 - Panel driver panel-boe-tv101wum-nl6.c provides the power sequence apis.
 - The apis are called before dsi poweron and after dsi poweroff.

Changes since v1:
 - Fix null point when dsi next bridge isn't a panel.
 - "dsi mmsys reset" is implement by
   https://patchwork.kernel.org/project/linux-mediatek/list/?series=515355

Jitao Shi (2):
  drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid
    leakage
  drm/mediatek: control panel's power before MIPI LP11

 drivers/gpu/drm/mediatek/mtk_dsi.c             | 28 ++++++--
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 3 files changed, 116 insertions(+), 28 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

-- 
2.12.5


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

* [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
  2021-11-16  9:49 ` Jitao Shi
  (?)
@ 2021-11-16  9:49   ` Jitao Shi
  -1 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

"auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
between IOVCC and mipi data.
The 2st version of SPEC modifies the timing requirements from IOVCC to
Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
otherwise there is a risk of leakage. It is recommended that the time
for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28
---
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 2 files changed, 94 insertions(+), 22 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
index db9d0b86d542..02efee06c430 100644
--- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
+++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
@@ -49,7 +49,7 @@ struct boe_panel {
 	struct regulator *avee;
 	struct regulator *avdd;
 	struct gpio_desc *enable_gpio;
-
+	int powered_refcnt;
 	bool prepared;
 };
 
@@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
 	return 0;
 }
 
-static int boe_panel_unprepare(struct drm_panel *panel)
+static int boe_panel_power_off(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
-	int ret;
 
-	if (!boe->prepared)
-		return 0;
+	if (WARN_ON(boe->powered_refcnt == 0))
+		return -EINVAL;
 
-	ret = boe_panel_enter_sleep_mode(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
-		return ret;
-	}
+	if (--boe->powered_refcnt != 0)
+		return 0;
 
 	msleep(150);
 
@@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
 		regulator_disable(boe->pp1800);
 	}
 
+	return 0;
+}
+
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_off(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_unprepare_power);
+
+static int boe_panel_unprepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	if (!boe->prepared)
+		return 0;
+
+	ret = boe_panel_enter_sleep_mode(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
+		return ret;
+	}
+
+	boe_panel_power_off(panel);
+
 	boe->prepared = false;
 
 	return 0;
 }
 
-static int boe_panel_prepare(struct drm_panel *panel)
+static int boe_panel_power_on(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
 	int ret;
 
-	if (boe->prepared)
+	if (++boe->powered_refcnt != 1)
 		return 0;
 
 	gpiod_set_value(boe->enable_gpio, 0);
@@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	gpiod_set_value(boe->enable_gpio, 1);
 	usleep_range(6000, 10000);
 
-	ret = boe_panel_init_dcs_cmd(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to init panel: %d\n", ret);
-		goto poweroff;
-	}
-
-	boe->prepared = true;
-
 	return 0;
 
-poweroff:
-	regulator_disable(boe->avee);
 poweroffavdd:
 	regulator_disable(boe->avdd);
 poweroff1v8:
@@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	return ret;
 }
 
+int panel_prepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_on(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_prepare_power);
+
+static int boe_panel_prepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	boe_panel_power_on(panel);
+
+	if (boe->prepared)
+		return 0;
+
+	ret = boe_panel_init_dcs_cmd(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to init panel: %d\n", ret);
+		return ret;
+	}
+
+	boe->prepared = true;
+
+	return 0;
+}
+
 static int boe_panel_enable(struct drm_panel *panel)
 {
 	msleep(130);
diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
new file mode 100644
index 000000000000..72abe3eb7840
--- /dev/null
+++ b/include/drm/panel_boe_tv101wum_nl6.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Jitao Shi <jitao.shi@mediatek.com>
+ */
+
+#ifndef __PANEL_BOE_TV101WUM_NL6_H__
+#define __PANEL_BOE_TV101WUM_NL6_H__
+
+#include <linux/types.h>
+#include <drm/drm_panel.h>
+
+#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
+int panel_unprepare_power(struct drm_panel *panel);
+int panel_prepare_power(struct drm_panel *panel);
+#else
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+
+int panel_prepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+#endif
+#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
+
-- 
2.12.5


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

* [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
@ 2021-11-16  9:49   ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

"auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
between IOVCC and mipi data.
The 2st version of SPEC modifies the timing requirements from IOVCC to
Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
otherwise there is a risk of leakage. It is recommended that the time
for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28
---
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 2 files changed, 94 insertions(+), 22 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
index db9d0b86d542..02efee06c430 100644
--- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
+++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
@@ -49,7 +49,7 @@ struct boe_panel {
 	struct regulator *avee;
 	struct regulator *avdd;
 	struct gpio_desc *enable_gpio;
-
+	int powered_refcnt;
 	bool prepared;
 };
 
@@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
 	return 0;
 }
 
-static int boe_panel_unprepare(struct drm_panel *panel)
+static int boe_panel_power_off(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
-	int ret;
 
-	if (!boe->prepared)
-		return 0;
+	if (WARN_ON(boe->powered_refcnt == 0))
+		return -EINVAL;
 
-	ret = boe_panel_enter_sleep_mode(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
-		return ret;
-	}
+	if (--boe->powered_refcnt != 0)
+		return 0;
 
 	msleep(150);
 
@@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
 		regulator_disable(boe->pp1800);
 	}
 
+	return 0;
+}
+
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_off(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_unprepare_power);
+
+static int boe_panel_unprepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	if (!boe->prepared)
+		return 0;
+
+	ret = boe_panel_enter_sleep_mode(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
+		return ret;
+	}
+
+	boe_panel_power_off(panel);
+
 	boe->prepared = false;
 
 	return 0;
 }
 
-static int boe_panel_prepare(struct drm_panel *panel)
+static int boe_panel_power_on(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
 	int ret;
 
-	if (boe->prepared)
+	if (++boe->powered_refcnt != 1)
 		return 0;
 
 	gpiod_set_value(boe->enable_gpio, 0);
@@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	gpiod_set_value(boe->enable_gpio, 1);
 	usleep_range(6000, 10000);
 
-	ret = boe_panel_init_dcs_cmd(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to init panel: %d\n", ret);
-		goto poweroff;
-	}
-
-	boe->prepared = true;
-
 	return 0;
 
-poweroff:
-	regulator_disable(boe->avee);
 poweroffavdd:
 	regulator_disable(boe->avdd);
 poweroff1v8:
@@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	return ret;
 }
 
+int panel_prepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_on(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_prepare_power);
+
+static int boe_panel_prepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	boe_panel_power_on(panel);
+
+	if (boe->prepared)
+		return 0;
+
+	ret = boe_panel_init_dcs_cmd(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to init panel: %d\n", ret);
+		return ret;
+	}
+
+	boe->prepared = true;
+
+	return 0;
+}
+
 static int boe_panel_enable(struct drm_panel *panel)
 {
 	msleep(130);
diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
new file mode 100644
index 000000000000..72abe3eb7840
--- /dev/null
+++ b/include/drm/panel_boe_tv101wum_nl6.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Jitao Shi <jitao.shi@mediatek.com>
+ */
+
+#ifndef __PANEL_BOE_TV101WUM_NL6_H__
+#define __PANEL_BOE_TV101WUM_NL6_H__
+
+#include <linux/types.h>
+#include <drm/drm_panel.h>
+
+#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
+int panel_unprepare_power(struct drm_panel *panel);
+int panel_prepare_power(struct drm_panel *panel);
+#else
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+
+int panel_prepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+#endif
+#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
+
-- 
2.12.5


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
@ 2021-11-16  9:49   ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: Jitao Shi, huijuan.xie, stonea168, xinlei.li, shuijing.li,
	linux-mediatek, liangxu.xu

"auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
between IOVCC and mipi data.
The 2st version of SPEC modifies the timing requirements from IOVCC to
Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
otherwise there is a risk of leakage. It is recommended that the time
for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28
---
 drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
 include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
 2 files changed, 94 insertions(+), 22 deletions(-)
 create mode 100644 include/drm/panel_boe_tv101wum_nl6.h

diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
index db9d0b86d542..02efee06c430 100644
--- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
+++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
@@ -49,7 +49,7 @@ struct boe_panel {
 	struct regulator *avee;
 	struct regulator *avdd;
 	struct gpio_desc *enable_gpio;
-
+	int powered_refcnt;
 	bool prepared;
 };
 
@@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
 	return 0;
 }
 
-static int boe_panel_unprepare(struct drm_panel *panel)
+static int boe_panel_power_off(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
-	int ret;
 
-	if (!boe->prepared)
-		return 0;
+	if (WARN_ON(boe->powered_refcnt == 0))
+		return -EINVAL;
 
-	ret = boe_panel_enter_sleep_mode(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
-		return ret;
-	}
+	if (--boe->powered_refcnt != 0)
+		return 0;
 
 	msleep(150);
 
@@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
 		regulator_disable(boe->pp1800);
 	}
 
+	return 0;
+}
+
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_off(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_unprepare_power);
+
+static int boe_panel_unprepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	if (!boe->prepared)
+		return 0;
+
+	ret = boe_panel_enter_sleep_mode(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
+		return ret;
+	}
+
+	boe_panel_power_off(panel);
+
 	boe->prepared = false;
 
 	return 0;
 }
 
-static int boe_panel_prepare(struct drm_panel *panel)
+static int boe_panel_power_on(struct drm_panel *panel)
 {
 	struct boe_panel *boe = to_boe_panel(panel);
 	int ret;
 
-	if (boe->prepared)
+	if (++boe->powered_refcnt != 1)
 		return 0;
 
 	gpiod_set_value(boe->enable_gpio, 0);
@@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	gpiod_set_value(boe->enable_gpio, 1);
 	usleep_range(6000, 10000);
 
-	ret = boe_panel_init_dcs_cmd(boe);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to init panel: %d\n", ret);
-		goto poweroff;
-	}
-
-	boe->prepared = true;
-
 	return 0;
 
-poweroff:
-	regulator_disable(boe->avee);
 poweroffavdd:
 	regulator_disable(boe->avdd);
 poweroff1v8:
@@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
 	return ret;
 }
 
+int panel_prepare_power(struct drm_panel *panel)
+{
+	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
+		return boe_panel_power_on(panel);
+
+	return 0;
+}
+EXPORT_SYMBOL(panel_prepare_power);
+
+static int boe_panel_prepare(struct drm_panel *panel)
+{
+	struct boe_panel *boe = to_boe_panel(panel);
+	int ret;
+
+	boe_panel_power_on(panel);
+
+	if (boe->prepared)
+		return 0;
+
+	ret = boe_panel_init_dcs_cmd(boe);
+	if (ret < 0) {
+		dev_err(panel->dev, "failed to init panel: %d\n", ret);
+		return ret;
+	}
+
+	boe->prepared = true;
+
+	return 0;
+}
+
 static int boe_panel_enable(struct drm_panel *panel)
 {
 	msleep(130);
diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
new file mode 100644
index 000000000000..72abe3eb7840
--- /dev/null
+++ b/include/drm/panel_boe_tv101wum_nl6.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2018 MediaTek Inc.
+ * Author: Jitao Shi <jitao.shi@mediatek.com>
+ */
+
+#ifndef __PANEL_BOE_TV101WUM_NL6_H__
+#define __PANEL_BOE_TV101WUM_NL6_H__
+
+#include <linux/types.h>
+#include <drm/drm_panel.h>
+
+#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
+int panel_unprepare_power(struct drm_panel *panel);
+int panel_prepare_power(struct drm_panel *panel);
+#else
+int panel_unprepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+
+int panel_prepare_power(struct drm_panel *panel)
+{
+	return 0;
+}
+#endif
+#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
+
-- 
2.12.5


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

* [PATCH v3 2/2] drm/mediatek: control panel's power before MIPI LP11
  2021-11-16  9:49 ` Jitao Shi
  (?)
@ 2021-11-16  9:49   ` Jitao Shi
  -1 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

"auo,kd101n80-45na" requires the panel's IOVDD take precedence over
MIPI DATA. Otherwise there is a risk of leakage.

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: I2da6179dea7e15bc5a53fe36db200b6c04f4d551
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 93b40c245f00..9fff0c483139 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -24,7 +24,7 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-
+#include <drm/panel_boe_tv101wum_nl6.h>
 #include "mtk_disp_drv.h"
 #include "mtk_drm_ddp_comp.h"
 
@@ -185,6 +185,7 @@ struct mtk_dsi {
 	struct drm_bridge bridge;
 	struct drm_bridge *next_bridge;
 	struct drm_connector *connector;
+	struct drm_panel *panel;
 	struct phy *phy;
 
 	void __iomem *regs;
@@ -619,10 +620,16 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,
 					  dsi->lanes);
 
+	if (dsi->panel) {
+		if (panel_prepare_power(dsi->panel)) {
+			DRM_INFO("can't prepare power the panel\n");
+			goto err_refcount;
+		}
+	}
 	ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
 	if (ret < 0) {
 		dev_err(dev, "Failed to set data rate: %d\n", ret);
-		goto err_refcount;
+		goto err_prepare_power;
 	}
 
 	phy_power_on(dsi->phy);
@@ -665,6 +672,11 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->engine_clk);
 err_phy_power_off:
 	phy_power_off(dsi->phy);
+err_prepare_power:
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 err_refcount:
 	dsi->refcount--;
 	return ret;
@@ -698,6 +710,11 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->digital_clk);
 
 	phy_power_off(dsi->phy);
+
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 }
 
 static void mtk_output_dsi_enable(struct mtk_dsi *dsi)
@@ -1001,7 +1018,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 {
 	struct mtk_dsi *dsi;
 	struct device *dev = &pdev->dev;
-	struct drm_panel *panel;
 	struct resource *regs;
 	int irq_num;
 	int ret;
@@ -1019,12 +1035,12 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	}
 
 	ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
-					  &panel, &dsi->next_bridge);
+					  &dsi->panel, &dsi->next_bridge);
 	if (ret)
 		goto err_unregister_host;
 
-	if (panel) {
-		dsi->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (dsi->panel) {
+		dsi->next_bridge = devm_drm_panel_bridge_add(dev, dsi->panel);
 		if (IS_ERR(dsi->next_bridge)) {
 			ret = PTR_ERR(dsi->next_bridge);
 			goto err_unregister_host;
-- 
2.12.5


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

* [PATCH v3 2/2] drm/mediatek: control panel's power before MIPI LP11
@ 2021-11-16  9:49   ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

"auo,kd101n80-45na" requires the panel's IOVDD take precedence over
MIPI DATA. Otherwise there is a risk of leakage.

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: I2da6179dea7e15bc5a53fe36db200b6c04f4d551
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 93b40c245f00..9fff0c483139 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -24,7 +24,7 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-
+#include <drm/panel_boe_tv101wum_nl6.h>
 #include "mtk_disp_drv.h"
 #include "mtk_drm_ddp_comp.h"
 
@@ -185,6 +185,7 @@ struct mtk_dsi {
 	struct drm_bridge bridge;
 	struct drm_bridge *next_bridge;
 	struct drm_connector *connector;
+	struct drm_panel *panel;
 	struct phy *phy;
 
 	void __iomem *regs;
@@ -619,10 +620,16 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,
 					  dsi->lanes);
 
+	if (dsi->panel) {
+		if (panel_prepare_power(dsi->panel)) {
+			DRM_INFO("can't prepare power the panel\n");
+			goto err_refcount;
+		}
+	}
 	ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
 	if (ret < 0) {
 		dev_err(dev, "Failed to set data rate: %d\n", ret);
-		goto err_refcount;
+		goto err_prepare_power;
 	}
 
 	phy_power_on(dsi->phy);
@@ -665,6 +672,11 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->engine_clk);
 err_phy_power_off:
 	phy_power_off(dsi->phy);
+err_prepare_power:
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 err_refcount:
 	dsi->refcount--;
 	return ret;
@@ -698,6 +710,11 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->digital_clk);
 
 	phy_power_off(dsi->phy);
+
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 }
 
 static void mtk_output_dsi_enable(struct mtk_dsi *dsi)
@@ -1001,7 +1018,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 {
 	struct mtk_dsi *dsi;
 	struct device *dev = &pdev->dev;
-	struct drm_panel *panel;
 	struct resource *regs;
 	int irq_num;
 	int ret;
@@ -1019,12 +1035,12 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	}
 
 	ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
-					  &panel, &dsi->next_bridge);
+					  &dsi->panel, &dsi->next_bridge);
 	if (ret)
 		goto err_unregister_host;
 
-	if (panel) {
-		dsi->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (dsi->panel) {
+		dsi->next_bridge = devm_drm_panel_bridge_add(dev, dsi->panel);
 		if (IS_ERR(dsi->next_bridge)) {
 			ret = PTR_ERR(dsi->next_bridge);
 			goto err_unregister_host;
-- 
2.12.5


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH v3 2/2] drm/mediatek: control panel's power before MIPI LP11
@ 2021-11-16  9:49   ` Jitao Shi
  0 siblings, 0 replies; 12+ messages in thread
From: Jitao Shi @ 2021-11-16  9:49 UTC (permalink / raw)
  To: Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter,
	Matthias Brugger, Chun-Kuang Hu, Philipp Zabel, dri-devel,
	linux-kernel
  Cc: Jitao Shi, huijuan.xie, stonea168, xinlei.li, shuijing.li,
	linux-mediatek, liangxu.xu

"auo,kd101n80-45na" requires the panel's IOVDD take precedence over
MIPI DATA. Otherwise there is a risk of leakage.

Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
Change-Id: I2da6179dea7e15bc5a53fe36db200b6c04f4d551
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 93b40c245f00..9fff0c483139 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -24,7 +24,7 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_simple_kms_helper.h>
-
+#include <drm/panel_boe_tv101wum_nl6.h>
 #include "mtk_disp_drv.h"
 #include "mtk_drm_ddp_comp.h"
 
@@ -185,6 +185,7 @@ struct mtk_dsi {
 	struct drm_bridge bridge;
 	struct drm_bridge *next_bridge;
 	struct drm_connector *connector;
+	struct drm_panel *panel;
 	struct phy *phy;
 
 	void __iomem *regs;
@@ -619,10 +620,16 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,
 					  dsi->lanes);
 
+	if (dsi->panel) {
+		if (panel_prepare_power(dsi->panel)) {
+			DRM_INFO("can't prepare power the panel\n");
+			goto err_refcount;
+		}
+	}
 	ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
 	if (ret < 0) {
 		dev_err(dev, "Failed to set data rate: %d\n", ret);
-		goto err_refcount;
+		goto err_prepare_power;
 	}
 
 	phy_power_on(dsi->phy);
@@ -665,6 +672,11 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->engine_clk);
 err_phy_power_off:
 	phy_power_off(dsi->phy);
+err_prepare_power:
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 err_refcount:
 	dsi->refcount--;
 	return ret;
@@ -698,6 +710,11 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->digital_clk);
 
 	phy_power_off(dsi->phy);
+
+	if (dsi->panel) {
+		if (panel_unprepare_power(dsi->panel))
+			DRM_INFO("Can't unprepare power the panel\n");
+	}
 }
 
 static void mtk_output_dsi_enable(struct mtk_dsi *dsi)
@@ -1001,7 +1018,6 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 {
 	struct mtk_dsi *dsi;
 	struct device *dev = &pdev->dev;
-	struct drm_panel *panel;
 	struct resource *regs;
 	int irq_num;
 	int ret;
@@ -1019,12 +1035,12 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	}
 
 	ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
-					  &panel, &dsi->next_bridge);
+					  &dsi->panel, &dsi->next_bridge);
 	if (ret)
 		goto err_unregister_host;
 
-	if (panel) {
-		dsi->next_bridge = devm_drm_panel_bridge_add(dev, panel);
+	if (dsi->panel) {
+		dsi->next_bridge = devm_drm_panel_bridge_add(dev, dsi->panel);
 		if (IS_ERR(dsi->next_bridge)) {
 			ret = PTR_ERR(dsi->next_bridge);
 			goto err_unregister_host;
-- 
2.12.5


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

* Re: [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
  2021-11-16  9:49   ` Jitao Shi
  (?)
@ 2022-01-10 23:34     ` Kevin Hilman
  -1 siblings, 0 replies; 12+ messages in thread
From: Kevin Hilman @ 2022-01-10 23:34 UTC (permalink / raw)
  To: Jitao Shi, Thierry Reding, Sam Ravnborg, David Airlie,
	Daniel Vetter, Matthias Brugger, Chun-Kuang Hu, Philipp Zabel,
	dri-devel, linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

Jitao Shi <jitao.shi@mediatek.com> writes:

> "auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
> between IOVCC and mipi data.
> The 2st version of SPEC modifies the timing requirements from IOVCC to
> Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
> otherwise there is a risk of leakage. It is recommended that the time
> for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Similar to what Daniel said on v2:  You're changing the behavior of
*all* users of this panel driver with this patch, in order to fix a
single user (in the next patch.)

> Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28

Please drop gerrit IDs from upstream submissions.

Kevin

> ---
>  drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
>  include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
>  2 files changed, 94 insertions(+), 22 deletions(-)
>  create mode 100644 include/drm/panel_boe_tv101wum_nl6.h
>
> diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> index db9d0b86d542..02efee06c430 100644
> --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> @@ -49,7 +49,7 @@ struct boe_panel {
>  	struct regulator *avee;
>  	struct regulator *avdd;
>  	struct gpio_desc *enable_gpio;
> -
> +	int powered_refcnt;
>  	bool prepared;
>  };
>  
> @@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
>  	return 0;
>  }
>  
> -static int boe_panel_unprepare(struct drm_panel *panel)
> +static int boe_panel_power_off(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
> -	int ret;
>  
> -	if (!boe->prepared)
> -		return 0;
> +	if (WARN_ON(boe->powered_refcnt == 0))
> +		return -EINVAL;
>  
> -	ret = boe_panel_enter_sleep_mode(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> -		return ret;
> -	}
> +	if (--boe->powered_refcnt != 0)
> +		return 0;
>  
>  	msleep(150);
>  
> @@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
>  		regulator_disable(boe->pp1800);
>  	}
>  
> +	return 0;
> +}
> +
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_off(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_unprepare_power);
> +
> +static int boe_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	if (!boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_enter_sleep_mode(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe_panel_power_off(panel);
> +
>  	boe->prepared = false;
>  
>  	return 0;
>  }
>  
> -static int boe_panel_prepare(struct drm_panel *panel)
> +static int boe_panel_power_on(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
>  	int ret;
>  
> -	if (boe->prepared)
> +	if (++boe->powered_refcnt != 1)
>  		return 0;
>  
>  	gpiod_set_value(boe->enable_gpio, 0);
> @@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	gpiod_set_value(boe->enable_gpio, 1);
>  	usleep_range(6000, 10000);
>  
> -	ret = boe_panel_init_dcs_cmd(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> -		goto poweroff;
> -	}
> -
> -	boe->prepared = true;
> -
>  	return 0;
>  
> -poweroff:
> -	regulator_disable(boe->avee);
>  poweroffavdd:
>  	regulator_disable(boe->avdd);
>  poweroff1v8:
> @@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	return ret;
>  }
>  
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_on(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_prepare_power);
> +
> +static int boe_panel_prepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	boe_panel_power_on(panel);
> +
> +	if (boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_init_dcs_cmd(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe->prepared = true;
> +
> +	return 0;
> +}
> +
>  static int boe_panel_enable(struct drm_panel *panel)
>  {
>  	msleep(130);
> diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
> new file mode 100644
> index 000000000000..72abe3eb7840
> --- /dev/null
> +++ b/include/drm/panel_boe_tv101wum_nl6.h
> @@ -0,0 +1,28 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2018 MediaTek Inc.
> + * Author: Jitao Shi <jitao.shi@mediatek.com>
> + */
> +
> +#ifndef __PANEL_BOE_TV101WUM_NL6_H__
> +#define __PANEL_BOE_TV101WUM_NL6_H__
> +
> +#include <linux/types.h>
> +#include <drm/drm_panel.h>
> +
> +#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
> +int panel_unprepare_power(struct drm_panel *panel);
> +int panel_prepare_power(struct drm_panel *panel);
> +#else
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +#endif
> +#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
> +
> -- 
> 2.12.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
@ 2022-01-10 23:34     ` Kevin Hilman
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Hilman @ 2022-01-10 23:34 UTC (permalink / raw)
  To: Jitao Shi, Thierry Reding, Sam Ravnborg, David Airlie,
	Daniel Vetter, Matthias Brugger, Chun-Kuang Hu, Philipp Zabel,
	dri-devel, linux-kernel
  Cc: linux-mediatek, stonea168, huijuan.xie, shuijing.li, liangxu.xu,
	xinlei.li, Jitao Shi

Jitao Shi <jitao.shi@mediatek.com> writes:

> "auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
> between IOVCC and mipi data.
> The 2st version of SPEC modifies the timing requirements from IOVCC to
> Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
> otherwise there is a risk of leakage. It is recommended that the time
> for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Similar to what Daniel said on v2:  You're changing the behavior of
*all* users of this panel driver with this patch, in order to fix a
single user (in the next patch.)

> Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28

Please drop gerrit IDs from upstream submissions.

Kevin

> ---
>  drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
>  include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
>  2 files changed, 94 insertions(+), 22 deletions(-)
>  create mode 100644 include/drm/panel_boe_tv101wum_nl6.h
>
> diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> index db9d0b86d542..02efee06c430 100644
> --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> @@ -49,7 +49,7 @@ struct boe_panel {
>  	struct regulator *avee;
>  	struct regulator *avdd;
>  	struct gpio_desc *enable_gpio;
> -
> +	int powered_refcnt;
>  	bool prepared;
>  };
>  
> @@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
>  	return 0;
>  }
>  
> -static int boe_panel_unprepare(struct drm_panel *panel)
> +static int boe_panel_power_off(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
> -	int ret;
>  
> -	if (!boe->prepared)
> -		return 0;
> +	if (WARN_ON(boe->powered_refcnt == 0))
> +		return -EINVAL;
>  
> -	ret = boe_panel_enter_sleep_mode(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> -		return ret;
> -	}
> +	if (--boe->powered_refcnt != 0)
> +		return 0;
>  
>  	msleep(150);
>  
> @@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
>  		regulator_disable(boe->pp1800);
>  	}
>  
> +	return 0;
> +}
> +
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_off(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_unprepare_power);
> +
> +static int boe_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	if (!boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_enter_sleep_mode(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe_panel_power_off(panel);
> +
>  	boe->prepared = false;
>  
>  	return 0;
>  }
>  
> -static int boe_panel_prepare(struct drm_panel *panel)
> +static int boe_panel_power_on(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
>  	int ret;
>  
> -	if (boe->prepared)
> +	if (++boe->powered_refcnt != 1)
>  		return 0;
>  
>  	gpiod_set_value(boe->enable_gpio, 0);
> @@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	gpiod_set_value(boe->enable_gpio, 1);
>  	usleep_range(6000, 10000);
>  
> -	ret = boe_panel_init_dcs_cmd(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> -		goto poweroff;
> -	}
> -
> -	boe->prepared = true;
> -
>  	return 0;
>  
> -poweroff:
> -	regulator_disable(boe->avee);
>  poweroffavdd:
>  	regulator_disable(boe->avdd);
>  poweroff1v8:
> @@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	return ret;
>  }
>  
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_on(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_prepare_power);
> +
> +static int boe_panel_prepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	boe_panel_power_on(panel);
> +
> +	if (boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_init_dcs_cmd(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe->prepared = true;
> +
> +	return 0;
> +}
> +
>  static int boe_panel_enable(struct drm_panel *panel)
>  {
>  	msleep(130);
> diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
> new file mode 100644
> index 000000000000..72abe3eb7840
> --- /dev/null
> +++ b/include/drm/panel_boe_tv101wum_nl6.h
> @@ -0,0 +1,28 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2018 MediaTek Inc.
> + * Author: Jitao Shi <jitao.shi@mediatek.com>
> + */
> +
> +#ifndef __PANEL_BOE_TV101WUM_NL6_H__
> +#define __PANEL_BOE_TV101WUM_NL6_H__
> +
> +#include <linux/types.h>
> +#include <drm/drm_panel.h>
> +
> +#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
> +int panel_unprepare_power(struct drm_panel *panel);
> +int panel_prepare_power(struct drm_panel *panel);
> +#else
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +#endif
> +#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
> +
> -- 
> 2.12.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage
@ 2022-01-10 23:34     ` Kevin Hilman
  0 siblings, 0 replies; 12+ messages in thread
From: Kevin Hilman @ 2022-01-10 23:34 UTC (permalink / raw)
  To: Jitao Shi, Thierry Reding, Sam Ravnborg, David Airlie,
	Daniel Vetter, Matthias Brugger, Chun-Kuang Hu, Philipp Zabel,
	dri-devel, linux-kernel
  Cc: Jitao Shi, huijuan.xie, stonea168, xinlei.li, shuijing.li,
	linux-mediatek, liangxu.xu

Jitao Shi <jitao.shi@mediatek.com> writes:

> "auo,kd101n80-45na" 2st LCD SPEC update, need to modify the timing
> between IOVCC and mipi data.
> The 2st version of SPEC modifies the timing requirements from IOVCC to
> Mipi Data. IOVCC is now required to take precedence over MIPI DATA,
> otherwise there is a risk of leakage. It is recommended that the time
> for MIPI to enter LP11 be postponed after IOVCC (delay20ms).

Similar to what Daniel said on v2:  You're changing the behavior of
*all* users of this panel driver with this patch, in order to fix a
single user (in the next patch.)

> Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>
> Change-Id: Ic5212e2145a7dbf2efef9e5585904a93e1bc5a28

Please drop gerrit IDs from upstream submissions.

Kevin

> ---
>  drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 88 +++++++++++++++++++-------
>  include/drm/panel_boe_tv101wum_nl6.h           | 28 ++++++++
>  2 files changed, 94 insertions(+), 22 deletions(-)
>  create mode 100644 include/drm/panel_boe_tv101wum_nl6.h
>
> diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> index db9d0b86d542..02efee06c430 100644
> --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c
> @@ -49,7 +49,7 @@ struct boe_panel {
>  	struct regulator *avee;
>  	struct regulator *avdd;
>  	struct gpio_desc *enable_gpio;
> -
> +	int powered_refcnt;
>  	bool prepared;
>  };
>  
> @@ -488,19 +488,15 @@ static int boe_panel_enter_sleep_mode(struct boe_panel *boe)
>  	return 0;
>  }
>  
> -static int boe_panel_unprepare(struct drm_panel *panel)
> +static int boe_panel_power_off(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
> -	int ret;
>  
> -	if (!boe->prepared)
> -		return 0;
> +	if (WARN_ON(boe->powered_refcnt == 0))
> +		return -EINVAL;
>  
> -	ret = boe_panel_enter_sleep_mode(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> -		return ret;
> -	}
> +	if (--boe->powered_refcnt != 0)
> +		return 0;
>  
>  	msleep(150);
>  
> @@ -520,17 +516,45 @@ static int boe_panel_unprepare(struct drm_panel *panel)
>  		regulator_disable(boe->pp1800);
>  	}
>  
> +	return 0;
> +}
> +
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_off(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_unprepare_power);
> +
> +static int boe_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	if (!boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_enter_sleep_mode(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to set panel off: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe_panel_power_off(panel);
> +
>  	boe->prepared = false;
>  
>  	return 0;
>  }
>  
> -static int boe_panel_prepare(struct drm_panel *panel)
> +static int boe_panel_power_on(struct drm_panel *panel)
>  {
>  	struct boe_panel *boe = to_boe_panel(panel);
>  	int ret;
>  
> -	if (boe->prepared)
> +	if (++boe->powered_refcnt != 1)
>  		return 0;
>  
>  	gpiod_set_value(boe->enable_gpio, 0);
> @@ -558,18 +582,8 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	gpiod_set_value(boe->enable_gpio, 1);
>  	usleep_range(6000, 10000);
>  
> -	ret = boe_panel_init_dcs_cmd(boe);
> -	if (ret < 0) {
> -		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> -		goto poweroff;
> -	}
> -
> -	boe->prepared = true;
> -
>  	return 0;
>  
> -poweroff:
> -	regulator_disable(boe->avee);
>  poweroffavdd:
>  	regulator_disable(boe->avdd);
>  poweroff1v8:
> @@ -580,6 +594,36 @@ static int boe_panel_prepare(struct drm_panel *panel)
>  	return ret;
>  }
>  
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	if (of_device_is_compatible(panel->dev->of_node, "auo,kd101n80-45na"))
> +		return boe_panel_power_on(panel);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(panel_prepare_power);
> +
> +static int boe_panel_prepare(struct drm_panel *panel)
> +{
> +	struct boe_panel *boe = to_boe_panel(panel);
> +	int ret;
> +
> +	boe_panel_power_on(panel);
> +
> +	if (boe->prepared)
> +		return 0;
> +
> +	ret = boe_panel_init_dcs_cmd(boe);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to init panel: %d\n", ret);
> +		return ret;
> +	}
> +
> +	boe->prepared = true;
> +
> +	return 0;
> +}
> +
>  static int boe_panel_enable(struct drm_panel *panel)
>  {
>  	msleep(130);
> diff --git a/include/drm/panel_boe_tv101wum_nl6.h b/include/drm/panel_boe_tv101wum_nl6.h
> new file mode 100644
> index 000000000000..72abe3eb7840
> --- /dev/null
> +++ b/include/drm/panel_boe_tv101wum_nl6.h
> @@ -0,0 +1,28 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * Copyright (c) 2018 MediaTek Inc.
> + * Author: Jitao Shi <jitao.shi@mediatek.com>
> + */
> +
> +#ifndef __PANEL_BOE_TV101WUM_NL6_H__
> +#define __PANEL_BOE_TV101WUM_NL6_H__
> +
> +#include <linux/types.h>
> +#include <drm/drm_panel.h>
> +
> +#if defined(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6)
> +int panel_unprepare_power(struct drm_panel *panel);
> +int panel_prepare_power(struct drm_panel *panel);
> +#else
> +int panel_unprepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +
> +int panel_prepare_power(struct drm_panel *panel)
> +{
> +	return 0;
> +}
> +#endif
> +#endif /* __PANEL_BOE_TV101WUM_NL6_H__ */
> +
> -- 
> 2.12.5
>
>
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

end of thread, other threads:[~2022-01-10 23:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16  9:49 [PATCH v3 0/2] seperate panel power control from panel prepare/unprepare Jitao Shi
2021-11-16  9:49 ` Jitao Shi
2021-11-16  9:49 ` Jitao Shi
2021-11-16  9:49 ` [PATCH v3 1/2] drm/panel: panel-boe-tv101wum-nl6: tune the power sequence to avoid leakage Jitao Shi
2021-11-16  9:49   ` Jitao Shi
2021-11-16  9:49   ` Jitao Shi
2022-01-10 23:34   ` Kevin Hilman
2022-01-10 23:34     ` Kevin Hilman
2022-01-10 23:34     ` Kevin Hilman
2021-11-16  9:49 ` [PATCH v3 2/2] drm/mediatek: control panel's power before MIPI LP11 Jitao Shi
2021-11-16  9:49   ` Jitao Shi
2021-11-16  9:49   ` Jitao Shi

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.