From nobody Fri Dec 17 10:09:56 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5CA5318FA39B; Fri, 17 Dec 2021 10:09:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JFl8j0rRnz4RhV; Fri, 17 Dec 2021 10:09:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9DAB19EFA; Fri, 17 Dec 2021 10:09:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BHA9ujF052700; Fri, 17 Dec 2021 10:09:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BHA9ukM052699; Fri, 17 Dec 2021 10:09:56 GMT (envelope-from git) Date: Fri, 17 Dec 2021 10:09:56 GMT Message-Id: <202112171009.1BHA9ukM052699@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 3e5fe3d5bf88 - main - pcf85063: Set RTC device to work in 24h mode List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e5fe3d5bf8812795e0b9f29f01c5e5cf5449871 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639735797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=529xNujGDcmNKlRpJ8u3/1+BAnRL8QlL5UH1Sy27J7o=; b=IHkfbzqb0OW/Zw7vKLEVTMbTGchccHw21vfmLkLgUh/M3Nv80dqF4DCMzWs43PFiFFmeue NJFZtJyfwD0lJXULRQltOHYgJfOD2nWNqSrtZ3xubonjrbxlIRCZwYgBi8oiYZb4P1p/sr 92XqkUaBnaL4XbFSsqgRWvn8VnBj5NANcDog7vNTXZ0IEAFDlNe3gn6+vRvbt4IjUemnyf ReJjRb97Shn83WurKjzz7yGtzZ4gLPeXy1QHQTUdrRTYy9HNzbPROJ1AjdVCR9l11fZR08 09+agss6YFMMLwwF3nDuDDPrgmAiEsHDVQqBEhvFg4W4f5/R0ULEtaw7SIjyfA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639735797; a=rsa-sha256; cv=none; b=XAiLDxY1m974tdJhBgYbF9GmluUYFW/edtCx9/8MtiKgzLUMH8FG4y/Phj6D+dO77aZYub +lhPRFAE+7NOtgaoHL5jjVIYEBR5tneoExfqvaAdEsdQGKQrXd4tIEyFjKaw/5UUKiOl2p KhrICavQKBIX8+KqTLXBvFji/Uis4Z7YXBDYg3iJ9Bru0CNiMLHTERcv49Hb0L/a1UfHvP yNrY0EEIREkwnCtXzLsqne238MModEDD4kAIwtHu+3BLiy5rXn2qtJqXsfNdGrxORjaYeF 7fzVcGPbcwvdbF31KhY4fu9M1o4fcXxsRxblaNPEkFYMf1WWmBqeXLzdYmVaxA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=3e5fe3d5bf8812795e0b9f29f01c5e5cf5449871 commit 3e5fe3d5bf8812795e0b9f29f01c5e5cf5449871 Author: Hubert Mazur AuthorDate: 2021-12-16 08:16:22 +0000 Commit: Wojciech Macek CommitDate: 2021-12-17 10:07:07 +0000 pcf85063: Set RTC device to work in 24h mode Sometimes the device did not set default hour mode setting correctly, which lead to conversion errors. Explicitly set device to work in 24h mode by clearing flag in register, instead of allowing defaults. Reviewed by: imp Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D33497 --- sys/dev/iicbus/rtc/pcf85063.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/dev/iicbus/rtc/pcf85063.c b/sys/dev/iicbus/rtc/pcf85063.c index dad52239f061..af2417a497db 100644 --- a/sys/dev/iicbus/rtc/pcf85063.c +++ b/sys/dev/iicbus/rtc/pcf85063.c @@ -183,7 +183,7 @@ pcf85063_set_time(device_t dev, struct timespec *ts) sizeof(uint8_t), IIC_WAIT); ts->tv_sec -= utc_offset(); - clock_ts_to_bcd(ts, &bcd, ctrl_reg & PCF85063_CTRL1_TIME_FORMAT); + clock_ts_to_bcd(ts, &bcd, false); clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, &bcd); data.sec = bcd.sec; @@ -194,11 +194,6 @@ pcf85063_set_time(device_t dev, struct timespec *ts) data.mon = bcd.mon; data.year = bcd.year; - /* Set this bit in case of 12-hour mode and pm hour. */ - if (!(ctrl_reg & PCF85063_CTRL1_TIME_FORMAT)) - if (bcd.ispm) - data.hour |= 0x20; - if (ts->tv_nsec > PCF85063_HALF_OF_SEC_NS) data.sec++; @@ -209,6 +204,8 @@ pcf85063_set_time(device_t dev, struct timespec *ts) return (error); ctrl_reg |= PCF85063_CTRL1_RTC_CLK_STOP; + /* Explicitly set 24-hour mode. */ + ctrl_reg &= ~PCF85063_CTRL1_TIME_FORMAT; error = iicdev_writeto(dev, PCF85063_CTRL1_REG, &ctrl_reg, sizeof(uint8_t), IIC_WAIT);