Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp53310pxb; Sun, 15 Aug 2021 23:03:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyyGGTx4t2TaH0zahm6qZd2MBrIIl1MmYyDVjWKJJHW7X+ypMKQ6+sWtMy9/QBKEpEScZJ X-Received: by 2002:a92:bf12:: with SMTP id z18mr10790070ilh.274.1629093827963; Sun, 15 Aug 2021 23:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629093827; cv=none; d=google.com; s=arc-20160816; b=iPM/8/xbRFQ/56Pr/jruGFOXl9HKhygIJnF9znuVJlzV6TEC+ygyD7gphiXvR53BFX QRzpkuik9sIKzXou7LfedoWT9bE2r/2kkEIw3Attb/1HbCuLdgHPAqIaGuDH5GJtuiAC dd3rwoTc6z1nSmXA2keibB2SuIeRJtS1J9i0iXn10Gjks6VG3kpl9nJ0Ez48cNU/BBIj EsuH4Kz57YsPozQP1m8SQwmRaAS6eLzAY4Y+jynoQHmMoeeo4XLLZt32WipFdnkXTlRR goo7sGspW/jfQM/xDd3mTElcFZw7Ha1UEvQLepkMPTTLIWZBLVD7M7SsOk8c4rnx3rcZ mqUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=KNPEObhBOvQit7YN70Kz6ytw95ir8IcA8rAlRiChOhw=; b=YmXDnp00880ZsRtG1ul0tlZ/GeFYSGR2dKD1ZIZnhQVSjl7Qvs0dr/DlvmWY8tiUiN tDmfnIhlPb9GXUmazYnrpGdROweEJ0M5cjpMZwVgCYqaLUn7+fq/WetEP8cHr9Bp0Bb0 ppTpau3kl4qTAaNdMwMOxQFrH48K6Q1KnBhcDi+PuIVJh9RIgeKyN1ywCSaI+pGQ00s8 dQQn8f+CC5hqqL1+FUgo7t6R3+B5QpYInDY28Eo9r9trnIENc98uiJT2YG1LT8nEDKbQ YvvyvRCqYo956R5elW6EjC33wKGXncJcbidDwIQTqWD6UzY66Q1CFG9Q4Ljug/QHu9AF RHww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si10049649ile.120.2021.08.15.23.03.35; Sun, 15 Aug 2021 23:03:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233188AbhHPGDC (ORCPT + 99 others); Mon, 16 Aug 2021 02:03:02 -0400 Received: from ZXSHCAS2.zhaoxin.com ([203.148.12.82]:39644 "EHLO ZXSHCAS2.zhaoxin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbhHPGC7 (ORCPT ); Mon, 16 Aug 2021 02:02:59 -0400 X-Greylist: delayed 904 seconds by postgrey-1.27 at vger.kernel.org; Mon, 16 Aug 2021 02:02:59 EDT Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS2.zhaoxin.com (10.28.252.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 16 Aug 2021 13:47:21 +0800 Received: from tony-HX002EA.zhaoxin.com (10.32.56.37) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Mon, 16 Aug 2021 13:47:19 +0800 From: Tony W Wang-oc To: , , , CC: , , , , , Subject: [PATCH] rtc: Fix set RTC time delay 500ms on some Zhaoxin SOCs Date: Mon, 16 Aug 2021 21:47:18 +0800 Message-ID: <1629121638-3246-1-git-send-email-TonyWWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.32.56.37] X-ClientProxiedBy: ZXSHCAS2.zhaoxin.com (10.28.252.162) To zxbjmbx1.zhaoxin.com (10.29.252.163) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the RTC divider is changed from reset to an operating time base, the first update cycle should be 500ms later. But on some Zhaoxin SOCs, this first update cycle is one second later. So set RTC time on these Zhaoxin SOCs will causing 500ms delay. Skip setup RTC divider on these SOCs in mc146818_set_time to fix it. Signed-off-by: Tony W Wang-oc --- drivers/rtc/rtc-mc146818-lib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c index dcfaf09..322f94b 100644 --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -190,8 +190,18 @@ int mc146818_set_time(struct rtc_time *time) spin_lock_irqsave(&rtc_lock, flags); save_control = CMOS_READ(RTC_CONTROL); CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); + +#ifdef CONFIG_X86 + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) && + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59))) { + save_freq_select = CMOS_READ(RTC_FREQ_SELECT); + CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); + } +#else save_freq_select = CMOS_READ(RTC_FREQ_SELECT); CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); +#endif #ifdef CONFIG_MACH_DECSTATION CMOS_WRITE(real_yrs, RTC_DEC_YEAR); @@ -209,7 +219,15 @@ int mc146818_set_time(struct rtc_time *time) #endif CMOS_WRITE(save_control, RTC_CONTROL); + +#ifdef CONFIG_X86 + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) && + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59))) + CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); +#else CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); +#endif spin_unlock_irqrestore(&rtc_lock, flags); -- 2.7.4