Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3385052rdb; Sun, 10 Dec 2023 03:47:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNB+FvSBX2aWGkk4NEjgDwtnR6ijJaAZFx4W26gG09crGm9ZLPVGbLQzzLdKF0y6KSG6EQ X-Received: by 2002:a17:90a:bd11:b0:286:a4fc:9f5c with SMTP id y17-20020a17090abd1100b00286a4fc9f5cmr2062551pjr.25.1702208836664; Sun, 10 Dec 2023 03:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702208836; cv=none; d=google.com; s=arc-20160816; b=OrXfi92SyFow0mn4W+cgV63T5gIeKRmVj8UzN0hYemLb41mn/nQGZ/iQVFBcSW4IC/ 4MWvt+0STsBZLNty9LwZwMfVtffJJ68/JAua+QqCVAUz5gV+yiFyvIOUxOOT9jjyAXlx Qx1st50I519Rvk++pxFMbPZXbWoCEY+355o7yIcaQvyQAOoE2ojM42+0bxCl+79PXsbn LPwXlq4ZmLYag1nWtYVcARMmWUhlHiPSygzYQjE0v4TGfACWotnwFGWNqIoIwTM/KAxu fU4r1yIRbpeIXI//6JQP9AW0WjM0gWBquKNlzG59WeSa4aoCrFQvJ48pDqjQ2UEFDpX6 7r7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject:from :content-language:user-agent:mime-version:date:message-id :dkim-signature; bh=cYrj7YLRRwrzGfDcX9P83UR5bzTmRqcF6ZHNEAxJQ20=; fh=zsBxv+28eS9P0xom3tuJBeMXpp/H3hS6b/+i6/r6+n4=; b=I560UhA5K9EUQSDvDd1txi4RMxar6/37iUZtbg/UZHxf46TARdMz9ZaFf5c6NWa+Xk 5jADCjMXMDIFBVLzg+WloclR7meCjvlFlHuToQW1Pbo3iDeAdwfXhMf/aig1ljrLXqVy FxCjBW2t3GcgmJFwujbldRRXKkF0CSD//KaFr9sAO07rM5FoPHU3h40uWDetZfz4FG1K 3whla5fjs3lXVFU6BqRyF+QxBlULHxaJsKcimBx7zriAVaJoIpL9IjL+9DuimuEDUZh4 y/o7godzJDGDE3QrNHHn9bOr4FfWCxOfnCrheyvcLMKPjfHx1Ryrb4g2hyydb3dZjcWf D1ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MRZk640C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id fh24-20020a17090b035800b00285ebeed85fsi5665228pjb.123.2023.12.10.03.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 03:47:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MRZk640C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2A3FF8087DC2; Sun, 10 Dec 2023 03:47:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjLJLqy (ORCPT + 99 others); Sun, 10 Dec 2023 06:46:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjLJLqx (ORCPT ); Sun, 10 Dec 2023 06:46:53 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8540EFF; Sun, 10 Dec 2023 03:46:59 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d0a5422c80so30802445ad.3; Sun, 10 Dec 2023 03:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702208819; x=1702813619; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=cYrj7YLRRwrzGfDcX9P83UR5bzTmRqcF6ZHNEAxJQ20=; b=MRZk640CVq3689f3oKKHZvPMh3vGIGcNaJ1b74Wq0FeegfiePX3Gy1aVEYPQWjMLFu yHqAciYTEzhZpLm9fXD8d0FS3OW+mUJASpxld4SOInn8eyWdwfrysWd9gTNjstsYpuMy YL91PE6s4k9ODtniz0FU58f+KTZBe4LUfy89y02rMbtS0AaBXCNvWS8BwRUB49FSylIF pao9JYF3sjk5uvMwvkbRorNUpp+ZJuVvUyat9mXPyiUUK0nTiAgAx8kLRyVsP2GC8lMS 8OQsw799wqSqeXCWkC1RNwmwB63ce5f+WvzXj2XxQEFRWLhvzatpLn86Pt57CziORdG6 wYbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702208819; x=1702813619; h=content-transfer-encoding:cc:to:subject:from:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=cYrj7YLRRwrzGfDcX9P83UR5bzTmRqcF6ZHNEAxJQ20=; b=R4EGO5odPEJAVpkRY4YfMdo3Zx6LU+9WtYBYKgk6TG2MC1uGvJaerZ/aXd6TAo0R94 kwzVtHLiNV8/zGmVQ6zJccPGqMv3iMnA81MtqEXVuzWseA5TVck2DbIJ6ie0E41X8R/w ZtxsUDscNigeByhORzYjWsBaziWnbv5h79w6cWyVloGyI/mogSJngb9rvsHOrZH80Dvu 5KD9nxFyDVk+z+sL4aKR2fKetVrqX6qadmN0RWv9BiZVNObmXr2Xu/UlQKY1P3bUnm+L OFxXM+lusbsZxZMF+45IHcpxm2lladXYnVzztxuM5opBKU9LAY/I5Qy4h60QCbbkRYKI DCVg== X-Gm-Message-State: AOJu0YxOiufr9DGoU0W5123B9vs59Gz3CqJS3qK0S/BhDpS6MLzoOEUi Z6Kel5HfB1ZpXko31TtvESCjmAQpYM8C3g== X-Received: by 2002:a17:903:2311:b0:1cf:c42c:cfbd with SMTP id d17-20020a170903231100b001cfc42ccfbdmr3432116plh.0.1702208818896; Sun, 10 Dec 2023 03:46:58 -0800 (PST) Received: from [192.168.238.123] ([103.208.68.40]) by smtp.gmail.com with ESMTPSA id gc4-20020a17090b310400b00288622137dfsm6331921pjb.5.2023.12.10.03.46.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Dec 2023 03:46:58 -0800 (PST) Message-ID: <881c6ba1-1701-41be-a4ac-81cdca5f0eea@gmail.com> Date: Sun, 10 Dec 2023 17:16:52 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Amitesh Singh Subject: [PATCH] feat(kernel/pca963x): implement power management To: Pavel Machek Cc: Lee Jones , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 10 Dec 2023 03:47:14 -0800 (PST) From a22dbd7390ce875e81d67f14f05f593d7f03d5c1 Mon Sep 17 00:00:00 2001 From: Amitesh Singh Date: Fri, 8 Dec 2023 15:08:33 +0530 Subject: [PATCH] feat(kernel/pca963x): implement power management 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 | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 47223c850e4b..462f917dc986 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,45 @@ static int pca963x_register_leds(struct i2c_client *client, return ret; } +#ifdef CONFIG_PM +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; +} + +static const struct dev_pm_ops pca963x_pmops = { + SET_SYSTEM_SLEEP_PM_OPS(pca963x_suspend, pca963x_resume) +}; + +#define PCA963X_SMBUS_PMOPS (&pca963x_pmops) + +#else +#define PCA963X_SMBUS_PMOPS NULL +#endif + static const struct of_device_id of_pca963x_match[] = { { .compatible = "nxp,pca9632", }, { .compatible = "nxp,pca9633", }, @@ -430,6 +470,7 @@ static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", .of_match_table = of_pca963x_match, + .pm = PCA963X_SMBUS_PMOPS }, .probe = pca963x_probe, .id_table = pca963x_id, -- 2.43.0