From patchwork Tue Jul 17 11:24:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 142128 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3530667ljj; Tue, 17 Jul 2018 04:25:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdbrI2sf6O3EL5cOvXByjUk07BdRbl38VKdOM6uyvzSaeOl+VpUFNQe+eNi/Ln7pzgG1K60 X-Received: by 2002:a62:8d7:: with SMTP id 84-v6mr287920pfi.172.1531826714291; Tue, 17 Jul 2018 04:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531826714; cv=none; d=google.com; s=arc-20160816; b=OliRfmVxZdj6IueYlQRIfZUxyQzFt+vKcocZLy3ugovxIicpZ5hDKTZo/CNJfv3fcZ LJzlgAM+XM/Pc+2cD9LnoCFiEk7Ach0/CXIq8r62bcMdsGt/qQhXiOyd81B02st83MXm 5w04muOmQbrmaMaA8BNFzHUXJ7vlxd093GbIsepgE/giDxxWrHNMhX41XgDPvavS3zFq 3uZU61dNZUwGwMsbzVzz9SPxzdNVYoffFIOslStqcayKp9jAoaA4+wBGooeqRm5ndh2g g437+uonidIwSJoQtp5bnzoQ0oP60JRJOxyo1OXbqO8WTInPwgZotkZ7psfhhoJ6m9sb sF/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=k3jKW0sCb0rK8PdrGlYTdRe+q05sdvywcfGkw5Lbutg=; b=NwwCAdysg1/rW7AIKhu93GdouH51dY1eN9JUU5MNMV5BIcQ5K1AMtT/eXMcOGU7r4D mPWcskhmgbmsUtkn3SBgEaxHtPWO/CN4c5K9AzNJRT2eIvTft3Rh8vrBhRXS9xwpgmH2 CXOdlSamB2PALVQGppaNhfChtIvUuufEPubLCkkNGdJWhJMP2j4Eno2o/IPHZfGtcRR3 mXs9QHIE8pIACZ3Kte/B6Wg8TLM/DiM9fG2HNSGQmiwYzH8SrKGHhIx1VOlSl6SWwfxo 4ygnvXwaCFkyiF1buvJTXdzBn2AwqGWvvMfAy/YtI0xLZjU4PrUSNZAYMBo3hzXRdD+z SCQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HgbzAvea; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18-v6si632181pgd.448.2018.07.17.04.25.14; Tue, 17 Jul 2018 04:25:14 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HgbzAvea; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731300AbeGQL5V (ORCPT + 31 others); Tue, 17 Jul 2018 07:57:21 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34822 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbeGQL5V (ORCPT ); Tue, 17 Jul 2018 07:57:21 -0400 Received: by mail-pg1-f196.google.com with SMTP id e6-v6so319544pgv.2 for ; Tue, 17 Jul 2018 04:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=k3jKW0sCb0rK8PdrGlYTdRe+q05sdvywcfGkw5Lbutg=; b=HgbzAveaSKoFkhJeJuYv38MCDkH8abJSq1TpKAP4jPut74BL6aFBLoUrAGAEnrO2cY nMxgwjwlMS3EPjDNLUHnyoCJpECeH4DrJx7MNdyKg9A80OqkcmjRrGPGHw5vhXxvXeCm 3yAgPIp3dBD4Wk1ehWJNSr6GmoJx47zF79w78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k3jKW0sCb0rK8PdrGlYTdRe+q05sdvywcfGkw5Lbutg=; b=IIDue6x/GLvMwPy2sen+1nG31o55Rt9sMlcYnCPMGKY/xug+5VBAIGmtZ9aRHdqlCJ Hy1OtEYJUt91oXDgdfXjQ1IiXUe3FG43VvYLRNQvVVoS0yKLcNMEkvb/rTLOWcY9xcK+ wKjEy6fa848G2PpWCRuzWglm8SMV5DcxhGg24zs41kz9QHuAClaBmU/mXXojzxhN3QuO 4ZAYMs6m0H/d2GayvmAPewajjMA7WlfbOSSgvdhifHDPiEiMEqI+JO4lUYQFLQnNuZUk u/bz98t/AqDxNCixrCXuznshJB5Rv67L5muZiqNE+QHn4S0UZhmAmckJQFrAyWYXTAW7 lY0g== X-Gm-Message-State: AOUpUlFEsk9ZwJWmEvQkEJFaYB/9I3AknvwYlh9WmZbzZm4xNN85kN0o MJJpKkmclqDSn7F4ejPHHDQ8Pw== X-Received: by 2002:a63:c80e:: with SMTP id z14-v6mr1172426pgg.77.1531826710885; Tue, 17 Jul 2018 04:25:10 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id y3-v6sm1391207pge.29.2018.07.17.04.25.08 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jul 2018 04:25:10 -0700 (PDT) From: Baolin Wang To: ysato@users.sourceforge.jp, dalias@libc.org, corbet@lwn.net Cc: baolin.wang@linaro.org, arnd@arndb.de, broonie@kernel.org, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 1/4] sh: dreamcast: rtc: push down rtc class ops into driver Date: Tue, 17 Jul 2018 19:24:24 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 Signed-off-by: Baolin Wang --- 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(-) -- 1.7.9.5 diff --git a/arch/sh/boards/mach-dreamcast/Makefile b/arch/sh/boards/mach-dreamcast/Makefile index 7b97546..62b024b 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 061d657..4f168d8 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 ad1a4db..672c2ad8 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 3f08dc5..1d27666 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 58f710e..59effd1 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 */