Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp216558ybx; Tue, 5 Nov 2019 22:42:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzqxXtOGlkkJsSbd3eLy0BD8kyQCbHFWFeI/9tLLHwajLkLupJB7WDZiMJWliVlX/VIIffj X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr11677067ejh.17.1573022528780; Tue, 05 Nov 2019 22:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573022528; cv=none; d=google.com; s=arc-20160816; b=s0E939yILqxexZG8W28z5salJPo61WqSGn7Vh0Tm61b17S9okziHo0k39ROT5hYSEp CsAokMdaGKkNVtZ4tOMaKfTiaXNRvf+bX5Ro6KCnCoNk07D0QugjDIpHdOjD4+BSxy0r MHavIJlM74fgbEhhLYm6L3mV9vZhoISv13Im51oDqSJe2ThJ/lhxzrSGzNFLBOp43qae Qvg9hKWPJJf9nHnL/X0bzcYDFTi5iyCMspM+9iqweVt9ftWNHrmezN194/5HEUiH3Jnh O6Gg8r1ZZvkXiKikKYrG6JZc7t6ZRoqEWSaMJ1nLlcjOHRPmKtOQW1b8emjyYOMy5NM6 0T5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YgDnWvqLsYl2Uf5oWTsvJbu/jf5bHyvnDXg/zuInjy0=; b=gdHGBoTAdksZE3ZmmStpjfgEHWHC8Rc5awJf3XYlsm1HDtwL+Ult1+2iL/egiSGKYT xR6ECwsEg6CFfq2tGH/37qQYS8SBLd1xh5cdf/fDyivuxNojHf9KoK9wxdbBbw14zxhZ iUIe+XvkFk6PXmG6D5LeB3jTR2CybjQ22AF9139bOqQfZ2jrwrHsKDKAggOihW6sRY3L PR2CafLKDN2mRy6JmDCBWHMMEAcUn+G8IhEgmoYYMoGdz81wThyNbPF8Iji2yULqCDKw RTZXhcbxS4gKFr0mIkm9lVZmWdHCBAkzX4UUV/f439FzrkNKIuGMNXd/6YZ3PRN1Vi0V 4P1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj22si5172978ejb.230.2019.11.05.22.41.44; Tue, 05 Nov 2019 22:42:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731096AbfKFGkn (ORCPT + 99 others); Wed, 6 Nov 2019 01:40:43 -0500 Received: from mailgw02.mediatek.com ([1.203.163.81]:26927 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728724AbfKFGkm (ORCPT ); Wed, 6 Nov 2019 01:40:42 -0500 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 CC: , , Jitao Shi 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-TM-SNTS-SMTP: 224C4AAF48E6FE1BCE1C6862644246DA71F19843E559249984CDFA4CC65D93E32000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.21.0