From patchwork Tue Jun 2 09:14:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49354 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3D9DD2052D for ; Tue, 2 Jun 2015 09:17:01 +0000 (UTC) Received: by wgla2 with SMTP id a2sf39275635wgl.1 for ; Tue, 02 Jun 2015 02:17:00 -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=NlhcvAJFC8doN3WiUUL6Fo7Gk4hTvTbO5W0sYXhpxJs=; b=ahUQl/HFCctKrEI+cp/8tU4fby1Yj9Ut2opF2W7cJ9NNQW6RUEulLO9K7V9Usfw/wp AMedFfUledkWUVmHSAKYSKZA0RQpKhEpku50zOEzAGaNZhKHvgyx1J92t/7RZH3zxWTP RW4EXokhHlhzjrg5xQ/N9MNrCSOK6JFpHHqoioORF7kZDCGAwJWBqvoObp97ngMDdlOy 6GQ2h+O50E4B5YvHtWAftdl/59dbweqcPqZCYVqj19tJDfIuUor8Qc9LerNCnpIj2hJ5 SFtzWsPU1+KTYe3kzdBubgPuopBPyIWmY7HlLpNNVwPW8smAnEU9mBfytQCf7IFfT87t 4ZYA== X-Gm-Message-State: ALoCoQnXz4xTsdPJOCtuBPwaNtnW8afNtHHZAQmql6665rkZ9vmst8kokcz6oDIkxyBFFtHJXG0S X-Received: by 10.180.83.72 with SMTP id o8mr15629641wiy.3.1433236620566; Tue, 02 Jun 2015 02:17:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.133 with SMTP id y5ls220668laj.19.gmail; Tue, 02 Jun 2015 02:17:00 -0700 (PDT) X-Received: by 10.112.125.166 with SMTP id mr6mr24448745lbb.83.1433236620372; Tue, 02 Jun 2015 02:17:00 -0700 (PDT) Received: from mail-lb0-x22a.google.com (mail-lb0-x22a.google.com. [2a00:1450:4010:c04::22a]) by mx.google.com with ESMTPS id jq16si14587608lab.7.2015.06.02.02.17.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 02:17:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22a as permitted sender) client-ip=2a00:1450:4010:c04::22a; Received: by lbbuc2 with SMTP id uc2so100408039lbb.2 for ; Tue, 02 Jun 2015 02:17:00 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr24817809lbb.29.1433236619894; Tue, 02 Jun 2015 02:16:59 -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 hn6csp2915001lbb; Tue, 2 Jun 2015 02:16:58 -0700 (PDT) X-Received: by 10.68.219.42 with SMTP id pl10mr10918671pbc.154.1433236616482; Tue, 02 Jun 2015 02:16:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oy6si25542974pdb.9.2015.06.02.02.16.54; Tue, 02 Jun 2015 02:16:56 -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 S1758602AbbFBJQr (ORCPT + 28 others); Tue, 2 Jun 2015 05:16:47 -0400 Received: from m50-110.126.com ([123.125.50.110]:43848 "EHLO m50-110.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753808AbbFBJQc (ORCPT ); Tue, 2 Jun 2015 05:16:32 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp4 (Coremail) with SMTP id jdKowACn3mAJdG1Vs_0qAQ--.3424S2; Tue, 02 Jun 2015 17:14:59 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , Alexandre Belloni , John Stultz , Arnd Bergmann , Xunlei Pang , Paul Bolle Subject: [PATCH v2 1/4] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization Date: Tue, 2 Jun 2015 17:14:34 +0800 Message-Id: <1433236477-1724-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jdKowACn3mAJdG1Vs_0qAQ--.3424S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4DCr1xXFWkuF45Cw1rZwb_yoW5Cryxpr WfA348KrZF9F45XrsrC397uFy5tas7J3yUGF13C3WF9FyUAryDur1ayrW7XrWUJrs3J39a qFyjgFnxuw1UCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j2zuXUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi7xkNv1Uwx566+wABs4 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:c04::22a 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. Cc: Paul Bolle Signed-off-by: Xunlei Pang --- v1->v2: Change "depends on RTC_XX = y" to "depends on RTC_XXX". 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..f422a46 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 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 + 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. */