Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3660627imu; Sun, 11 Nov 2018 20:48:57 -0800 (PST) X-Google-Smtp-Source: AJdET5evOJ+6aKkiiAor2kxEt0zhytPQtBPnWyhVEl/CzP/yJW15oofur0UjrnQMQHiE3VBRr9nB X-Received: by 2002:a63:cd17:: with SMTP id i23mr16047806pgg.13.1541998137320; Sun, 11 Nov 2018 20:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541998137; cv=none; d=google.com; s=arc-20160816; b=S9DggsVAXlbC8Xktvg00uWZ8rZ1+6Ga905KC65Rc+JSdQ4hTTED7Z8yyCLnNQ8G9z0 Ew/ccws7+fRvMtdzcpm6IhIDjmFVirfApqzO12RTOy25nx1AWoaBMLtU9eFOoq5gUFvM rS2caNjhCY8/KtJXz80SKwYZSSb3RY/QVPgsdtNybguG9IGCuDJhsDaFNbliVlW0m/nW yV3vMbOGjnO/9z68p97nNZsn5GAwoXa8cVtHnzTHYYWUKJ+XtImLcvsFsB5nD2+xPTcs gjUXZF8+zL9fJ6wLMhgwASmEgbjUfJWW9LRP71vGWSS3O7LEG1cmuWMSmqZGDeyTIrST SIpQ== 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=UvRlpmEoZokMTddOxLMw3FBaqTyUNfic8LLRpb2dxjg=; b=AyZMHJdu18aR28RBXIoInLidy9V+B9wuMZ65KCFPbVl/UsslyR0DU4zF3BfNa6qyoc yDT3Pz22psDRA+D/bWXXAi8cG5ozmaAAJBLXit/DtcESUld8xqvKTR6ROde8HT8gjC+4 nuvc1A+Ou5HsAqux91eRI31LDVOc8RFRoGlfbf3Xx9pOcVuTJGASJNlYwtJ5MGiC8UVB aqSZ0+JZ99HyvYsgOL5WKA1MfKUqF0mH64qjR/FstCxO/wGmIXf//XfMLVnvu4xLVHnM eM4RvRXbOAZy5M+alR/4OHSYCrFKeWBwM4q1DcevUAuW8ompc5uy0FwruuIN+ngi0PCf YwNQ== 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 j22si13219499pgj.244.2018.11.11.20.48.42; Sun, 11 Nov 2018 20:48:57 -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 S1731406AbeKLOjL (ORCPT + 99 others); Mon, 12 Nov 2018 09:39:11 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:48672 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730706AbeKLOiX (ORCPT ); Mon, 12 Nov 2018 09:38:23 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id E7075297EA; Sun, 11 Nov 2018 23:46:55 -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: In-Reply-To: References: From: Finn Thain Subject: [RFC PATCH 07/13] m68k: amiga: 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/amiga/config.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index a575ad419b23..40ebd471cc3c 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -461,7 +462,30 @@ void __init config_amiga(void) *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80; } +static u64 amiga_read_clk(struct clocksource *cs); + +static struct clocksource amiga_clk = { + .name = "ciab", + .rating = 250, + .read = amiga_read_clk, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + static unsigned short jiffy_ticks; +static u32 clk_total; + +static irqreturn_t ciab_timer_handler(int irq, void *data) +{ + irq_handler_t timer_routine = data; + unsigned long flags; + + local_irq_save(flags); + clk_total += jiffy_ticks; + local_irq_restore(flags); + + return timer_routine(irq, data); +} static void __init amiga_sched_init(irq_handler_t timer_routine) { @@ -481,15 +505,16 @@ static void __init amiga_sched_init(irq_handler_t timer_routine) * Please don't change this to use ciaa, as it interferes with the * SCSI code. We'll have to take a look at this later */ - if (request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL)) + if (request_irq(IRQ_AMIGA_CIAB_TA, ciab_timer_handler, IRQF_TIMER, + "timer", timer_routine)) pr_err("Couldn't register timer interrupt\n"); /* start timer */ ciab.cra |= 0x11; -} -#define TICK_SIZE 10000 + clocksource_register_hz(&amiga_clk, amiga_eclock); +} -static u32 amiga_gettimeoffset(void) +static u64 amiga_read_clk(struct clocksource *cs) { unsigned long flags; unsigned short hi, lo, hi2; @@ -512,14 +537,13 @@ static u32 amiga_gettimeoffset(void) if (ticks > jiffy_ticks / 2) /* check for pending interrupt */ if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA) - offset = 10000; + offset = jiffy_ticks; local_irq_restore(flags); ticks = jiffy_ticks - ticks; - ticks = (10000 * ticks) / jiffy_ticks; - return (ticks + offset) * 1000; + return clk_total + ticks + offset; } static void amiga_reset(void) __noreturn; -- 2.18.1