From patchwork Wed Sep 6 01:49:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 810361 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="smvZf/nz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xn65s1Pg8z9sNq for ; Wed, 6 Sep 2017 11:52:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 935F3C21E01; Wed, 6 Sep 2017 01:51:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1CC8AC21DF7; Wed, 6 Sep 2017 01:51:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 29C03C21DBE; Wed, 6 Sep 2017 01:50:18 +0000 (UTC) Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) by lists.denx.de (Postfix) with ESMTPS id EEB0BC21EB9 for ; Wed, 6 Sep 2017 01:50:17 +0000 (UTC) Received: by mail-oi0-f50.google.com with SMTP id n18so34507344oig.2 for ; Tue, 05 Sep 2017 18:50:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lzc0aJo2Kt4IW3U0svFFog7cMWTmIa1EgiKVvaCYQCM=; b=smvZf/nzMvs8rP6vCF1eu1emmY93D4z7NF0SYSa6dGnMDjnTqBXVWhU4w/8Wys1j4K KwfA1IICAnSlhpuD533KkDmhTJB4G6Tuj+8oOZnsmvCjm9oCpiT9UkGlsYr/U2mRiDmm gcKm6g24dahJG7j5s/phm41jtbj3iMqpKDyV1QvkPzMIsl6DViUMAXqyCgweWQg8Wa3H JJmJ4rfZ76u1EqAdDFnNOD0te7BAFSrF9UuWK7ojbgDn6CLABW6tSvJhcVid2v2L+o7E AbU4quDzdFbvvtfZ3CD4XWoVtVRwlZLNbPyS3anPw6ifhV21okTBRdSdCEB3hmAD7ltu dNqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Lzc0aJo2Kt4IW3U0svFFog7cMWTmIa1EgiKVvaCYQCM=; b=JZyWxwPc+5Li5G7yrQA5MlB8XlUBIgYwSCVvEGvFyXd2uhAWGiZeXanuMhHc7qqcIA wGRvzyGiyWd7gzzZqFYZXxKG+euBEQPg55MCwu5NU/Kidc4p7hWQJDpZdqHuR8pVy0As AiZwHao8xMBJGm7wgePcz3b4nG8jv0ZuHhjZuyDMLWhrbdSbVoR+TIhC8LCfw7Fy3Mmy 8yVKqJeT87gdLDltypynwBd48dvRcuYoCE3rXI/tJKAolOYej8JkvM4KqJm5wETsaqLN mOfmTkzt0PKjS3FE17cM2XmoOwKMOzUZJP2ohqWX7qh9wIc1b0mBRzL9XqvW7Xo8bJQ+ /uIg== X-Gm-Message-State: AHPjjUj11p6g1kuPR0c16mstP2XkSP+Gi7mCP/fRJjUglWZ/bfCOLMKS 3VUs8pQS8xzqcKTkUwzBnQ== X-Google-Smtp-Source: ADKCNb6oKwT8G6UKRE78m37bOo4ULIEGImCEqzeIK9gOqL/f/MAW7Lj/X18xJLiczaN+r2ivHcqcrQ== X-Received: by 10.202.224.130 with SMTP id x124mr1066185oig.100.1504662616587; Tue, 05 Sep 2017 18:50:16 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:0:10f2:0:899a:2ed0:e52d:6fc6]) by smtp.gmail.com with ESMTPSA id k129sm2060987oib.33.2017.09.05.18.50.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Sep 2017 18:50:15 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id C60481405D6; Tue, 5 Sep 2017 19:50:12 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 5 Sep 2017 19:49:47 -0600 Message-Id: <20170906014950.132960-4-sjg@chromium.org> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170906014950.132960-1-sjg@chromium.org> References: <20170906014950.132960-1-sjg@chromium.org> Subject: [U-Boot] [PATCH v3 3/6] dm: x86: Update timer_get_boot_us to work before DM is ready X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use the new separate init function so that we can make use of the timer before driver model is started up. At some point we should consider adding the microsecond timer to the timer uclass interface since it would reduce the amount of plumbing here slightly. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: - Rebase on top of early timer code and simplify slightly drivers/timer/tsc_timer.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index 0012fecde0..db49de87a2 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -295,11 +295,6 @@ ulong notrace timer_get_us(void) return get_ticks() / get_tbclk_mhz(); } -ulong timer_get_boot_us(void) -{ - return timer_get_us(); -} - void __udelay(unsigned long usec) { u64 now = get_ticks(); @@ -374,6 +369,20 @@ u64 notrace timer_early_get_count(void) return rdtsc() - gd->arch.tsc_base; } +ulong timer_get_boot_us(void) +{ + if (!gd->timer) { + u64 now_tick; + + tsc_timer_ensure_setup(); + now_tick = rdtsc() - gd->arch.tsc_base; + + return now_tick / (gd->arch.clock_rate / 1000000); + } + + return timer_get_us(); +} + static const struct timer_ops tsc_timer_ops = { .get_count = tsc_timer_get_count, };