From patchwork Tue Jan 16 07:24:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitesh Singh X-Patchwork-Id: 188438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp98349dye; Mon, 15 Jan 2024 23:25:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGglVISNyP8qm3mAxu+37Whr19GbHv1yxRkV5+fQGFzINcoIlzhCnr6Dx8X2GKqNvlqdXF6 X-Received: by 2002:a05:6808:3986:b0:3bd:5ac5:cf07 with SMTP id gq6-20020a056808398600b003bd5ac5cf07mr7913063oib.36.1705389925430; Mon, 15 Jan 2024 23:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705389925; cv=none; d=google.com; s=arc-20160816; b=Zj5LZbXCM+IZOfg6AGqmtWqPl0/Yc3D3+3W94rguJLic8IbYTZK/jrkXaII5gRR32h k1fe8NVC6huFaxw+MQzxtN6DvEhW+Bmo4UgBz0WF4oN9OkPXiXESGXLTImyoBlWax6hI xt9wCVjgwmEQobIuQaRFvlZ34/dpM7pAe/ze3Rsi0FCpLR3xrbrMyJEDXFEzEHbILRWD VHFUMwRsvjQSZ4vYBx11D3oI9JcpECYInaq2rBX6n/mEoihyrY5XPHCSc63xTRlsy1sp jydTCKhfuIZWUebvHUFrvNo8vBBg4YK34i811qURJSSe10CNxY1s8rNCXWb4JFfYXRSB zRqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=IFU8V44giJ9TqpBstuJqgsawkBd+gwhzF3e12FlfS0Q=; fh=WMTpDzSh8T70HxUELB8ZHxDIFXOZwlflHAjhf3HCTPU=; b=CU8CNBLMYrj0Bd5h5++7c6KW16BJMmq+tks3ZrgniHSZxsxvLFb5vL/hY9MbXztHlM 5Lxxg4Z8z+Pl2S7EzSsOJbZ9sZ6jsWc7JP9361+SqnSCQ/ih/BXQ89Ge/kD/RC15BAsL 8AOysCKmjCBt/jvChN+7y6ZGNAGe2H4qRV9UOAbgWZgKks3sVirzlCCzerDvStyD3nKD kcU7B3U9lIAMqb6P6COICpPVOUX5wzbd+Qx3Sz/yVcmeKzOfZdKDsHNTravMB1rbj3Yt Qq0EsVNsdqtFXHPfQkll3yUMJiZuQ6L723uKD7FS098TB1cZ79zlZJK8tLo7DuJojiAm U9uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LViGTcfc; spf=pass (google.com: domain of linux-kernel+bounces-27071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w4-20020a05620a148400b00783159be85esi9130561qkj.550.2024.01.15.23.25.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:25:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LViGTcfc; spf=pass (google.com: domain of linux-kernel+bounces-27071-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 39ECB1C2308B for ; Tue, 16 Jan 2024 07:25:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60F96111A1; Tue, 16 Jan 2024 07:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LViGTcfc" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 984CF10A30; Tue, 16 Jan 2024 07:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6d99980b2e0so7865739b3a.2; Mon, 15 Jan 2024 23:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705389910; x=1705994710; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IFU8V44giJ9TqpBstuJqgsawkBd+gwhzF3e12FlfS0Q=; b=LViGTcfc+2hEbvVLqgu7Ab/c5GFEbJ0/EUnCWV8lyOw3B3ADs4nF0PiQZLFJ4QUIbX LEYWIC1n0zN1821+g0ruLZZVispET4bAdN4+YeDk/Az0VD/GQcdeehj5PjAWdR/LT+Ht tM5+huWXgNpzCMnp6RhYnEQERtanmoA1nGMcKsfYQw+pwcsfvb5F7DTkCxGNLb6guRgh EirO36KzzV/6aL+XjG65uWUP0r7cfO+ayaRmIUCebMT09e2Ji39CN9tlsLaU+PYdwvtr kr8/dixocCYYraGeDgyzAHk0pAhn7HmZy46gPhmJZTI47M7/urdd2aMl38etDGzqLq3r qdLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705389910; x=1705994710; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IFU8V44giJ9TqpBstuJqgsawkBd+gwhzF3e12FlfS0Q=; b=gI/ZxjuK+9HISimxIVUeBvUvIQqs8bLKj0DioJBHj/HE3vsuZcIa0YFIMso1Xe9JsK l+NMffYCwATkuFGs1Fb3Kzp6yM6emerjipkd6nDXrC3/xAKSlK9ffoSV8mydpnS9hoqo ZmdpqCbF740/veswIOWihUsrKWED3G9K1/FZ45oR+vKvdrm8yn3LZs7cd6YJGdwtNNEk KmEZUo13xnJx7WIRHSEKfEoUnCoPyS7PSRjOjE1ch200ohYI7oCuGODPmlPMXsDOEX3X an1XFMqUjn8aZ92sAH+VJwfX/ceCUNTxanAgz5CyNP/0ZKt2M18S61rOt3JlEnjmxVBD tbyw== X-Gm-Message-State: AOJu0Yz7nRa9IUfr2RL8YbBbmtPSbmNR9T4XCe14LU4w/D9BIJRzeOhI C62H4yx9nNpuZZeIjjeP6xI= X-Received: by 2002:a05:6a00:b4c:b0:6d9:b075:a7d6 with SMTP id p12-20020a056a000b4c00b006d9b075a7d6mr9267851pfo.19.1705389909792; Mon, 15 Jan 2024 23:25:09 -0800 (PST) Received: from amiden.localdomain ([2402:e280:2243:161:4f40:49bc:8675:1a83]) by smtp.gmail.com with ESMTPSA id t12-20020a056a00138c00b006d9ecb8e956sm8853148pfg.173.2024.01.15.23.25.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:25:09 -0800 (PST) From: Amitesh Singh To: pavel@ucw.cz Cc: lee@kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Amitesh Singh Subject: [PATCH] leds/pca963x: implement power management Date: Tue, 16 Jan 2024 12:54:57 +0530 Message-ID: <20240116072457.383438-1-singh.amitesh@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788230946475665206 X-GMAIL-MSGID: 1788230946475665206 This implements power management in upstream driver for pca9633 which enables device sleep and resume on system-wide sleep/hibernation Signed-off-by: Amitesh Singh --- drivers/leds/leds-pca963x.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 47223c850e4b..2474e40d8479 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -39,6 +39,7 @@ #define PCA963X_LED_PWM 0x2 /* Controlled through PWM */ #define PCA963X_LED_GRP_PWM 0x3 /* Controlled through PWM/GRPPWM */ +#define PCA963X_MODE1_SLEEP 0x04 /* Normal mode or Low Power mode, oscillator off */ #define PCA963X_MODE2_OUTDRV 0x04 /* Open-drain or totem pole */ #define PCA963X_MODE2_INVRT 0x10 /* Normal or inverted direction */ #define PCA963X_MODE2_DMBLNK 0x20 /* Enable blinking */ @@ -380,6 +381,42 @@ static int pca963x_register_leds(struct i2c_client *client, return ret; } +#ifdef CONFIG_PM_SLEEP +static int pca963x_suspend(struct device *dev) +{ + struct pca963x *chip; + u8 reg; + + chip = dev_get_drvdata(dev); + + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1); + reg = reg | (1 << PCA963X_MODE1_SLEEP); + i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg); + + return 0; +} + +static int pca963x_resume(struct device *dev) +{ + struct pca963x *chip; + u8 reg; + + chip = dev_get_drvdata(dev); + + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1); + reg = reg & ~(1 << PCA963X_MODE1_SLEEP); + i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg); + + return 0; +} +#endif + +static const struct dev_pm_ops pca963x_pmops = { + SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume) +}; + +static SIMPLE_DEV_PM_OPS(pca963x_pm, pca963x_suspend, pca963x_resume); + static const struct of_device_id of_pca963x_match[] = { { .compatible = "nxp,pca9632", }, { .compatible = "nxp,pca9633", }, @@ -430,6 +467,7 @@ static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", .of_match_table = of_pca963x_match, + .pm = &pca963x_pmops }, .probe = pca963x_probe, .id_table = pca963x_id,