Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3568713pxf; Mon, 29 Mar 2021 06:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0fVo6U1rOwy5yoyzId7+o3PvGZ+ZEZJVUiw1dlqEEcucH6YyJ/CUeKWguqReTrRa2Ka71 X-Received: by 2002:a05:6402:31b7:: with SMTP id dj23mr28927784edb.245.1617022852069; Mon, 29 Mar 2021 06:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617022852; cv=none; d=google.com; s=arc-20160816; b=K07oT3y+euIzJJLo1EJT6NO0SVPnGDKXs8Xrf6fjSWriRn7QdDS+JImX3E3xdPnl0v 21AN/mDMkrMFHhm/KReauzS9nnXjiSk0vmzbKLN/X8LmXiz5g/15S0m0hdxS6Y2mn1qs Co9jSYZoQcVCMkBitdhZl28dceodUWnsSlVC3FdR3V+C3jG2BUKpQwJ4ai09COnMwqWx Nk9N6/PUR5tjy71KEHZw0PaxtAppH+xB91oJTsB667Xi8zAZtBh4D6zDEFCUeGp1sltq Jz/7XmqMB369rEAdIdecqrYvyaRpMREymY56X3uXZ25LSnf5eWcvwg/NTp026wg74uLE MO7Q== 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=PSIXRmFBk+PjMaRg1ORkwMJsQqVzAdiySDzsAjkJOnA=; b=niBS9N6ILglXkUMnYoFobAtE8Y+DeCQPdgKFDEfsdNYNsdDRR+mQlLefoVsGJweSQh 5b136iI+SZlrknDsTB+d6ZD5T6r9ecPuDTLg+pXVn5tL/PzDXUEX6VMLfhb/BtRrKb1O vjSLNqLftK1vzsKQWDWObILIDkE+H9chh+Ljd0rmxneoMn0MmKmXqvhSBAcVqpqJWrkW rYRjnMHcBIDgdNT4HV5/2x3JPwWyiW0hS7k35vSRrfQ6bQIlLlPrInyhFjY6YMuIM2Rj 4Q37iEcny5omftZdv3cfotLQm3ghPFIyQUeuxd0bLtW9db1jVkcNl1stW+cXRad/rHXU Gaig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pqgruber.com header.s=mail header.b=XlIEkXaE; 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=REJECT 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 ia10si13127266ejc.92.2021.03.29.06.00.29; Mon, 29 Mar 2021 06:00:52 -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=@pqgruber.com header.s=mail header.b=XlIEkXaE; 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=REJECT sp=NONE dis=NONE) header.from=pqgruber.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbhC2M7K (ORCPT + 99 others); Mon, 29 Mar 2021 08:59:10 -0400 Received: from mail.pqgruber.com ([52.59.78.55]:55426 "EHLO mail.pqgruber.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbhC2M6s (ORCPT ); Mon, 29 Mar 2021 08:58:48 -0400 Received: from workstation.tuxnet (213-47-165-233.cable.dynamic.surfer.at [213.47.165.233]) by mail.pqgruber.com (Postfix) with ESMTPSA id AF5ACC72850; Mon, 29 Mar 2021 14:58:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pqgruber.com; s=mail; t=1617022726; bh=PSIXRmFBk+PjMaRg1ORkwMJsQqVzAdiySDzsAjkJOnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlIEkXaEvoBe2BZDkrK+X2JJ/XanhIAIbz6GaJ90EvnyessGdY6ZEzrDeNRjHPJ3w 01TFniVcm8X1iSD2lN967IHMxWmiWo9c1PRovV5wUcRIInVJiuAO8VTZ+1YFFtfgbG FGULS2rVJvThF/XUkd3p7Jho+CD3U/BjIEhMifu4= From: Clemens Gruber To: linux-pwm@vger.kernel.org Cc: Thierry Reding , Sven Van Asbroeck , u.kleine-koenig@pengutronix.de, linux-kernel@vger.kernel.org, Clemens Gruber Subject: [PATCH v6 3/7] pwm: pca9685: Improve runtime PM behavior Date: Mon, 29 Mar 2021 14:57:03 +0200 Message-Id: <20210329125707.182732-3-clemens.gruber@pqgruber.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329125707.182732-1-clemens.gruber@pqgruber.com> References: <20210329125707.182732-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 fb026a25fb61..4d6684b90819 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c @@ -469,14 +469,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; } @@ -488,7 +493,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.31.1