Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp18907pxu; Tue, 15 Dec 2020 13:31:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzylWTpXayTXymMrle7ORDYRRLBikdLz8j/3ArUrghrftrlQdbvcM/aM1ltYsNdcHmi6HSu X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr25058387ejc.349.1608067899753; Tue, 15 Dec 2020 13:31:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608067899; cv=none; d=google.com; s=arc-20160816; b=rZASAx4OIybtZif7rxSV3+h+QAGMou7VqBcKx50UnoS7NCwPCzvuU0e0PXIKYqKpj1 T+575J2RdN2UbpssAIs72kOMGl+fU5O02OXTrJXNqw3ToaypNvsZVbHwLiTAIB8gY8Ie dwF9qCat8hODLeSmmadW51j35OhH8u0Z6E4tEC0yTZYNBdfvH0swjiWUJNrWKmZbOylj tkPN7arrdgj5AL9LYW9HqDXhWCj4xcDPM161wyH+jfEcMXCZkKLf5UcZumudW/Mf5vSb r7PwB3qs6WfbALsITzWkdK3qdbFESHnYUxyyYkd1RH1dd18poXaIm0FL/aPtjBapZ2t/ 6bog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LxJvhwlUf9lRUgb/k0fnj/AV++LyinyiB1CxyKFrzr8=; b=hHIZGOC7aiyQg793hthJoJL6jcr9Yd97Hfkw+BDdVzoavCtBGAR9M++E5jxp1gZ1t6 rN+m4YSOZH8nqEz9vEGaqu5e2VxJCWZnVzizxmeMM1JtaTaXBNBnF/46TiH+D2r+twKc WOS5uw7xO+KPRvHCJHpRGGbwLOjG5YJd54nnAzLU2FcMeO2o++suvFaibDVMybg8Pujw jBIsPqQO4AQkDBvBBLamRoXNNJoHQhztpyWtbMO8McEU5pziCl04g8i61UXeojFG8k1p ot03muA6YHipvmOsIoPxieZb6poe7mVfJ4pI1nYM57Ur0/59F7Cim9JXc9eld2Bm3V5l XEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqgruber.com header.s=mail header.b=mfAsdYFZ; 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=QUARANTINE sp=NONE dis=NONE) header.from=pqgruber.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si1297239eds.566.2020.12.15.13.31.16; Tue, 15 Dec 2020 13:31:39 -0800 (PST) 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=@pqgruber.com header.s=mail header.b=mfAsdYFZ; 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=QUARANTINE sp=NONE dis=NONE) header.from=pqgruber.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbgLOV2x (ORCPT + 99 others); Tue, 15 Dec 2020 16:28:53 -0500 Received: from mail.pqgruber.com ([52.59.78.55]:54778 "EHLO mail.pqgruber.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgLOV2N (ORCPT ); Tue, 15 Dec 2020 16:28:13 -0500 Received: from workstation.tuxnet (213-47-165-233.cable.dynamic.surfer.at [213.47.165.233]) by mail.pqgruber.com (Postfix) with ESMTPSA id 8B414C727E0; Tue, 15 Dec 2020 22:27:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqgruber.com; s=mail; t=1608067648; bh=LxJvhwlUf9lRUgb/k0fnj/AV++LyinyiB1CxyKFrzr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfAsdYFZv58AHJqoWc1wfwsA49WCN3pPl1+pC+8TKjuj4URm5WPjb/sS2V0aYyiEA ZWFAoFWd/2CbpLWSoWLACE9Ez7D/VOeL7IicfMu83THFBoGzXXd3TZRExa0OmiNch1 /WbYz9y2OQvtdlDzUvFOeYkn+c+sGOU9X5x4zbL0= From: Clemens Gruber To: linux-pwm@vger.kernel.org Cc: Thierry Reding , u.kleine-koenig@pengutronix.de, Sven Van Asbroeck , Lee Jones , linux-kernel@vger.kernel.org, Mika Westerberg , David Jander , Clemens Gruber Subject: [PATCH v5 3/7] pwm: pca9685: Improve runtime PM behavior Date: Tue, 15 Dec 2020 22:22:24 +0100 Message-Id: <20201215212228.185517-3-clemens.gruber@pqgruber.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215212228.185517-1-clemens.gruber@pqgruber.com> References: <20201215212228.185517-1-clemens.gruber@pqgruber.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The chip does not come out of POR in active state but in sleep state. To be sure (in case the bootloader woke it up) we force it to sleep in probe. On kernels without CONFIG_PM, we wake the chip in .probe and put it to sleep in .remove. Signed-off-by: Clemens Gruber --- drivers/pwm/pwm-pca9685.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index b3398963c0ff..7b14447f3c05 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c @@ -467,14 +467,19 @@ static int pca9685_pwm_probe(struct i2c_client *client, return ret; } - /* The chip comes out of power-up in the active state */ - pm_runtime_set_active(&client->dev); /* - * Enable will put the chip into suspend, which is what we - * want as all outputs are disabled at this point + * The chip comes out of power-up in the sleep state, + * but force it to sleep in case it was woken up before */ + pca9685_set_sleep_mode(pca, true); + pm_runtime_set_suspended(&client->dev); pm_runtime_enable(&client->dev); + if (!IS_ENABLED(CONFIG_PM)) { + /* Wake the chip up on non-PM environments */ + pca9685_set_sleep_mode(pca, false); + } + return 0; } @@ -486,7 +491,14 @@ static int pca9685_pwm_remove(struct i2c_client *client) ret = pwmchip_remove(&pca->chip); if (ret) return ret; + pm_runtime_disable(&client->dev); + + if (!IS_ENABLED(CONFIG_PM)) { + /* Put chip in sleep state on non-PM environments */ + pca9685_set_sleep_mode(pca, true); + } + return 0; } -- 2.29.2