From patchwork Tue Jun 1 02:31:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 451679 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 3F68CC47083 for ; Tue, 1 Jun 2021 02:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F35A61375 for ; Tue, 1 Jun 2021 02:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbhFACfH (ORCPT ); Mon, 31 May 2021 22:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232268AbhFACfG (ORCPT ); Mon, 31 May 2021 22:35:06 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31A7CC06174A; Mon, 31 May 2021 19:33:26 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id f30so19427302lfj.1; Mon, 31 May 2021 19:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zKZDR8p/L3oeefldCNHrdGkondf8D1T4dxfFGeyIb9I=; b=EDbSPZgN874700gJpT+4dz+/VYX0Av7nGyzOQzOJ+tAEay2tuk8bnBaczhOc1QuuYo LxkoI+e4wC8XzsMODLQJVoZmn/YpeoO/TrJVyjFhBBc2uB1CeqzVDjnrPOXL+lwvMbkb XFqEmdX6jQQH0yZYc0oZoC92XyGIMXxMXU6iwYELviApo6B4CXR+iNWGKpaB1lVf+/XS KvFekkgQv96O9vask4ay+ZAyscs9zfh1IRnQVew8gArrTHI3H0UvIo0vV579tQsy6MBg Ar0YlEmLffc51akmtx56AT8JjR8ecjPoMmrsbc2yI2YPJ1XzfZGURjX3rp0mzcleFLvx PqgQ== 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=zKZDR8p/L3oeefldCNHrdGkondf8D1T4dxfFGeyIb9I=; b=LG4KAVqn5c9HzqjfQXi0/gDVHGOGiypnltO6CHEetBnAV/EsS2i23Zdz4DU6yWplRP nNivAm1xqYynLlYC8jKhsrQg1aQArO0vV1F0kz/vEjiQP1SGvgm/+nAazZj9Yw1gEgBm CCDn6DpK+4frSwyZa94v4ZQkGM7xFACROK87cCLndbO8o1/sz3Nyx8xHo8r1yftUP+kh +bKmQ6z2afUN3cthI2k+hvY8fItGjsFI4alxK56gOB/1gAMNbNY7CMTaSZ7Xh2dE0Hnd m2HOG/dty0yqjlgqX7uV3Qg16CwseowTe7NqeOgTY5zNh9qc2+8DDroia0fYe3smyQ77 lpyQ== X-Gm-Message-State: AOAM530tuQ6spktV0UE7sq8yrA3bsIGDFx5vey0ejXEiYKZnMZ64lbil 7OyRP+y7kNVnwyWuW0kMW+A= X-Google-Smtp-Source: ABdhPJwJkLFu+/LOfRUP0ItGpxKYb2L4n+engi+nXAeAz5+k8jGWK6tVKtkEbCOrerNG7UULP8yw7w== X-Received: by 2002:ac2:52b3:: with SMTP id r19mr8615926lfm.525.1622514804614; Mon, 31 May 2021 19:33:24 -0700 (PDT) Received: from localhost.localdomain (79-139-170-222.dynamic.spd-mgts.ru. [79.139.170.222]) by smtp.gmail.com with ESMTPSA id l21sm107848lfc.28.2021.05.31.19.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 19:33:24 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , =?utf-8?q?Nikola_Milosavljevi=C4=87?= , Ulf Hansson , Peter Geis , Nicolas Chauvet , Viresh Kumar , Stephen Boyd , Matt Merhar , Paul Fertser , Mark Brown , Liam Girdwood , Krzysztof Kozlowski , Mikko Perttunen Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Nathan Chancellor , linux-clk@vger.kernel.org Subject: [PATCH v6 01/14] regulator: core: Add regulator_sync_voltage_rdev() Date: Tue, 1 Jun 2021 05:31:06 +0300 Message-Id: <20210601023119.22044-2-digetx@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210601023119.22044-1-digetx@gmail.com> References: <20210601023119.22044-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Some NVIDIA Tegra devices use a CPU soft-reset method for the reboot and in this case we need to restore the coupled voltages to the state that is suitable for hardware during boot. Add new regulator_sync_voltage_rdev() helper which is needed by regulator drivers in order to sync voltage of a coupled regulators. Acked-by: Mark Brown Signed-off-by: Dmitry Osipenko --- drivers/regulator/core.c | 23 +++++++++++++++++++++++ include/linux/regulator/driver.h | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index e20e77e4c159..aae978c0c148 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4111,6 +4111,29 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, } EXPORT_SYMBOL_GPL(regulator_set_voltage_time_sel); +int regulator_sync_voltage_rdev(struct regulator_dev *rdev) +{ + int ret; + + regulator_lock(rdev); + + if (!rdev->desc->ops->set_voltage && + !rdev->desc->ops->set_voltage_sel) { + ret = -EINVAL; + goto out; + } + + /* balance only, if regulator is coupled */ + if (rdev->coupling_desc.n_coupled > 1) + ret = regulator_balance_voltage(rdev, PM_SUSPEND_ON); + else + ret = -EOPNOTSUPP; + +out: + regulator_unlock(rdev); + return ret; +} + /** * regulator_sync_voltage - re-apply last regulator output voltage * @regulator: regulator source diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4ea520c248e9..35e5a611db81 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -540,6 +540,7 @@ int regulator_set_current_limit_regmap(struct regulator_dev *rdev, int regulator_get_current_limit_regmap(struct regulator_dev *rdev); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay); +int regulator_sync_voltage_rdev(struct regulator_dev *rdev); /* * Helper functions intended to be used by regulator drivers prior registering