From patchwork Tue Jan 16 07:34:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitesh Singh X-Patchwork-Id: 188442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp101419dye; Mon, 15 Jan 2024 23:34:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHAvIZjCGJvUHxtRw95UBgPXUV345oFCvlbybYX8THcUUl0zQrHspu5l3vt8wZXIaVjPU7y X-Received: by 2002:a17:906:57:b0:a2c:cdef:b03c with SMTP id 23-20020a170906005700b00a2ccdefb03cmr4789732ejg.30.1705390495693; Mon, 15 Jan 2024 23:34:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705390495; cv=none; d=google.com; s=arc-20160816; b=rW3wQmD9g2gfSez3m1pMZqVp4ik0iAQSUrk4X1fLVU3R0oKF3aBGHpjeBYDQ1lgbCD cXx7mEoRwCgIc1eJk46GIb5cTwKi7cP2SxYw3L6ps3Cgd8weBEfc6+7x9/P4paBqWDkG 36NwQYNAe0VTiwKokzFQUW2AlYh5Ke2l7tctEJSaEoQZbmnzx+3V40S5pPTjhhahh30H Kha62afBDyhStxpx9DkSe4JDvRgnXPv5+HtgYVZDSd8AxyZN8YMbGYraJg/pJgvr3ojS voPqhC8tG30JDjcxXr72HltbBcx0e7JSQe57Yauq3jggLLsShBk16xqbIpsdQ8d7vHgA eK6g== 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=rDF06Zzvqqqna3Wwn8GfbWo7pzcxs94u77eb9fZ1A8o=; fh=WMTpDzSh8T70HxUELB8ZHxDIFXOZwlflHAjhf3HCTPU=; b=qgrSFXXu+6or+oDpehLaCPwkiSDXkrh3pEo4U2HxC0xfboK0Nf8PcNwppMeQWClHhU gV8mWWwbRKHhb0iwcPc4vJfz89UC43DG7rb2KY5I5gYJ8qzEaKv1aDCs7oqiuicDMjqv /8lqq2ATMPBavdBJ8H6PkgP6JUEK9f2q/iUsCy/lswiEHfUsrxIXMAA10B/Y9KQ6pnOx YV4Tj+nO3yvjlW7pg21GihvmcobkcdCu1EopSiCJVqMZ4WnJOOsXQbW1U8e0rQpT/mEV nTZ5VK53DXmIFeMfGkRWYceGgEj0shVspr32jt4skb0rapaB6GhuyHPB0y4zwEEtSfws e1Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X2UQs8Ku; spf=pass (google.com: domain of linux-kernel+bounces-27081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27081-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d8-20020a1709067f0800b00a2d6b8efb18si2146807ejr.495.2024.01.15.23.34.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:34:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X2UQs8Ku; spf=pass (google.com: domain of linux-kernel+bounces-27081-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27081-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4924D1F24CF5 for ; Tue, 16 Jan 2024 07:34:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8B63111A4; Tue, 16 Jan 2024 07:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X2UQs8Ku" Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 0163010A3B; Tue, 16 Jan 2024 07:34:34 +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-oi1-f174.google.com with SMTP id 5614622812f47-3bd6581bc66so2241604b6e.1; Mon, 15 Jan 2024 23:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705390474; x=1705995274; 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=rDF06Zzvqqqna3Wwn8GfbWo7pzcxs94u77eb9fZ1A8o=; b=X2UQs8KuPyl7EJ4JiaCjGp7JVwDPEaL+9vCScai3EzuBe3TgkIw/jTNsgSwIfI3oEJ gz7ydvxg7NCyU37cs7shcOvi33GTn9jLdtfd9eyQ/4iKptZtnlJRBQURrFP5nEPXroG6 xhgtbD93ioq/txPlMlG6gqFBIWTic1/ffDrh6rtplOFqhtBbJtyaXgHsH5pi4fBqd6FN ZhOEAzCD1mhbKWKj+XqpKWQD0m9nKaB1n/wNBPd3/IcGaVame7kBX6yQbIj56GJ/lcmu 5D/UdTNL3lMlFCVR/VAtMPMGdeAFmuhp3q01zBTXVjbaXaWtilV1HxRLJx5WhaBHbLA1 wmWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705390474; x=1705995274; 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=rDF06Zzvqqqna3Wwn8GfbWo7pzcxs94u77eb9fZ1A8o=; b=YI8Y5GJWpXYp6axQJK01Ks4xbl0tsuBHNAaxayxYoHLy72TaZiHJdyTu3I/v7upEsd z+dF/5AxPYLhTsdiaQjrqI0upns1Uu9yG21EbwN3VR89PEBLdAwwqdCxr0TnpCl28hxR UNh23PCx7I/azq8GABWmgcKplllhQAPmfDBLMFmBgMy6qy1C9AV97eBOkyvvqR82FZ1L oMITgFhxkDwGtyaFVNERPMK4m6Hpkat8aXQUG7tPLK0/cRogiyvEAUIfgB6dv5f0K8vx FizgT4ve7iBRxad1GbQ2lOizs/LPSOdT9vh9KfGNRgguvWZnUrblpB0X3W3Cys6wi7lz UWWQ== X-Gm-Message-State: AOJu0YycJz9yBY1yHInjxMT3X2Z8SyKGn2Fa+yMEDmFCX8wTe03fCloT YZgPdkRzObdVF/5kVqUR7swGzeawQuI= X-Received: by 2002:a05:6808:14c5:b0:3bd:38c1:fdec with SMTP id f5-20020a05680814c500b003bd38c1fdecmr8930182oiw.67.1705390473870; Mon, 15 Jan 2024 23:34:33 -0800 (PST) Received: from amiden.localdomain ([2402:e280:2243:161:fb91:1080:2d1d:9736]) by smtp.gmail.com with ESMTPSA id m11-20020a62f20b000000b006daa809584csm8526886pfh.182.2024.01.15.23.34.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 23:34:33 -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 13:04:21 +0530 Message-ID: <20240116073421.395547-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: 1788231544235170670 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 47223c850e4b..a5804989d756 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,38 @@ 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 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 +463,7 @@ static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", .of_match_table = of_pca963x_match, + .pm = &pca963x_pm }, .probe = pca963x_probe, .id_table = pca963x_id,