Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2929105yba; Sat, 18 May 2019 06:06:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7z2HrC1xI0Z6pqmZvIBR4dimdJAX0GlvbKCexV2EGWbSs1qB3N6JlDJ6c1q/e5wrGdlKq X-Received: by 2002:a63:fb02:: with SMTP id o2mr61668882pgh.357.1558184770709; Sat, 18 May 2019 06:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558184770; cv=none; d=google.com; s=arc-20160816; b=K4J3XDNOEFthpCoyID5oGyoJzbIU3bfSh6vnXOogChOBwJwNhqCGiv4+9R917hb+JP kvortYtojOIw6HWRhY8J42vkMIiozwHkj3TgtpmQSiZ77yyhUJf9C8D6R994mqyZPJxf W+u1X1WpJsZoWjIx8hSfUXVVdGzexuN0MbL7kb6y1ep0q/4jbQcEQRkTIGGu2aE26leD fBf5QzWVB0V0cul5NNsWWcGIPEhdRgNbRIIKchyCAOFCvLjEOETXtZtln1frzqdjr+7A dzdxLCJj4lVAetFbO5Otx9Ae26WRPD2Rkm9zgSKCH68gku9Ht8UnE+FD/K9p+ks9z98m oSbg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AGpYiAbMaH4AXpawILW/hjICenFjU9NyqjccDXCl/ng=; b=Tj437/fc0giMLh/awE1Mk5QGVK5QOyGuRE979ks3W5mIsMg5XiOh+lcmrMcLpxuJ0G vrp1+jPUunG5bsxBZUjsu6DdPIPPfEWzzWXN3X45B2kArjfl3YbHjgbf2Jkql2xT/ZqF +Be1QsHf5Z+gR8w3MUpZAtPsyqlxo5j2ur6LzQbGX1u61rzuoh8DH2ZNqi6C3Aawucr6 cbTV0TNXS1DYjfVjgyKBM613IeA+HNfVF+1FZRTx0EOEaRXKlPSBDSz1FM+GI0akkm2o +YwhTm8cCkgR4PCWXEsJq5dinb1PhcRiJ9GNqnxjb+EHuHKRhuI2DjwonQ8U23NH89jR f3Kw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si11767828pgd.558.2019.05.18.06.05.55; Sat, 18 May 2019 06:06:10 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbfERJ4g (ORCPT + 99 others); Sat, 18 May 2019 05:56:36 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:62977 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729688AbfERJ4d (ORCPT ); Sat, 18 May 2019 05:56:33 -0400 X-UUID: b857715442c54e68baa81bb136f7831c-20190518 X-UUID: b857715442c54e68baa81bb136f7831c-20190518 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 346400647; Sat, 18 May 2019 17:56:29 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS33N1.mediatek.inc (172.27.4.75) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 18 May 2019 17:56:27 +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; Sat, 18 May 2019 17:56:26 +0800 From: Jitao Shi To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , , David Airlie , Matthias Brugger CC: Jitao Shi , Thierry Reding , Ajay Kumar , Inki Dae , Rahul Sharma , Sean Paul , Vincent Palatin , Andy Yan , Philipp Zabel , Russell King , , , , , , , Sascha Hauer , , , , , , Subject: [v4 4/5] drm/mediatek: control dpi pins dpi or gpio mode in on or off Date: Sat, 18 May 2019 17:56:17 +0800 Message-ID: <20190518095618.18454-5-jitao.shi@mediatek.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190518095618.18454-1-jitao.shi@mediatek.com> References: <20190518095618.18454-1-jitao.shi@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pull dpi pins low when dpi has nothing to display. Aovid leakage current from some dpi pins (Hsync Vsync DE ... ). Some chips have dpi pins, but there are some chip don't have pins. So this function is controlled by chips driver data. Signed-off-by: Jitao Shi --- drivers/gpu/drm/mediatek/mtk_dpi.c | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 77e6e0f99188..0c4ba0a2be27 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -17,10 +17,12 @@ #include #include #include -#include #include #include +#include #include +#include +#include #include #include #include @@ -79,6 +81,9 @@ struct mtk_dpi { enum mtk_dpi_out_yc_map yc_map; enum mtk_dpi_out_bit_num bit_num; enum mtk_dpi_out_channel_swap channel_swap; + struct pinctrl *pinctrl; + struct pinctrl_state *pins_default; + struct pinctrl_state *pins_dpi; int refcount; }; @@ -118,6 +123,7 @@ struct mtk_dpi_conf { u32 reg_h_fre_con; bool edge_sel_en; bool dual_edge; + bool dpi_pin_ctrl; }; static void mtk_dpi_mask(struct mtk_dpi *dpi, u32 offset, u32 val, u32 mask) @@ -392,6 +398,9 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi) if (--dpi->refcount != 0) return; + if (dpi->conf->dpi_pin_ctrl) + pinctrl_select_state(dpi->pinctrl, dpi->pins_default); + mtk_dpi_disable(dpi); clk_disable_unprepare(dpi->pixel_clk); clk_disable_unprepare(dpi->engine_clk); @@ -416,6 +425,9 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_pixel; } + if (dpi->conf->dpi_pin_ctrl) + pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi); + mtk_dpi_enable(dpi); return 0; @@ -724,6 +736,27 @@ static int mtk_dpi_probe(struct platform_device *pdev) dpi->dev = dev; dpi->conf = (struct mtk_dpi_conf *)of_device_get_match_data(dev); + if (dpi->conf->dpi_pin_ctrl) { + dpi->pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(dpi->pinctrl)) { + dev_err(&pdev->dev, "Cannot find pinctrl!\n"); + return PTR_ERR(dpi->pinctrl); + } + + dpi->pins_default = pinctrl_lookup_state(dpi->pinctrl, + "default"); + if (IS_ERR(dpi->pins_default)) { + dev_err(&pdev->dev, "Cannot find pinctrl default!\n"); + return PTR_ERR(dpi->pins_default); + } + + dpi->pins_dpi = pinctrl_lookup_state(dpi->pinctrl, "dpimode"); + if (IS_ERR(dpi->pins_dpi)) { + dev_err(&pdev->dev, "Cannot find pinctrl dpimode!\n"); + return PTR_ERR(dpi->pins_dpi); + } + } + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); dpi->regs = devm_ioremap_resource(dev, mem); if (IS_ERR(dpi->regs)) { -- 2.21.0