From patchwork Fri Jun 12 03:10:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 49784 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0DE0920C81 for ; Fri, 12 Jun 2015 03:14:09 +0000 (UTC) Received: by wgla2 with SMTP id a2sf6168720wgl.1 for ; Thu, 11 Jun 2015 20:14:08 -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=Ss6RWqVgHejD2Ku/woovzuYStoLhMISkSJTMARJGs8U=; b=Id8JVGObna+uJx6/UVXj1PDx9ijSnzkKDAfyA3UTs9trW9MjchwCFHYFgXLvR9CHZl SBs6bRslGE2UatJoKVYaymNeROPFlGLG4TR6U4HN6mIdTiu9aBAVtxRgI00MvTVTSAa5 xUV6PBsf5bJIc3r64fEzQ2ZiA5BSDAoe08b8XTAeqcj49vFFQ/XVGrI3SrVYVQMZZc/d 8C3cVx025WEPFueobk5dtvELeYaSQOGSUhAtwdl/4u1cRhAhzqexYTjq8E72MVW1wurO +muIBlPw2ATaEtskb0Vdk8FKOOqvYTGdz+8MB0iwpLCk86PpXQ8pN6RCDNfdafCes1S7 cUDQ== X-Gm-Message-State: ALoCoQl3DDPQH5haU//gjPvA/yI5oaOsIS3i6mtGzXc8RzKEh7//sjmrgmCxJkX8fv0jjtd6N/La X-Received: by 10.180.36.172 with SMTP id r12mr1689318wij.6.1434078848361; Thu, 11 Jun 2015 20:14:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.199 with SMTP id y7ls270040lad.47.gmail; Thu, 11 Jun 2015 20:14:08 -0700 (PDT) X-Received: by 10.112.213.108 with SMTP id nr12mr13085238lbc.42.1434078848166; Thu, 11 Jun 2015 20:14:08 -0700 (PDT) Received: from mail-la0-x22e.google.com (mail-la0-x22e.google.com. [2a00:1450:4010:c03::22e]) by mx.google.com with ESMTPS id p9si2215356laj.176.2015.06.11.20.14.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 20:14:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22e as permitted sender) client-ip=2a00:1450:4010:c03::22e; Received: by lagh7 with SMTP id h7so3406294lag.0 for ; Thu, 11 Jun 2015 20:14:08 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr12815117lay.72.1434078848040; Thu, 11 Jun 2015 20:14:08 -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 hn6csp242987lbb; Thu, 11 Jun 2015 20:14:06 -0700 (PDT) X-Received: by 10.70.128.68 with SMTP id nm4mr19723156pdb.74.1434078846184; Thu, 11 Jun 2015 20:14:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si3372014pds.196.2015.06.11.20.14.05; Thu, 11 Jun 2015 20:14:06 -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 S1753160AbbFLDOB (ORCPT + 29 others); Thu, 11 Jun 2015 23:14:01 -0400 Received: from m50-111.126.com ([123.125.50.111]:54654 "EHLO m50-111.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753002AbbFLDN6 (ORCPT ); Thu, 11 Jun 2015 23:13:58 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp5 (Coremail) with SMTP id jtKowAAnbaa5TXpVUaYwAQ--.1090S2; Fri, 12 Jun 2015 11:11:07 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , Alexandre Belloni , John Stultz , Arnd Bergmann , "David S. Miller" , sparclinux@vger.kernel.org, Xunlei Pang , Paul Bolle Subject: [PATCH v3 1/3] NTP: rtc: Add CONFIG_RTC_SYSTOHC_DEVICE for NTP synchronization Date: Fri, 12 Jun 2015 11:10:16 +0800 Message-Id: <1434078618-16373-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jtKowAAnbaa5TXpVUaYwAQ--.1090S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZw4DCr1xXw4fur17Xr17trb_yoW5Cryxpr WfA34IgrsFgF45XrsrC3ykuFy5Kas7J3yUGF13G3WF9FyUArykCr1ayrW7XrWUJFs3t39a qFy0gFnxuw1UCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jzmhrUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbi6AsXv1UJQdk27wAAsW 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::22e as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@126.com; 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 CONFIG_RTC_HCTOSYS_DEVICE which is "rtc0" by default. After this patch, NTP will sync up "rtc0" by default. Cc: Paul Bolle 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..1dcfab4 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 RTC_HCTOSYS_DEVICE + 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. */