From patchwork Thu Oct 8 15:46:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11823425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 351C71592 for ; Thu, 8 Oct 2020 15:51:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD01420739 for ; Thu, 8 Oct 2020 15:51:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3IeYabFL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD01420739 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TmpBYuwSXVGpnAjQn3XMYGwgVBnBUGrfjathrTlR8yc=; b=3IeYabFLNN/Iqy4Si73yKAiom nCmV5oNKra1ysDqBntnXUnT9TpYGHu5pWrRPtFumzGaHXGOOKJT68x20+n0TB7DP4tfTw3BVnEOqX Nx7GCIsWbQHeLnNcpxmsaYvCj8/f5Y+GDyn80rVQkKUVQ3IeLrsebE3EhsZjOLCFIoZFg9l6k+KK9 Cr5P4JWC63ODArz4xxtd/DaeYKyVJObLvDwsBoJHjoqV6L+ycAqzQ75uAhY+Jrd8GjNHBQFOUFF2d jd2niyY5w9q2cV8U9+dFfu3pssUkyhypAQoZ8ly5xyTYfNWWEwkoHgG6J+5YzcFKxiTzcgS+8rhx1 0wC9iouZw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQYBk-0003mK-SG; Thu, 08 Oct 2020 15:50:41 +0000 Received: from mout.kundenserver.de ([217.72.192.75]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQYAI-0002x7-6Q for linux-arm-kernel@lists.infradead.org; Thu, 08 Oct 2020 15:49:17 +0000 Received: from localhost.localdomain ([192.30.34.233]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MStT6-1jwLIa42la-00ULFd; Thu, 08 Oct 2020 17:48:43 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org Subject: [RFC 13/13] m68k: mac: convert to generic clockevent Date: Thu, 8 Oct 2020 17:46:51 +0200 Message-Id: <20201008154651.1901126-14-arnd@arndb.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201008154651.1901126-1-arnd@arndb.de> References: <20201008154651.1901126-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:t2TT0Gg6iZNzNSgl+OLD57/ppw5gg1Qso/eeRLVLEYaTBf/jIqQ Hjytsid5qWOgO94sXb2HqufDu6sYujxasZU8I0d6fpbSQ3aPXdulhuhjy1hT49RzBos4jzD TAn0VTtO47u4tnZhkeNMXUv9noQBvjvT6/jveq0eVE28BolhK15dXE6GaGQHpS+2wQbV7+C u0hUaI+Xe6zAY/NJfNthg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:gXB8YuDxJok=:EX4k3kZ8QtbIajiEgQTjiv SxHIuk7BFtV13qQjcBtlTsbXwtVoVK8kQhARoOlwilggxhieawtrezJt3Nn/X5O7tByqjdCC0 BF62tpUUIYAbDtBIVIyZL2hUzvGMBZNsEbCoqkY9JNhrpx9qZIHES7A8RwQ3xHrexkILfIFta ySe2T7/BEMRY7zaRt35YvBZwbB2RYMnEHD4/epdU+npcF0vqxHlZ8EGd349xDSIQkFZLZ5/Qd A6jnQYe7kQEHk2S9vzlaQOLax2NzPVWqx2qJ8khlWwesz67wbkkbpL0Dia4r2XK7k5JK1j+1D OMulG+KxbdmVVTvwvWNoHtad5bJVLSuGm2XUP6X+H61R+j+K8DXxGPjyevNrwIRaX6RLhZxQP zqis6uJwcdAddHd2+B9sXPL6z4eBoA1GmBGjW/SJD50AJACvQ4E0e/0i2tHiNHS0rnm3bJLBJ lwrq4bHMoSrC7PqyJ7+CBr3egpqFuksOiesZ1mQdOw3OPSAD6kA3Yr0hajcJyhVUXPycwhCVN C++u17zvMBTUP/mYPIpUdEBDhmSi38cn4WzhKDeC3hciNlHjXobBSdiixilXs3+Dw4XeCYSVz 7Jy4BI50XcOxXCsnDEB4OPfSY3lqmAlyfxuSOW71Bbyl2aq4pE3hKYNiEQgx7M9GbLDsZCOhK /hwCC8rZXxH5x7+rCA0y7WcXnU+HjxGdER3IrB1Y5dZA3PXErgwUwwS2FAj8rlOKAMDs2zlVj BCQFJHvQcyP0SVgL+KsIAIoC2cONpmrqvhYyJ8KXY4ZKZCPOXJYlz2xx0MLLHvLC31pYlmJdM gh3zpYEZMSfwruQm5IBEZRtnKPMy9488EKTQyfQYASbr3lI25bzfMveHN011XHRSJ3ZPMfJ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201008_114910_473544_1D748540 X-CRM114-Status: GOOD ( 22.01 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.72.192.75 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [217.72.192.75 listed in wl.mailspike.net] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sam Creasey , Fenghua Yu , Linus Walleij , Tony Luck , Thomas Gleixner , linux-parisc@vger.kernel.org, Arnd Bergmann , linux-ia64@vger.kernel.org, Stephen Boyd , Helge Deller , Daniel Lezcano , Russell King , Finn Thain , "James E.J. Bottomley" , linux-m68k@lists.linux-m68k.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, John Stultz , Philip Blundell , Greg Ungerer , Joshua Thompson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Now that the infrastructure allows kernels to have both legacy timer ticks and clockevent drivers in the same image, start by moving one platform to generic clockevents. As qemu only supports the q800 platform among the classic m68k, use that as an example. I also tried adding oneshot mode, which was successful but broke the clocksource. It's probably not hard to make it work properly, but this is where I've stopped. Signed-off-by: Arnd Bergmann --- I have never tried implementing a clockevent or clocksource driver in the past, so this is really just an experiment and I expect I got something wrong. arch/m68k/Kconfig.machine | 2 +- arch/m68k/mac/via.c | 44 ++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine index 8a4e8bd8aade..cccabdad618e 100644 --- a/arch/m68k/Kconfig.machine +++ b/arch/m68k/Kconfig.machine @@ -30,7 +30,7 @@ config MAC depends on MMU select MMU_MOTOROLA if MMU select HAVE_ARCH_NVRAM_OPS - select LEGACY_TIMER_TICK + select GENERIC_CLOCKEVENTS help This option enables support for the Apple Macintosh series of computers (yes, there is experimental support now, at least for part diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c index 8ad734e3c934..dd4c13c318b6 100644 --- a/arch/m68k/mac/via.c +++ b/arch/m68k/mac/via.c @@ -24,6 +24,7 @@ */ #include +#include #include #include #include @@ -602,27 +603,54 @@ static u32 clk_total, clk_offset; static irqreturn_t via_timer_handler(int irq, void *dev_id) { + struct clock_event_device *evt = dev_id; + clk_total += VIA_TIMER_CYCLES; clk_offset = 0; - legacy_timer_tick(1); + evt->event_handler(evt); return IRQ_HANDLED; } -void __init via_init_clock(void) +static int via_set_periodic(struct clock_event_device *evt) { - if (request_irq(IRQ_MAC_TIMER_1, via_timer_handler, IRQF_TIMER, "timer", - NULL)) { - pr_err("Couldn't register %s interrupt\n", "timer"); - return; - } - via1[vT1LL] = VIA_TC_LOW; via1[vT1LH] = VIA_TC_HIGH; via1[vT1CL] = VIA_TC_LOW; via1[vT1CH] = VIA_TC_HIGH; via1[vACR] |= 0x40; + return 0; +} + +static int via_set_shutdown(struct clock_event_device *evt) +{ + via1[vACR] &= ~0x40; + + return 0; +} + +static struct clock_event_device via_clk_event = { + .name = "via1", + .rating = 250, + .irq = IRQ_MAC_TIMER_1, + .owner = THIS_MODULE, + + .features = CLOCK_EVT_FEAT_PERIODIC, + .set_state_shutdown = via_set_shutdown, + .set_state_periodic = via_set_periodic, +}; + +void __init via_init_clock(void) +{ + clockevents_config_and_register(&via_clk_event, VIA_CLOCK_FREQ, 1, 0xffff); + + if (request_irq(IRQ_MAC_TIMER_1, via_timer_handler, IRQF_TIMER, "timer", + &via_clk_event)) { + pr_err("Couldn't register %s interrupt\n", "timer"); + return; + } + clocksource_register_hz(&mac_clk, VIA_CLOCK_FREQ); }