From patchwork Fri May 29 14:46:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49221 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 98E8B218E7 for ; Fri, 29 May 2015 14:48:47 +0000 (UTC) Received: by lani11 with SMTP id i11sf21296761lan.3 for ; Fri, 29 May 2015 07:48:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=hH6mBPa09yvvBdv3ZjRtZDN63HxxblaajlMR6p0SiWw=; b=M1KXbGsp95eyq7sSSotl9Dhl6RDwbh6O5tS7ivmZ6Om6cZleAvU4QqutWk8pMr/g+x VCQ1kj33HK3H83VaiwRiLHGinGKSOh8ZwjHAlr4+3AnN0Qa6Cy9IKvOWEU4k5+8s9YwE s315U6I4rwdxNsZibngM6mq9hyy9eOM0Vt+4TmfEevKeERbMa2cuznRibPx+RfEBpdnR 5kkp99ONdCiDD5GxyrHY5VEzuUiOGbNZGBRpVu20FQG+HdjNhAFGtj4q6rhKY1Ba/xE1 D80ElGb/K16e5DzYHN0l+HcKC3CCg9jhgzK3LrPGmVRKYmk5b/yYG6HRCShwQ4a/3Rfs kLPQ== X-Gm-Message-State: ALoCoQlJ20CcTiziAFnDZ6BK+SGg6gIW0R6+yEXAYd/dkluPEpH1WE/YRSm7a7hl9bknL6xlS96Z X-Received: by 10.194.236.230 with SMTP id ux6mr7533766wjc.5.1432910926462; Fri, 29 May 2015 07:48:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.65 with SMTP id yg1ls321600lab.26.gmail; Fri, 29 May 2015 07:48:46 -0700 (PDT) X-Received: by 10.112.72.2 with SMTP id z2mr8225562lbu.39.1432910926120; Fri, 29 May 2015 07:48:46 -0700 (PDT) Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com. [2a00:1450:4010:c03::22b]) by mx.google.com with ESMTPS id s10si4862228laj.84.2015.05.29.07.48.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 07:48:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b; Received: by lagv1 with SMTP id v1so57553340lag.3 for ; Fri, 29 May 2015 07:48:45 -0700 (PDT) X-Received: by 10.152.2.133 with SMTP id 5mr6969604lau.36.1432910925832; Fri, 29 May 2015 07:48:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp393922lbb; Fri, 29 May 2015 07:48:44 -0700 (PDT) X-Received: by 10.66.161.198 with SMTP id xu6mr8022774pab.58.1432910923951; Fri, 29 May 2015 07:48:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l3si5095184pdp.109.2015.05.29.07.48.42; Fri, 29 May 2015 07:48:43 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756403AbbE2Osg (ORCPT + 28 others); Fri, 29 May 2015 10:48:36 -0400 Received: from m50-111.126.com ([123.125.50.111]:45443 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756345AbbE2OsU (ORCPT ); Fri, 29 May 2015 10:48:20 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowAAHLTLCe2hVnOL+AA--.2718S2; Fri, 29 May 2015 22:46:50 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , John Stultz , Arnd Bergmann , "David S. Miller" , sparclinux@vger.kernel.org, linux-cris-kernel@axis.com, Mikael Starvik , Jesper Nilsson , Xunlei Pang Subject: [PATCH v2 1/4] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization Date: Fri, 29 May 2015 22:46:15 +0800 Message-Id: <1432910778-314-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jtKowAAHLTLCe2hVnOL+AA--.2718S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4DCr1xWr1UGF4rurWUCFg_yoW5AF17pr WfA34xKrsFgF45XrsrA3ykuFy5K3Z7J3yUGF13C3WF9FyUArykur1ayrW7XrWUJrs3J39a qFy0gFnxuw1UCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jzmhrUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbijBoJv1GfViNy8wAAsa Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22b as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang Currently, CONFIG_RTC_SYSTOHC uses CONFIG_RTC_HCTOSYS_DEVICE which is originally used by CONFIG_RTC_HCTOSYS, but this rtc device has some limiations, for example, it must be battery-backed, be able to work with irq off and through system suspension, etc. So add CONFIG_RTC_SYSTOHC_DEVICE used exclusively for CONFIG_RTC_SYSTOHC, it is more lenient compared to CONFIG_RTC_HCTOSYS_DEVICE, and could be assigned any available RTC in the system. Default value is "rtc0". After this patch, NTP will sync up "rtc0" by default. Signed-off-by: Xunlei Pang --- drivers/rtc/Kconfig | 28 +++++++++++++++++++--------- drivers/rtc/systohc.c | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 0fe4ad8..f429e9a 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -25,17 +25,9 @@ config RTC_HCTOSYS the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. -config RTC_SYSTOHC - bool "Set the RTC time based on NTP synchronization" - default y - help - If you say yes here, the system time (wall clock) will be stored - in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 - minutes if userspace reports synchronized NTP status. - config RTC_HCTOSYS_DEVICE string "RTC used to set the system time" - depends on RTC_HCTOSYS = y || RTC_SYSTOHC = y + depends on RTC_HCTOSYS = y default "rtc0" help The RTC device that will be used to (re)initialize the system @@ -56,6 +48,24 @@ config RTC_HCTOSYS_DEVICE sleep states. Do not specify an RTC here unless it stays powered during all this system's supported sleep states. +config RTC_SYSTOHC + bool "Set the RTC time based on NTP synchronization" + default y + help + If you say yes here, the system time (wall clock) will be stored + in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 + minutes if userspace reports synchronized NTP status. + +config RTC_SYSTOHC_DEVICE + string "RTC used to synchronize NTP adjustment" + depends on RTC_SYSTOHC = y + default "rtc0" + help + The RTC device used for NTP synchronization. The main difference + between RTC_HCTOSYS_DEVICE and RTC_SYSTOHC_DEVICE is that this + one can sleep when setting time, because it runs in the workqueue + context. + config RTC_DEBUG bool "RTC debug support" help diff --git a/drivers/rtc/systohc.c b/drivers/rtc/systohc.c index 7728d5e..b4a68ff 100644 --- a/drivers/rtc/systohc.c +++ b/drivers/rtc/systohc.c @@ -31,7 +31,7 @@ int rtc_set_ntp_time(struct timespec64 now) else rtc_time64_to_tm(now.tv_sec + 1, &tm); - rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); + rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); if (rtc) { /* rtc_hctosys exclusively uses UTC, so we call set_time here, * not set_mmss. */