From patchwork Wed Dec 11 15:03:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 181235 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp910071och; Wed, 11 Dec 2019 07:17:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzPBkuFS9OaZTTWuMSBU7J3QPFUy7xOxJDTzZ+h9EzOvuJtThbouWwOjYxm0/njj0hmK8ZQ X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr2543654otp.137.1576077449265; Wed, 11 Dec 2019 07:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576077449; cv=none; d=google.com; s=arc-20160816; b=vs2956xIG38ryd8wVd/OD/puSj2Gnnwn2qKl0J6EDq+zi8xWqktKsMZi68jMqgT7bn ivqD/v/B2FFn5bxdJsv8oiwf5TXafWBc+HUtMD3paOVFWAwUBMlJ36OgahQ69m7yDqYJ okvX5CgMWrQvzn+0Bo91G6Kq7lRXSx/7A/I7iaJAmNbRdwLQ5AVAULxizOA4a0Tg2dzF DyTdJjdI9W7aQf4WNtsua+8Za8k3D64mivDnIZGvqnOCBCzcPOQIQHf9xqQQz4nBd7oO Yaj45yAAyDB3ZLFaUmSdKIj73PJwy8PZ1egaD1PlrDCU2dGlqJNuPs/bC5r0WiUjvlpR 26Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U2JnKag5k89Bc6WZqGcPt17fupkeNy5mLtrkuWnq9/Y=; b=m2h3D2ogAI5bATAC5kHG9TBER2vctcRpBaUE7sEpmNCbWK/Ur8hzuvoVfwQyDWZ8vr 6bZuP4W8y5ucAT1ssnkAu7SC6aah+E75KUAHY/cl22cCKe8fU014AYNSvT7AzpErMRgp s22rLfI20xxJMhCLV5Yb6jIu6piG+eQZPXmCiSpvaoqSSsLn78MHzjRdE8n3iY5dFdf0 s9NJHE2frbXwPtbxEAtx2Hg7eNpQundmm1bQkv98c12InPVPfJnRNQPKVI5TTEw+1xIS FRc1Cgncce9ddco0riigxf/0yZ+5nfzSA+7MgdUQP/ZQDxw14SkvKdFp17tHRf7zCJ1e ji/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=brGXA7qs; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si1158238otk.172.2019.12.11.07.17.29; Wed, 11 Dec 2019 07:17:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@kernel.org header.s=default header.b=brGXA7qs; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732013AbfLKPR1 (ORCPT + 14 others); Wed, 11 Dec 2019 10:17:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:44882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730633AbfLKPR0 (ORCPT ); Wed, 11 Dec 2019 10:17:26 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCCA022527; Wed, 11 Dec 2019 15:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077446; bh=ukoFwnczgAyE2vRjc7IL7n7fPud8uYiaaSklVZ9SKis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=brGXA7qsdzkCREmqATgfv9k6PmgMWY9gt1v4ZoOBmL28omvFC08snuAsmzRKQ8O7S JFQHxgD37YCJGOX73FKSs2bBFcfG+zWbK1JvZthzjtF/vQXJehGjZE0rG1g+v0PS6K JMfP4y5qHwIuZXPV4v4rhM3wJrWCfIQNoSpZI31M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.19 043/243] rtc: s3c-rtc: Avoid using broken ALMYEAR register Date: Wed, 11 Dec 2019 16:03:25 +0100 Message-Id: <20191211150342.039887686@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150339.185439726@linuxfoundation.org> References: <20191211150339.185439726@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marek Szyprowski [ Upstream commit 50c8aec4212a966817e868056efc9bfbb73337c0 ] (RTC,ALM)YEAR registers of Exynos built-in RTC device contains 3 BCD characters. s3c-rtc driver uses only 2 lower of them and supports years from 2000..2099 range. The third BCD value is typically set to 0, but it looks that handling of it is broken in the hardware. It sometimes defaults to a random (even non-BCD) value. This is not an issue for handling RTCYEAR register, because bcd2bin() properly handles only 8bit values (2 BCD characters, the third one is skipped). The problem is however with ALMYEAR register and proper RTC alarm operation. When YEAREN bit is set for the configured alarm, RTC hardware triggers alarm only when ALMYEAR and RTCYEAR matches. This usually doesn't happen because of the random noise on the third BCD character. Fix this by simply skipping setting ALMYEAR register in alarm configuration. This workaround fixes broken alarm operation on Exynos built-in rtc device. My tests revealed that the issue happens on the following Exynos series: 3250, 4210, 4412, 5250 and 5410. Signed-off-by: Marek Szyprowski Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/rtc/rtc-s3c.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.20.1 diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 75c8c5033e087..58e03ac3578b7 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c @@ -327,7 +327,6 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) struct rtc_time *tm = &alrm->time; unsigned int alrm_en; int ret; - int year = tm->tm_year - 100; dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", alrm->enabled, @@ -356,11 +355,6 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR); } - if (year < 100 && year >= 0) { - alrm_en |= S3C2410_RTCALM_YEAREN; - writeb(bin2bcd(year), info->base + S3C2410_ALMYEAR); - } - if (tm->tm_mon < 12 && tm->tm_mon >= 0) { alrm_en |= S3C2410_RTCALM_MONEN; writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON);