From patchwork Thu Oct 18 08:52:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 149105 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1699163lji; Thu, 18 Oct 2018 01:52:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV62PfJumgNLqsLL3m3gwPiCWRYI6aGs1X4lb5cpoXOiOmhTPjr9ZUxx5bS5WmpMoaXl7I/a0 X-Received: by 2002:a17:902:1e2:: with SMTP id b89-v6mr29727364plb.296.1539852779387; Thu, 18 Oct 2018 01:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539852779; cv=none; d=google.com; s=arc-20160816; b=C4q10Z3NKTBz5NYvfQ9sqbz2Khmn5dvHqcThLVKq20G3mbNjgSHYERQaSu9p20tRfY Fn2kgOhih8EbVrf7XSb/Y90zfoLY4QRfAKD/4AmRT9ZviGyMcZVvZ36ZRDqQ7ydRpKdf AHS5lHAXmYv6WE2ZtnBMP4nAzJtqnmc2NaMZDBi5a8BBiuRL0pLYfyRfN3F4sYNSr4Sl GO6NPft1v+teISuOixHZQ+n4N97q9JY19oRlEKyek3M/uOtgfrPA0LhpzEhlzSr5hoK6 xl+Rp6VuENt4QwSXfQlGRIcwZ+E1/g7xgZ22n+WBSFoWKTvSHq7GLYSy08Ft71UIh/Nm mlLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=x1nRgoQUZ83pegJhrhtQ6KjoIL98LywhZ2h6g+wmhPg=; b=QYYxEZus6eCAw4i+lEUkHY9IhmPETGJJQ8hy799L3I8pZ2za0VqRrJKEMRC+QOqCuS KOj6n5W69FIItn3h6FVLxdp4aaIs9SnbG5kAXp00vk/fSehEMVLPltajs0VBGf6psjjV dkGNeyX/9+5UAWDvH7v8Rdj7gFV/U/NixGmcvIn4wb4xPxDKuDGHUcitQSSI+tv3SwF1 E3d2HQDihDr4h7NfuQLz2JHft/bnEe901aTuWAouVg5lfR2+nt4nUWFgkXJtmsNQOILI Z0J5yH1snZdw7mtQyEItf5Rv4NLNtMJwEkc3sJg8RPYN59pimY9Yg1ySIIY2GrUKIB8M LC4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XqOW8k7j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s64-v6si20960609pfi.134.2018.10.18.01.52.59; Thu, 18 Oct 2018 01:52:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XqOW8k7j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727986AbeJRQwz (ORCPT + 32 others); Thu, 18 Oct 2018 12:52:55 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40701 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727489AbeJRQwy (ORCPT ); Thu, 18 Oct 2018 12:52:54 -0400 Received: by mail-pl1-f196.google.com with SMTP id 1-v6so14014008plv.7 for ; Thu, 18 Oct 2018 01:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=x1nRgoQUZ83pegJhrhtQ6KjoIL98LywhZ2h6g+wmhPg=; b=XqOW8k7jjTgAWLYpZfRfud/yIu2mDZv3OPT7bqPN/Pm289Hvi37fhtx6uKf/M576oE Hp8wdCDZJQRo0LC7Zp7EXzQ1ddEJ5+qLB5D0/riHdTy4fpeTFwkqRsdxAleHmBPHBNmR OzMUIlKj+UZJ/yUYLMUuvr6dMTYAIRgKmxg00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=x1nRgoQUZ83pegJhrhtQ6KjoIL98LywhZ2h6g+wmhPg=; b=JmzXhgZjYjadRIm9mM/qu9WcfOfO4mFHtTUwvIGGTrUT9Y3mctd5kceNtkOEGJXj9v QFvv/Ny4RK3lCM6ydOQAnAlnHdNsqWOi/E7mDdO+ipn/k5Gh3mULqT8jHeVFf/6lAM0R SXOHCsuPfHDLLL00mH1fbWIeKi/9M9k755OEiXk8V/PCa/todyyG6i5mZs5zjUEaecv8 D0kOLTuHg5tql7GAP/hyz2SubMzTatD0R3G7N1RvZ45sp86puKXN+pkSADB++1youCCO 3Go0kdVmL7DvyMsTX3qqoTXemvFnqH6jpg6Mx7vi/Iacu+/u5J7L7rRZOiAUCN4Rpkq3 sIfQ== X-Gm-Message-State: ABuFfojBIZ3P1tTIZBKZegenuuN+zLmSWZ3O6b1XuLc1ODSo9Vkfykeo wOgb44jgKl46xaWAXwEJuR2pLw== X-Received: by 2002:a17:902:7e0b:: with SMTP id b11-v6mr28875383plm.246.1539852775833; Thu, 18 Oct 2018 01:52:55 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id x186-v6sm18467528pfb.125.2018.10.18.01.52.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 01:52:54 -0700 (PDT) From: Baolin Wang To: a.zummo@towertech.it, alexandre.belloni@bootlin.com Cc: broonie@kernel.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH 4/5] rtc: sc27xx: Add check to see if need to enable the alarm interrupt Date: Thu, 18 Oct 2018 16:52:29 +0800 Message-Id: <4b0d13b57a64b6ba6ba65c4c2b60319633911427.1539851865.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RTC interrupt enable register is not put in always-power-on region supplied by VDDRTC, so we should check if we need enable the alarm interrupt when system booting. Signed-off-by: Baolin Wang --- drivers/rtc/rtc-sc27xx.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 1.7.9.5 diff --git a/drivers/rtc/rtc-sc27xx.c b/drivers/rtc/rtc-sc27xx.c index 4ecabe6..72bb002 100644 --- a/drivers/rtc/rtc-sc27xx.c +++ b/drivers/rtc/rtc-sc27xx.c @@ -563,6 +563,32 @@ static int sprd_rtc_check_power_down(struct sprd_rtc *rtc) return 0; } +static int sprd_rtc_check_alarm_int(struct sprd_rtc *rtc) +{ + u32 val; + int ret; + + ret = regmap_read(rtc->regmap, rtc->base + SPRD_RTC_SPG_VALUE, &val); + if (ret) + return ret; + + /* + * The SPRD_RTC_INT_EN register is not put in always-power-on region + * supplied by VDDRTC, so we should check if we need enable the alarm + * interrupt when system booting. + * + * If we have set SPRD_RTC_POWEROFF_ALM_FLAG which is saved in + * always-power-on region, that means we have set one alarm last time, + * so we should enable the alarm interrupt to help RTC core to see if + * there is an alarm already set in RTC hardware. + */ + if (!(val & SPRD_RTC_POWEROFF_ALM_FLAG)) + return 0; + + return regmap_update_bits(rtc->regmap, rtc->base + SPRD_RTC_INT_EN, + SPRD_RTC_ALARM_EN, SPRD_RTC_ALARM_EN); +} + static int sprd_rtc_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; @@ -596,6 +622,13 @@ static int sprd_rtc_probe(struct platform_device *pdev) rtc->dev = &pdev->dev; platform_set_drvdata(pdev, rtc); + /* check if we need set the alarm interrupt */ + ret = sprd_rtc_check_alarm_int(rtc); + if (ret) { + dev_err(&pdev->dev, "failed to check RTC alarm interrupt\n"); + return ret; + } + /* check if RTC time values are valid */ ret = sprd_rtc_check_power_down(rtc); if (ret) {