Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5026331ybh; Tue, 6 Aug 2019 23:04:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDIab7+zI1E5Oi9aZ9cltd39TUkDR/dUHQSB4s52nCD64s7eH366KmP+SXQs92ocuQv/VW X-Received: by 2002:a17:90a:8c0c:: with SMTP id a12mr6772589pjo.67.1565157855380; Tue, 06 Aug 2019 23:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565157855; cv=none; d=google.com; s=arc-20160816; b=qMaO82Uj7dWJ8SRgjJwLQ56n1xrx8wgWa5LYIf4LsY9sNTzt9B2Wg09kGOkwwz+E3g 51pnrI10OPwHu/DDXtDDJtfRx6k5pzcpUJ20ysXKBFCLlGPzLa5fR2qI2Pwq0rHTHXUC hKXqxzrSdGjyF519AkEq69VhfyphYKUtHthCXm+XWvBh4aUrzzReyP1Hv6exa27E4qKL 4JE89yPDPzPmGFu+NvWLKcvtoTzgjW/Yep0ueNsrnpxFJ3KHSW/IadOSMYc3nmGjp48y vXiwD6jVeQGTjrbQ8ivqBmisCG4iRhryZxFiMpQhqBo3IlIZ6inTr0YM00JmWVkf0u3l zUrQ== 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=c9yvMn9Y0lfGwmnUPbXwS/piXTvrrPhPkfuKaYbGdCs=; b=zoUWp/ZdkDxVosNX8dG7lHhYJ84XCeMUV+MMXe7XzNkMKbMhBVtlgktS7Eh9Ful9si d0IRDDghLdyTKWSgIzH9nopGLgVH5kFT5sjzzLyB7PFqh14Z50uC5zceUrgQr8olxwbE DQLjnM0lveozGEDjT5z5ZPG0OZ8pDFU1/0kQjHXpM1keN4LYRG3k+z2WhL1V/QypyKLx zA0Lp3wM/y1HjiMcTxWsBIonC7HZdJmxpyl9av+WCoy2TKnkf27UCxD1lB6kwk0Aoefz mCWEz8Y0Z2NXTf7kxAmZ+J4Sqe3jEl+LxIXYj0BrP6enmAC8SWt+bl63dK8b0ygpnWM6 29tg== 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 j62si48527785pgd.170.2019.08.06.23.03.58; Tue, 06 Aug 2019 23:04:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbfHGGDU (ORCPT + 99 others); Wed, 7 Aug 2019 02:03:20 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:50329 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726137AbfHGGDT (ORCPT ); Wed, 7 Aug 2019 02:03:19 -0400 X-UUID: 66379fd288374440afeac1fca168d612-20190807 X-UUID: 66379fd288374440afeac1fca168d612-20190807 Received: from mtkcas34.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 564144345; Wed, 07 Aug 2019 14:03:11 +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; Wed, 7 Aug 2019 14:03:09 +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, 7 Aug 2019 14:03:07 +0800 From: Jitao Shi To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , , 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: [PATCH v5 4/4] drm/mediatek: control dpi pins dpi or gpio mode in on or off Date: Wed, 7 Aug 2019 14:02:57 +0800 Message-ID: <20190807060257.57007-5-jitao.shi@mediatek.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190807060257.57007-1-jitao.shi@mediatek.com> References: <20190807060257.57007-1-jitao.shi@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-TM-SNTS-SMTP: 1B2CA2D23DF96E5EB5B80F2CCDC9DF7A23B524F7C9EECA1DDDD30165E22A6FB52000:8 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 device tree. Signed-off-by: Jitao Shi --- drivers/gpu/drm/mediatek/mtk_dpi.c | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 4f2700cbfdb7..83fb0d753f72 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -9,10 +9,12 @@ #include #include #include -#include #include #include +#include #include +#include +#include #include #include #include @@ -71,8 +73,12 @@ 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_gpio; + struct pinctrl_state *pins_dpi; int refcount; bool dual_edge; + bool dpi_pin_ctrl; }; static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e) @@ -384,6 +390,9 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi) if (--dpi->refcount != 0) return; + if (dpi->dpi_pin_ctrl) + pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); + mtk_dpi_disable(dpi); clk_disable_unprepare(dpi->pixel_clk); clk_disable_unprepare(dpi->engine_clk); @@ -408,6 +417,9 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_pixel; } + if (dpi->dpi_pin_ctrl) + pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi); + mtk_dpi_enable(dpi); return 0; @@ -713,6 +725,31 @@ static int mtk_dpi_probe(struct platform_device *pdev) dpi->dev = dev; dpi->conf = (struct mtk_dpi_conf *)of_device_get_match_data(dev); dpi->dual_edge = of_property_read_bool(dev->of_node, "dpi_dual_edge"); + dpi->dpi_pin_ctrl = of_property_read_bool(dev->of_node, + "dpi_pin_mode_swap"); + + if (dpi->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_gpio = pinctrl_lookup_state(dpi->pinctrl, + "gpiomode"); + if (IS_ERR(dpi->pins_gpio)) { + dev_err(&pdev->dev, "Cannot find pinctrl gpiomode!\n"); + return PTR_ERR(dpi->pins_gpio); + } + + pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); + + 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); -- 2.21.0