Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 162F5CCA468 for ; Wed, 1 Jun 2022 13:51:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 834D28421F; Wed, 1 Jun 2022 15:51:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Q8JWpueg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEA8683B15; Wed, 1 Jun 2022 09:55:40 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2400E82169 for ; Wed, 1 Jun 2022 09:55:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dinesh.maniyam@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654070137; x=1685606137; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=0kh30qtIPZkidh8YYyCnrTNNZUO1gOecDvGC/4XkS9k=; b=Q8JWpuegoDgD5OHsBDAPzIaZ8ZxPaZhXiU7n7YnSdUduby7FFT+8RZQz YaHiUkybGexO8Veme2/YKdMnfU5gijBwNhMhmMnsk7cy2GiASJgohp8OT yNrc+3wI27zA5nT0CA57ravmVwt5aWnRvnq1mp/uUqNoVhcT9msJO+41B REZjaGZbsCficIgMKVzdAaJ/lJWKs5kV4VniC1dq3yUmNWDJ1I47Qh7Ku TPT38ZRVIuAc5WrNdp/XWR8GN2ILjZqxza6l7gQ0F0PaZwM8XFowe+YCE /kkSg6GKu27cYvqNF+k7thCkx3vJ+0qt+ibuR8d/V4D99JSCzCSwGgVmN g==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="336165544" X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="336165544" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2022 00:55:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="667309121" Received: from pglc00514.png.intel.com ([10.221.239.206]) by FMSMGA003.fm.intel.com with ESMTP; 01 Jun 2022 00:55:22 -0700 From: dinesh.maniyam@intel.com To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Goldschmidt , Tien Fong Chee , Kok Kiang , Yau Wai , Sin Hui , Raaj , Dinesh , Chee Hong Ang Subject: [PATCH] arch: arm: socfpga: timer_s10: Override udelay for secure section Date: Wed, 1 Jun 2022 15:54:59 +0800 Message-Id: <20220601075459.30997-1-dinesh.maniyam@intel.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 01 Jun 2022 15:51:12 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Dinesh Maniyam Override __udelay() as 'always inlined' function so that PSCI code run in '__secure' section can call this delay function as well. Signed-off-by: Chee Hong Ang Signed-off-by: Dinesh Maniyam --- arch/arm/mach-socfpga/timer_s10.c | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-socfpga/timer_s10.c b/arch/arm/mach-socfpga/timer_s10.c index 7d5598e1a3..33afc87749 100644 --- a/arch/arm/mach-socfpga/timer_s10.c +++ b/arch/arm/mach-socfpga/timer_s10.c @@ -1,11 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2017-2018 Intel Corporation + * Copyright (C) 2017-2022 Intel Corporation * */ #include #include +#include #include #include @@ -26,3 +27,35 @@ int timer_init(void) #endif return 0; } + +__always_inline u64 __get_time_stamp(void) +{ + u64 cntpct; + + isb(); + asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct)); + + return cntpct; +} + +__always_inline uint64_t __usec_to_tick(unsigned long usec) +{ + u64 tick = usec; + u64 cntfrq; + + asm volatile("mrs %0, cntfrq_el0" : "=r" (cntfrq)); + tick *= cntfrq; + do_div(tick, 1000000); + + return tick; +} + +__always_inline void __udelay(unsigned long usec) +{ + /* get current timestamp */ + u64 tmp = __get_time_stamp() + __usec_to_tick(usec); + + while (__get_time_stamp() < tmp + 1) /* loop till event */ + ; +} + -- 2.25.1