From patchwork Tue Dec 18 21:28:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 154200 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4204337ljp; Tue, 18 Dec 2018 13:31:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xy25q+2a31dM9jv355pb6BK3zkQwTy3YLw7cgIe1p7CnSB0wV5ghZogU8YMxOxtjSLT+w/ X-Received: by 2002:a17:902:2969:: with SMTP id g96mr17811791plb.295.1545168662667; Tue, 18 Dec 2018 13:31:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545168662; cv=none; d=google.com; s=arc-20160816; b=jbiJ/SUaygoyqX+erPqalcBqEsz/QF7jb71MYzt0WnZXpnJRdXowL0ybamSYpxL6uH Gxd6I6SojePGIi3wlzJ4YDrnydjZ3aBwFIvDAWWr5hND8gLap8xjwf3xOfpYnD/WmSED C1dJp3IWfVVPIw/o/gxDkGxIHfnedjK/2aXUwdWCxKboPRxr2ZXF3luZCdduqq2ww4yN H3i0D/PVh7kcT0KqdWOtTj8JZ0kpiQOmP6trfvUT0AU9vti+2ZOXbiD1bIZY1R2vcH5H OB8UrCHGBS2KfzLztpqWadzJBNp2zqQ0HEJoUSVR7AFioEBfbV2kLJRWnkXtnLACJOBO jH0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=+kk49u2E8Mo1JNxE8BrR9oOARp9WmK1DmRN/2CO3j/8=; b=dNeuuW825mS1Rv5AoTiHgtsL6RsjLzVcRPRbsi6H8QlUndrf/oK/nmU6ja2opOp8NC MgGB8oZlxeTAUlE1/gbnxQZj8N4q/vp6uxSicJUXTf8MlxnEnU0FJufB+KL8zYNx0fWD 6XNc+J+3D7I+TXUqb8tk1tubPjZVa+2KE+7116zJW2kF95YeH/DsycgeMWcB24x1NpXT YjOSnYPVFf85hxr+DzEtXeLkjFhgCAt8DgrQWGG56vcQPqCdzr9eVXIh8LvEdQAPYj51 pizEpIQb2Y13u1O0QpImgnaTgvFIv1VtFlHQ8aLlDjo8s3qx4lNe8ccy3YmPX/p05kRr BNFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JT/ZsqfQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si13747485pgl.303.2018.12.18.13.31.02; Tue, 18 Dec 2018 13:31:02 -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; dkim=pass header.i=@linaro.org header.s=google header.b="JT/ZsqfQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbeLRV3Y (ORCPT + 31 others); Tue, 18 Dec 2018 16:29:24 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55290 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727420AbeLRV3W (ORCPT ); Tue, 18 Dec 2018 16:29:22 -0500 Received: by mail-wm1-f68.google.com with SMTP id a62so4087825wmh.4 for ; Tue, 18 Dec 2018 13:29:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+kk49u2E8Mo1JNxE8BrR9oOARp9WmK1DmRN/2CO3j/8=; b=JT/ZsqfQLVVSX+jbMOMwvdmTraAUh2j/2iIoSl0jGXgA15MSLhzzoSfM9jCn+rNy9i k0FnfddkVZjRaa3CS8Q2P9eoYYMhlpkT6CslTRnZ7GLniqwBtx4ehL/B93ISFzEMf//6 fG7g3U/ReKJQHa6S/EMTgVhtGkPbKfd0r9bC4= 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; bh=+kk49u2E8Mo1JNxE8BrR9oOARp9WmK1DmRN/2CO3j/8=; b=KKkV3cuvjnkxSbMvMidKBKFY4TKZZjaxNbg2wGA3uDbS9UoHDeSMzJbOK3X92yLJ3I 287YW/VeG/6PXWa8HZDpzUEoPmQh8ETHKcDpV+S64V9oxV8hG2XejsVYE76YGR/TmKfs rZYXAhRplCZB0465YrgPUX3moKR1Vr6IkieJqHATxliPOtuYtQ6QuchT9sWgo1B8xvXZ v0y8VM0nw9g1dTqUp5o1WJvmz1l7JwWiQtmmEru6kNcuV0Rxwsssqa2N8oT6zqsFsIyL ms0R6wvQtArFPTUavhOXN6nEcJj2aBQMgEhih5/xXMcypj1aj8f8FLLboA/gVdiX2e4S 9bDA== X-Gm-Message-State: AA+aEWY5lH1RBxYrfdMwjsm76pZ6jW9gXoKow6aIJQhaXo1dOh/o4QMu TxngHLuTbmvpkeWH9WsQYkIJmA== X-Received: by 2002:a1c:ae88:: with SMTP id x130mr4442834wme.91.1545168559808; Tue, 18 Dec 2018 13:29:19 -0800 (PST) Received: from localhost.localdomain (105.50.92.92.rev.sfr.net. [92.92.50.105]) by smtp.gmail.com with ESMTPSA id o4sm4153485wrq.66.2018.12.18.13.29.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Dec 2018 13:29:19 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Martin Blumenstingl , Carlo Caione , Kevin Hilman , linux-arm-kernel@lists.infradead.org (moderated list:ARM/Amlogic Meson SoC support), linux-amlogic@lists.infradead.org (open list:ARM/Amlogic Meson SoC support) Subject: [PATCH 07/25] clocksource/drivers/meson6_timer: Implement the ARM delay timer Date: Tue, 18 Dec 2018 22:28:25 +0100 Message-Id: <20181218212844.30445-7-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181218212844.30445-1-daniel.lezcano@linaro.org> References: <20181218212844.30445-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Martin Blumenstingl 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 Signed-off-by: Daniel Lezcano --- drivers/clocksource/meson6_timer.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.17.1 diff --git a/drivers/clocksource/meson6_timer.c b/drivers/clocksource/meson6_timer.c index 23c7638e2bb3..84bd9479c3f8 100644 --- a/drivers/clocksource/meson6_timer.c +++ b/drivers/clocksource/meson6_timer.c @@ -22,6 +22,10 @@ #include #include +#ifdef CONFIG_ARM +#include +#endif + #define MESON_ISA_TIMER_MUX 0x00 #define MESON_ISA_TIMER_MUX_TIMERD_EN BIT(19) #define MESON_ISA_TIMER_MUX_TIMERC_EN BIT(18) @@ -54,6 +58,18 @@ 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); @@ -192,6 +208,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",