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
"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 <[email protected]>
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
"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 <[email protected]>
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 <[email protected]>
+ */
+
+#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
Jitao Shi <[email protected]> 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 <[email protected]>
> 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 <[email protected]>
> + */
> +
> +#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
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-mediatek