From patchwork Wed Nov 22 18:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Eichenberger X-Patchwork-Id: 168501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1520994vqb; Wed, 22 Nov 2023 10:18:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXajnpsUlxqzs6UTjzjcVwLnxQXu8ZzRfqyyc2qnoe5+Fl3H++jWYogyy8lDMSSPgUQZ2s X-Received: by 2002:a05:6a20:e30b:b0:187:b5b8:f438 with SMTP id nb11-20020a056a20e30b00b00187b5b8f438mr3008002pzb.18.1700677130776; Wed, 22 Nov 2023 10:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677130; cv=none; d=google.com; s=arc-20160816; b=e9OKupQUN7kgwl56qoHAEl7jWAleoIItgVEaCgiJQfKzEzsjA+bLIUJqd7Zy8z/5Pj jJvVlpU4HmpwMeYcR0eno1t1eXdbjRmvA2sMOXtggIbLxlAfcrG3dwDi0YTSMVB5SeOx TtsrROZL7J3Cd+dlbHZUlJ7nUIDuUkF3hrinWehkE1dDWh0iQZSU9xQX5vztThHNDxSH WrM2YqWYZOhjswQgDRsb2UabWh4JiVmY9NnMxGV0VR2mW5zTHc9RXhzsmFnxZyd3N12c 0BtXuZkY07rHHek/FOOsPFlx8C0+sndy8MIT9O1poeugghbK6iQsppht0af7E0dMKeju zIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DNKke+f9nL2R7UOg+skl46azWZAH5Kx0OODrdJmgO9Y=; fh=afdq1ZTkXV/5uxq9vt83sEwwOtYJSk4+4s0NMYraqTQ=; b=kHN1LlxDqpvgqRYrS4W3+h1RyVUrUrsnFU9ClcJN4rsXAMMRAElPIhdf8g7Z4fSrjb 2GyS//3Si6ff/7WYgYDCpGcT7XTQGL0S0wlMmSywJocAMRh25IBzRc0MOGFr9K1ZyGg2 H5D2hblBe8Kl8ZtL+Bh67fVvTHSrarLXRjFsjgQzEWCatYkHkkPY1MB5VCBvhbaWUpS5 m6H3TbwM+4OKvgb/nrdjEI/r1mv9ilsSrxXnVpYUoTX6SMk9cxINr8LGCFS0kSsLgrZY 77xAQVG2dZACpcYnpRe6fYcMjDcNcuYLL+2UmYGn/7moWp9mdBnf7xU40E26jEyhw/bQ ewrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KGIbPNBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s60-20020a17090a2f4200b002791bfc67bdsi97231pjd.41.2023.11.22.10.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:18:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KGIbPNBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id A692380BC503; Wed, 22 Nov 2023 10:16:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231744AbjKVSQT (ORCPT + 99 others); Wed, 22 Nov 2023 13:16:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230510AbjKVSQR (ORCPT ); Wed, 22 Nov 2023 13:16:17 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CE1D101; Wed, 22 Nov 2023 10:16:14 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a00a9c6f283so4230866b.0; Wed, 22 Nov 2023 10:16:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700676972; x=1701281772; 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=DNKke+f9nL2R7UOg+skl46azWZAH5Kx0OODrdJmgO9Y=; b=KGIbPNBJr5FbJgdMDDDsnN38tkqOgR8odObVsNx0C/MtxAk0IGNu+C6Mxi8/22ZfQw 3/KUBKGD/zeOT8+7DwUUQl11qgHp9BVzAr4Iy8IqsbolUPITkN3KdkmbEQSiAEFtpSA2 /cl4N5c3ZsqgsnNhjgo9+gJQb8U3zvDOobHoSkkUceAaM1nLvmActCjxiNvS21O5cu4n //Quh5+bM7OLaXxXxMyAWFubKglRLydV0EetQ//4UD2tdVRtbDZ4tw8tf68y+npDg9/F 8AKo82XHc7l9MmGxFLtVZ3LpPafH/jvK9vnFB0Gfmjw+DvNAcHwB726wTFYfGQRol9l6 yeLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700676972; x=1701281772; 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=DNKke+f9nL2R7UOg+skl46azWZAH5Kx0OODrdJmgO9Y=; b=ez93Cnh7GHG0HB4EYg7gdBZmSfaBYkMFF20CZX8nidkHvRv7++ktTOeyMes9XyPFcl rOR8dm8Z+ZrE9ItSHMyfcQ6AbaKek5lBUi3KzopnEXNsV5K45i6ykZeXdt+Q0iLnQhlG OkE5PqUjfZANRa/LUI5XZYCt8/6degByKU1OnCR4/+JkBfnxsbIKjqXF11SfNOWHSPrj 75brDnPo6lhqvVvPEUMymU1yOoa13uFO4ReR0o9PxDndgUFnQOkoC0vF4c7Ssm13i/ev m6m3FNJO3Wk18DUTewM4d4E9ZCFuHcJYNElIqjKQ5EMH6V/NoVuvyBHhStUOgKq110l9 xqXA== X-Gm-Message-State: AOJu0YyBx2wz2cBUl1sQtHautu5HeIEft+U8dlEzdf9mf/5alKyvKlD8 hy33CCq55kaq4uZwSF3Trs4= X-Received: by 2002:a17:907:c002:b0:9fd:deec:a273 with SMTP id ss2-20020a170907c00200b009fddeeca273mr2574627ejc.25.1700676972221; Wed, 22 Nov 2023 10:16:12 -0800 (PST) Received: from eichest-laptop.lan ([2a02:168:af72:0:e883:3641:f460:3a14]) by smtp.gmail.com with ESMTPSA id e23-20020a1709062c1700b009fc0c42098csm44682ejh.173.2023.11.22.10.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:16:11 -0800 (PST) From: Stefan Eichenberger To: a.zummo@towertech.it, alexandre.belloni@bootlin.com Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rtc: rv8803: Add power management support Date: Wed, 22 Nov 2023 19:16:11 +0100 Message-Id: <20231122181611.164792-1-eichest@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:16:18 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783289223059737064 X-GMAIL-MSGID: 1783289223059737064 Add power management support to the driver. This allows a SoC to wake from suspend using the nINT provided by the RTC. Only register it as a wakeup device if the interrupt is provided and handled. Signed-off-by: Stefan Eichenberger --- drivers/rtc/rtc-rv8803.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index 1a3ec1bb5b814..11e6b0d31f5d7 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c @@ -17,6 +17,7 @@ #include #include #include +#include #define RV8803_I2C_TRY_COUNT 4 @@ -607,6 +608,28 @@ static int rv8803_regs_configure(struct rv8803_data *rv8803) return 0; } +static int rv8803_resume(struct device *dev) +{ + struct rv8803_data *rv8803 = dev_get_drvdata(dev); + + if (rv8803->client->irq > 0 && device_may_wakeup(dev)) + disable_irq_wake(rv8803->client->irq); + + return 0; +} + +static int rv8803_suspend(struct device *dev) +{ + struct rv8803_data *rv8803 = dev_get_drvdata(dev); + + if (rv8803->client->irq > 0 && device_may_wakeup(dev)) + enable_irq_wake(rv8803->client->irq); + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(rv8803_pm_ops, rv8803_suspend, rv8803_resume); + static const struct i2c_device_id rv8803_id[] = { { "rv8803", rv_8803 }, { "rv8804", rx_8804 }, @@ -683,6 +706,11 @@ static int rv8803_probe(struct i2c_client *client) if (err) { dev_warn(&client->dev, "unable to request IRQ, alarms disabled\n"); client->irq = 0; + } else { + device_init_wakeup(&client->dev, true); + err = dev_pm_set_wake_irq(&client->dev, client->irq); + if (err) + dev_err(&client->dev, "failed to set wake IRQ\n"); } } if (!client->irq) @@ -737,6 +765,7 @@ static struct i2c_driver rv8803_driver = { .driver = { .name = "rtc-rv8803", .of_match_table = of_match_ptr(rv8803_of_match), + .pm = &rv8803_pm_ops, }, .probe = rv8803_probe, .id_table = rv8803_id,