From patchwork Tue Nov 13 11:32:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 150964 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4286644ljp; Tue, 13 Nov 2018 03:33:07 -0800 (PST) X-Google-Smtp-Source: AJdET5fTavxWrp/JiffH7/JOIXRqocuZAUOhPYQzIGRL/fe5Iu6w3VyEJznPH7ZkgKGxU2ZJ8E/+ X-Received: by 2002:a62:43cd:: with SMTP id l74-v6mr4915736pfi.240.1542108787076; Tue, 13 Nov 2018 03:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542108787; cv=none; d=google.com; s=arc-20160816; b=p/pkX+q831rwqQPdCuPFtZtofjsSmkcepLzh/N6vebAegOX6uq7nodTuLkjbT7aHK6 haMc7aMOFoH01jGABCNTNjjFQlxeLqoY+jKauxtmSaFDDRbkidk52c2YJrhaN4n5HEns ngWHnzZgcYGRBg6/XIqfpXJO3vlllQfT1tPV49zJnNl2t1zBkT2hcWpeyaciuLi1MfKA 6Klcvr2DaGAFACwtTt/BYDutk8frrlPamJYGv0pramKmIsSuKhBgUGAvT3w3X+d2xCW/ MY5VCMQ8V2X/1dBjEtd1Lzdwcxmkdp5vyodJUv1bsOcod38I5dp+6PUs6SI22fYiZ2hK P0Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=iOoJU0iNTiK0psWiZsqYmpjNB24OGeS0a90Pg8Yxgi0=; b=KPNsvTDs7NKSf1SQrC6TPh6WNIAxCxQWLbuyPbTT4mtA3SE3gSVfVPhHgu7mnQC+Dn 94VoNs1olBgDCEjw9c33LaVA8Q4ikaYsMfpEwoPFSrCNhqN40ppH2Ff0PxyAzj0UPY1a cvZCLxUGWIRMmeYbBDkp+s9z6LNlckLN4PjWn5ZrBHOxkRjOjp5DMdi0HUtxAb4UPRWM ZNAghF3hdaVQU67PqIg9ijkP0jBfKVsfqhLwYl2lawZrj0+R/LM2GTRTBk8muyGOr6nz vTJ0t/ms+DMQnWgqtdQyfugxC0SmtKszw6dVYHDg+x7WWLhWA4a7H40TCnpLSZHuT1LW PksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=pP3Lv3MX; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22-v6si20632234plp.201.2018.11.13.03.33.06; Tue, 13 Nov 2018 03:33:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-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=@samsung.com header.s=mail20170921 header.b=pP3Lv3MX; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732526AbeKMVat (ORCPT + 3 others); Tue, 13 Nov 2018 16:30:49 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:49572 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732104AbeKMVas (ORCPT ); Tue, 13 Nov 2018 16:30:48 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181113113304euoutp0202edc798eaf2a65e9f7d7cc64ebc9ebb~mq8Tmmotl1489714897euoutp02j; Tue, 13 Nov 2018 11:33:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181113113304euoutp0202edc798eaf2a65e9f7d7cc64ebc9ebb~mq8Tmmotl1489714897euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542108784; bh=iOoJU0iNTiK0psWiZsqYmpjNB24OGeS0a90Pg8Yxgi0=; h=From:To:Cc:Subject:Date:References:From; b=pP3Lv3MXhrBEMXkn3ipG067fFwY4QNIinhm8Nak3/ogRbzKDWmvIVR41UWHboO+yR tvRcfpSnwazI5IUNkwkIqTL9kstPDGWpE+FRZiLH6RoySsyzSonDWcqCejmpK15NPG jnGBvE2Btpp66GbXKcvRDzrSUiY9Iyy0UnTvR11Q= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181113113303eucas1p27c45246d5cb0910f3adf933eca6510f4~mq8S7RjVr3240232402eucas1p2b; Tue, 13 Nov 2018 11:33:03 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id CA.F1.04441.F66BAEB5; Tue, 13 Nov 2018 11:33:03 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181113113303eucas1p130a8d53b363d8ff378389e2cfc6f6cc6~mq8SPhyim3147531475eucas1p1Q; Tue, 13 Nov 2018 11:33:03 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-c6-5beab66fdd2c Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 0E.52.04284.F66BAEB5; Tue, 13 Nov 2018 11:33:03 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PI4008Z7QQZ3H30@eusync4.samsung.com>; Tue, 13 Nov 2018 11:33:03 +0000 (GMT) From: Marek Szyprowski To: linux-rtc@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Alexandre Belloni , Alessandro Zummo , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH] rtc: s3c-rtc: Avoid using broken ALMYEAR register Date: Tue, 13 Nov 2018 12:32:50 +0100 Message-id: <20181113113250.15527-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRmVeSWpSXmKPExsWy7djPc7r5215FGxx7rWix5OJVdov2d8vY LTbOWM9qcf78BnaLY6uvsFnMOL+PyWLtkbvsDuwe89ZUe2xa1cnm0bdlFaPH9Hk/mTw+b5IL YI3isklJzcksSy3St0vgyvi1fyVTwTKBihNbVRoYt/J2MXJySAiYSPx+O5G9i5GLQ0hgBaPE 4flnmCGcz4wS3Ws+MMNUrXjzkBUisYxRYubqlSwQTgOTxLGp09lAqtgEDCW63naB2SICDhJf /7wFK2IWeMcosWftGhaQhLCAk8Tvm7vAbBYBVYkzv4+B2bwCthJv/16FWicvsXrDASj7JavE tDX2ELaLxOw9B9kgbGGJV8e3sEPYMhKdHQeZQJZJCDQzSrTPmMUO4fQwSmydswOqw1ri8PGL rCA2swCfxKRt04E2cADFeSU62oQgSjwk+tcfASsREoiV6L74mWkCo8QCRoZVjOKppcW56anF hnmp5XrFibnFpXnpesn5uZsYgXF2+t/xTzsYv15KOsQowMGoxMN7YvrLaCHWxLLiytxDjBIc zEoivDtNXkUL8aYkVlalFuXHF5XmpBYfYpTmYFES561meBAtJJCeWJKanZpakFoEk2Xi4JRq YFzj8DPWkI2xzvB7z4bz4pOebT4ie/NSzLfpl/qX1FiJfetc86z8eu1q2f2TOQMu2fLbCHhk fs8XShfkXGipJTetTJLJ4P7sxG13dhiKmIh8XRj7LmVz8rU1tnayyVPMV77fyCLc4+3StsPs 3hoeL8FphvpXjj5vdDD/+3HFu99ePwJaC8s0FiqxFGckGmoxFxUnAgCw/MtKrwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHJMWRmVeSWpSXmKPExsVy+t/xa7r5215FGxyawGqx5OJVdov2d8vY LTbOWM9qcf78BnaLY6uvsFnMOL+PyWLtkbvsDuwe89ZUe2xa1cnm0bdlFaPH9Hk/mTw+b5IL YI3isklJzcksSy3St0vgyvi1fyVTwTKBihNbVRoYt/J2MXJySAiYSKx485C1i5GLQ0hgCaPE wWstUE4Tk8StfXtYQKrYBAwlut52sYHYIgIOEl//vGUBKWIW+MAoseTCGWaQhLCAk8Tvm7vA GlgEVCXO/D4GZvMK2Eq8/XuVGWKdvMTqDQeYJzByLWBkWMUoklpanJueW2yoV5yYW1yal66X nJ+7iREYCtuO/dy8g/HSxuBDjAIcjEo8vCemv4wWYk0sK67MPcQowcGsJMK70+RVtBBvSmJl VWpRfnxRaU5q8SFGaQ4WJXHe8waVUUIC6YklqdmpqQWpRTBZJg5OqQZGj55tE0Jbuf8wJTyI rw4Mfdjx5Oq8p5mtQhPz4t/dmnP++fniX3eX2fJbPvW/N336g/idF/Z8XdXy5aWUdw7z35wW vy9rj51pq/0iwf/427dE36UBHX2nvn+dpuCzPpjpQPzdGNH8Ga3bG31NikLrj1nOdCtpD11w ijOoq335PtVO1ghp5ZVflViKMxINtZiLihMBAYklngECAAA= X-CMS-MailID: 20181113113303eucas1p130a8d53b363d8ff378389e2cfc6f6cc6 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181113113303eucas1p130a8d53b363d8ff378389e2cfc6f6cc6 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org (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 --- drivers/rtc/rtc-s3c.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.17.1 diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index 75c8c5033e08..58e03ac3578b 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);