From patchwork Thu Apr 1 05:32:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 12177191 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 333FEC433B4 for ; Thu, 1 Apr 2021 05:32:15 +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 E424761005 for ; Thu, 1 Apr 2021 05:32:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E424761005 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 3842C6E0C9; Thu, 1 Apr 2021 05:32:11 +0000 (UTC) Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 787256E15F for ; Thu, 1 Apr 2021 05:32:09 +0000 (UTC) Received: by mail-pj1-x102d.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so2463470pjc.2 for ; Wed, 31 Mar 2021 22:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c1cAo8Q6JnwrIFH4GqvcB//z48eg380I+/+VVYBbplQ=; b=VgKK5ZLepHRx7vc1FI63cNrjnwmnj0HJ5skSzcgCRAMpBqZNnIk0WT2R/mxuVDLU2I LCzScLegxgUR4FykNGGWqSjqsodeDAwEIEgL7L2veWyMM55PFoH8SGN5lA7HMtf+139a A+1h0pkmpOiuIBHNeku4I41s8U+AaNdhXCNo8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c1cAo8Q6JnwrIFH4GqvcB//z48eg380I+/+VVYBbplQ=; b=aOzr9wPMPtZ8B2y7+g4446Q6epcvv+FTT2njKPgbewdyn0pcZB/nlEj0LydysV7ZsW awBQtUYC8pDsHlk+NYOyVF0bKXI79nQY8biBi8HXa+fpkGZMtH7fqH8mlgaRiIZdYd4z vZacW7q+ZFsa0IPksu44lM2QRJdhkW0qp7HmNYEadJ9GA0O4/sg79TZ0S/lAHJJ4cE92 M/7nOY4dhae2Lo5nf4eiG9I/1q1oPxV18PxkVpwza90Q2NlJ10PsYu3Xu+kE1KjduLmQ JGsEtJT7/L+17yrpNELKnoJJD46hVDjO/pSz1KyLIgw5h7sEipCCH/fttZqbDr3H53oW oT9Q== X-Gm-Message-State: AOAM5324sf6SfUVlf6ClvX6mbNbLnChMcm65Hf9Uh8WFMuWeDVg3qxdn xzDfpztKzo4OsniXdrJoSYXf3Q== X-Google-Smtp-Source: ABdhPJybYXeNDW+BlCY1C2JhUoEV3Kldg2fII3nPuGiLcfTJI0u4CrMSNybS0oKxNZaNhiDh4LA2rA== X-Received: by 2002:a17:90a:a603:: with SMTP id c3mr7052936pjq.107.1617255129107; Wed, 31 Mar 2021 22:32:09 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:8730:fe8e:d1f8:82c]) by smtp.gmail.com with ESMTPSA id mz11sm3990058pjb.6.2021.03.31.22.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 22:32:08 -0700 (PDT) From: Hsin-Yi Wang To: Sam Ravnborg , Laurent Pinchart , dri-devel@lists.freedesktop.org Subject: [RESEND PATCH v4 2/2] drm/bridge: anx7625: disable regulators when power off Date: Thu, 1 Apr 2021 13:32:02 +0800 Message-Id: <20210401053202.159302-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210401053202.159302-1-hsinyi@chromium.org> References: <20210401053202.159302-1-hsinyi@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Neil Armstrong , David Airlie , linux-kernel@vger.kernel.org, Robert Foss , Rob Herring , Xin Ji Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When suspending the driver, anx7625_power_standby() will be called to turn off reset-gpios and enable-gpios. However, power supplies are not disabled. To save power, the driver can get the power supply regulators and turn off them in anx7625_power_standby(). Signed-off-by: Hsin-Yi Wang Reviewed-by: Robert Foss Reviewed-by: Xin Ji --- drivers/gpu/drm/bridge/analogix/anx7625.c | 34 +++++++++++++++++++++++ drivers/gpu/drm/bridge/analogix/anx7625.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 65cc05982f826..23283ba0c4f93 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -875,12 +876,25 @@ static int sp_tx_edid_read(struct anx7625_data *ctx, static void anx7625_power_on(struct anx7625_data *ctx) { struct device *dev = &ctx->client->dev; + int ret, i; if (!ctx->pdata.low_power_mode) { DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n"); return; } + for (i = 0; i < ARRAY_SIZE(ctx->pdata.supplies); i++) { + ret = regulator_enable(ctx->pdata.supplies[i].consumer); + if (ret < 0) { + DRM_DEV_DEBUG_DRIVER(dev, "cannot enable supply %d: %d\n", + i, ret); + goto reg_err; + } + usleep_range(2000, 2100); + } + + usleep_range(4000, 4100); + /* Power on pin enable */ gpiod_set_value(ctx->pdata.gpio_p_on, 1); usleep_range(10000, 11000); @@ -889,11 +903,16 @@ static void anx7625_power_on(struct anx7625_data *ctx) usleep_range(10000, 11000); DRM_DEV_DEBUG_DRIVER(dev, "power on !\n"); + return; +reg_err: + for (--i; i >= 0; i--) + regulator_disable(ctx->pdata.supplies[i].consumer); } static void anx7625_power_standby(struct anx7625_data *ctx) { struct device *dev = &ctx->client->dev; + int ret; if (!ctx->pdata.low_power_mode) { DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n"); @@ -904,6 +923,12 @@ static void anx7625_power_standby(struct anx7625_data *ctx) usleep_range(1000, 1100); gpiod_set_value(ctx->pdata.gpio_p_on, 0); usleep_range(1000, 1100); + + ret = regulator_bulk_disable(ARRAY_SIZE(ctx->pdata.supplies), + ctx->pdata.supplies); + if (ret < 0) + DRM_DEV_DEBUG_DRIVER(dev, "cannot disable supplies %d\n", ret); + DRM_DEV_DEBUG_DRIVER(dev, "power down\n"); } @@ -1742,6 +1767,15 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->client = client; i2c_set_clientdata(client, platform); + pdata->supplies[0].supply = "vdd10"; + pdata->supplies[1].supply = "vdd18"; + pdata->supplies[2].supply = "vdd33"; + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pdata->supplies), + pdata->supplies); + if (ret) { + DRM_DEV_ERROR(dev, "fail to get power supplies: %d\n", ret); + return ret; + } anx7625_init_gpio(platform); atomic_set(&platform->power_status, 0); diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h index 193ad86c54503..e4a086b3a3d7b 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -350,6 +350,7 @@ struct s_edid_data { struct anx7625_platform_data { struct gpio_desc *gpio_p_on; struct gpio_desc *gpio_reset; + struct regulator_bulk_data supplies[3]; struct drm_bridge *panel_bridge; int intp_irq; u32 low_power_mode;