Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3660028imu; Sun, 11 Nov 2018 20:47:50 -0800 (PST) X-Google-Smtp-Source: AJdET5fmRqupRXwJ/N2o5M81t2APEKm40cJHanphOOsAax6SOimOdYplQGxCWzflHscx93Z+rfwr X-Received: by 2002:aa7:8348:: with SMTP id z8-v6mr18509902pfm.81.1541998070408; Sun, 11 Nov 2018 20:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541998070; cv=none; d=google.com; s=arc-20160816; b=RonNQUg3eXwLokETN/wCx6D5d7YU3eJEdS7vB+PSvQQ89hs8TGHR7ASX+c7DHkezd8 S8a3/qZv7TmmNR6aVLDhV/HY1edaaH4m38zWyzbuDCsBz8BY9KKAOht4MfEdu51NUlW/ vLwR1Ff3wcoXFhymEIgAqPh3qBkAgVvLK54lleF5BaEfBBAmGFEHh8CrIOXWzKOdEEwp 3NxeBG3zb5nyLRijCqWdiYp8PctB/sVOhbp5BVdUT15zbj0igbnLT0QscT39ySXtVOx6 WfIqCTs5cnx0RGvvGGBaJ+DuJZ81I8gVdre+1Vi0q3tCenPbyJWQ8AHAnxIS27ilc3kL hgAA== 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=qtsWyQpqm0v6u8Q3CckB/fhynE51yL6ubz0VD5DkYmw=; b=ubMKzBi7Oswuay/hOCPPXZfhbT67nnK2GK/crN/M/3//m/ZzMAmoKwIqqRZt56OyOJ JnXQR5zIDbus7mS4EC104ZHXicxErElafZSgAoLeFMP9CHME9JtzxRXHvRMKG92VypTf 0dbU8O/KCvtUK02Lv9Drtmu0XvKxyX99Z1QMfcNuflFrBPAVMa7oF2jjTZiazhQcANWR 9EeMyO9uB+VCiDGqsHxdBmudYZ3jYHkbGpv6JfQOdh1u+XQwxdbOIxDrg7y3ZqwYMpxb injjy8UKoP38YnLMxbyhluNGq8UMzXPbzwMzAKLzdqqfQHQ6+Q+n7KLFGYr0QMOmkh93 kQCg== 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 v5-v6si3413165plp.85.2018.11.11.20.47.35; Sun, 11 Nov 2018 20:47:50 -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 S1731153AbeKLOiY (ORCPT + 99 others); Mon, 12 Nov 2018 09:38:24 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48716 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730982AbeKLOiY (ORCPT ); Mon, 12 Nov 2018 09:38:24 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 5D4AF297EF; 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 Message-Id: <2f4015ba435f6f06b874295d2a47319875474c7f.1541995959.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [RFC PATCH 13/13] m68k: mvme16x: 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. Signed-off-by: Finn Thain --- arch/m68k/mvme16x/config.c | 45 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index f1ed52331df3..7bd3a25b2d75 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -49,12 +50,6 @@ extern void mvme16x_reset (void); int bcd2int (unsigned char b); -/* Save tick handler routine pointer, will point to xtime_update() in - * kernel/time/timekeeping.c, called via mvme16x_process_int() */ - -static irq_handler_t tick_handler; - - unsigned short mvme16x_config; EXPORT_SYMBOL(mvme16x_config); @@ -348,9 +343,31 @@ static irqreturn_t mvme16x_abort_int (int irq, void *dev_id) return IRQ_HANDLED; } +static u64 mvme16x_read_clk(struct clocksource *cs); + +static struct clocksource mvme16x_clk = { + .name = "pcc", + .rating = 250, + .read = mvme16x_read_clk, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static u32 clk_total; + +#define PCC_TIMER_CLOCK_FREQ 1000000 +#define PCC_TIMER_CYCLES (PCC_TIMER_CLOCK_FREQ / HZ) + static irqreturn_t mvme16x_timer_int (int irq, void *dev_id) { + irq_handler_t tick_handler = dev_id; + unsigned long flags; + + local_irq_save(flags); *(volatile unsigned char *)0xfff4201b |= 8; + clk_total += PCC_TIMER_CYCLES; + local_irq_restore(flags); + return tick_handler(irq, dev_id); } @@ -359,16 +376,17 @@ void mvme16x_sched_init (irq_handler_t timer_routine) uint16_t brdno = be16_to_cpu(mvme_bdid.brdno); int irq; - tick_handler = timer_routine; /* Using PCCchip2 or MC2 chip tick timer 1 */ *(volatile unsigned long *)0xfff42008 = 0; - *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */ + *(volatile unsigned long *)0xfff42004 = PCC_TIMER_CYCLES; *(volatile unsigned char *)0xfff42017 |= 3; *(volatile unsigned char *)0xfff4201b = 0x16; - if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, - "timer", mvme16x_timer_int)) + if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, IRQF_TIMER, + "timer", timer_routine)) panic ("Couldn't register timer int"); + clocksource_register_hz(&mvme16x_clk, PCC_TIMER_CLOCK_FREQ); + if (brdno == 0x0162 || brdno == 0x172) irq = MVME162_IRQ_ABORT; else @@ -378,10 +396,11 @@ void mvme16x_sched_init (irq_handler_t timer_routine) panic ("Couldn't register abort int"); } - -u32 mvme16x_gettimeoffset(void) +static u64 mvme16x_read_clk(struct clocksource *cs) { - return (*(volatile u32 *)0xfff42008) * 1000; + u32 count = *(volatile u32 *)0xfff42008; + + return clk_total + count; } int bcd2int (unsigned char b) -- 2.18.1