Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp290012rdb; Mon, 15 Jan 2024 23:25:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhqoYIYqxp5ab+ma5IYlIl2WczVMC5KiPbqeNC20gsluFyLXJo8Fdy7i1Px1CrIlfsYfhg X-Received: by 2002:a05:6e02:e04:b0:35f:c628:546c with SMTP id a4-20020a056e020e0400b0035fc628546cmr5312004ilk.51.1705389918510; Mon, 15 Jan 2024 23:25:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705389918; cv=none; d=google.com; s=arc-20160816; b=lKggHWFwrDUXT0REDwKmL1EKemAaALjXB6utpTPZk5OPj1OS2wFupAWI9tow0ucihO u84iPXgbZxwQdh5qrRvnupnClXTIZKqdl+CVddQCKu2OHmfk5phoCNm9FKZTTYgaeebN MLt8zeWP2Qs5eb3GhdoyK4vf+1XyixTfUPmHMd6hNoIgeXKpKCP7EKH3Xg8AQBa5G1a3 tYLPYGv2MYiJsWP0FR/e7XWToq5UlvZ8otcwgFEfAUkEIEMZegmj6L2qQ6mpgcZTcPQ5 afrTU95VnrCdRdulDokZFGHLsC4Q0zCYj6gOALUyrvmzrydma7iYYPwN2V3vpJZqr9oJ ufQQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v12-20020a63150c000000b005c68d9545c7si10651259pgl.334.2024.01.15.23.25.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:25:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27071-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27071-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A951E284194 for ; Tue, 16 Jan 2024 07:25:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94FD810A3F; Tue, 16 Jan 2024 07:25:12 +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 Content-Transfer-Encoding: 8bit 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, -- 2.43.0