Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1495161rdb; Sat, 3 Feb 2024 08:26:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIYYAXTxFdzBkMT2QAMQ5kedXz4SEFXKUp8XF0JlLlft8qlkLXsKOu5p1V2zRpmGLRDNRI X-Received: by 2002:a05:6a20:2444:b0:19e:2dd2:1f56 with SMTP id t4-20020a056a20244400b0019e2dd21f56mr2158388pzc.10.1706977568157; Sat, 03 Feb 2024 08:26:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706977568; cv=pass; d=google.com; s=arc-20160816; b=ocUQNWgM0Oz64l5KSG2rvdJTwkNskr9qRH8yPtYFg2zUlpGxrtb16K/JyJNRoGUFxV I7nTBIZjQ1n8LDaRYP1dmdJeqeIAl9TYnjJwWl9l950fm+XPhGHhuaXFHgBIic4qqvi8 NzCPCmKxLayFiAiJYIgPDNeexOCu/x3iSJfh9sBXy0CJgYPAxhVo4zKygvv6TuTGSTd+ Nn8aJkOhCWVwoH8QcLTGZ3+Xc0hfuJB9Rzk0P7OC5Rh+sDkUj74vV/G7s+31Cp8bGzbW cOBDNwqEEysTLfEsdOmxAnoXJ+M6wTPAjZ7Qb4sq3RBpGsKicg2RQj9x+XyFMXSLLnJi sQOg== ARC-Message-Signature: i=2; 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=ToPL14RSULT7QbGvlmdx27Bs8DTvWoRTeHF6hY0RNjY=; fh=TS9YJSdhJLmex+kkfBJd+GBcjU48SZ8dw2Lvl4/pnZA=; b=OlDVGEcQ2O0yahOfV6dHlL6jGNPPF7jzhKUrECtPzY6Do0aeZC3XWM8YnmsRe3SAje ns5HKBseAd8lGjq8b5KsAvrgaIPPn+LgmRb+rlmjztW8l9UsRWK3dYSSdqSghjkYA+RN rpaq14kOoRYc82TVuPPBDHksaPVc1+0fljFS6Afu9Og+b4z6msn3sa79aNbR9YQmIHOa 12bE6+8Mt9YsFaADddbRdCe+NxgliMLo4S0u1sz/0UA5RjwT/NZLxWLjT2yyjNCDlS6e K4YJmemD5z+QsGKgSUnfJPQH58oNcATQzGMVhJUIj8k2sJMHtdSA7mKzsuvNJyKEh9ie m5cg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gekoZkpy; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51181-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVFob44gg6QpIc/ctBvinWYBGHPmA8tjkwSlzRFuLeOv7tQK+8efapxKezY5VoEoAI2HFQp7hNwtsRJL5v2FbOqlflX6PLLYzZ2A5DC/g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g23-20020a63dd57000000b005d8b7c3a00csi3422949pgj.145.2024.02.03.08.26.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 08:26:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gekoZkpy; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51181-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51181-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 D05C5284376 for ; Sat, 3 Feb 2024 16:26:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6B7D5F877; Sat, 3 Feb 2024 16:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gekoZkpy" Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 B5ADF5F848; Sat, 3 Feb 2024 16:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706977538; cv=none; b=NAEPahyGyza/VpQIH8btmOV5qNPMXMxZQ8yQcZRnaOHMnoiiUErxOFXlRwj71+NPTs4Mx4k/HVGkY4LDgEVrFupApOtzosf8unzWS7OX/pbpRjmzVUsNe42f6s6m+ksyfvlDjKKpBILl0vGO1wpBbkkI9EAq42YyCtjLTZ18VZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706977538; c=relaxed/simple; bh=ss8RClTJALLtRnsGtN1dO1Gt0LzZwyG8LN2tBScIzVg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=f3TWev9KeBdHeyGQd73B1XHodIYli2uGTb90HoZ1PDoCDxnm+UhFi8FsdeWeFCmJ8Jx0RpnHrNdaPTBIX281iANNE3mWKJA+HRyAUgSfvNuFzrWJqeVHYKHbPtr2MoxhWwA/klJAZBF1S/vfUoP4XgP9iUSzQi+ydVUgJ0bPAh0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gekoZkpy; arc=none smtp.client-ip=209.85.216.45 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-pj1-f45.google.com with SMTP id 98e67ed59e1d1-29661facbd0so447839a91.1; Sat, 03 Feb 2024 08:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706977536; x=1707582336; 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=ToPL14RSULT7QbGvlmdx27Bs8DTvWoRTeHF6hY0RNjY=; b=gekoZkpyc67VCdNKSwj9756QITA2R6H/JFJVrVxhz1Q6Dfkp3EPtJErAVvZHK2cPMM GJvxYaHOyKLiq11E2ENKTRwdwckqHhm+G6i7tvc7LZ6DKbJbONanIEk7GyaEr6M7Y0F+ mxGHRoBTWsjJaFw6UAU8e556fEa7ExlLPG2i75AfkuYfh85r5sUIZFJyRISMCeVJENpp Rrgsb+uKd84QHJVR3UWLpxN0RfAIcX/XydgIlevuZoCiKzbEq5QiMwyP3yy8RoFe5CAO j3aHp+dhdX2U3WcWzR1cPZRYZX2yuS+D7QBvjnyqfsyESYaOI3+HN32mY7p1lee0UD9b cYYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706977536; x=1707582336; 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=ToPL14RSULT7QbGvlmdx27Bs8DTvWoRTeHF6hY0RNjY=; b=hMYXtFD1BNixRVuyrGFvykgaHuweDfr8zHt4wv0hL3YHDE0nkT+PIfvfKIcx5zapDz rwsS0oLYP6VR8jtg+SAdTOA6487BIcN9dRf6mPGbZYuKtYktaTSK0UgzSy4ID3JcKw6f 1TtWR2K29iwlCMg5STy+pvsIzv32aVpISR67MayL8QEKF4cPQqG2zMuiAQ8QUDf1EEbb uN/NRCZvoKyOgHEpsFR/SSUakpO6zeWbaCWK8rn7vpFJ3jIq4vJEwnWUvI/6/4cDDUE0 hL32YC4vF0DjHsJYIwQ8m9SD+HkcZAk5GpvMWVDpLW6YS2jHEhLeK0Vi9EO2kT3ovoO1 4I5Q== X-Gm-Message-State: AOJu0Yxjmogv7lXJOY1V/olQNG6+5+d4QZIJ8bjIL+wgGpSUQ+PNWhtE +NbU7jRGljE75z6+N9OcNbqhYB0OUd6jV2QRbdrfR06QJsSvfYnn2W/DFH28Vs0= X-Received: by 2002:a17:90b:2384:b0:296:33fd:a020 with SMTP id mr4-20020a17090b238400b0029633fda020mr2390909pjb.1.1706977535926; Sat, 03 Feb 2024 08:25:35 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWvPS/FWM/sb1ofubz1Es6PY4bEottEYGG5ZtQtkNBdJIUA2f++wegfsYG32/QMar0o9LWiutCIFV5mCImGL/qprvA+MdQGusGacmWAFs7JVg+3BgdCvVrASiK6tgwf4Sq7O5jq8S8mtKAJCc/WgSN/u+ZLFMVz4EM= Received: from amiden.localdomain ([2402:e280:2243:161:4f40:49bc:8675:1a83]) by smtp.gmail.com with ESMTPSA id oh14-20020a17090b3a4e00b00295c8bc35e1sm2022708pjb.38.2024.02.03.08.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 08:25:35 -0800 (PST) From: Amitesh Singh To: pavel@ucw.cz, lee@kernel.org, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Amitesh Singh Subject: [PATCH v3] leds: pca963x: Add power management support Date: Sat, 3 Feb 2024 21:55:24 +0530 Message-ID: <20240203162524.343936-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 for pca9633 which enables device sleep and resume on system-wide sleep/hibernation Signed-off-by: Amitesh Singh --- drivers/leds/leds-pca963x.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 47223c850e4b..b53905da3592 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,32 @@ static int pca963x_register_leds(struct i2c_client *client, return ret; } +static int pca963x_suspend(struct device *dev) +{ + struct pca963x *chip = dev_get_drvdata(dev); + u8 reg; + + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1); + reg = reg | BIT(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 = dev_get_drvdata(dev); + u8 reg; + + reg = i2c_smbus_read_byte_data(chip->client, PCA963X_MODE1); + reg = reg & ~BIT(PCA963X_MODE1_SLEEP); + i2c_smbus_write_byte_data(chip->client, PCA963X_MODE1, reg); + + return 0; +} + +static DEFINE_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 +457,7 @@ static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", .of_match_table = of_pca963x_match, + .pm = pm_sleep_ptr(&pca963x_pm) }, .probe = pca963x_probe, .id_table = pca963x_id, -- 2.43.0