Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp114856ybg; Mon, 8 Jun 2020 18:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycXoWWsfI+rwVpN5ZtWr9O5dKcx99/8udWPpLX2/eL9rmuhseqowNWgORZl1BjZze2NpZz X-Received: by 2002:a05:6402:c1a:: with SMTP id co26mr23742717edb.207.1591664509302; Mon, 08 Jun 2020 18:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664509; cv=none; d=google.com; s=arc-20160816; b=c/D3zNqTCIrKH6s3Jep4jjaMbuM22GvMo8IuSriHBaug6VFx+iX+loEGLY5j6edJj8 MwKnek0ZU5Nb5AgXHPWV0hN7JtM7UMK6lVZPFabeaVkt9cTA6HCIF0qaKGyL7o0KGtEo VXaw10l9ktysepbebjp2e0IqIUSUdlaouth5U63MYQnJSFap9oSgOx80ayJVxL4A1lx/ hqFjknpWwTyie9qajxXK5zFz3LFvx5n0RBgeEtEFzI/LghwFM7bHLl63XYQaBTqzXOaE ZmUOwYR83UfdhAJ3gp1XfC12sm6ocKJS+PpX6Ihn06RqXn59Yvi1NsTiaMrWy1b/mprb E1VQ== 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 :dkim-signature; bh=8NJIlU6zHtj6MkiMftxHUSOQawlhPA/O8HkkXcRr+9s=; b=J3BvYUgcoGsVfMnbLaYeqse2dCA3Ae3VJeidOxG7lcrFseSTfSonjcunTErBvQzytQ OR5aAzZuWc+Paeicm+O8cAWH7AKvu9nEYfSaGS2fN3MhO9oGOUYcivuFdhDxewJoj1hT gEjDpLG/ofCe8CZ/mtXKHEder6Ybat+OyGXmIbEmmiH7/+Q6fP5DWN+BpBCXpDNdDuAN pt2O9K/7gjQu6z8Dp9hKapbxzkodePfQeAwwPOMrE4kfcAU/LT6F7osoUXEHfyopy+54 +bln8A4xdX4/FofsYDN3KwiB4JZ/zhjlGK2EOcenCi5WGONknOJfl2D7+BbIosL8PcOH 7IKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zh3ynFLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt17si13220710ejc.457.2020.06.08.18.01.26; Mon, 08 Jun 2020 18:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zh3ynFLV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbgFIA7q (ORCPT + 99 others); Mon, 8 Jun 2020 20:59:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:53832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbgFHXIa (ORCPT ); Mon, 8 Jun 2020 19:08:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 874EE208B6; Mon, 8 Jun 2020 23:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657710; bh=jMmbglSJ9HsqY9/TfgPULYPabzVlojJgWVf48BoOzOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zh3ynFLVfdi2Yz2Ro4cFdlxoiEYJQq+mtVP0POsrA798y1K2U0eKXnqfBUIinPHUQ 0SuEaU/gGEHSGzyDsIG/WwrjhKgIemHkB2tw0sOcGSn6FaU5UnvvZItpI+ypBd+WSI cPWNUZwXQeTCMlaVLdppK52OEgUTsETUtkdNEsGw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jitao Shi , Chun-Kuang Hu , Sasha Levin , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 106/274] drm/mediatek: set dpi pin mode to gpio low to avoid leakage current Date: Mon, 8 Jun 2020 19:03:19 -0400 Message-Id: <20200608230607.3361041-106-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jitao Shi [ Upstream commit 6bd4763fd532cff43f9b15704f324c45a9806f53 ] Config dpi pins mode to output and pull low when dpi is disabled. Aovid leakage current from some dpi pins (Hsync Vsync DE ... ). Signed-off-by: Jitao Shi Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- drivers/gpu/drm/mediatek/mtk_dpi.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 4f0ce4cd5b8c..2994c63ea279 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include @@ -74,6 +76,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_gpio; + struct pinctrl_state *pins_dpi; int refcount; }; @@ -379,6 +384,9 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi) if (--dpi->refcount != 0) return; + if (dpi->pinctrl && dpi->pins_gpio) + pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); + mtk_dpi_disable(dpi); clk_disable_unprepare(dpi->pixel_clk); clk_disable_unprepare(dpi->engine_clk); @@ -403,6 +411,9 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_pixel; } + if (dpi->pinctrl && dpi->pins_dpi) + pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi); + mtk_dpi_enable(dpi); return 0; @@ -705,6 +716,26 @@ 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->pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(dpi->pinctrl)) { + dpi->pinctrl = NULL; + dev_dbg(&pdev->dev, "Cannot find pinctrl!\n"); + } + if (dpi->pinctrl) { + dpi->pins_gpio = pinctrl_lookup_state(dpi->pinctrl, "sleep"); + if (IS_ERR(dpi->pins_gpio)) { + dpi->pins_gpio = NULL; + dev_dbg(&pdev->dev, "Cannot find pinctrl idle!\n"); + } + if (dpi->pins_gpio) + pinctrl_select_state(dpi->pinctrl, dpi->pins_gpio); + + dpi->pins_dpi = pinctrl_lookup_state(dpi->pinctrl, "default"); + if (IS_ERR(dpi->pins_dpi)) { + dpi->pins_dpi = NULL; + dev_dbg(&pdev->dev, "Cannot find pinctrl active!\n"); + } + } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); dpi->regs = devm_ioremap_resource(dev, mem); if (IS_ERR(dpi->regs)) { -- 2.25.1