From patchwork Wed Nov 6 06:40:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jitao Shi X-Patchwork-Id: 11229377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEE2D1864 for ; Wed, 6 Nov 2019 06:40:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B607207FA for ; Wed, 6 Nov 2019 06:40:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B607207FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 983046E187; Wed, 6 Nov 2019 06:40:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailgw02.mediatek.com (unknown [1.203.163.81]) by gabe.freedesktop.org (Postfix) with ESMTP id AFFF76E187 for ; Wed, 6 Nov 2019 06:40:35 +0000 (UTC) X-UUID: 78686ba0df8a4be7b48ecccce2e7562e-20191106 X-UUID: 78686ba0df8a4be7b48ecccce2e7562e-20191106 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1127936845; Wed, 06 Nov 2019 14:40:25 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS33N2.mediatek.inc (172.27.4.76) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 6 Nov 2019 14:40:22 +0800 Received: from mszsdclx1018.gcn.mediatek.inc (172.27.4.253) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 6 Nov 2019 14:40:21 +0800 From: Jitao Shi To: Thierry Reding , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , , , CK Hu Subject: [PATCH] drm/panel: seperate panel power control from panel prepare/unprepare Date: Wed, 6 Nov 2019 14:40:05 +0800 Message-ID: <20191106064005.8016-1-jitao.shi@mediatek.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-SNTS-SMTP: 224C4AAF48E6FE1BCE1C6862644246DA71F19843E559249984CDFA4CC65D93E32000:8 X-MTK: N X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jitao Shi , sj.huang@mediatek.com, linux-mediatek@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some dsi panels require the dsi lanes keeping low before panel power on. So seperate the panel power control and the communication with panel. And put the power control in drm_panel_prepare_power and drm_panel_unprepare_power. Put the communication with panel in drm_panel_prepare and drm_panel_unprepare. Signed-off-by: Jitao Shi --- drivers/gpu/drm/drm_panel.c | 38 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 17 +++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 6b0bf42039cf..e57f6385d2cc 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -131,6 +131,24 @@ void drm_panel_detach(struct drm_panel *panel) } EXPORT_SYMBOL(drm_panel_detach); +/** + * drm_panel_prepare_power - power on a panel's power + * @panel: DRM panel + * + * Calling this function will enable power and deassert any reset signals to + * the panel. + * + * Return: 0 on success or a negative error code on failure. + */ +int drm_panel_prepare_power(struct drm_panel *panel) +{ + if (panel && panel->funcs && panel->funcs->prepare_power) + return panel->funcs->prepare_power(panel); + + return panel ? -ENOSYS : -EINVAL; +} +EXPORT_SYMBOL(drm_panel_prepare_power); + /** * drm_panel_prepare - power on a panel * @panel: DRM panel @@ -170,6 +188,26 @@ int drm_panel_unprepare(struct drm_panel *panel) } EXPORT_SYMBOL(drm_panel_unprepare); +/** + * drm_panel_unprepare_power - power off a panel + * @panel: DRM panel + * + * Calling this function will completely power off a panel (assert the panel's + * reset, turn off power supplies, ...). After this function has completed, it + * is usually no longer possible to communicate with the panel until another + * call to drm_panel_prepare_power and drm_panel_prepare(). + * + * Return: 0 on success or a negative error code on failure. + */ +int drm_panel_unprepare_power(struct drm_panel *panel) +{ + if (panel && panel->funcs && panel->funcs->unprepare_power) + return panel->funcs->unprepare_power(panel); + + return panel ? -ENOSYS : -EINVAL; +} +EXPORT_SYMBOL(drm_panel_unprepare_power); + /** * drm_panel_enable - enable a panel * @panel: DRM panel diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 624bd15ecfab..0d8c4855405c 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -61,6 +61,13 @@ struct display_timing; * the panel. This is the job of the .unprepare() function. */ struct drm_panel_funcs { + /** + * @prepare_power: + * + * Turn on panel power. + */ + int (*prepare_power)(struct drm_panel *panel); + /** * @prepare: * @@ -89,6 +96,13 @@ struct drm_panel_funcs { */ int (*unprepare)(struct drm_panel *panel); + /** + * @unprepare_power: + * + * Turn off panel_power. + */ + int (*unprepare_power)(struct drm_panel *panel); + /** * @get_modes: * @@ -155,6 +169,9 @@ void drm_panel_remove(struct drm_panel *panel); int drm_panel_attach(struct drm_panel *panel, struct drm_connector *connector); void drm_panel_detach(struct drm_panel *panel); +int drm_panel_prepare_power(struct drm_panel *panel); +int drm_panel_unprepare_power(struct drm_panel *panel); + int drm_panel_prepare(struct drm_panel *panel); int drm_panel_unprepare(struct drm_panel *panel);