From patchwork Fri Jan 27 12:55:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Aaltonen X-Patchwork-Id: 1732850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P3Hd20mY2z23hm for ; Fri, 27 Jan 2023 23:56:06 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pLOGo-0007X7-Kg; Fri, 27 Jan 2023 12:55:54 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pLOGG-0006lt-0O for kernel-team@lists.ubuntu.com; Fri, 27 Jan 2023 12:55:20 +0000 Received: from bryant.. (mobile-user-c1d2e1-113.dhcp.inet.fi [193.210.225.113]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 9F4073F188 for ; Fri, 27 Jan 2023 12:55:19 +0000 (UTC) From: Timo Aaltonen To: kernel-team@lists.ubuntu.com Subject: [PATCH 16/16] iio: light: cm32181: Add PM support Date: Fri, 27 Jan 2023 14:55:11 +0200 Message-Id: <20230127125511.110394-17-tjaalton@ubuntu.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230127125511.110394-1-tjaalton@ubuntu.com> References: <20230127125511.110394-1-tjaalton@ubuntu.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Kai-Heng Feng BugLink: https://bugs.launchpad.net/bugs/1981773 The read on in_illuminance_input keeps at 0 after system sleep. So add proper suspend and resume callback to make the sensor keep working after system sleep. Signed-off-by: Kai-Heng Feng Link: https://lore.kernel.org/r/20220707000151.33381-1-kai.heng.feng@canonical.com Signed-off-by: Jonathan Cameron (cherry picked from commit 68c1b3dd5c48b2323067f8c1f0649ae2f31ab20b) Signed-off-by: Timo Aaltonen --- drivers/iio/light/cm32181.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c index 97649944f1df..edbe6a3138d0 100644 --- a/drivers/iio/light/cm32181.c +++ b/drivers/iio/light/cm32181.c @@ -460,6 +460,8 @@ static int cm32181_probe(struct i2c_client *client) return PTR_ERR(client); } + i2c_set_clientdata(client, indio_dev); + cm32181 = iio_priv(indio_dev); cm32181->client = client; cm32181->dev = dev; @@ -486,6 +488,25 @@ static int cm32181_probe(struct i2c_client *client) return 0; } +static int cm32181_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD, + CM32181_CMD_ALS_DISABLE); +} + +static int cm32181_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev)); + + return i2c_smbus_write_word_data(client, CM32181_REG_ADDR_CMD, + cm32181->conf_regs[CM32181_REG_ADDR_CMD]); +} + +DEFINE_SIMPLE_DEV_PM_OPS(cm32181_pm_ops, cm32181_suspend, cm32181_resume); + static const struct of_device_id cm32181_of_match[] = { { .compatible = "capella,cm3218" }, { .compatible = "capella,cm32181" }, @@ -506,6 +527,7 @@ static struct i2c_driver cm32181_driver = { .name = "cm32181", .acpi_match_table = ACPI_PTR(cm32181_acpi_match), .of_match_table = cm32181_of_match, + .pm = pm_sleep_ptr(&cm32181_pm_ops), }, .probe_new = cm32181_probe, };