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: 13110411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE646C25B4E for ; Fri, 20 Jan 2023 19:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZD4eQ2sk2ImaQr6J7t+webIyfAKPmVzsgMPS7WFOTIU=; b=1BvzUyjFdl4nHe ycHkIGSiVYAHbsp/NzOTzIeKNp2eBt86BTHYxwZIf2XXb+Bw96CZ58udouP3L/TlB8hnsJy33nbla P+duOPh3ieKrCX4jHHy97J4eGYeqxrveBzjO/EnXLvXHmsrJbf1yh+GoPnlTUnqOsPX6U5HGCkX5w 57sGmmaf5ykUdnAe80vAH2VDrpanAYiymq77V/k6KhKGHANv8cU6E5UmiKqaL0qYrUT2j9XugPL1Y RoFHagYMD7P51udd9SAzEGuUoRmxCoy5B6tz7CvNa+/mohSD6K1P/Qgrs9HAEE+dOBSftL7uwL5bo +sBo9A5ono2OcJSxmasg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIwev-00Bwjv-NA; Fri, 20 Jan 2023 19:02:41 +0000 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIweh-00Bwd8-8W for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2023 19:02:28 +0000 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-15fe106c7c7so1185432fac.8 for ; 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=cwqcLIwesYD2ZYSpLVAX+lBOe3+D358vM86rkkAdGG7jB7pFuQL9RS6WoxRR2vj6l4 ltL9Pw8DytWqVyaDNhpwaOWODldMpmsuMpKA64sMB4+C3Crj3FfTmRh7y1bV+uxiq0Gr RuozaXW4bXWA62PoXYspDcu6+yqKhg3xkeBa0370/Kwxj3cZ+m6fRJgU4RV8B3iwEbo+ 37JpKQCjXrbE5U5A9tkrirsFDyuRfNekCvdFEHhLEJ8fEJbe/lVzr7OPF016aO0vyUHK b1TwqVSzrQPIPXot/fcOBcEnTKpF/8Uj/o3PdVZlycJZhAzs47wQES3eWP5G7AEFZtNd cRKw== X-Gm-Message-State: AFqh2kr4QLsYAFEROiFNT8qyXrv+Ml+nvN84G0B4m3tN/4zU51/GNUTq zHV+WjGMjL6i58kPz3WmlkM= X-Google-Smtp-Source: AMrXdXsK3rb24IkcXVqFKHwUF49SEPlnN/5ksK/9sve7PrZGtMncS1IEl2kZYoWbgrc+oTCVV7/8sQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_110227_343279_7B1E35AF X-CRM114-Status: GOOD ( 15.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; }