Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3661014imu; Sun, 11 Nov 2018 20:49:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eErxRRHriLArenCXnmaQFzQKjMj3iOYrbw96olXsmtYUmnHwrjCyAt1k0sxUX/Fu0UJHPJ X-Received: by 2002:a63:9c1a:: with SMTP id f26mr16284079pge.381.1541998176134; Sun, 11 Nov 2018 20:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541998176; cv=none; d=google.com; s=arc-20160816; b=KtDKkrt0EwIpMOsWb8h9MjXbNa4w/ahb9DA152pToYz7mDPgnoimHswDF7emAuG0jF M/XDPkfHKpX9iBwJPOW+VxWSMc4Vi+pIC2y+CyEp14crX65lvsJyNcg9KrIBV1Pm9K+/ 5RFybfk/2P+oURUA5rbX4GTiV9dnYMDokZdE5DlNokkXGLWq1xk2r86g6CRV5A4K2utp V3wtS93fV9Pmrhn7Hv8zV3Wc4FLkDQBHHOPvuasrzlIvujTmHYUQ8bNYUY8sVQCFMJIL SC8elUelsCtVJQ47fYydMTErktsLvSWLQrftlRgQU3fZmnTwIptgX1un3fPrBPVOSwL3 5MSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=d84U6yD/PzB7thjOaQoK8gL3BC0Il1uJyEfOMTiWR3M=; b=LnPNjSNhqgFUMt9Om/EJlDQLYi9Pn4j071/ei1G68YtodnmkJIop/L+MaArOGGW0IA R8sRDCbqfxlhbtlk1hCQFZy0FxacOYiLghbLF0hJVT0epce1TMP+vc+aUs0x5TRM5D7U cxnW/G3Y/S4oaL4IqVlxS3BuGEuyagHRhRImwYKmRopg7GFijEdZ+HHbLZpJFAdddUdo 4YkfsyhS8hG2u69B+RM0VELa60D3Lf46iLRjSN4hGL4YxkRLECT9R3vDPAqjeFNZ+361 uuUPJxu44Ls/5W3f5pV5qniXuylAJ2TWJ4uAs37El0KtEhvAeb1nshC7MAkrgPfgVM5Q eM1w== 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 i5-v6si3628144plt.108.2018.11.11.20.49.21; Sun, 11 Nov 2018 20:49:36 -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 S1731304AbeKLOi4 (ORCPT + 99 others); Mon, 12 Nov 2018 09:38:56 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48670 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730708AbeKLOiX (ORCPT ); Mon, 12 Nov 2018 09:38:23 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 06E53297EB; Sun, 11 Nov 2018 23:46:56 -0500 (EST) To: Geert Uytterhoeven Cc: Arnd Bergmann , Stephen N Chivers , Thomas Gleixner , Daniel Lezcano , John Stultz , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, Michael Schmitz Message-Id: In-Reply-To: References: From: Finn Thain Subject: [RFC PATCH 08/13] m68k: atari: Convert to clocksource API Date: Mon, 12 Nov 2018 15:12:39 +1100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a platform clocksource by adapting the existing arch_gettimeoffset implementation. Cc: Michael Schmitz Signed-off-by: Finn Thain --- arch/m68k/atari/time.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c index 4765e9a58293..d066599fcc54 100644 --- a/arch/m68k/atari/time.c +++ b/arch/m68k/atari/time.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,30 @@ DEFINE_SPINLOCK(rtc_lock); EXPORT_SYMBOL_GPL(rtc_lock); +static u64 atari_read_clk(struct clocksource *cs); + +static struct clocksource atari_clk = { + .name = "mfp", + .rating = 250, + .read = atari_read_clk, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static u32 clk_total; + +static irqreturn_t mfp_timer_handler(int irq, void *data) +{ + irq_handler_t func = data; + unsigned long flags; + + local_irq_save(flags); + clk_total += INT_TICKS; + local_irq_restore(flags); + + return func(irq, data); +} + void __init atari_sched_init(irq_handler_t timer_routine) { @@ -32,15 +57,16 @@ atari_sched_init(irq_handler_t timer_routine) /* start timer C, div = 1:100 */ st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60; /* install interrupt service routine for MFP Timer C */ - if (request_irq(IRQ_MFP_TIMC, timer_routine, 0, "timer", timer_routine)) + if (request_irq(IRQ_MFP_TIMC, mfp_timer_handler, IRQF_TIMER, "timer", + timer_routine)) pr_err("Couldn't register timer interrupt\n"); + + clocksource_register_hz(&atari_clk, INT_CLK); } /* ++andreas: gettimeoffset fixed to check for pending interrupt */ -#define TICK_SIZE 10000 - -u32 atari_gettimeoffset(void) +static u64 atari_read_clk(struct clocksource *cs) { unsigned long flags; u32 ticks, offset = 0; @@ -53,14 +79,13 @@ u32 atari_gettimeoffset(void) if (ticks > INT_TICKS - INT_TICKS / 50) /* Check for pending timer interrupt */ if (st_mfp.int_pn_b & (1 << 5)) - offset = TICK_SIZE; + offset = INT_TICKS; local_irq_restore(flags); ticks = INT_TICKS - ticks; - ticks = ticks * 10000L / INT_TICKS; - return (ticks + offset) * 1000; + return clk_total + ticks + offset; } -- 2.18.1