From patchwork Tue Jan 23 11:59:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 125500 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1711041ljf; Tue, 23 Jan 2018 04:00:45 -0800 (PST) X-Google-Smtp-Source: AH8x227QdWqlRJkYT4zfIAzXhjHXcJWrBBLTIw9D3xuTeg3b4PfpHwFRdWWVsXiDwBIC4mXi6OD2 X-Received: by 10.98.110.202 with SMTP id j193mr10289132pfc.19.1516708845128; Tue, 23 Jan 2018 04:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516708845; cv=none; d=google.com; s=arc-20160816; b=oA3IYUv6aykACiUp4Pqu+QbEmE3SENW7fPxie01gVgTuiDFpGF/uaaWvvwoIVBdTXs il3WsUyTQhnFDXDZ46c1j7hP0uG96MeZjeIhqZ9OOxRW+46M9rrfWU+jgKaWcJ11k4AD +v2nt26KkvEZtQs5DH3Qvgm6hR4P7G0+ddoj7y6kZAkops/pKOb+zJT0rPtrwmRSSVh1 CeE5kIlQ7Jx2JrqxANQAU7Lk0rhanwhDLmeX7a+5Jd/iOBvuONmENyU8nItcvgSVqMr8 fntwwNfFXCNi0ATUzyOVibilpVqGswTUOO0vtUZ0VqN8r6WRPszaRZn5uJb8Fh2SzFHD Y9hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=tNJ+fUpjQBCpJ7+oXcXuMv9jnEVklGbxaHO7Y14v5kM=; b=f2idjqVTZ7Szk+AUz+Td85R+HGxDUMUp1uNqfywVALyqGP0nUI5GoYbLFsDZrDpp7g 9G5yuN7P+s563Z+tBwLg388Ui19XXUbjrbB+tGJKxbLBPriotmREBNxOdi70cXz0XA9L Rxd951nXPN5xlISuDsDqFkYad+ns6xUeuqd0wSeeCw/ydUay1/RQnItVBguOkC8EZoRc W84bHl8bwR0LMjzq8VS/0FaPVs+EgjCbPpMLew+3OB+oNXECn9aB7O6hPQVGjLdjpYDV UtEI7ZnmyV+R9uO8d4ugHeU6ljEA4ytf4oGL4NPTwZDHv/Fb/sX64PxlNbRLJftVgKNp YFLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SWW2acvt; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3-v6si4652450plq.254.2018.01.23.04.00.44; Tue, 23 Jan 2018 04:00:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SWW2acvt; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156AbeAWMAo (ORCPT + 6 others); Tue, 23 Jan 2018 07:00:44 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:44132 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbeAWMAn (ORCPT ); Tue, 23 Jan 2018 07:00:43 -0500 Received: by mail-pg0-f66.google.com with SMTP id m20so121479pgc.11 for ; Tue, 23 Jan 2018 04:00:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=JvNSlIMTyVFAQEYAKhkukqbzC538/hhFEd2DI7mvImM=; b=SWW2acvtEocO6q00oD4Caexi7fNbgExBI1AQqVKL7/UXp6ek1z+1tuuuxum6CnzfWc wD9W6ltjpioijhmOLpofJ/eiBOpLGVyAIKopzphFLw2b3kuWIpJx6BVOfQTlYUfHbTJh +V8m/GbCQ3doqW6myYL9HyL+mH0782CO9XoWI= 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; bh=JvNSlIMTyVFAQEYAKhkukqbzC538/hhFEd2DI7mvImM=; b=ZCYHE1OA0HAW4m0rrFhBCb/Ivi1hzo2CEgLjuclMJI0zD0mNoyzuT69AsnpYdoZpxz lUpO7Ft3ZP8jjZb9fxndfz+k17pw6rHI/S0VNMM/zUTi7H8yJQtBFtugda7O5H/iNPqb cjEVUY3bzoVjS2uJHfX9tUP0GsWDODpdaUeChfIyr4gD5l10JWx2r7Z3gpX1T5yDDW9g 03t9DEbUGDImDgV0phL8HK0tmsry4260rWhsrkDjuFtX7n1QKQfxRhhycmb7n5z5NGW1 RS79SMiiPnGIosQpMjK0/PXSNLk2PTyJlbgi9lMTqqOeBNtQkyh/75io2utmIXzESLj2 XHzg== X-Gm-Message-State: AKwxytc/1uVg97UM9ZRtyqOPAHlV0fA0hr2JVZ65j/ZNjjQ3pjj0KYW+ PMh9jpu4xIE7PpAuoCDfaoOhSZ9BUt8= X-Received: by 2002:a17:902:8b8a:: with SMTP id ay10-v6mr5311042plb.156.1516708842578; Tue, 23 Jan 2018 04:00:42 -0800 (PST) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id p75sm5853049pfi.148.2018.01.23.04.00.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:00:41 -0800 (PST) From: Chunyan Zhang To: Mark Brown , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH V4 1/5] bindings: regulator: added support for suspend states Date: Tue, 23 Jan 2018 19:59:39 +0800 Message-Id: <1516708783-6288-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some systems need to set regulators to specific states when they enter low power modes, especially around CPUs. There are many of these modes depending on the particular runtime state. Currently the regulator consumers are not granted permission to change suspend state of regulator devices, the constraints are configured at startup. In order to allow changes in a vlotage range, we need to add new properties for voltage range and a flag to give permission to change the suspend voltage and suspend on/off in suspend mode. Signed-off-by: Chunyan Zhang Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/regulator/regulator.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 378f6dc..e459226 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt @@ -42,8 +42,16 @@ Optional properties: - regulator-state-[mem/disk] node has following common properties: - regulator-on-in-suspend: regulator should be on in suspend state. - regulator-off-in-suspend: regulator should be off in suspend state. - - regulator-suspend-microvolt: regulator should be set to this voltage - in suspend. + - regulator-suspend-min-microvolt: minimum voltage may be set in + suspend state. + - regulator-suspend-max-microvolt: maximum voltage may be set in + suspend state. + - regulator-suspend-microvolt: the default voltage which regulator + would be set in suspend. This property is now deprecated, instead + setting voltage for suspend mode via the API which regulator + driver provides is recommended. + - regulator-changeable-in-suspend: whether the default voltage and + the regulator on/off in suspend can be changed in runtime. - regulator-mode: operating mode in the given suspend state. The set of possible operating modes depends on the capabilities of every hardware so the valid modes are documented on each regulator From patchwork Tue Jan 23 11:59:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 125503 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1711184ljf; Tue, 23 Jan 2018 04:01:01 -0800 (PST) X-Google-Smtp-Source: AH8x2275WsgZ+wqb9W+5rVX6WD1Ssd4vn1m7dDa1QJugl6mpICERD1ITBRbRWkI/V6U8OBVhmJC2 X-Received: by 2002:a17:902:3084:: with SMTP id v4-v6mr4640601plb.61.1516708861125; Tue, 23 Jan 2018 04:01:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516708861; cv=none; d=google.com; s=arc-20160816; b=f/MTc1It/GBTaJkg2c5OwU2FKq/G2W1LkZtxZ7NsXtXniYxWXDH+R+IKvNHwXwvU7q botk0qk8ZUWVyF8tU/tlQb/jDnOjocsWzqYJ1o09v+HTj5cl1978+n8JMGFceWZX7asq H6GuezRymX0bl9Z8EjxdUNtU9BoEDy97HXxgNVLk/glsrcdk3aHqXDnTo28snM6hzu3V NQdhiGVtUTL/+05NRtzaNEP65AerNzfmoaywiseSThWOnLQLvvrMIFb+WplKcJhYBJsM 42GR0wsMWZOutMLAzgWH3bhj+u1KclexLcH76cZoi5Cv53MmX8HhBXZZE3aeE3fdjqMd jB1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=X6L1uBKnd2nmWo6NCCsYWIOQXZkzfLCnhgSRlvduXic=; b=O2umkIj2mbaRocKF4Y0gsQm4+Uy00umH3eKEbOMeSt6HneA7hSIh/bkqGN6WUk7EDV MiunSn6CBiIM97fYNh7n8qDw/FGzqrWMSVoL9AnUIl80avITYI3QGfG9UaEW/qOH2koV F0AewgpUSepOAk82+/vmYlXC7Vv3TLXeIRamNAR8D8fsVcIiQtRI8fcXA5j2nWNhulUK 3x4xnQ9tdjB1b4i+UdrwhL84DiSCLw0/hItpykncLcI8UG2bxXNaImptMW+LcbRMQJM7 dnuqXopOq8RgqNcdBWOpehM5IGataxyl17vTQEUq+8kKHk4GsEEooqaGRqVGypxnH0x5 MnnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hPuB5XBx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l59-v6si4624140plb.743.2018.01.23.04.01.00; Tue, 23 Jan 2018 04:01:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hPuB5XBx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751382AbeAWMA7 (ORCPT + 6 others); Tue, 23 Jan 2018 07:00:59 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:44155 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbeAWMA4 (ORCPT ); Tue, 23 Jan 2018 07:00:56 -0500 Received: by mail-pg0-f67.google.com with SMTP id m20so121867pgc.11 for ; Tue, 23 Jan 2018 04:00:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PgJpBAWoL6UfAEBRKx+NUQscAn0hvzT2js/EGzJp15w=; b=hPuB5XBxhv+tsegvEHW8c2zxSxLZrM4to0IY4SCB3Lw/1nGj9JPl2/ocUEXTN0u5Rr RNr4WpZQEJ+9z3tPXFU1gkF5K8S13u12YGeiIGlg22tbx5RE8U7/B3dR2vM9pY9EeASa yb0FpYfdhZvsmu1SNHVa3hVp3MCBI4dXOByhw= 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; bh=PgJpBAWoL6UfAEBRKx+NUQscAn0hvzT2js/EGzJp15w=; b=gGcQG0eo7qEoYXAyO2ClZxXNxVlVjt2VJq3vqMl+gg3zJBDtITezmFpK4dh1gfWeZI atUHG1sYyYdxCd+UIsJqv9A3hJHkhhgJqYiP9xOop8xe7s8LmpcVSAOTJ4DUiUGZBQ74 a5feehxb/MfNX97DsNIBfSG+aw1hZZbimEw3oLj7w26soUmk6w5QQHc88BfZbZWiz62p ndghwSxp6At8rzZ0NJSxR39ZNODTeuj+IZXgq+dJiq0hQw1C8KnCbLQm2ZN2Wn65iqqY QgjFl7Y5FK9bLvPE55ZNnkuIPHVd/HCC4n12/saTNEtd9EGt0FqIAc7WvOZBJS7/R3dL LAGQ== X-Gm-Message-State: AKwxytdTqL3tcvWz6qw5pSRhvNFxDkZxYU7D9u5ShQQwHycn7mi/7Few qIUzXeBlM7ahKeIxZ8TLz6OQXw== X-Received: by 10.101.80.204 with SMTP id s12mr8828833pgp.185.1516708856357; Tue, 23 Jan 2018 04:00:56 -0800 (PST) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id p75sm5853049pfi.148.2018.01.23.04.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:00:55 -0800 (PST) From: Chunyan Zhang To: Mark Brown , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH V4 4/5] drivers: regulator: empty the old suspend functions Date: Tue, 23 Jan 2018 19:59:42 +0800 Message-Id: <1516708783-6288-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516708783-6288-1-git-send-email-zhang.chunyan@linaro.org> References: <1516708783-6288-1-git-send-email-zhang.chunyan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Regualtor suspend/resume functions should only be called by PM suspend core via registering dev_pm_ops, and regulator devices should implement the callback functions. Thus, any regulator consumer shouldn't call the regulator suspend/resume functions directly. In order to avoid compile errors, two empty functions with the same name still be left for the time being. Signed-off-by: Chunyan Zhang --- drivers/regulator/core.c | 74 --------------------------------------- include/linux/regulator/machine.h | 5 ++- 2 files changed, 2 insertions(+), 77 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5ea80e9..080c233 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4179,80 +4179,6 @@ void regulator_unregister(struct regulator_dev *rdev) } EXPORT_SYMBOL_GPL(regulator_unregister); -static int _regulator_suspend_prepare(struct device *dev, void *data) -{ - struct regulator_dev *rdev = dev_to_rdev(dev); - const suspend_state_t *state = data; - int ret; - - mutex_lock(&rdev->mutex); - ret = suspend_prepare(rdev, *state); - mutex_unlock(&rdev->mutex); - - return ret; -} - -/** - * regulator_suspend_prepare - prepare regulators for system wide suspend - * @state: system suspend state - * - * Configure each regulator with it's suspend operating parameters for state. - * This will usually be called by machine suspend code prior to supending. - */ -int regulator_suspend_prepare(suspend_state_t state) -{ - /* ON is handled by regulator active state */ - if (state == PM_SUSPEND_ON) - return -EINVAL; - - return class_for_each_device(®ulator_class, NULL, &state, - _regulator_suspend_prepare); -} -EXPORT_SYMBOL_GPL(regulator_suspend_prepare); - -static int _regulator_suspend_finish(struct device *dev, void *data) -{ - struct regulator_dev *rdev = dev_to_rdev(dev); - int ret; - - mutex_lock(&rdev->mutex); - if (rdev->use_count > 0 || rdev->constraints->always_on) { - if (!_regulator_is_enabled(rdev)) { - ret = _regulator_do_enable(rdev); - if (ret) - dev_err(dev, - "Failed to resume regulator %d\n", - ret); - } - } else { - if (!have_full_constraints()) - goto unlock; - if (!_regulator_is_enabled(rdev)) - goto unlock; - - ret = _regulator_do_disable(rdev); - if (ret) - dev_err(dev, "Failed to suspend regulator %d\n", ret); - } -unlock: - mutex_unlock(&rdev->mutex); - - /* Keep processing regulators in spite of any errors */ - return 0; -} - -/** - * regulator_suspend_finish - resume regulators from system wide suspend - * - * Turn on regulators that might be turned off by regulator_suspend_prepare - * and that should be turned on according to the regulators properties. - */ -int regulator_suspend_finish(void) -{ - return class_for_each_device(®ulator_class, NULL, NULL, - _regulator_suspend_finish); -} -EXPORT_SYMBOL_GPL(regulator_suspend_finish); /** * regulator_has_full_constraints - the system has fully specified constraints diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index ce89c55..c4a56df 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -236,12 +236,12 @@ struct regulator_init_data { #ifdef CONFIG_REGULATOR void regulator_has_full_constraints(void); -int regulator_suspend_prepare(suspend_state_t state); -int regulator_suspend_finish(void); #else static inline void regulator_has_full_constraints(void) { } +#endif + static inline int regulator_suspend_prepare(suspend_state_t state) { return 0; @@ -250,6 +250,5 @@ static inline int regulator_suspend_finish(void) { return 0; } -#endif #endif