From patchwork Fri Dec 7 13:48:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 153153 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp521574ljp; Fri, 7 Dec 2018 05:49:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VXbpbBAQ2eUNB7vdpt6IdmTn8i6CIm0iDivv4qqXpJ3EGnn6DSTJmN7omUDQNBTKNPOTla X-Received: by 2002:a17:902:42e4:: with SMTP id h91mr2271992pld.18.1544190574237; Fri, 07 Dec 2018 05:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544190574; cv=none; d=google.com; s=arc-20160816; b=qN8vO5YIzBqbXyCE3jihHQTSFYeMwk+zicSeuYdJ3i61gek+aAdjAiKuUAhkk0VDlm 9Wl6MXei4hctCieyOcNDEF1RQE6UGQeVsAOuo66N9DJojg9vGndYbEg13fK/TsZ6kpsU M8eoWnDkRmy1VayVAn6XaE1GGu4lg7Ic5OvMWGJJdjQIdDChgde7GG/3Vn6yTOuKa35F wfvZuVGtw0+ZQE2k4O2CsOnnZudXFGeo210bRbGVNVJnaNXPzEabGYIX45vLINeXurtB JN26qPkEU8B50ShiZ2tZAzcZFCsNdqWspSe9/2JriUZ25ye7V+M3CaSwzEfeGRzpAMoS fI4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nXGhvgbtM2MVYnmUcBhRNm1HWv2dEUpncTRfWaB6YNs=; b=kjxKlt/k1sG4Erz+0IhE/KMKnMkxp8DjAeM9B/MGZU4Q3z62tibaBBt9W781s1ulWe O9GvLA/wQm7jxu2E/9LjclY5HxmDWSsoDCqHCETmpSe4nOAiUyZLsZ5zjCgO3qIxvbBU Ezu3SA6cmSJHnSUFHAXo+zqbOGixLyEo1pGOsvMD5tvXPueSWxKCcBhP7wpvIkJK/cjL 7l0zRdLGb+B8O6fB7ZWbvVPyEYY8CDcBSBPLCiZMXZ9+OXKL1uc/9CKEM24fisISgFwf E9cLjWpq62pWKYmaTwRAtgstC6RcgjbUX+HdXQxIina6Tf1e+7KbaQppaJbsbFZrSF9o ZB1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si2980983pla.335.2018.12.07.05.49.33; Fri, 07 Dec 2018 05:49:34 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726161AbeLGNtc (ORCPT + 31 others); Fri, 7 Dec 2018 08:49:32 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:49273 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbeLGNt2 (ORCPT ); Fri, 7 Dec 2018 08:49:28 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MTRAS-1guSKU31dE-00TkSU; Fri, 07 Dec 2018 14:48:58 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-sh@vger.kernel.org, Baolin Wang , Andrew Morton , John Stultz , Alexander Viro , Thomas Gleixner , Rich Felker , Yoshinori Sato , Arnd Bergmann Subject: [PATCH 1/8] sh: dreamcast: rtc: push down rtc class ops into driver Date: Fri, 7 Dec 2018 14:48:17 +0100 Message-Id: <20181207134824.300024-2-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181207134824.300024-1-arnd@arndb.de> References: <20181207134824.300024-1-arnd@arndb.de> X-Provags-ID: V03:K1:iMOMQODGfxdkXkIiy3bpmWxGlvGkMgbchhdvPBw5kYhBgtYI+N1 esf5jxvn10dz8Z/kV6SkBDIvX+rhSPTO9pyF50LC9P6cVdhs8+DZSKMAmhzWMzbRm30dmn2 bWWWmOyFM+pZ8BNnQJvXLHANHYyyypsgvJY2sj1bfE8xx5YQPjcGbbCNLUjJwSTb2Kl1EGP gJ36oGH/SPVze5pFK8ThQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:H5CSwJcgbyU=:/Vk3o9HFH7jmv1Sz9gsGN7 /ekn6jJO7Xc+/R5e/ws3mQJQZw8dnUurIbuMruCvyAuofagfgSPYIg69v1ljQQKHMDswPmklD fqVx4gVQXZIum6ESZC5YY95Xs/ZLoz3GsBGsFc/Fbu8tyKNBfLfclYVj+C1jzu0Vozpid5pTh TKXPZ//TG7BggB4VQs+A7kUrs6G2xgPSXFI50snDkfSXF4z06GiL9oZp3eFZjeKfm/ejvKuZM BNFq5GICebEP+QtcCDYnpMM9m4fpOGKtzswOPWWcb3ncYh1Lwp/qaT/HCwO31rdDE+gItlTWJ +YFyfRgk1h6SauZBH8s4IAdknErOnxoN6MVVbU1cbCEuDzYDlJLmTL7/ufS1xPdJz0IuRmhV4 5VWUUncWpeS5lZYsJDZAzrr2tkWOd8efwgnevT4XrMX42zRyUqrNWdwQtndiCPvy6UkB21aPN 3Y/Cpp0p5x8y+UIlZkRqf8p2vIM+LhN3yg/3NXrkct+l0/YCTe2yT7xLqfrUBX12b0agKkkD1 Q6QQL8/yMb29Ocll7D7fNwr3hL/n0Ak5kU//GNQGC9On3XwDZwq5SeXWJFLUyP51rxjvhyF/Q NV5n0fR5RJuUz5gmJ/FkphoxIGNGLnxGwBIl+pwg4/hxgy14LtF6ohhDmTJGL0ztkaDFmCOSG MI5n27zUCx8eWhh0D9pYGsosHnnItHHq61fgWPk8SezQ0eBOASxUiA5BWe2cb14cNTclxMmBu auiPX+YKGwXry9zXi32DVC2Fz6pxFHzhXSsM6w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dreamcast RTC support has an extra level of indirection to provide either the old read_persistent_clock/update_persistent_clock interface or the rtc-generic device for hctosys/systohc. Both do the same thing here, so we can do away with the abstraction and simply enable the RTC core code to take care of it. Signed-off-by: Arnd Bergmann --- arch/sh/boards/mach-dreamcast/Makefile | 4 +- arch/sh/boards/mach-dreamcast/rtc.c | 39 +++++++++++++------ arch/sh/boards/mach-dreamcast/setup.c | 1 - arch/sh/configs/dreamcast_defconfig | 2 + arch/sh/include/mach-dreamcast/mach/sysasic.h | 1 - 5 files changed, 31 insertions(+), 16 deletions(-) -- 2.18.0 diff --git a/arch/sh/boards/mach-dreamcast/Makefile b/arch/sh/boards/mach-dreamcast/Makefile index 7b97546c7e5f..62b024bc2a3e 100644 --- a/arch/sh/boards/mach-dreamcast/Makefile +++ b/arch/sh/boards/mach-dreamcast/Makefile @@ -2,5 +2,5 @@ # Makefile for the Sega Dreamcast specific parts of the kernel # -obj-y := setup.o irq.o rtc.o - +obj-y := setup.o irq.o +obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o diff --git a/arch/sh/boards/mach-dreamcast/rtc.c b/arch/sh/boards/mach-dreamcast/rtc.c index 061d65714fcc..4f168d8d2951 100644 --- a/arch/sh/boards/mach-dreamcast/rtc.c +++ b/arch/sh/boards/mach-dreamcast/rtc.c @@ -11,8 +11,9 @@ */ #include -#include -#include +#include +#include +#include /* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in seconds) to get the standard Unix Epoch when getting the time, and add @@ -30,9 +31,10 @@ * * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch. */ -static void aica_rtc_gettimeofday(struct timespec *ts) +static int aica_rtc_gettimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; + time64_t t; do { val1 = ((__raw_readl(AICA_RTC_SECS_H) & 0xffff) << 16) | @@ -42,10 +44,12 @@ static void aica_rtc_gettimeofday(struct timespec *ts) (__raw_readl(AICA_RTC_SECS_L) & 0xffff); } while (val1 != val2); - ts->tv_sec = val1 - TWENTY_YEARS; + /* normalize to 1970..2106 time range */ + t = (u32)(val1 - TWENTY_YEARS); - /* Can't get nanoseconds with just a seconds counter. */ - ts->tv_nsec = 0; + rtc_time64_to_tm(t, tm); + + return 0; } /** @@ -54,10 +58,11 @@ static void aica_rtc_gettimeofday(struct timespec *ts) * * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. */ -static int aica_rtc_settimeofday(const time_t secs) +static int aica_rtc_settimeofday(struct device *dev, struct rtc_time *tm) { unsigned long val1, val2; - unsigned long adj = secs + TWENTY_YEARS; + time64_t secs = rtc_tm_to_time64(tm); + u32 adj = secs + TWENTY_YEARS; do { __raw_writel((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H); @@ -73,9 +78,19 @@ static int aica_rtc_settimeofday(const time_t secs) return 0; } -void aica_time_init(void) +static const struct rtc_class_ops rtc_generic_ops = { + .read_time = aica_rtc_gettimeofday, + .set_time = aica_rtc_settimeofday, +}; + +static int __init aica_time_init(void) { - rtc_sh_get_time = aica_rtc_gettimeofday; - rtc_sh_set_time = aica_rtc_settimeofday; -} + struct platform_device *pdev; + + pdev = platform_device_register_data(NULL, "rtc-generic", -1, + &rtc_generic_ops, + sizeof(rtc_generic_ops)); + return PTR_ERR_OR_ZERO(pdev); +} +arch_initcall(aica_time_init); diff --git a/arch/sh/boards/mach-dreamcast/setup.c b/arch/sh/boards/mach-dreamcast/setup.c index ad1a4db72e04..672c2ad8f8d5 100644 --- a/arch/sh/boards/mach-dreamcast/setup.c +++ b/arch/sh/boards/mach-dreamcast/setup.c @@ -30,7 +30,6 @@ static void __init dreamcast_setup(char **cmdline_p) { - board_time_init = aica_time_init; } static struct sh_machine_vector mv_dreamcast __initmv = { diff --git a/arch/sh/configs/dreamcast_defconfig b/arch/sh/configs/dreamcast_defconfig index 3f08dc54480b..1d27666c029f 100644 --- a/arch/sh/configs/dreamcast_defconfig +++ b/arch/sh/configs/dreamcast_defconfig @@ -70,3 +70,5 @@ CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_HUGETLBFS=y # CONFIG_CRYPTO_ANSI_CPRNG is not set +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_GENERIC=y diff --git a/arch/sh/include/mach-dreamcast/mach/sysasic.h b/arch/sh/include/mach-dreamcast/mach/sysasic.h index 58f710e1ebc2..59effd1ed3e1 100644 --- a/arch/sh/include/mach-dreamcast/mach/sysasic.h +++ b/arch/sh/include/mach-dreamcast/mach/sysasic.h @@ -42,7 +42,6 @@ /* arch/sh/boards/mach-dreamcast/irq.c */ extern int systemasic_irq_demux(int); extern void systemasic_irq_init(void); -extern void aica_time_init(void); #endif /* __ASM_SH_DREAMCAST_SYSASIC_H */