From patchwork Tue Jan 24 20:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 47881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2354029wrn; Tue, 24 Jan 2023 12:17:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtSuUM3ub17kTz6QBHmZr6dsnIjHrtnw+qaSDBbnKiWbLzaX43xWAu97n95PsrIZQxskIf0 X-Received: by 2002:a05:6402:f04:b0:480:cbe7:9ee2 with SMTP id i4-20020a0564020f0400b00480cbe79ee2mr37296655eda.22.1674591454988; Tue, 24 Jan 2023 12:17:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674591454; cv=none; d=google.com; s=arc-20160816; b=LOLf91XpjZQZ2TFNq533s4147yKn9J27QU89qB36gVsZ80cqYSqKl/t3KkvIzNdwmM x8leOIdZ1xQSdBHWw/QpccEiao+ukO5pva9CDkBSBk7QGMCw6EEiHP07aL1toiXBwR2M OLIZ5NXcr72mh5w6NoHfXd3TwzFAr7cMh1qfByoREJ/P64eLRwfBeCtSClWPdv6vFhd+ jhMasX+GDaxrgMnkSSkSaJ5+flg/mp52YqGBlzwMMC7AVqErnhQUXFi0EbL9tA6JZXQB soob/Or8f5rDe0akrWvCP4x6MokejcLpiAT6CubfcBXSm1m/6uYV+RXep8n9rhHfaAq0 6Z/g== 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=ll14lOuViaenf8FjC8Zh9d13ikWCf4/ACX98HmRIznQ=; b=YRovxy7bClwsS92e0bbT2Un85hFt9sVMSWv03MaxRQ8ru1Iz1cyuEATXhonBr4iylg QcwaPNga9AczYj4zMTfBAqxsj2Hp5GVFzg0vMMJfez1pU87S0qAjmSXLoamkKKQX8Zi0 1dwSIEFUBtIsuXN5ewmGZyEdpC0aT01r9CL6/OxDKIw7EaCYGYlIbP0zC+eaVSEOQ/O4 HGfJpqPXtjNH20heSK9QVVS9No8+DLAaK+UcnmRmDKY6RIhASy0g6N/0+g4f7RE/veIQ dnsalZr73rBDQuQufWWKj0vnONJQ5KEhCcOTToctrnzIUdcvVR1mzxM4eslrhPn/0w3j soMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZAopVKkN; 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 uo28-20020a170907cc1c00b00870a4c96667si3589840ejc.177.2023.01.24.12.17.11; Tue, 24 Jan 2023 12:17:34 -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=ZAopVKkN; 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 S230011AbjAXUPG (ORCPT + 99 others); Tue, 24 Jan 2023 15:15:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjAXUOx (ORCPT ); Tue, 24 Jan 2023 15:14:53 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D732A15E; Tue, 24 Jan 2023 12:14:52 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso2402796pju.0; Tue, 24 Jan 2023 12:14:52 -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=ll14lOuViaenf8FjC8Zh9d13ikWCf4/ACX98HmRIznQ=; b=ZAopVKkN0s7Png4zG+tuGkTd3xixUMd69So0uL2bMx5KZYtc59pIqZ4f2v8pmvU3AB Kv95PTiLofjK8wrWBwJZDyZmKerFogMJQE3VWtLiLWEbnfCFI9IBKwP2Fnkao1M50VV6 jPwciYogW4lFiUwTsf7OxNMVtNrC1BOvo7FD2DvB62ARFsUh32Tw3rImxM28KOBudBZx o3DrAhuk052jHvkh1NKylSFBAdr/sH8ccp1r0dbjQOm+qfst19wDunhyd4k4SlIK/bLa lEHCOhLIuivm1krpd8+vkGHCDUaqD+GfMOc/C8jxl1H08Mio2yA+Tl3Jjyf37nv50I1Y o9OQ== 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=ll14lOuViaenf8FjC8Zh9d13ikWCf4/ACX98HmRIznQ=; b=o/+ZTXdM5UNdPmo+6Rcvy8Q0ryT7CTmaQa7eb1ZHjQUkuCere5xp/yUklm3a01ZhjG PTt5ElEgCTmHeUZgVeYhrQ45a0MZzRGNLJvUTTiveT1yua15FW1d5IYs3qB1pTsfiQ9j IF59bEyKxW/DJ8Cq6lH9iNO6Ogve75IE8k/cU2rcy9kem+aZlcvlvxSl1NvVYnVnK76Q gukGbvuJ6JBStzfeSR7vkpQVRWAJtLyjFXf6vuzH/4gnXIzDKHj5g45HSukfRzdGGpRu 1v7kYmqSMZIqX0srE4Xr7S8SFC1XPSdlDBrM2n0s5atyHZFXwy9GVwGDCAezz5kI6es0 QxMg== X-Gm-Message-State: AFqh2kq/I7v8weZos6PF3rjeZFDl1HQO9y6DcTYdGi76hMVZ9nkvKtex PcdovrnGXcVJH/pXem4XuMQ= X-Received: by 2002:a17:902:ca13:b0:195:f265:66dc with SMTP id w19-20020a170902ca1300b00195f26566dcmr12490201pld.68.1674591291804; Tue, 24 Jan 2023 12:14:51 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d13-20020a170902728d00b00174f61a7d09sm2057824pll.247.2023.01.24.12.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 12:14:51 -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 v2 1/2] dt-bindings: rtc: brcm,brcmstb-waketimer: add alarm interrupt Date: Tue, 24 Jan 2023 12:14:29 -0800 Message-Id: <20230124201430.2502371-2-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124201430.2502371-1-opendmb@gmail.com> References: <20230124201430.2502371-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?1755936409311824671?= X-GMAIL-MSGID: =?utf-8?q?1755936409311824671?= A second interrupt can optionally be specified for this device to be used for generating RTC alarm interrupts. Signed-off-by: Doug Berger Reviewed-by: Krzysztof Kozlowski Acked-by: Florian Fainelli --- .../bindings/rtc/brcm,brcmstb-waketimer.yaml | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml b/Documentation/devicetree/bindings/rtc/brcm,brcmstb-waketimer.yaml index 9fe079917a98..c6c57636c729 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 @@ -35,10 +42,10 @@ additionalProperties: false examples: - | - rtc@f0411580 { + rtc@f041a080 { compatible = "brcm,brcmstb-waketimer"; - reg = <0xf0411580 0x14>; - interrupts = <0x3>; - interrupt-parent = <&aon_pm_l2_intc>; + reg = <0xf041a080 0x14>; + interrupts-extended = <&aon_pm_l2_intc 0x04>, + <&upg_aux_aon_intr2_intc 0x08>; clocks = <&upg_fixed>; }; From patchwork Tue Jan 24 20:14:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 47882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2354208wrn; Tue, 24 Jan 2023 12:18:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxK5uTghyTZ/nbPx0KRsuv0IekhUPCqW6NTOnuZsPc0Tyy0TX5LJPAwTIlRP5x6TWI8nqI X-Received: by 2002:a17:906:2542:b0:877:6e07:92df with SMTP id j2-20020a170906254200b008776e0792dfmr25507867ejb.15.1674591482003; Tue, 24 Jan 2023 12:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674591481; cv=none; d=google.com; s=arc-20160816; b=kMPQVzmW7Y2928BKy38jchAbzrny6ams9XGI57KZC1pxSkkHPAD9C7cJIdNzjowLzT bfmNqlCHRZGRO853iRNqPuI+6ADfpYzYy5Y1C333zsYMc8+V/maU1T3SmLFH0RQMBtIs nhNqzFoSjEio2ZqhYn0pFFCQ4UjakJyaLQtKtGERKv+419mLJOfQkct8ekowl8pq/mIr 2+YPAbk+OeahcKXKeXfrzqTjCvr3ARbu6WlYErp18ld2gdXVJy9m+9ELlyL4tzlS5dXo l1W2wAEV4dvsknx28Ahpc+yy//7AYJ9UrFvTwxvjHOE97Tn58MTnEOEEhjrvbsgkFkRt S13g== 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=oEtY5LynS2vkRPJ1R/kvYmV9SRofdb2LH2C1cStAz2M=; b=utZZoOMnQBu2wg/2yNFMz7+o1W0T76OjV0CQ1J24JV4B3QinSVENQEvF6JDmPhm6x9 vKlQktSFZtQkUj73qI20O8c+ZQ9dXdWtwjZrTj9NGTbyvqeDbgvOmyGsPhQ90AZkTzja RXoMQUM/sg1HAKzQsPwQ5Je6BH6Xp354iOv7u36g1YJrTxvO1rE++1q80zpqUEqK08xW 1gZ5bzpkMAQydKLHcPXYXwnLFiFk0G1NkiKW5wXaMC59XRK5gzDEP6SNcNad6tIi/X59 m3UrySLHS9j0+ivuv5bzW6Cu7K7Su04KhrqtcbOBwvbfkFXm0MPPI1zrl5qLi0ddQhFi xEyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YLqMn6DX; 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 ex15-20020a170907954f00b0084d354539a5si3055442ejc.584.2023.01.24.12.17.38; Tue, 24 Jan 2023 12:18:01 -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=YLqMn6DX; 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 S230252AbjAXUPM (ORCPT + 99 others); Tue, 24 Jan 2023 15:15:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbjAXUOz (ORCPT ); Tue, 24 Jan 2023 15:14:55 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47AF31E5C6; Tue, 24 Jan 2023 12:14:54 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id u1-20020a17090a450100b0022936a63a21so19817656pjg.4; Tue, 24 Jan 2023 12:14:54 -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=oEtY5LynS2vkRPJ1R/kvYmV9SRofdb2LH2C1cStAz2M=; b=YLqMn6DXAHVh1XoLozY4AjSZ2agwCfvhkAMhaBbQlDjZBccFd5CgQll9zu3+eXv+T3 lut752J6pdicDNwtPw0D/+VEKasV0TNfcTCgXpPB0+JjUkK9ObZ5KeUXHB4eBdiCgMkS rAsMHZUlC4kZpqXMwZFqItpHxhcsPA2Noz9zjHKcdCT3BueUIdmHnnQRZNxkxJqrQKcx 73PR4NrdkovewfZ3usoqswNOzbAYl+8khJh3bxc7hzSMHjXLOYeeH6BYtu/OA+CUrS4O 3PzgLegGlYVKJyk9LsJVomZ987ObpTgG9tGRWdgemBqxaQ6xBdhniwDIeH/nvK/6pAuE rP4Q== 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=oEtY5LynS2vkRPJ1R/kvYmV9SRofdb2LH2C1cStAz2M=; b=Vg6VeW8lC4EhbhXBwPmcsYfSihSdRr5etMv1R1Fyy3+FwHd9TrqUeEXjA2b5uKTL0A ZgJt2RpaCo8EQlf5bRdh/0z8aUddKnYgaMCeo3E+ptDrrxhIzJw8+SVYNwsn47teRwxy 1cYLrXZqlkIhPdTBmGFxJTEZgM7gawbtvVMQgmkDIWo68m7atE80cW6P9DGLKPgCw5iO hQLQwrvNBUDXBP2YAP1UslpvvCJVPoZJWxZ+R7OHZQbo85l3QX8al4ct5SGI9dJ998BP Cr2dWEhaKn87FZJf7roPL4+jmjAJuJNJy9zV5xcaQRNll7V8s49gULsNRZyYm/IiPfcn 81RA== X-Gm-Message-State: AO0yUKWKASRiHYug93PVla9D+aozZGyRUfiDcxc1KLw04qrAPcYn3ALs q0O7Wg2rKdbXgezTmgSLFpk= X-Received: by 2002:a05:6a20:6985:b0:bb:a0a2:c37a with SMTP id t5-20020a056a20698500b000bba0a2c37amr4187151pzk.33.1674591293717; Tue, 24 Jan 2023 12:14:53 -0800 (PST) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id d13-20020a170902728d00b00174f61a7d09sm2057824pll.247.2023.01.24.12.14.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 12:14:53 -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 v2 2/2] rtc: brcmstb-waketimer: allow use as non-wake alarm Date: Tue, 24 Jan 2023 12:14:30 -0800 Message-Id: <20230124201430.2502371-3-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124201430.2502371-1-opendmb@gmail.com> References: <20230124201430.2502371-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?1755936438146031603?= X-GMAIL-MSGID: =?utf-8?q?1755936438146031603?= 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");