From patchwork Fri Jan 20 19:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46575 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp373936wrn; Fri, 20 Jan 2023 11:04:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXtjYI+ZVv3l1t7Vn6AFT5qyGE+2cSIEnPv2Je9A+w1Suc5Nb4HJrqX1FEMyxjLZ0aWvsw2F X-Received: by 2002:a17:90b:3b4a:b0:229:91f7:8476 with SMTP id ot10-20020a17090b3b4a00b0022991f78476mr18094917pjb.10.1674241478483; Fri, 20 Jan 2023 11:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241478; cv=none; d=google.com; s=arc-20160816; b=MLtMq5CTbbBASPSIS+CZ8Z4sb0W6+MjCbH5Bt+oU3ZJecXxuNtTbOlBZdGxYxwRJAi 0VLDLMulROIj/L17aXgLMsgjR+dvh2gx2Oc4d7qx2PimjeYiJCcQHpJk135TmrLTAUcY Yq8Xy5vI4OQUfyYHjJdyfoojCDe19Svdf0JQsTVP2YUU1XLA+ErFGrN12MlGDbwWs8Ww jg+jqovSAwr6an6h58zkEGmj3JIjF57zB4/mZBuMjygJD55dK/bEP1whGqrjqkmMG8aZ IcmFToFw0YAsQXWOG40TUc6etaWFV0w2kj2AxwRRo4Ch7MorYGh0jOkf8fmvKwLxZMRl chbg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ML/rF7kF1SaTj4j5/ZJzUsj/h2DG3Q7mK3i99v+DSLQ=; b=MbRK4oV1FuD7xrElI4wCXDHKBoRNqqL3VnvZHE25mRwkyJuixPEyPOyWswrGla9G0T nSsSQZkuXwHCSPiHzeCfmDa2gTd52a5OFAxTV5Oe4gMdPZ9E/qjKE/DLZUSr/9VBxNMR Anhha9sbPjAHv4njMybiTRha72g4OgG7VW/83hmtqoAnfo5pkh6igOIrpoYd7TjhAPa1 dTe0AMx1bQGSuLmKTtvTO+rbskGFIFSNE0lSWYrRcpTvGhJnrCo1/sPgR/AkzTwDoGve Lm6xTAjG9fx8O0XwWuXE//b18anenolB+HoEGb6ByejNBaAlB5257bv32M4tKIgw0LER bJCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L6wLACqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk17-20020a17090b081100b00219f65e19fcsi2299625pjb.170.2023.01.20.11.04.26; Fri, 20 Jan 2023 11:04:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L6wLACqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229788AbjATTC2 (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjATTC0 (ORCPT ); Fri, 20 Jan 2023 14:02:26 -0500 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C12285347; Fri, 20 Jan 2023 11:02:25 -0800 (PST) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-15ebfdf69adso7366784fac.0; Fri, 20 Jan 2023 11:02:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ML/rF7kF1SaTj4j5/ZJzUsj/h2DG3Q7mK3i99v+DSLQ=; b=L6wLACquDlqMxqvXkyh+Ok3t9fNKo8EDGsGK5N0sp5U65CgkNX5nwg3ArQWuFe8KjX AYCu3pzlL8Sx8cp1rKjZ6TvSVA7TgjpHgjARoSLwms+fAlSDZeAt0LK+dWkX36qmmJIG toXXKYmEwhML0FjDYgBi6ytc1hTLDpeHbHGJurcvR0+QEr9AfEU9285CnWndZVs5JQLC t4oQA5m9X21edc6y97jCZHd8euZm3tP4zs0a95+Nn941YisdXE25yryMrmfB+NxjmQB1 pmWsuY8ehEt/mDkXl0kniRqASW5LnThmL82kehQKKLvdzygsTDF0g+cusYDWjVl0fZrB dnOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ML/rF7kF1SaTj4j5/ZJzUsj/h2DG3Q7mK3i99v+DSLQ=; b=sBapNBbqrFTN5KaVhXMYtjYyfU0zCsPqbo6GT7Jm9L9t2p1n82GuFMZPFluWhhbUJn ho1eiz8Er8Byx7GyjTZePtLC4cYveywgAmZ/gP5AAju/20PRH2gvd3Rgwxl76Y9RAH9N El9e3ZBr2X6S8rGSiShYNGTAUUkbu/RPi4jdwTZMj4nPWBC2uxWKiq3qXxdRNLfGFOAG H4R0w1k+iLqRfPwOozufR5xpC3Tey5aQht4jmriMSrwoBAnA2Kd7hHNTwpP8R/IwqKTr 6/lsZHDjiXsVCGC1D55Ti85K5MeLiAeOSAFz2D3IrsChoURudN/QHiqvD+u2kGwYsr2h EmIQ== X-Gm-Message-State: AFqh2kqd2ANkafxtfGP1tj5vUVv2ugteLAHkLGUd6eQ63re6vjeWYgRy 0o0jqEspAyszeZR4YisAz2I= X-Received: by 2002:a05:6870:b0d:b0:15f:930a:5cd0 with SMTP id lh13-20020a0568700b0d00b0015f930a5cd0mr5300530oab.26.1674241344705; Fri, 20 Jan 2023 11:02:24 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:24 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 1/6] rtc: brcmstb-waketimer: introduce WKTMR_ALARM_EVENT flag Date: Fri, 20 Jan 2023 11:01:42 -0800 Message-Id: <20230120190147.718976-2-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569432358808788?= X-GMAIL-MSGID: =?utf-8?q?1755569432358808788?= This commit defines bit 0 as the bit of interest within the BRCMSTB_WKTMR_EVENT register to make the implementation more readable. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/rtc/rtc-brcmstb-waketimer.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-brcmstb-waketimer.c b/drivers/rtc/rtc-brcmstb-waketimer.c index c74130e8f496..fbeb8be6664b 100644 --- a/drivers/rtc/rtc-brcmstb-waketimer.c +++ b/drivers/rtc/rtc-brcmstb-waketimer.c @@ -34,6 +34,7 @@ struct brcmstb_waketmr { }; #define BRCMSTB_WKTMR_EVENT 0x00 +#define WKTMR_ALARM_EVENT BIT(0) #define BRCMSTB_WKTMR_COUNTER 0x04 #define BRCMSTB_WKTMR_ALARM 0x08 #define BRCMSTB_WKTMR_PRESCALER 0x0C @@ -41,9 +42,17 @@ struct brcmstb_waketmr { #define BRCMSTB_WKTMR_DEFAULT_FREQ 27000000 +static inline bool brcmstb_waketmr_is_pending(struct brcmstb_waketmr *timer) +{ + u32 reg; + + reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); + return !!(reg & WKTMR_ALARM_EVENT); +} + static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer) { - writel_relaxed(1, timer->base + BRCMSTB_WKTMR_EVENT); + writel_relaxed(WKTMR_ALARM_EVENT, timer->base + BRCMSTB_WKTMR_EVENT); (void)readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); } @@ -147,7 +156,6 @@ static int brcmstb_waketmr_getalarm(struct device *dev, { struct brcmstb_waketmr *timer = dev_get_drvdata(dev); time64_t sec; - u32 reg; sec = readl_relaxed(timer->base + BRCMSTB_WKTMR_ALARM); if (sec != 0) { @@ -156,8 +164,7 @@ static int brcmstb_waketmr_getalarm(struct device *dev, rtc_time64_to_tm(sec, &alarm->time); } - reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); - alarm->pending = !!(reg & 1); + alarm->pending = brcmstb_waketmr_is_pending(timer); return 0; } From patchwork Fri Jan 20 19:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp373954wrn; Fri, 20 Jan 2023 11:04:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtaRdMSIDadlOtkABqLFdxqsShn6QT10nmJA+EaPBIklnwSsHMISY9jbB6te0iZf8Ae4eOm X-Received: by 2002:a05:6a20:2905:b0:b6:4fb2:9afa with SMTP id t5-20020a056a20290500b000b64fb29afamr33953728pzf.28.1674241480403; Fri, 20 Jan 2023 11:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241480; cv=none; d=google.com; s=arc-20160816; b=nTVLhCbAvI8WTa2whzPyA+TSTmD/wceTGeHfnDHVjx46VACeF2+2eFVxGi+P4YWHsz CUb9pIrcvCkCmcJHAGr85GvhQg2aZ4BlHNjXKZI6Cu+Xj5SyBgU1mn7Ys74B/TBzvHEs 3Emyt4Q40G3nbjgzcnAXEdgDX9ZZcXsywzoQ0uq37eTpILGWREUeBstPBWsKbgtxpqFP JxarsrReHiooQrVW3HC+jJE85NB5QFwhk6B5tKqdDI5n+ynb2e8eQuu+hIcYPaeDbFh6 +be2PHeM2t2YMTWbdPyOOW0v2Kc5irWfjk0DPYKYNlBKSvs+o7qipFU7zHwMw2LpuTf8 HMXg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PT42Zl2MuPs/Wu9jh4sQMK4BVAdg3CNaxRS3csl2Gmk=; b=ej7JG83jwgxutC8iF98ntDqnzy0JwEvI6tNxDtw3wPkQq5pAWm6uQjYdWbC1s12Le1 AXGyHp2T2hEyZGtM7AGR4wRTvJoBi4YERlXYHaUg8n/kteto0XVMvhccD5qRr+c1J344 vzWDJPhK7RwXFmk0+61xv4ilI4yrFk3i7vr5+uZ0hTglf63ObygTAx0TyNTy8hGxfQfB +XwChHj3wyRIiXc1+YLPqw0vgkTSVW81VD0yP3Q5HG37j5lMlX2hNFN3GZOgX1VAnPQ/ 6+YiQAas60zc1Je5GkdWU3xT18kGNhvB2pJqEN2EZN7a8DHB4+b/s74idoE32YxQvzT4 ZOxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="YgMU1Tm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i69-20020a638748000000b004cfeacfba87si10369363pge.364.2023.01.20.11.04.28; Fri, 20 Jan 2023 11:04:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="YgMU1Tm/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbjATTCa (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjATTC2 (ORCPT ); Fri, 20 Jan 2023 14:02:28 -0500 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B74C4E8A; Fri, 20 Jan 2023 11:02:27 -0800 (PST) Received: by mail-il1-x134.google.com with SMTP id p12so3160637ilq.10; Fri, 20 Jan 2023 11:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PT42Zl2MuPs/Wu9jh4sQMK4BVAdg3CNaxRS3csl2Gmk=; b=YgMU1Tm/SWN5kuzg9KE0Cq1L9BqLdj77L+ImuL3FdAEO30CVMjJzhspc7fXWo45AOw fBcRb0NkdP9N3aY+rceOTA7NNYEzQimVr2aq4Nw3ram5kpP0Gs9YNTZnO53nc6VpEmXd Imue2WitnqlW/k6aNpZe0+rU1oesQiKsfdIMrGIf+JvdE4UC4A25Jgndwscx57+MK2iL Aw26dwMqQu/IWcQDok3S8jzIWw+bEknjwhBMIMliCBF2uSJDrarjlKj568SFleWZJ3Um +CKC6EjY0GIs403gJqLiZESoCFY7h7VBwt5KvYAbhH3Hn/54Zr0yhi+j4fVsV7Gi3V// edTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PT42Zl2MuPs/Wu9jh4sQMK4BVAdg3CNaxRS3csl2Gmk=; b=YOcNjivh2cPE2gJlc5fU5lI2vNHdfoGDu7C+hBm1yo7JU1e5mIuuu4krc1vZHRPCow cn86mq+UPR0F3HVwAsSOZPOQaXxbfVNCJL2dvCy+vKZfNVMRxGhZgf8aGqnTRLp5mhma 97c3KxA8R72gr2aPmuDNglBXxzRo8KrQywCFRoOG5quE2EWim3ldb18GlJfDw1AXZcHb v/4akpXYVRVcoz/FFYp5lf4e8xxLLFWT9vy5yra8WVhRW2IovOtHdOC5a/kOKHbgbuF0 8YE2RLUV/IUvZbL0zIAwOreiuzkjSpwu6oRxqOMKEPyqBejX20cfbySsa72zRVKddJRh 6J6w== X-Gm-Message-State: AFqh2kpvzrK2xXaN/xCeiqqLPMWt32el846SvVCe8zWmo2lWlGSFW8cP klmJi9EOMJ80/KDEFkSyh/c= X-Received: by 2002:a05:6e02:1ba2:b0:30f:63f0:b215 with SMTP id n2-20020a056e021ba200b0030f63f0b215mr854272ili.26.1674241346839; Fri, 20 Jan 2023 11:02:26 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:26 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 2/6] rtc: brcmstb-waketimer: non-functional code changes Date: Fri, 20 Jan 2023 11:01:43 -0800 Message-Id: <20230120190147.718976-3-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569434543163199?= X-GMAIL-MSGID: =?utf-8?q?1755569434543163199?= These changes are not intended to affect functionality, but simplify the source code. They are performed here to simplify review and reduce confusion with other changes in this set. Since set_alarm includes the alarm_irq_enable functionality call it directly from that function for simplicity (even though it does nothing at the moment). The order of the declarations is changed to prevent the need for a prototype. The function device_init_wakeup() is used to replace the functions device_set_wakeup_capable() and device_wakeup_enable() since it is equivalent. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/rtc/rtc-brcmstb-waketimer.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/rtc/rtc-brcmstb-waketimer.c b/drivers/rtc/rtc-brcmstb-waketimer.c index fbeb8be6664b..582c23793550 100644 --- a/drivers/rtc/rtc-brcmstb-waketimer.c +++ b/drivers/rtc/rtc-brcmstb-waketimer.c @@ -169,6 +169,16 @@ static int brcmstb_waketmr_getalarm(struct device *dev, return 0; } +/* + * Does not do much but keep the RTC class happy. We always support + * alarms. + */ +static int brcmstb_waketmr_alarm_enable(struct device *dev, + unsigned int enabled) +{ + return 0; +} + static int brcmstb_waketmr_setalarm(struct device *dev, struct rtc_wkalrm *alarm) { @@ -182,17 +192,7 @@ static int brcmstb_waketmr_setalarm(struct device *dev, brcmstb_waketmr_set_alarm(timer, sec); - return 0; -} - -/* - * Does not do much but keep the RTC class happy. We always support - * alarms. - */ -static int brcmstb_waketmr_alarm_enable(struct device *dev, - unsigned int enabled) -{ - return 0; + return brcmstb_waketmr_alarm_enable(dev, alarm->enabled); } static const struct rtc_class_ops brcmstb_waketmr_ops = { @@ -228,8 +228,7 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev) * Set wakeup capability before requesting wakeup interrupt, so we can * process boot-time "wakeups" (e.g., from S5 soft-off) */ - device_set_wakeup_capable(dev, true); - device_wakeup_enable(dev); + device_init_wakeup(dev, true); timer->irq = platform_get_irq(pdev, 0); if (timer->irq < 0) From patchwork Fri Jan 20 19:01:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp373960wrn; Fri, 20 Jan 2023 11:04:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXsM/pR+IhqKSwvW+j1A6JxXMSpiEqmkJpLT3EChF6OLCwnTzRR4JW8CHGo2lcyUxNqRU09n X-Received: by 2002:a17:902:8c90:b0:191:2b76:612c with SMTP id t16-20020a1709028c9000b001912b76612cmr14056094plo.62.1674241481351; Fri, 20 Jan 2023 11:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241481; cv=none; d=google.com; s=arc-20160816; b=hvUJvVa7iC47MGYlR0V3VkaaSUGy2eayei8mt/Mu+FfQHtaZn/4BIWn96coWucetAv iGWZCY50I4ybw/Sqt2j60Qh7XQlHBDiMxX65ewYyl2OfMIDRJpZzPJRpsFIrn8umPFRR 4Tm3Ow6oI6OhjhUZmkHxorYtNiew71EfdT3DtwNxA7pWML+64cUg6al04/0pBLg2+mCg /FjtNJvyoZaUXXrckpjM/iX1ZZRPgArrL8kJiHk/aszpq6VtYi3l2aPY+83OcOL6RXT+ GXrqBaWEHhvP4MlyIQKPLwOXOlqdeqEXY4uzaVEFh25cf92M25EOyDQcNIlMkXbiMsBc cAYw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5rhB+jCWXlDHeyaWPTfhoKZG0YZcAyGqC3yxhLv7U6w=; b=YCFeZehyR7tWJJp5LyKKv4oqWBlq0WupbLgz9Jn0yenUXBZqFm/nCvC/+L164slgeL R7LyKAs3EyK6v1CjVLRs4MQ78cIvSOY3wXLxgljnohK3JsbVRmgcFUxAaOZIVCOQW7MR h6Su7BiAPNdw+qg6SD77djJ/F2EMaEW0AH/LfVT7SaT5RJyxCDwJP6bDB+LmUGAm4xn3 adUFAP/BB1xsB1D/9TRC5RECGMk+zPHuLTCV0EUNBbY3w4wKMJa5FrH1eWCe5xvl5/83 Q971XsdcJu2YwBP0Ygzif5n8/2+eV0ekbEhw0Jrzd5dYQ5uOtfmr6DwoLBf9uL/7ZZK9 ngoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lknvwgac; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a170902db0800b001930212bebfsi1239214plx.530.2023.01.20.11.04.29; Fri, 20 Jan 2023 11:04:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lknvwgac; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbjATTCf (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjATTCa (ORCPT ); Fri, 20 Jan 2023 14:02:30 -0500 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB46385347; Fri, 20 Jan 2023 11:02:29 -0800 (PST) Received: by mail-il1-x12c.google.com with SMTP id h15so2874824ilh.4; Fri, 20 Jan 2023 11:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5rhB+jCWXlDHeyaWPTfhoKZG0YZcAyGqC3yxhLv7U6w=; b=lknvwgacWgowNZLC4XECbtZKNlv6HqjFRHYejN+rgvjaZ5WNBGQWmWzQGZ+QtDTGRk Ca/IdGy/Fp/yIQEIdXDjKJas19zHXmPUiJgkKEyInmq/R1f/nIo/PkFD1Lwa0AG9NNTd b1jjB77CEuqFd5Z47Rn1DLAuM2pzQ71u/gUwp1bhMiRdLAcWPnNS/NMNBQnEhOtmLsPC 2p5Pg0OMGn4IewYGDV9wTo8Sk5SkX02wnx3TlsEkIuEFcSuD2IsTdwI9kXUkq7zWXMq8 +ccujkOLxcCK6C8lVneugYs6LpdYvkYuXnazLtwvjRG3osyWhJ6FbpndCJlfIup/+bVy h0MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5rhB+jCWXlDHeyaWPTfhoKZG0YZcAyGqC3yxhLv7U6w=; b=zA1BYhjYEKBkxMVit2LHGAbxgoNmU0HF7PB16yMo8CDr/2Rjnl55HmoO7SHc2TLmBY 9DJjS5bgwtrzeaOeyGzWghPwIX3M9kzDXS7u3dw8MCJcD/TDY2A9m9URB+ntU8ozK0lr dApX2aDjkhn1zd4Y3OX+BF8jcxdpXnOIKodSRb4sX3CuLWOZOf6tIJb/iXqk3PIXQSJU 7zMzCXcL3rogkAkNoDYyOGMH+XHOciiVLlDdk/7MM6qp0nJqmU/L6K6O174TnzUAYahe 282cs/25Ht05iqo80hIvIi0V4i6KThqtuObr7lLYpJMPKtLsh+Qh3BnN9wDzClaYu6UG HVjw== X-Gm-Message-State: AFqh2krOzW+02X/NSBuQ62MvQ6k+Bi6wJN/8HFPvGyZxnA2KvEkZcGdh C3HYM5SMfryptpn8EkZYqH4= X-Received: by 2002:a05:6e02:6cc:b0:30c:4846:57c3 with SMTP id p12-20020a056e0206cc00b0030c484657c3mr12050911ils.4.1674241348972; Fri, 20 Jan 2023 11:02:28 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:28 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 3/6] rtc: brcmstb-waketimer: compensate for lack of wktmr disable Date: Fri, 20 Jan 2023 11:01:44 -0800 Message-Id: <20230120190147.718976-4-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569435441577842?= X-GMAIL-MSGID: =?utf-8?q?1755569435441577842?= Since the WKTMR hardware block cannot be disabled it is necessary for the driver to accommodate for associated timing hazards. This commit targets the following possibilities: A possible race between clearing a wktmr event and the alarm expiring is made one-sided by setting the alarm to its maximum value before clearing the event. Programming alarm values close to the current time may not trigger events if the counter advances while the alarm is being programmed. After programming an alarm, a check is made to ensure that it is either in the future or an expiration event is pending. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/rtc/rtc-brcmstb-waketimer.c | 52 +++++++++++++++++++---------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-brcmstb-waketimer.c b/drivers/rtc/rtc-brcmstb-waketimer.c index 582c23793550..c791e92532b8 100644 --- a/drivers/rtc/rtc-brcmstb-waketimer.c +++ b/drivers/rtc/rtc-brcmstb-waketimer.c @@ -31,6 +31,8 @@ struct brcmstb_waketmr { struct notifier_block reboot_notifier; struct clk *clk; u32 rate; + unsigned long rtc_alarm; + bool alarm_en; }; #define BRCMSTB_WKTMR_EVENT 0x00 @@ -52,6 +54,11 @@ static inline bool brcmstb_waketmr_is_pending(struct brcmstb_waketmr *timer) static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer) { + u32 reg; + + timer->alarm_en = false; + reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_COUNTER); + writel_relaxed(reg - 1, timer->base + BRCMSTB_WKTMR_ALARM); writel_relaxed(WKTMR_ALARM_EVENT, timer->base + BRCMSTB_WKTMR_EVENT); (void)readl_relaxed(timer->base + BRCMSTB_WKTMR_EVENT); } @@ -59,12 +66,22 @@ static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer) static void brcmstb_waketmr_set_alarm(struct brcmstb_waketmr *timer, unsigned int secs) { + unsigned int now; + brcmstb_waketmr_clear_alarm(timer); /* Make sure we are actually counting in seconds */ writel_relaxed(timer->rate, timer->base + BRCMSTB_WKTMR_PRESCALER); - writel_relaxed(secs + 1, timer->base + BRCMSTB_WKTMR_ALARM); + writel_relaxed(secs, timer->base + BRCMSTB_WKTMR_ALARM); + now = readl_relaxed(timer->base + BRCMSTB_WKTMR_COUNTER); + + while ((int)(secs - now) <= 0 && + !brcmstb_waketmr_is_pending(timer)) { + secs = now + 1; + writel_relaxed(secs, timer->base + BRCMSTB_WKTMR_ALARM); + now = readl_relaxed(timer->base + BRCMSTB_WKTMR_COUNTER); + } } static irqreturn_t brcmstb_waketmr_irq(int irq, void *data) @@ -155,27 +172,30 @@ static int brcmstb_waketmr_getalarm(struct device *dev, struct rtc_wkalrm *alarm) { struct brcmstb_waketmr *timer = dev_get_drvdata(dev); - time64_t sec; - sec = readl_relaxed(timer->base + BRCMSTB_WKTMR_ALARM); - if (sec != 0) { - /* Alarm is enabled */ - alarm->enabled = 1; - rtc_time64_to_tm(sec, &alarm->time); - } + alarm->enabled = timer->alarm_en; + rtc_time64_to_tm(timer->rtc_alarm, &alarm->time); alarm->pending = brcmstb_waketmr_is_pending(timer); return 0; } -/* - * Does not do much but keep the RTC class happy. We always support - * alarms. - */ static int brcmstb_waketmr_alarm_enable(struct device *dev, unsigned int enabled) { + struct brcmstb_waketmr *timer = dev_get_drvdata(dev); + + if (enabled && !timer->alarm_en) { + if ((int)(readl_relaxed(timer->base + BRCMSTB_WKTMR_COUNTER) - + readl_relaxed(timer->base + BRCMSTB_WKTMR_ALARM)) >= 0 && + !brcmstb_waketmr_is_pending(timer)) + return -EINVAL; + timer->alarm_en = true; + } else if (!enabled && timer->alarm_en) { + timer->alarm_en = false; + } + return 0; } @@ -183,14 +203,10 @@ static int brcmstb_waketmr_setalarm(struct device *dev, struct rtc_wkalrm *alarm) { struct brcmstb_waketmr *timer = dev_get_drvdata(dev); - time64_t sec; - if (alarm->enabled) - sec = rtc_tm_to_time64(&alarm->time); - else - sec = 0; + timer->rtc_alarm = rtc_tm_to_time64(&alarm->time); - brcmstb_waketmr_set_alarm(timer, sec); + brcmstb_waketmr_set_alarm(timer, timer->rtc_alarm); return brcmstb_waketmr_alarm_enable(dev, alarm->enabled); } From patchwork Fri Jan 20 19:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp374003wrn; Fri, 20 Jan 2023 11:04:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7+aQ/OR5UlNzLSyK3zMUEijO+DAj5Y1WiDy/MH1Kx362abZH1kuFCh+pQ5rkoSB1Nv7lV X-Received: by 2002:a17:902:e80a:b0:194:6f0e:990 with SMTP id u10-20020a170902e80a00b001946f0e0990mr42653728plg.39.1674241484209; Fri, 20 Jan 2023 11:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241484; cv=none; d=google.com; s=arc-20160816; b=gQQXJm5CBUR/MgAG/qafWhvp6Hr7tUkivrEhen9jO7+E4vq1d9KZhqd+xO9X0S0nrY XWJc2tuIaFlYctga411q3NpSn8LEq9tKAr0XuL0S5jPH+QKmzeJdnT7BCCmf2yTQGwBP lAMx5SB1P/PCeCqDE6tepXzDVOw5UuTyIdiLpjipc1EYV08xx2laZsGvWS35qJYU2i/0 Uc9DKJteOCYCRcpQ7GoAW3IQYJmx92nVYqpjZQDQ7DRKKUD2QeSGby267k5dmcCsu9se nSJ+zlsZNGZjYQvdkrFi8hxdZUOsMorL0GKEC9qZc166t0QXx0LexjA9adH4AjsqBiTT IQ/A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O/0h0heB6R7vr68pBP8mp0KNKIM3bG6DI1Vn2wipkYU=; b=ng184BgDkj2fujKtbPsQBllSrrhawrd5Fs2CCg4ZGrdT6fkYvgMj5gPPaAlyWyk3BL Bc4NTIiIEB6EwKVp3XnqPuepyc7ZaEAU/bVc9gX/MVdzm0bKOOM0afIe1lVWGWskwKjE pmMR9bKJ1vwXhBotUXkSopftw8Yx4IaTYbDzdedTVxXcHUdiHyhj2NfeAP9cdlGTuPB3 fiXXDYrceAt5OIbna9rA6uVDLM6YxpXWbVjtnEQyc8h73/dm59vP5tVAl0+UnQX26VF6 7N80Vxc4DSrTJuygZ/JgQ7FEAEp+9tFa3WA7MAKW2ZTw+SzZxZgPQ4WQd8SsWKwXvFN+ E6Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="kEqwe/PU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a1709026ac200b00189c8b6e603si7820945plt.583.2023.01.20.11.04.31; Fri, 20 Jan 2023 11:04:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="kEqwe/PU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbjATTCl (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjATTCf (ORCPT ); Fri, 20 Jan 2023 14:02:35 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BC4CC5C9; Fri, 20 Jan 2023 11:02:32 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id n2so4430181qvo.1; Fri, 20 Jan 2023 11:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O/0h0heB6R7vr68pBP8mp0KNKIM3bG6DI1Vn2wipkYU=; b=kEqwe/PUsz08w5m0iF19xnZtx1fg80HTYcBEMVXbIWsvSG5mO6585xZiAizKMT98S7 nY4ut/1oDiPiY8HqS40JbqcdJ+emuoXQwg6XmJKEwZOB60TGgGl3iydQ7fuoYn0SsS7k KY5DVucmMuoaWV5NrbFJuEvnqODTA0LxoFyZUoKhBmTu1TpEeyk7CXZ8TLzWRGTc3/rP fBjUrYxutoNlZPJfYgw26JOdoSB7aSWg6Rbx1DJpviuThuUFphoK5On5YNAeasguHYab xuC4aKsjyYQW3FfUI7NwsCCwyWGccRZorJpbnPbTmsu3vNm7bJJ13l0K2dJbkS0qjnEN KlaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O/0h0heB6R7vr68pBP8mp0KNKIM3bG6DI1Vn2wipkYU=; b=s1eS99MrH/Khnsjme2cExFgv74bFn/O6Ct4Yody6JkzCAOy8m8ey9h852Ock4iBsLt kBwNQT2b9PvnL9nKT6pK0PtSK41KN11FPJgqUFI/okFKEDJO/HcxY4qsN8MVaF8ONn/M BWBUdrLPum2xNlE0StOgSVwYXwiK6gqpG05wd39PSNt2VVpbBJQLB3yuGoxLxdiFtv4b ivf4Wzvin/pf0l2u1zKclIBPqQ0tmwk6p4nbF0JsHqVRqxk+p2hKj3/NTrzmT+nuEKcQ 7UCSWOzZyH52RYGwQ94XDdwwq9EYrhHnW8pWpuw5wDhRRw/zf3j/NmbIBOJZ99TPrtrs cGbA== X-Gm-Message-State: AFqh2krLfruUgYeuVUmNlh0xz6i4qxHhQUR8tYVxiq6+FW9BPhuXJUlL lRzROWgc+JwfM7AKa2x9G+o= X-Received: by 2002:a0c:ea2c:0:b0:532:1fc2:9ad5 with SMTP id t12-20020a0cea2c000000b005321fc29ad5mr50095693qvp.0.1674241351099; Fri, 20 Jan 2023 11:02:31 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:30 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 4/6] rtc: brcmstb-waketimer: rename irq to wake_irq Date: Fri, 20 Jan 2023 11:01:45 -0800 Message-Id: <20230120190147.718976-5-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569438581989617?= X-GMAIL-MSGID: =?utf-8?q?1755569438581989617?= In preparation for adding a second interrupt to service RTC interrupts, the existing interrupt is renamed from the generic 'irq' to 'wake_irq' to more clearly convey its role. It is also converted to an unsigned int. Finally, the driver message that outputs the IRQ number when registered is removed since devm_rtc_register_device() already provides a report of registration and the interrupts can be found in /proc/interrupts. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/rtc/rtc-brcmstb-waketimer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/rtc/rtc-brcmstb-waketimer.c b/drivers/rtc/rtc-brcmstb-waketimer.c index c791e92532b8..e25f9fcd6ed1 100644 --- a/drivers/rtc/rtc-brcmstb-waketimer.c +++ b/drivers/rtc/rtc-brcmstb-waketimer.c @@ -27,7 +27,7 @@ struct brcmstb_waketmr { struct rtc_device *rtc; struct device *dev; void __iomem *base; - int irq; + unsigned int wake_irq; struct notifier_block reboot_notifier; struct clk *clk; u32 rate; @@ -117,7 +117,7 @@ static int brcmstb_waketmr_prepare_suspend(struct brcmstb_waketmr *timer) int ret = 0; if (device_may_wakeup(dev)) { - ret = enable_irq_wake(timer->irq); + ret = enable_irq_wake(timer->wake_irq); if (ret) { dev_err(dev, "failed to enable wake-up interrupt\n"); return ret; @@ -246,9 +246,10 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev) */ device_init_wakeup(dev, true); - timer->irq = platform_get_irq(pdev, 0); - if (timer->irq < 0) + ret = platform_get_irq(pdev, 0); + if (ret < 0) return -ENODEV; + timer->wake_irq = (unsigned int)ret; timer->clk = devm_clk_get(dev, NULL); if (!IS_ERR(timer->clk)) { @@ -263,7 +264,7 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev) timer->clk = NULL; } - ret = devm_request_irq(dev, timer->irq, brcmstb_waketmr_irq, 0, + ret = devm_request_irq(dev, timer->wake_irq, brcmstb_waketmr_irq, 0, "brcmstb-waketimer", timer); if (ret < 0) goto err_clk; @@ -278,8 +279,6 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev) if (ret) goto err_notifier; - dev_info(dev, "registered, with irq %d\n", timer->irq); - return 0; err_notifier: @@ -317,7 +316,7 @@ static int brcmstb_waketmr_resume(struct device *dev) if (!device_may_wakeup(dev)) return 0; - ret = disable_irq_wake(timer->irq); + ret = disable_irq_wake(timer->wake_irq); brcmstb_waketmr_clear_alarm(timer); From patchwork Fri Jan 20 19:01:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46579 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp374161wrn; Fri, 20 Jan 2023 11:04:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvsCtgSI3l8CNIEPa6GxF+dRyt3VdQg+zPSJ/BmgHifArPJ2HjV8KNdZ/6jRYNhsRBbfU5N X-Received: by 2002:a17:907:a80b:b0:86f:220e:94af with SMTP id vo11-20020a170907a80b00b0086f220e94afmr27365103ejc.56.1674241498221; Fri, 20 Jan 2023 11:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241498; cv=none; d=google.com; s=arc-20160816; b=nSw2UgIhIseCAbsbyBLbXcUGb8820jtFT6WwnzT+jDiq3LzR/gZ+MD8xaMRI0BQCNh EX00aRoxrMFZvBBbfLq4m81QXgODlqKg4CItiPv7TQZPW9MQSoGtINSroXXybDTbm8Jc SUUev4h+hfkWRd1fFE1ynf8JPim+csrkTlYITtzfg5vEGqHDmtHzTcNpqsLvPRYrfkwi 7jzh9Yq4wtJuXcam+f13PZjM3GjaQYRg9M4ABKrnz18xPEOdoXgWM0T6r4rxL/kBTEfv 0XXRCa1nHTAcRSRaVIIgYguelIPwckGDY8DTVwzPSe8HO7fNWqLa7L85ZOXnfee5X5lM RlyQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q6gBQQgTi4K3Y99K1tsHxOMMy9BG9zhs5uBNfgpAj1A=; b=mmpSaj0Q3oN9eCrsvjEiQA201olZyVtbd5SgbgOgT3PiZUhhvUfpgtzudNIqjHMbK4 w8iEpKb0B0FSCvGFsi9K4q3tLhz536e5iRtuTwFPAjkbisw4nnNrvpM5ci852YWp3lzt Qu3agyxqwnAbuWNN+By+pQztQoaoq2Liie+NWZ8zrn6m8gHD/7sXvxTZrCETm+Ng5zGE LWdhUoB84IllUEOAosTZr4/kiTz4F5Ja3iKdolM4YUTgbRHrDTnGk/X1jV7s1ZBIS3VS a3S0iMi3sexUULrE2oaMXz4Cx0DYhrtKmmUJyaXSnABjEMwahnZYVtT3NBvUfPddCZrx AQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EgIBICgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r28-20020a50c01c000000b00461c50013b8si45478785edb.192.2023.01.20.11.04.34; Fri, 20 Jan 2023 11:04:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EgIBICgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjATTCn (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbjATTCk (ORCPT ); Fri, 20 Jan 2023 14:02:40 -0500 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81072BF8A5; Fri, 20 Jan 2023 11:02:33 -0800 (PST) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-15ebfdf69adso7367248fac.0; Fri, 20 Jan 2023 11:02:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q6gBQQgTi4K3Y99K1tsHxOMMy9BG9zhs5uBNfgpAj1A=; b=EgIBICgKIBipBfwSWWMa8ggl7BQSSomW1dcuUEpM8OqWVn78MmHecIUszpyI1Y9V8h cqRDoGlGHzxS3qgJsWwjNBSHAWGPEjwuDbiiSKCiWBLXbDcxGFhktrH6W/2y1kWUe8zu lYTr27JxgKASsC67XkOUa2uOxgb4Tuq5RpiGk5H71gOXb8clRQthKzpM1jAYSoL0BxNO 63XW9c/LefvLWLgYF0A8UPD0U+H05/VwgEHUH4hX2KEhnlZ32fJDtnL+5kS4yUCgs2BG gf8GmMCIfpc0Fkv/v6OcPNex6ahR8c0m82IueUtNUkZZqGTgGcYVg2fRXD175xWaRZXJ cLDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q6gBQQgTi4K3Y99K1tsHxOMMy9BG9zhs5uBNfgpAj1A=; b=SRk7ftl9jI07Bu5ndPdJ7L+BqgCpxzjkcoKIrEyVc6OUuEmm7uaWBGjYWV807/BAPL ZAPDhxJA5K7XuWsUMWmmWSUYm3A3gGgFjPHvnIJ6tyGBuwIN1KJab0DsOchiKLfBYBvi bkIYYTLeZVAb9w5ltYXdbjxM1NjCWnQuSFSOvXqCiis8H9dxOWZN3kh47OxrT7mG02tH yEYRyoFpcgxKV6g662EDPseUGdHkJ+LtB0n+4q185VFpEqMfDLSjsYLXLfHhpFXaEwUC 5qBFwSksW0dCghc9XyA6vp9CVB+On89CbGViWnMrT3Jg6NaEMN5ovRWHfLJphccqwPxD Hruw== X-Gm-Message-State: AFqh2koTUv7rykgzSHV17gaf74AhXyDu/t6rGG/Zr6HsEvbb1l2cNs4a /n+arfmgxZATsv3H6LTlm0o= X-Received: by 2002:a05:6870:ed49:b0:144:57b1:c8cf with SMTP id ex9-20020a056870ed4900b0014457b1c8cfmr8460943oab.47.1674241353197; Fri, 20 Jan 2023 11:02:33 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:32 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 5/6] dt-bindings: rtc: brcm,brcmstb-waketimer: add alarm interrupt Date: Fri, 20 Jan 2023 11:01:46 -0800 Message-Id: <20230120190147.718976-6-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569453644712195?= X-GMAIL-MSGID: =?utf-8?q?1755569453644712195?= A second interrupt can optionally be specified for this device to be used for generating RTC alarm interrupts. Signed-off-by: Doug Berger --- .../bindings/rtc/brcm,brcmstb-waketimer.yaml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml b/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml index 9fe079917a98..a9199f299a68 100644 --- a/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml +++ b/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml @@ -11,7 +11,8 @@ maintainers: description: The Broadcom STB wake-up timer provides a 27Mhz resolution timer, with the - ability to wake up the system from low-power suspend/standby modes. + ability to wake up the system from low-power suspend/standby modes and + optionally generate RTC alarm interrupts. allOf: - $ref: "rtc.yaml#" @@ -24,8 +25,14 @@ properties: maxItems: 1 interrupts: - description: the TIMER interrupt - maxItems: 1 + minItems: 1 + items: + - description: the TIMER interrupt + - description: the ALARM interrupt + description: + The TIMER interrupt wakes the system from low-power suspend/standby modes. + An ALARM interrupt may be specified to interrupt the CPU when an RTC alarm + is enabled. clocks: description: clock reference in the 27MHz domain @@ -42,3 +49,12 @@ examples: interrupt-parent = <&aon_pm_l2_intc>; clocks = <&upg_fixed>; }; + + - | + rtc@f041a080 { + compatible = "brcm,brcmstb-waketimer"; + reg = <0xf041a080 0x14>; + interrupts-extended = <&aon_pm_l2_intc 0x04>, + <&upg_aux_aon_intr2_intc 0x08>; + clocks = <&upg_fixed>; + }; From patchwork Fri Jan 20 19:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 46581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp374267wrn; Fri, 20 Jan 2023 11:05:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXvcq6OnDXoGgHsorIheUHCAI1ua33FAaGJgulW1frd+gjShLnvSfor90duQlCm7Qn1yHOsP X-Received: by 2002:aa7:8f09:0:b0:587:364f:17f5 with SMTP id x9-20020aa78f09000000b00587364f17f5mr36142739pfr.7.1674241508144; Fri, 20 Jan 2023 11:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241508; cv=none; d=google.com; s=arc-20160816; b=nBchq897d9mNEQkGtO7iX+ZHKoDyoAn7hhyi0ro29p9aOoVkjfsM9az8teOvkIryN/ AIj0z1Mu3Gj67lJ3ImiteD5Xjba6lm9560Q+Y0PcOESbdmYQXmjxkFau9E4O/h7m8NTL j9LXvvZ9IrS/wJxPj7qcCsEuVge9sKrSZeKbaqL8XaYm73u0aIIcm6NJeLIh6BGuqnOt mhS5WP4gs+HhJCU/PyMbctMJ788rPbnhFCC7xCw0dnMi5Ad5aAZnLxI2FYjFwfeP43X0 GwnNrrnQbPkwnXsrhS4H0pNelh9XV/xpNGucBinyrYmF12enMsXI+EdK3jQ86wFn0FU0 brUA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uqkC6sovxRXM6xizruGfWT9Cuv1q7uo8QTDLi10Fn4g=; b=g99D6cGoLP3tr6IqzDBCwflNNRhD+AHdkwiCP8SZiKeW4u9fnHJ9m4Mg1Ayiynv+S9 faf1f1BXwQswqcXtr/vrvYoovDJ6XW2UGdZCcC46UEm8dClAY2tdoY7WbVc2bpWkZhsY gOao88MOFCukVtbbQK68QAoYQJ78XFcB9FQT+A+q22hinWBCOJxwgxI6P23EUkDV1Kn/ s7g/KNcdbrFrmAbETQVDtgzGlXU/iZPthd2QuM8P45LX99funGkljs5pp0v8Bq642C4r 5gvc6SjH434nHwkORICXbpWsn/bB9kPT25ktBqGGjVQL6xr3kaLwzq+hLQRlNe86SaKt SXCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EKuaVn9G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a056a0015ce00b0058dd8430b2esi11099667pfu.213.2023.01.20.11.04.55; Fri, 20 Jan 2023 11:05:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EKuaVn9G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjATTCw (ORCPT + 99 others); Fri, 20 Jan 2023 14:02:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjATTCm (ORCPT ); Fri, 20 Jan 2023 14:02:42 -0500 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F8B3A88; Fri, 20 Jan 2023 11:02:35 -0800 (PST) Received: by mail-il1-x131.google.com with SMTP id i1so3161030ilu.8; Fri, 20 Jan 2023 11:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uqkC6sovxRXM6xizruGfWT9Cuv1q7uo8QTDLi10Fn4g=; b=EKuaVn9G3pyj6UJjR4KsvEGeAKeMW/ybk5bDiRItK543Wilx6Jfd7+C6b2FRBQOjaX XBucpToQF7YKAbHpfvWaRfkUyIy9PYC6mDdD/oo24Z3uLTRohw8SZ/Pysy9V0JIdtv97 hbLKehRGToyuPqdDqIZbFvlpJYEZNsqMkKCYWrLwwZgEfg0aJ7iRAGLWx4ThVSczPTE9 CmN9LSgn34DRhElpbkwKzf3PSE2eQ8MtJxdvsesqaRzo4jry5rlCxm1K6HFQ8jWeO3kT MKI7c/CQR4yUMBdIeUP5H4lhcXicAji0+7Z5K63tO+X7zINQrNm2XF0RPOfmX52zNnCf aOnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uqkC6sovxRXM6xizruGfWT9Cuv1q7uo8QTDLi10Fn4g=; b=8Cb9gQN1D3Q1ieMQeOTRU2cg5UpyZRC0aoNEmJhcu7OXrmPK61ml4umgZA/Hwhb4l/ xAxsIRaeR3bDFTXSgDJDVkwr3tlYeP2KDPswiIMe8j3qADHrPb6k4X2TkcJabiQvr5Vp ZGvF2uV5UlTxTNDuV8UjpuEz3fKW0rnzEaS178WHk/hSJFIYzlrHQKyllzGv6rc8Yi+n j+W53pthcmIr+t2Mokbo/JtoL6Fua2LLbPVB6tcb361SG9RLwBG4W9+zFvdS8lrurR/1 ZrJDgwxLQLG/KzGXcrIhY+3/0Zjle6RDMT5GrCHDJUCJyAB2CKFAjB3yjLzzJH9iQpFh 3wKw== X-Gm-Message-State: AFqh2krS1t9UnFfoE+Zvn+EcV9WTOCqrFHnLsOxootXPN+aZTKE3lxHN +6eH5PHeT0EjPmqDKS2KCaQ= X-Received: by 2002:a05:6e02:1562:b0:30f:3736:25ab with SMTP id k2-20020a056e02156200b0030f373625abmr8463918ilu.28.1674241355300; Fri, 20 Jan 2023 11:02:35 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id y13-20020a37f60d000000b006fa2b1c3c1esm10379806qkj.58.2023.01.20.11.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:02:34 -0800 (PST) From: Doug Berger To: Alessandro Zummo , Alexandre Belloni Cc: Brian Norris , Markus Mayer , Rob Herring , Krzysztof Kozlowski , Florian Fainelli , Broadcom internal kernel review list , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 6/6] rtc: brcmstb-waketimer: allow use as non-wake alarm Date: Fri, 20 Jan 2023 11:01:47 -0800 Message-Id: <20230120190147.718976-7-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230120190147.718976-1-opendmb@gmail.com> References: <20230120190147.718976-1-opendmb@gmail.com> 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_NONE,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755569463693100185?= X-GMAIL-MSGID: =?utf-8?q?1755569463693100185?= The wake interrupt only fires when the system is in a suspend state. Fortunately we have another interrupt that fires in a non-suspend state at the L2 controller UPG_AUX_AON. Add support for this interrupt line so we can use the alarm in a non-wake context. Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/rtc/rtc-brcmstb-waketimer.c | 55 +++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-brcmstb-waketimer.c b/drivers/rtc/rtc-brcmstb-waketimer.c index e25f9fcd6ed1..1efa81cecc27 100644 --- a/drivers/rtc/rtc-brcmstb-waketimer.c +++ b/drivers/rtc/rtc-brcmstb-waketimer.c @@ -28,6 +28,7 @@ struct brcmstb_waketmr { struct device *dev; void __iomem *base; unsigned int wake_irq; + unsigned int alarm_irq; struct notifier_block reboot_notifier; struct clk *clk; u32 rate; @@ -56,6 +57,8 @@ static inline void brcmstb_waketmr_clear_alarm(struct brcmstb_waketmr *timer) { u32 reg; + if (timer->alarm_en && timer->alarm_irq) + disable_irq(timer->alarm_irq); timer->alarm_en = false; reg = readl_relaxed(timer->base + BRCMSTB_WKTMR_COUNTER); writel_relaxed(reg - 1, timer->base + BRCMSTB_WKTMR_ALARM); @@ -88,7 +91,25 @@ static irqreturn_t brcmstb_waketmr_irq(int irq, void *data) { struct brcmstb_waketmr *timer = data; - pm_wakeup_event(timer->dev, 0); + if (!timer->alarm_irq) + pm_wakeup_event(timer->dev, 0); + return IRQ_HANDLED; +} + +static irqreturn_t brcmstb_alarm_irq(int irq, void *data) +{ + struct brcmstb_waketmr *timer = data; + + /* Ignore spurious interrupts */ + if (!brcmstb_waketmr_is_pending(timer)) + return IRQ_HANDLED; + + if (timer->alarm_en) { + if (!device_may_wakeup(timer->dev)) + writel_relaxed(WKTMR_ALARM_EVENT, + timer->base + BRCMSTB_WKTMR_EVENT); + rtc_update_irq(timer->rtc, 1, RTC_IRQF | RTC_AF); + } return IRQ_HANDLED; } @@ -114,7 +135,7 @@ static void wktmr_read(struct brcmstb_waketmr *timer, static int brcmstb_waketmr_prepare_suspend(struct brcmstb_waketmr *timer) { struct device *dev = timer->dev; - int ret = 0; + int ret; if (device_may_wakeup(dev)) { ret = enable_irq_wake(timer->wake_irq); @@ -122,9 +143,17 @@ static int brcmstb_waketmr_prepare_suspend(struct brcmstb_waketmr *timer) dev_err(dev, "failed to enable wake-up interrupt\n"); return ret; } + if (timer->alarm_en && timer->alarm_irq) { + ret = enable_irq_wake(timer->alarm_irq); + if (ret) { + dev_err(dev, "failed to enable rtc interrupt\n"); + disable_irq_wake(timer->wake_irq); + return ret; + } + } } - return ret; + return 0; } /* If enabled as a wakeup-source, arm the timer when powering off */ @@ -192,7 +221,11 @@ static int brcmstb_waketmr_alarm_enable(struct device *dev, !brcmstb_waketmr_is_pending(timer)) return -EINVAL; timer->alarm_en = true; + if (timer->alarm_irq) + enable_irq(timer->alarm_irq); } else if (!enabled && timer->alarm_en) { + if (timer->alarm_irq) + disable_irq(timer->alarm_irq); timer->alarm_en = false; } @@ -269,6 +302,19 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev) if (ret < 0) goto err_clk; + brcmstb_waketmr_clear_alarm(timer); + + /* Attempt to initialize non-wake irq */ + ret = platform_get_irq(pdev, 1); + if (ret > 0) { + timer->alarm_irq = (unsigned int)ret; + ret = devm_request_irq(dev, timer->alarm_irq, brcmstb_alarm_irq, + IRQF_NO_AUTOEN, "brcmstb-waketimer-rtc", + timer); + if (ret < 0) + timer->alarm_irq = 0; + } + timer->reboot_notifier.notifier_call = brcmstb_waketmr_reboot; register_reboot_notifier(&timer->reboot_notifier); @@ -317,6 +363,8 @@ static int brcmstb_waketmr_resume(struct device *dev) return 0; ret = disable_irq_wake(timer->wake_irq); + if (timer->alarm_en && timer->alarm_irq) + disable_irq_wake(timer->alarm_irq); brcmstb_waketmr_clear_alarm(timer); @@ -346,4 +394,5 @@ module_platform_driver(brcmstb_waketmr_driver); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Brian Norris"); MODULE_AUTHOR("Markus Mayer"); +MODULE_AUTHOR("Doug Berger"); MODULE_DESCRIPTION("Wake-up timer driver for STB chips");