From patchwork Sun Oct 28 12:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10658601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B50A113A4 for ; Sun, 28 Oct 2018 12:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2A8428387 for ; Sun, 28 Oct 2018 12:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 957F128505; Sun, 28 Oct 2018 12:57:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F38A28387 for ; Sun, 28 Oct 2018 12:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=/SmRxZ31PFDlEEwGdIXVPcJl/OH9Tq6agf56bydnXYg=; b=H9qrOg0Z/hjypz gsT9o842XxJoQp/Ry6uh9Lmrul7iRasWrbuUSvOwRFIZhOBaO1W6yqoyuFbzGJRTkn6BGExBtCUzx PI5Mx5HBrpR/T6RGJWlV30r8eM1Sn23DeF+xLfAxWFjPXYBulFBzb8fxkwPedvg7PcZwiAZFcEnrL nIUUkmXOmlAEkcwzq3B1nYdfOqtkjW+ezZ5dA1KeUFLZCE+fbPpFAAtOI+jOlbyODL+Qab1wBIoW5 BjP5kabx62jG1T92vMRpI4o+b3CvH0soUhnVC8s/dxyfOzzpytN9Q+2u4odHYLwxYcehtWr4xVT6X xjCRNd4y2WXWPgzWoOHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gGkct-0003Yi-Ce; Sun, 28 Oct 2018 12:57:07 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gGkbI-0002Ln-JH; Sun, 28 Oct 2018 12:55:30 +0000 Received: by mail-wm1-x344.google.com with SMTP id l26-v6so5556016wmh.3; Sun, 28 Oct 2018 05:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZkqiSK0foukgf/wyUrP43W1JLOOI7NiMe4dW1YSf01k=; b=Z7IWfZcPcB/PNywoYxW/PWEV03Ypu5mWL0eY1bCC+X3r+BP99BfoGGhcKQA7pl7Q7y /5lVMTeT4PokHF3gUNtwNJsRtm89a5ctfXv9b+U7YyAB+9UWDmYzg9RtgOQbbPpLReRD K/5Y5mEtemcD5PeIvgFTBiCNGzm3R8BBgJhlF8vaBqP7BnXPDpzNDkR7FgCbeCm+Mkt/ u7W3Xt3vsfyGtDjUCpDXMADD186INcbV85TSXjIlN9iWsK90Xb2/RCthxxkScwrnFVea b1wqhdPm7AsucPhx4JwhdyvS+CtNlks54LE/eYtEaVc0e0vpUGzfmtBsZI0oUVJbyWmW mmbw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZkqiSK0foukgf/wyUrP43W1JLOOI7NiMe4dW1YSf01k=; b=paSuXcY293gebf3nv2i1FwI24+tAkSiaBfvMOYIZF/UrZjKsxxc+6VHErjUoQil38s dBNva25ICTdZkYSAEwH8M9DSYIRzTw1Z1lG/gvBeKmkKJq2LVLpWlhtcx8QIR817Z8Tr 8MyW60qQDcAHwPVSY200MzWy2vIDFiWoFHUC/7NNxAX/EiI5AEIiAM4BHGc9WlcqF42X QRbYUK2jCCpgpEeBgwfP298AzrN2dxn8CsFI84TBQWPduN9cx3InFJ3s12jWoAEzNVAh /VIlpwPEVX9AKhc9SQ0odnAomRe2N6xWv9zCJ9EfuTvn7/mobFJj8x3+pWy4uWu9aFN4 rrgg== X-Gm-Message-State: AGRZ1gLzjnZ5gfWeAc19GSpVakf2n0XMFUaUDslqH+NagW8ARRSNSMSk OhDDS004bLg1YoOtJmdRlgBIgbz5 X-Google-Smtp-Source: AJdET5fNaBy49wFoVlhlhHSMueD4TpIheu+8OV97VsJV+9DxdBtIU+NJ0UVQP41SqmDOxXSw0prkjg== X-Received: by 2002:a1c:a794:: with SMTP id q142-v6mr11517090wme.77.1540731316600; Sun, 28 Oct 2018 05:55:16 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD7072200691979D1FB980407.dip0.t-ipconnect.de. [2003:dc:d707:2200:6919:79d1:fb98:407]) by smtp.googlemail.com with ESMTPSA id u10-v6sm13759388wrt.59.2018.10.28.05.55.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 05:55:15 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, daniel.lezcano@linaro.org Subject: [PATCH 2/2] clocksource: meson6_timer: implement ARM delay timer Date: Sun, 28 Oct 2018 13:55:01 +0100 Message-Id: <20181028125501.17336-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181028125501.17336-1-martin.blumenstingl@googlemail.com> References: <20181028125501.17336-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181028_055528_665461_87663DAE X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: carlo@caione.org, khilman@baylibre.com, Martin Blumenstingl , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Implement an ARM delay timer to be used for udelay(). This allows us to skip the delay loop calibration at boot. With this patch udelay() is now independent of CPU frequency changes. This is a good thing on Meson8, Meson8b and Meson8m2 because changing the CPU frequency requires running the CPU clock off the XTAL while changing the PLL or it's dividers. After changing the CPU clocks we need to wait a few usecs for the clock to become stable. So having an udelay() implementation that doesn't depend on the CPU frequency is beneficial. Suggested-by: Jianxin Pan Signed-off-by: Martin Blumenstingl --- drivers/clocksource/meson6_timer.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/clocksource/meson6_timer.c b/drivers/clocksource/meson6_timer.c index c622135bee9d..5ee2a575069b 100644 --- a/drivers/clocksource/meson6_timer.c +++ b/drivers/clocksource/meson6_timer.c @@ -22,6 +22,10 @@ #include #include +#ifdef CONFIG_ARM +#include +#endif + enum meson6_timera_input_clock { MESON_TIMERA_CLOCK_1US = 0x0, MESON_TIMERA_CLOCK_10US = 0x1, @@ -60,6 +64,18 @@ enum meson6_timere_input_clock { static void __iomem *timer_base; +#ifdef CONFIG_ARM +static unsigned long meson6_read_current_timer(void) +{ + return readl_relaxed(timer_base + MESON_ISA_TIMERE); +} + +static struct delay_timer meson6_delay_timer = { + .read_current_timer = meson6_read_current_timer, + .freq = 1000 * 1000, +}; +#endif + static u64 notrace meson6_timer_sched_read(void) { return (u64)readl(timer_base + MESON_ISA_TIMERE); @@ -198,6 +214,12 @@ static int __init meson6_timer_init(struct device_node *node) clockevents_config_and_register(&meson6_clockevent, USEC_PER_SEC, 1, 0xfffe); + +#ifdef CONFIG_ARM + /* Also use MESON_ISA_TIMERE for delays */ + register_current_timer_delay(&meson6_delay_timer); +#endif + return 0; } TIMER_OF_DECLARE(meson6, "amlogic,meson6-timer",