From patchwork Mon Sep 28 14:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372681 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=vCzNIqQT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QVl5LZwz9s0b for ; Tue, 29 Sep 2020 00:53:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14D198235A; Mon, 28 Sep 2020 16:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="vCzNIqQT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5386E82294; Mon, 28 Sep 2020 16:52:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3388182294 for ; Mon, 28 Sep 2020 16:52:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x743.google.com with SMTP id 16so1190603qkf.4 for ; Mon, 28 Sep 2020 07:52:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AvhCmNBDRwLbkI6zyopnnWaKfuuYwktl2VHR6zEHSYA=; b=vCzNIqQTrvcfEyaL913Rbg2gD4F7OQ2SG+4wIs4ivCG0ocjqFIZajXqJ7RzEdsHvsL gD6AoMWGiAZQcA19DUSIt1/tW61hIiIFkzDiXIFzl3Ud1pYJbFLrVie6QFduV0KnSJeF wZR7obcEz0cwSaDSElltzFFMluHNGCGXIU+qE7NZPGBxWWakRiVn+Fk4RTbcZnEcbu8D mtoWym0tdpcKmuLW+rmWzFl7k+dohITOjbJzWT9PhDXCxsMy7quDkFe08kUOvqx8/Unu 0oQPMzrYmrSXXWiLELuVbZC6XyV/6VdnA0Ef4OIvxQ5RnbTTQB6t+tFk/6aa2XRP8W0/ b+jw== 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=AvhCmNBDRwLbkI6zyopnnWaKfuuYwktl2VHR6zEHSYA=; b=A+jQDpxwj1nAlLaK1+6O0L8tnmX1xF1tfLkUiKbPU2nEyJVL/Uigxd4Zmuf5DtxG3j y+GRgEFd18f9CMrP//LIeveD1m0b9BeXdIaee8xHiPlf9atANe0on8cpbrkGPmHuR7LT 0oAvZ6ja2XQGxXIqilN1HxaFCdsz2MfzC3hXLqQGboliu7rTapYCjMaQiMN5UYzVMErC NXfQzl+u+lv5xzeE7/sVOJnOSBtwY2oNcEisFBII7w5n+6hb+9JjtbpwspQmeqg5vepJ qRXipaVUPxZtqlcdTt5McezImpYAKr8MzmFvGZr2OyBsDXrkAtsKw8qdGXK6AW+4u3hC azxQ== X-Gm-Message-State: AOAM531oaeEy9Zdk9LpdUSTGBekf2xh9kil2gAEx+SzUaoYfJe5T14z8 A4wQGuQzpE9mAcmtLjI/xjIccqy1yXPn3g== X-Google-Smtp-Source: ABdhPJxl1RGokHYqJGwd54lEIWsAyFRJdNJMfVgDHJ9M7stGPxmbUjkYNam3/627ecnNTqHjgIS3og== X-Received: by 2002:a05:620a:48:: with SMTP id t8mr1870543qkt.368.1601304765679; Mon, 28 Sep 2020 07:52:45 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:45 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Bin Meng , Rick Chen Subject: [PATCH v6 1/9] riscv: Rework riscv timer driver to only support S-mode Date: Mon, 28 Sep 2020 10:52:21 -0400 Message-Id: <20200928145229.449782-2-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The riscv-timer driver currently serves as a shim for several riscv timer drivers. This is not too desirable because it bypasses the usual timer selection via the driver model. There is no easy way to specify an alternate timing driver, or have the tick rate depend on the cpu's configured frequency. The timer drivers also do not have device structs, and so have to rely on storing parameters in gd_t. Lastly, there is no initialization call, so driver init is done in the same function which reads the time. This can result in confusing error messages. To a user, it looks like the driver failed when trying to read the time, whereas it may have failed while initializing. This patch removes the shim functionality from the riscv-timer driver, and has it instead implement the former rdtime.c timer driver. This is because existing u-boot users who pass in a device tree (e.g. qemu) do not create a timer device for S-mode u-boot. The existing behavior of creating the riscv-timer device in the riscv cpu driver must be kept. The actual reading of the CSRs has been redone in the style of Linux's get_cycles64. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- (no changes since v4) Changes in v4: - Modify RISCV_TIMER KConfig - Now depends on RISCV - Implied by S-Mode (with or without SPL) Changes in v2: - Remove RISCV_RDTIME KConfig option arch/riscv/Kconfig | 8 ------- arch/riscv/cpu/ax25/Kconfig | 2 +- arch/riscv/cpu/fu540/Kconfig | 2 +- arch/riscv/cpu/generic/Kconfig | 2 +- arch/riscv/lib/Makefile | 1 - arch/riscv/lib/rdtime.c | 38 --------------------------------- drivers/timer/Kconfig | 4 ++-- drivers/timer/riscv_timer.c | 39 +++++++++++++++++----------------- 8 files changed, 25 insertions(+), 71 deletions(-) delete mode 100644 arch/riscv/lib/rdtime.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 009a545fcf..21e6690f4d 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -185,14 +185,6 @@ config ANDES_PLMT The Andes PLMT block holds memory-mapped mtime register associated with timer tick. -config RISCV_RDTIME - bool - default y if RISCV_SMODE || SPL_RISCV_SMODE - help - The provides the riscv_get_time() API that is implemented using the - standard rdtime instruction. This is the case for S-mode U-Boot, and - is useful for processors that support rdtime in M-mode too. - config SYS_MALLOC_F_LEN default 0x1000 diff --git a/arch/riscv/cpu/ax25/Kconfig b/arch/riscv/cpu/ax25/Kconfig index 8d8d71dcbf..5cb5bb51eb 100644 --- a/arch/riscv/cpu/ax25/Kconfig +++ b/arch/riscv/cpu/ax25/Kconfig @@ -3,7 +3,7 @@ config RISCV_NDS select ARCH_EARLY_INIT_R imply CPU imply CPU_RISCV - imply RISCV_TIMER + imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE) imply ANDES_PLIC if (RISCV_MMODE || SPL_RISCV_MMODE) imply ANDES_PLMT if (RISCV_MMODE || SPL_RISCV_MMODE) imply SPL_CPU_SUPPORT diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig index 53e19635c8..ac3f183342 100644 --- a/arch/riscv/cpu/fu540/Kconfig +++ b/arch/riscv/cpu/fu540/Kconfig @@ -10,7 +10,7 @@ config SIFIVE_FU540 select SPL_RAM if SPL imply CPU imply CPU_RISCV - imply RISCV_TIMER + imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE) imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE) imply CMD_CPU imply SPL_CPU_SUPPORT diff --git a/arch/riscv/cpu/generic/Kconfig b/arch/riscv/cpu/generic/Kconfig index b2cb155d6d..f4c2e2643c 100644 --- a/arch/riscv/cpu/generic/Kconfig +++ b/arch/riscv/cpu/generic/Kconfig @@ -7,7 +7,7 @@ config GENERIC_RISCV select ARCH_EARLY_INIT_R imply CPU imply CPU_RISCV - imply RISCV_TIMER + imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE) imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE) imply CMD_CPU imply SPL_CPU_SUPPORT diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 6c503ff2b2..10ac5b06d3 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -15,7 +15,6 @@ obj-$(CONFIG_SIFIVE_CLINT) += sifive_clint.o obj-$(CONFIG_ANDES_PLIC) += andes_plic.o obj-$(CONFIG_ANDES_PLMT) += andes_plmt.o else -obj-$(CONFIG_RISCV_RDTIME) += rdtime.o obj-$(CONFIG_SBI) += sbi.o obj-$(CONFIG_SBI_IPI) += sbi_ipi.o endif diff --git a/arch/riscv/lib/rdtime.c b/arch/riscv/lib/rdtime.c deleted file mode 100644 index e128d7fce6..0000000000 --- a/arch/riscv/lib/rdtime.c +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright (C) 2018, Anup Patel - * Copyright (C) 2018, Bin Meng - * - * The riscv_get_time() API implementation that is using the - * standard rdtime instruction. - */ - -#include - -/* Implement the API required by RISC-V timer driver */ -int riscv_get_time(u64 *time) -{ -#ifdef CONFIG_64BIT - u64 n; - - __asm__ __volatile__ ( - "rdtime %0" - : "=r" (n)); - - *time = n; -#else - u32 lo, hi, tmp; - - __asm__ __volatile__ ( - "1:\n" - "rdtimeh %0\n" - "rdtime %1\n" - "rdtimeh %2\n" - "bne %0, %2, 1b" - : "=&r" (hi), "=&r" (lo), "=&r" (tmp)); - - *time = ((u64)hi << 32) | lo; -#endif - - return 0; -} diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 637024445c..d40d313011 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -146,8 +146,8 @@ config RISCV_TIMER bool "RISC-V timer support" depends on TIMER && RISCV help - Select this to enable support for the timer as defined - by the RISC-V privileged architecture spec. + Select this to enable support for a generic RISC-V S-Mode timer + driver. config ROCKCHIP_TIMER bool "Rockchip timer support" diff --git a/drivers/timer/riscv_timer.c b/drivers/timer/riscv_timer.c index 9f9f070e0b..449fcfcfd5 100644 --- a/drivers/timer/riscv_timer.c +++ b/drivers/timer/riscv_timer.c @@ -1,36 +1,37 @@ // SPDX-License-Identifier: GPL-2.0+ /* + * Copyright (C) 2020, Sean Anderson * Copyright (C) 2018, Bin Meng + * Copyright (C) 2018, Anup Patel + * Copyright (C) 2012 Regents of the University of California * - * RISC-V privileged architecture defined generic timer driver + * RISC-V architecturally-defined generic timer driver * - * This driver relies on RISC-V platform codes to provide the essential API - * riscv_get_time() which is supposed to return the timer counter as defined - * by the RISC-V privileged architecture spec. - * - * This driver can be used in both M-mode and S-mode U-Boot. + * This driver provides generic timer support for S-mode U-Boot. */ #include #include #include #include -#include - -/** - * riscv_get_time() - get the timer counter - * - * Platform codes should provide this API in order to make this driver function. - * - * @time: the 64-bit timer count as defined by the RISC-V privileged - * architecture spec. - * @return: 0 on success, -ve on error. - */ -extern int riscv_get_time(u64 *time); +#include static int riscv_timer_get_count(struct udevice *dev, u64 *count) { - return riscv_get_time(count); + if (IS_ENABLED(CONFIG_64BIT)) { + *count = csr_read(CSR_TIME); + } else { + u32 hi, lo; + + do { + hi = csr_read(CSR_TIMEH); + lo = csr_read(CSR_TIME); + } while (hi != csr_read(CSR_TIMEH)); + + *count = ((u64)hi << 32) | lo; + } + + return 0; } static int riscv_timer_probe(struct udevice *dev) From patchwork Mon Sep 28 14:52:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372682 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=bGRMzNKZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QW011qwz9s0b for ; Tue, 29 Sep 2020 00:53:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E9ED82369; Mon, 28 Sep 2020 16:52:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="bGRMzNKZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 812BE8233E; Mon, 28 Sep 2020 16:52:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6812F822ED for ; Mon, 28 Sep 2020 16:52:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf42.google.com with SMTP id j3so579765qvi.7 for ; Mon, 28 Sep 2020 07:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NiG2wLIsLnaGEzByN9edL5UlRQR3KU86bhpBoupey+Y=; b=bGRMzNKZskeldypD4Cdt1JPpXu60Rksf/ojNHKsBwuRkK9kX1mDTsNsdlfRgwhvCQO nbWJvrk2vNrDI3bDmsF0HZ8RPHe25760FoKtVmr4mLRtdW/Zy8XrRxy6AubyYnq0MPS2 mmynWal9YcsG9EDJ5TAV6393HiQ0gQgiTh2q4ewxappN6+7hUu6PidyVXqF+8vA9hR57 K8qFLngC6wvAnevjum1paKbZmAhOllig9XU25bSc4QgfHsy8B54dCH3gLgJ2crx31cBz 5XB32slXs2Df74MdfyzxB+UY+SNqiHd3B7JMNBT2MhXS1iPdHjTxnLjJvtm1KTQj48Gr VQ6g== 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=NiG2wLIsLnaGEzByN9edL5UlRQR3KU86bhpBoupey+Y=; b=GeqNWvcUn/rGE0ICo5FFyt/klKniOdKa2G8a/pL00YCrqz72T4/2jCxPFS/NGPXN/4 51IY9f2acZAg5bRsryOZyFQXVqIateM0rmK8LBXyqFgwqxorp26HkCGk8PyShgOqhYVg 8+m4K4dxZN1trIQ18GiQunFPzVnVGUbIYxyObRT5GGwd0+JNuRfMvLAOvqXww2qoaYI8 aENz8GdgNTPFtd2x+cLlEpD4rkDSMWoPrY1BpUP3cVgBBpcZ6kRZ3IIPXgBZXlEcqaTe dCSCzs+pikSqXl4OcLUVx6Y5nGQolXwD5KIXOBYP5pBFsMVkvRegvaCy8ilsiROAq/k2 FJeA== X-Gm-Message-State: AOAM530gYCNRKLO804lUUinYMH7qW6e/WiamLqeFa1PihjZGrnSxNiM/ UJtDV0xzw/JlUn/UhHItjI8O86VS3LXgOw== X-Google-Smtp-Source: ABdhPJwWQz9fIXTSwu9//pdUoHdT1XUag3Yjte2VJOJk07/d7R9KYMEaEGh/BUVnqAxhrR6gEn0p9Q== X-Received: by 2002:a0c:f44e:: with SMTP id h14mr12682343qvm.4.1601304767027; Mon, 28 Sep 2020 07:52:47 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:46 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Simon Glass , Bin Meng , Rick Chen Subject: [PATCH v6 2/9] timer: Add helper for drivers using timebase fallback Date: Mon, 28 Sep 2020 10:52:22 -0400 Message-Id: <20200928145229.449782-3-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This function is designed to be used when a timer used to be initialized by the cpu (e.g. RISC-V timers), but now is initialized by dm_timer_init. In such a case, the timer may prefer to use the clocks and clock-frequency properties, but should be able to fall back on using the cpu's timebase-frequency. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Rick Chen --- Changes in v6: - Don't compile timer_timebase_fallback if CONFIG_CPU is disabled. This config is only disabled on nds32; perhaps it can be enabled in the future? In addition, SPL_CPU_SUPPORT should probably be renamed to SPL_CPU Changes in v4: - New drivers/timer/timer-uclass.c | 31 +++++++++++++++++++++++++++++++ include/timer.h | 15 +++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 14dde950a1..e9802c8b43 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -79,6 +80,36 @@ static int timer_post_probe(struct udevice *dev) return 0; } +/* + * TODO: should be CONFIG_IS_ENABLED(CPU), but the SPL config has _SUPPORT on + * the end... + */ +#if defined(CONFIG_CPU) || defined(CONFIG_SPL_CPU_SUPPORT) +int timer_timebase_fallback(struct udevice *dev) +{ + struct udevice *cpu; + struct cpu_platdata *cpu_plat; + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + + /* Did we get our clock rate from the device tree? */ + if (uc_priv->clock_rate) + return 0; + + /* Fall back to timebase-frequency */ + dev_dbg(dev, "missing clocks or clock-frequency property; falling back on timebase-frequency\n"); + cpu = cpu_get_current_dev(); + if (!cpu) + return -ENODEV; + + cpu_plat = dev_get_parent_platdata(cpu); + if (!cpu_plat) + return -ENODEV; + + uc_priv->clock_rate = cpu_plat->timebase_freq; + return 0; +} +#endif + u64 timer_conv_64(u32 count) { /* increment tbh if tbl has rolled over */ diff --git a/include/timer.h b/include/timer.h index a49b500ce3..8b9fa51c53 100644 --- a/include/timer.h +++ b/include/timer.h @@ -15,6 +15,21 @@ */ int dm_timer_init(void); +/** + * timer_timebase_fallback() - Helper for timers using timebase fallback + * @dev: A timer partially-probed timer device + * + * This is a helper function designed for timers which need to fall back on the + * cpu's timebase. This function is designed to be called during the driver's + * probe(). If there is a clocks or clock-frequency property in the timer's + * binding, then it will be used. Otherwise, the timebase of the current cpu + * will be used. This is initialized by the cpu driver, and usually gotten from + * ``/cpus/timebase-frequency`` or ``/cpus/cpu@X/timebase-frequency``. + * + * Return: 0 if OK, or negative error code on failure + */ +int timer_timebase_fallback(struct udevice *dev); + /* * timer_conv_64 - convert 32-bit counter value to 64-bit * From patchwork Mon Sep 28 14:52:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372683 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=jIG9YVLg; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QWC40Glz9s0b for ; Tue, 29 Sep 2020 00:53:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 343648233D; Mon, 28 Sep 2020 16:52:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="jIG9YVLg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A19F28233E; Mon, 28 Sep 2020 16:52:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9A7C382287 for ; Mon, 28 Sep 2020 16:52:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x843.google.com with SMTP id r8so918578qtp.13 for ; Mon, 28 Sep 2020 07:52:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zUMmae2EwjBE3VIN7XprEKj7yIhK8HfbL/DStjIVtkc=; b=jIG9YVLgS0Sw5qG7A8nL9CQckAuX/yltti8XatlwySz7EXRHPDwAr28W8NtJ8moevt ROhr69k8wjR6ZBf/aVj3PxJeSbvd2mnWls82pER4dxaPa2ZB6TkvABfQ2o5aHRSLDaSI ZK5GNISidGEUWBgVaDqO3ryOaID/tWdvPWrfaIm03283mjaCxsKk3+bHrbDzmDLoOet2 Ay0hSOX9ZjG+6+WPPUmONC7FKOQypVVs07icdm533UjMaDV57Gji5i4XgQjiqqHg9anl UJ/IfQ1rbKFVGJwwMQidsvHNeuRcnTRJkXrgx9TMCFq/FKtw4MJR+OHA7WQKQs9kzb1Q JIIw== 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=zUMmae2EwjBE3VIN7XprEKj7yIhK8HfbL/DStjIVtkc=; b=Za7hrIjkBsIFC2bXOCQRcuXA85az5lNzDR7a5b6pC+LSDCastPKiAClUeh0z0FjufH oQzztKugeqFObRe8qKcba2nDlqeHWnWPeUL8B+Am4O1Q4iimuvhFj7iFME+A8nJ5FK/0 H09tkGC+9b+hzkF4l7owhXU1bgJlGn3tb0YiqJgQD09ZVzHuQsKFbEg3Mhq7cOTnxP95 6fCn8ipECZrB4n6+CjeS2siPSyONDNiQA2xePk+CDk3VRDgeNRoQvTa/JmKoQI/i29Gf bMiiA8bX+cWhbNAp8Hcj2MjE9cPdnfele0qwBcDTLQj1sfBgnkl5bBY9luQKi9RMSzPh vfDw== X-Gm-Message-State: AOAM532Cv0QizEzyThjepjRIKit0SpHCJyFvubx4nN2HaFaDxEVu5+uO rVvcqT/SN/LB9RBh8oL0Btkcy+KPzxzgZw== X-Google-Smtp-Source: ABdhPJyn23AaTMLz1jU4hArcz11SovIY63lGJfDpNfovNotMTSgTeNyQmCwe5jZkN6cha2yxKhbt2A== X-Received: by 2002:ac8:3261:: with SMTP id y30mr1987891qta.242.1601304768231; Mon, 28 Sep 2020 07:52:48 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:47 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Simon Glass Subject: [PATCH v6 3/9] timer: Add a test for timer_timebase_fallback Date: Mon, 28 Sep 2020 10:52:23 -0400 Message-Id: <20200928145229.449782-4-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean To test this function, sandbox CPU must set cpu_platdata.timebase_freq on bind. It also needs to expose a method to set the current cpu. I also make some most members of cpu_sandbox_ops static. On the timer side, the device tree property sandbox,timebase-frequency-fallback controls whether sandbox_timer_probe falls back to time_timebase_fallback or to SANDBOX_TIMER_RATE. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v5) Changes in v5: - New arch/sandbox/dts/test.dts | 9 +++++++- arch/sandbox/include/asm/cpu.h | 11 ++++++++++ drivers/cpu/cpu_sandbox.c | 39 ++++++++++++++++++++++++++++------ drivers/timer/sandbox_timer.c | 4 +++- test/dm/timer.c | 27 ++++++++++++++++++++++- 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 arch/sandbox/include/asm/cpu.h diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 9f45c48e4e..2f559265a5 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -533,7 +533,9 @@ }; cpus { + timebase-frequency = <2000000>; cpu-test1 { + timebase-frequency = <3000000>; compatible = "sandbox,cpu_sandbox"; u-boot,dm-pre-reloc; }; @@ -839,11 +841,16 @@ 0x58 8>; }; - timer { + timer@0 { compatible = "sandbox,timer"; clock-frequency = <1000000>; }; + timer@1 { + compatible = "sandbox,timer"; + sandbox,timebase-frequency-fallback; + }; + tpm2 { compatible = "sandbox,tpm2"; }; diff --git a/arch/sandbox/include/asm/cpu.h b/arch/sandbox/include/asm/cpu.h new file mode 100644 index 0000000000..c97ac7ba95 --- /dev/null +++ b/arch/sandbox/include/asm/cpu.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2020 Sean Anderson + */ + +#ifndef __SANDBOX_CPU_H +#define __SANDBOX_CPU_H + +void cpu_sandbox_set_current(const char *name); + +#endif /* __SANDBOX_CPU_H */ diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index caa26e50f2..4ba0d1b99e 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -8,14 +8,15 @@ #include #include -int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size) +static int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"); return 0; } -int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info) +static int cpu_sandbox_get_info(const struct udevice *dev, + struct cpu_info *info) { info->cpu_freq = 42 * 42 * 42 * 42 * 42; info->features = 0x42424242; @@ -24,21 +25,29 @@ int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info) return 0; } -int cpu_sandbox_get_count(const struct udevice *dev) +static int cpu_sandbox_get_count(const struct udevice *dev) { return 42; } -int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size) +static int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, + int size) { snprintf(buf, size, "Languid Example Garbage Inc."); return 0; } -int cpu_sandbox_is_current(struct udevice *dev) +static const char *cpu_current = "cpu-test1"; + +void cpu_sandbox_set_current(const char *name) { - if (!strcmp(dev->name, "cpu-test1")) + cpu_current = name; +} + +static int cpu_sandbox_is_current(struct udevice *dev) +{ + if (!strcmp(dev->name, cpu_current)) return 1; return 0; @@ -52,7 +61,22 @@ static const struct cpu_ops cpu_sandbox_ops = { .is_current = cpu_sandbox_is_current, }; -int cpu_sandbox_probe(struct udevice *dev) +static int cpu_sandbox_bind(struct udevice *dev) +{ + int ret; + struct cpu_platdata *plat = dev_get_parent_platdata(dev); + + /* first examine the property in current cpu node */ + ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq); + /* if not found, then look at the parent /cpus node */ + if (ret) + ret = dev_read_u32(dev->parent, "timebase-frequency", + &plat->timebase_freq); + + return ret; +} + +static int cpu_sandbox_probe(struct udevice *dev) { return 0; } @@ -67,5 +91,6 @@ U_BOOT_DRIVER(cpu_sandbox) = { .id = UCLASS_CPU, .ops = &cpu_sandbox_ops, .of_match = cpu_sandbox_ids, + .bind = cpu_sandbox_bind, .probe = cpu_sandbox_probe, }; diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c index 5228486082..6a503c2f15 100644 --- a/drivers/timer/sandbox_timer.c +++ b/drivers/timer/sandbox_timer.c @@ -40,7 +40,9 @@ static int sandbox_timer_probe(struct udevice *dev) { struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); - if (!uc_priv->clock_rate) + if (dev_read_bool(dev, "sandbox,timebase-frequency-fallback")) + return timer_timebase_fallback(dev); + else if (!uc_priv->clock_rate) uc_priv->clock_rate = SANDBOX_TIMER_RATE; return 0; diff --git a/test/dm/timer.c b/test/dm/timer.c index 95dab97665..70043b9eee 100644 --- a/test/dm/timer.c +++ b/test/dm/timer.c @@ -7,8 +7,10 @@ #include #include #include +#include #include #include +#include /* * Basic test of the timer uclass. @@ -17,9 +19,32 @@ static int dm_test_timer_base(struct unit_test_state *uts) { struct udevice *dev; - ut_assertok(uclass_get_device(UCLASS_TIMER, 0, &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@0", &dev)); ut_asserteq(1000000, timer_get_rate(dev)); return 0; } DM_TEST(dm_test_timer_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* + * Test of timebase fallback + */ +static int dm_test_timer_timebase_fallback(struct unit_test_state *uts) +{ + struct udevice *dev; + + cpu_sandbox_set_current("cpu-test1"); + ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev)); + ut_asserteq(3000000, timer_get_rate(dev)); + ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); + + cpu_sandbox_set_current("cpu-test2"); + ut_assertok(uclass_get_device_by_name(UCLASS_TIMER, "timer@1", &dev)); + ut_asserteq(2000000, timer_get_rate(dev)); + + cpu_sandbox_set_current("cpu-test1"); + + return 0; +} +DM_TEST(dm_test_timer_timebase_fallback, + UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); From patchwork Mon Sep 28 14:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372684 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=GOSalXuy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QWR32Tlz9s0b for ; Tue, 29 Sep 2020 00:53:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E2CAE82380; Mon, 28 Sep 2020 16:53:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="GOSalXuy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DA0F18233E; Mon, 28 Sep 2020 16:52:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C3B9D82294 for ; Mon, 28 Sep 2020 16:52:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x843.google.com with SMTP id 19so944090qtp.1 for ; Mon, 28 Sep 2020 07:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SAy+KRcHvnJu7M3RoeYMq63x1OQxPMSCy6wbEzD5SEk=; b=GOSalXuyPHXYaMXrwTEUbhrq72Cq0neZ9867BTqhupPoUhEV0xPnTJ1rwlB6KpNjCO CXu6WPjfjVIbKfcEu54HOlESnaq0b6ANFTR3p00WttRrOs+1P8ud4t/nbp/QANCpeztf CHNBngrDhV7J9c9tzxDM1WQw3ACC1H2IBMEjPmW6f4TOPQ/5Fx56qJZ5O6NQ2sY5y3a+ QBBXtXbfDDWK31/4h6MZqrSfGhwD7a1xvUoQFokItRATkSiX7/6dXqWaNRIcecunPMSe f7ztzawf2iFslIYzkXrEfj4gW0MhObJ0BCwaNbz3mZ1ZVQfr7bwo2zQTsnCydMzbl0a8 jGoA== 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=SAy+KRcHvnJu7M3RoeYMq63x1OQxPMSCy6wbEzD5SEk=; b=HxUXi2w+KI/j+cK8XYcku80N9nNGd6DGKkwRAWpa5fPemzSvMa+gcnTNFkYKDBMehY 04icqB6pMtwJzt4kzm54jrIWmOpk0JUrdEb8GXcYdL7t4JT2VPeoPG0uy4YY7IBMhabG BP5TPWYlIqm2xAj6cu9OD+1RH62kSbSO95yIs6OYhv37vd212FQcNAtkiFng6r6yPky/ oIhjBfOi+y59wgaED3Gh414mlm7HpCFEcL/LyWOgzEq12lxMQIf263M0Lt2nvu+nUe/1 30tJ3nY07KvIqm9OC7lwsONQzmkdGBja0MF4oH/XgXYmw32w3+aPCP7bRruvZLzoGMUI 5mYQ== X-Gm-Message-State: AOAM533sbMkZG/XitEVZQM8nBFmHwWxHRVMVNmMm3MDulxqwHFR2MfVT 9jUn7qcDbFhJQqcUaGYopP+BxSAjQI47xg== X-Google-Smtp-Source: ABdhPJxya8LiAgLO0ZchrRyPY2koR7FYcfJmviLcqHCEVLHSf9W1/tpC8z6ll+mbQ2keLwt38POFbg== X-Received: by 2002:ac8:23a3:: with SMTP id q32mr1945701qtq.361.1601304769441; Mon, 28 Sep 2020 07:52:49 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:48 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Rick Chen Subject: [PATCH v6 4/9] riscv: Rework Andes PLMT as a UCLASS_TIMER driver Date: Mon, 28 Sep 2020 10:52:24 -0400 Message-Id: <20200928145229.449782-5-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This converts the PLMT driver from the riscv-specific timer interface to be a DM-based UCLASS_TIMER driver. The clock-frequency/clocks properties are preferred over timebase-frequency for two reasons. First, properties which affect a device should be located near its binding in the device tree. Using timebase-frequency only really makes sense when the cpu itself is the timer device. This is the case when we read the time from a CSR, but not when there is a separate device. Second, it lets the device use the clock subsystem which adds flexibility. If the device is configured for a different clock speed, the timer can adjust itself. Signed-off-by: Sean Anderson Reviewed-by: Rick Chen --- This patch builds but has NOT been tested. (no changes since v5) Changes in v5: - Remove RISCV_SYSCON_PLMT - Undo changes to ae350 device trees. They are unnecessary with timer_timebase_fallback. Changes in v4: - Use timer_timebase_fallback arch/riscv/Kconfig | 4 --- arch/riscv/include/asm/global_data.h | 3 -- arch/riscv/include/asm/syscon.h | 4 +-- arch/riscv/lib/andes_plmt.c | 44 +++++++++++++--------------- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 21e6690f4d..d9155b9bab 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -177,10 +177,6 @@ config ANDES_PLIC config ANDES_PLMT bool depends on RISCV_MMODE || SPL_RISCV_MMODE - select REGMAP - select SYSCON - select SPL_REGMAP if SPL - select SPL_SYSCON if SPL help The Andes PLMT block holds memory-mapped mtime register associated with timer tick. diff --git a/arch/riscv/include/asm/global_data.h b/arch/riscv/include/asm/global_data.h index b711fcc44d..d3a0b1d221 100644 --- a/arch/riscv/include/asm/global_data.h +++ b/arch/riscv/include/asm/global_data.h @@ -24,9 +24,6 @@ struct arch_global_data { #ifdef CONFIG_ANDES_PLIC void __iomem *plic; /* plic base address */ #endif -#ifdef CONFIG_ANDES_PLMT - void __iomem *plmt; /* plmt base address */ -#endif #if CONFIG_IS_ENABLED(SMP) struct ipi_data ipi[CONFIG_NR_CPUS]; #endif diff --git a/arch/riscv/include/asm/syscon.h b/arch/riscv/include/asm/syscon.h index 26a008ca59..c3629e4b53 100644 --- a/arch/riscv/include/asm/syscon.h +++ b/arch/riscv/include/asm/syscon.h @@ -7,13 +7,13 @@ #define _ASM_SYSCON_H /* - * System controllers in a RISC-V system + * System controllers in a RISC-V system. These should only be used for + * identifying IPI controllers. Other devices should use DM to probe. */ enum { RISCV_NONE, RISCV_SYSCON_CLINT, /* Core Local Interruptor (CLINT) */ RISCV_SYSCON_PLIC, /* Platform Level Interrupt Controller (PLIC) */ - RISCV_SYSCON_PLMT, /* Platform Level Machine Timer (PLMT) */ }; #endif /* _ASM_SYSCON_H */ diff --git a/arch/riscv/lib/andes_plmt.c b/arch/riscv/lib/andes_plmt.c index a7e90ca992..a28c14c1eb 100644 --- a/arch/riscv/lib/andes_plmt.c +++ b/arch/riscv/lib/andes_plmt.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2019, Rick Chen + * Copyright (C) 2020, Sean Anderson * * U-Boot syscon driver for Andes's Platform Level Machine Timer (PLMT). * The PLMT block holds memory-mapped mtime register @@ -9,46 +10,43 @@ #include #include -#include -#include +#include #include -#include #include /* mtime register */ #define MTIME_REG(base) ((ulong)(base)) -DECLARE_GLOBAL_DATA_PTR; - -#define PLMT_BASE_GET(void) \ - do { \ - long *ret; \ - \ - if (!gd->arch.plmt) { \ - ret = syscon_get_first_range(RISCV_SYSCON_PLMT); \ - if (IS_ERR(ret)) \ - return PTR_ERR(ret); \ - gd->arch.plmt = ret; \ - } \ - } while (0) - -int riscv_get_time(u64 *time) +static int andes_plmt_get_count(struct udevice *dev, u64 *count) { - PLMT_BASE_GET(); - - *time = readq((void __iomem *)MTIME_REG(gd->arch.plmt)); + *count = readq((void __iomem *)MTIME_REG(dev->priv)); return 0; } +static const struct timer_ops andes_plmt_ops = { + .get_count = andes_plmt_get_count, +}; + +static int andes_plmt_probe(struct udevice *dev) +{ + dev->priv = dev_read_addr_ptr(dev); + if (!dev->priv) + return -EINVAL; + + return timer_timebase_fallback(dev); +} + static const struct udevice_id andes_plmt_ids[] = { - { .compatible = "riscv,plmt0", .data = RISCV_SYSCON_PLMT }, + { .compatible = "riscv,plmt0" }, { } }; U_BOOT_DRIVER(andes_plmt) = { .name = "andes_plmt", - .id = UCLASS_SYSCON, + .id = UCLASS_TIMER, .of_match = andes_plmt_ids, + .ops = &andes_plmt_ops, + .probe = andes_plmt_probe, .flags = DM_FLAG_PRE_RELOC, }; From patchwork Mon Sep 28 14:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372685 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=uwdanzxG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QWf726tz9s0b for ; Tue, 29 Sep 2020 00:53:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9953C8238C; Mon, 28 Sep 2020 16:53:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="uwdanzxG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B17498234E; Mon, 28 Sep 2020 16:52:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D33C8822ED for ; Mon, 28 Sep 2020 16:52:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x743.google.com with SMTP id x201so798156qkb.11 for ; Mon, 28 Sep 2020 07:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84Dz2pFPzm/8gPXbqgsJclH4SsItjAAam8glmVJEulg=; b=uwdanzxGzteKN0OPIn3tcnCdPguTcOBmOiIbPb5YM/msxng/AF7dnchR8jKtKetOYW b4gWoLcc2inEdodMwa5O2YuUzCjIFd+OtHzDGfrc1P7TtwVWep8J3qKUyjrdWWbsnALp KZFrXdwoevCmy0r6Pqbi/dcX0k4udi03DaWmwnZFTWqiJMIfJJ1HGhcctyVyvMRTV865 BzkyLzLCxHgAoGHwQfNozOTUSt1vsLff5MvKUGTbeyhbAZ49hAstTUes2J7uN1W3aLJC be6eNolJCaUH8c3tNB1nNX2wcG1j38W4wGG7nu9tqHCUkuSAV9dnsvEVKvAE/0PcbQMW 5QuA== 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=84Dz2pFPzm/8gPXbqgsJclH4SsItjAAam8glmVJEulg=; b=uUtONt9w2DYMmcrAyLhkYq/X3z8pyIQ6CcNqfMZZuqfxLEmhh7ck55NEF70fb+GPrs YPvCa6CNezknJXXrF2B41cm6EwTcZtvUiFK1jwxPiYAoh3ZW4KIe0AZBnpEucHNALVb2 R8vQ3Q6zEdAMpEVLNkTACZ4q+5rtRXcWX1TBpssl/1AlGYBXDboXPst8grd5x76n/OIh Mc9+2DcYXYx3MRKt8crOOGNjpo0TzCc3tz5+f9pwH8yOVQydoz2612IMIg5L9tuZlwSv FYZcZQPeuS1riLm/X2eijg7z4C2JfSTCYaENl+ofxnoOQJ82jK2e+9GL+i3gTRhB9eoE hsaQ== X-Gm-Message-State: AOAM530pe9ptfD8qm0PqKyXk59uLf7Ml1ZDWXlRNHbaJrEdFzhdgQc/n 8WL2ll06KB9x6mbS62gHBDcUJLAMJZ6ZhQ== X-Google-Smtp-Source: ABdhPJw4QmCK3lmzVdIISlbIEIwW6K53BJ5G9MQmISe92orrLvC0UwqY2t4eVMXMNdx1Y6u3ScRIbw== X-Received: by 2002:a05:620a:661:: with SMTP id a1mr1077878qkh.92.1601304770541; Mon, 28 Sep 2020 07:52:50 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:49 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Bin Meng Subject: [PATCH v6 5/9] riscv: Clean up initialization in Andes PLIC Date: Mon, 28 Sep 2020 10:52:25 -0400 Message-Id: <20200928145229.449782-6-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This merges the PLIC initialization code from two functions into one. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng --- This patch builds but has NOT been tested. (no changes since v1) arch/riscv/lib/andes_plic.c | 58 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/arch/riscv/lib/andes_plic.c b/arch/riscv/lib/andes_plic.c index c2a8fe4d9e..267d6a191b 100644 --- a/arch/riscv/lib/andes_plic.c +++ b/arch/riscv/lib/andes_plic.c @@ -41,53 +41,45 @@ static int enable_ipi(int hart) return 0; } -static int init_plic(void) +int riscv_init_ipi(void) { - struct udevice *dev; - ofnode node; int ret; + long *base = syscon_get_first_range(RISCV_SYSCON_PLIC); + ofnode node; + struct udevice *dev; u32 reg; + if (IS_ERR(base)) + return PTR_ERR(base); + gd->arch.plic = base; + ret = uclass_find_first_device(UCLASS_CPU, &dev); if (ret) return ret; + else if (!dev) + return -ENODEV; - if (dev) { - ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { - const char *device_type; + ofnode_for_each_subnode(node, dev_ofnode(dev->parent)) { + const char *device_type; - device_type = ofnode_read_string(node, "device_type"); - if (!device_type) - continue; + device_type = ofnode_read_string(node, "device_type"); + if (!device_type) + continue; - if (strcmp(device_type, "cpu")) - continue; + if (strcmp(device_type, "cpu")) + continue; - /* skip if hart is marked as not available */ - if (!ofnode_is_available(node)) - continue; + /* skip if hart is marked as not available */ + if (!ofnode_is_available(node)) + continue; - /* read hart ID of CPU */ - ret = ofnode_read_u32(node, "reg", ®); - if (ret == 0) - enable_ipi(reg); - } - - return 0; + /* read hart ID of CPU */ + ret = ofnode_read_u32(node, "reg", ®); + if (ret == 0) + enable_ipi(reg); } - return -ENODEV; -} - -int riscv_init_ipi(void) -{ - long *ret = syscon_get_first_range(RISCV_SYSCON_PLIC); - - if (IS_ERR(ret)) - return PTR_ERR(ret); - gd->arch.plic = ret; - - return init_plic(); + return 0; } int riscv_send_ipi(int hart) From patchwork Mon Sep 28 14:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372686 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=VDy/V+II; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QWv2Ffnz9s0b for ; Tue, 29 Sep 2020 00:54:02 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CB5B82304; Mon, 28 Sep 2020 16:53:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="VDy/V+II"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C127D82371; Mon, 28 Sep 2020 16:52:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DEC4B82287 for ; Mon, 28 Sep 2020 16:52:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x742.google.com with SMTP id g72so1177808qke.8 for ; Mon, 28 Sep 2020 07:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FqEdxC07vOClZHrqIA5TScO+7EH/knQw6BIclbqxtqE=; b=VDy/V+IIDz8XfIt1XYeHEtQq1oSQpg8bUhjKG3zfw49SRtXeyubKoT9pJ3C2SPGRrR 54IJMkCzeMPt5a057p/CI6VRWZAFI7VzAL27TdybB8NI/ac5fvAE148FAv9u/sElFBjM sIpPzT3tWxZavY4c2F0q0rcbDbecwnAQK7HFsRjLV737DRap/LUj9toRn004CpGpNwWT MiUPMq7YiEaeGt/0QF4oU9tis1yctYxdRM4RhIc4Djd7nBdpou2T9R5aq8XNa7htwrhI qZ33J4o4iUgsBdmj2LTCIDykf88HXWibtg2k3Z7ys9faAPf+MIhBBAPAwAlA9HMqt9S0 fV0w== 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=FqEdxC07vOClZHrqIA5TScO+7EH/knQw6BIclbqxtqE=; b=mRcWlSEgIDQADYRZhPZf9OkFmDv8XT0AGzipVke5L9LC6YItbGXqFF2pLOu6EEnQrQ 5U0/Ix6q+LlBZe4/oSU+hy4n2/wEH/0DGAluRROjCb+CahnSAVky3K7DUZynMm5sFMfv 1AQeldlLB9yDieg9SNfsJ64LUTl6JF05qlx0mEZd1aKarJMNXp5dTjDqW0fAFLVV8pIP +950pkS/OYoAPG/UDUWnK2kXP3/HShJ5f6TgVV3HqJyd0/YaRdDH8MA8VsVtirwgw4ge r+qEwTQifxfE61UDV5+yMEBPl+d7d594N/6iugGkWBRWG2456HI3Bhb/6C40mdBlMm0n 8EgA== X-Gm-Message-State: AOAM533X3W3//6PChnqKidobQO2Ffkfi2yFuU4A4tBXbTzaYrEYL0PwL e6yGmaD0b+dy0UKx6um4QqTWjSgBeE/Icg== X-Google-Smtp-Source: ABdhPJyl9K61TAhsTEDUVS5C/Dy1gtOBESlc1XZpI7GoWmNLZioSc8Z4w7Vzr45RMWacFaNYu2hkXw== X-Received: by 2002:a37:acb:: with SMTP id 194mr1722088qkk.321.1601304771550; Mon, 28 Sep 2020 07:52:51 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:51 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Pragnesh Patel Subject: [PATCH v6 6/9] riscv: Rework Sifive CLINT as UCLASS_TIMER driver Date: Mon, 28 Sep 2020 10:52:26 -0400 Message-Id: <20200928145229.449782-7-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This converts the clint driver from the riscv-specific interface to be a DM-based UCLASS_TIMER driver. In addition, the SiFive DDR driver previously implicitly depended on the CLINT to select REGMAP. Unlike Andes's PLMT/PLIC (which AFAIK never have anything pass it a dtb), the SiFive CLINT is part of the device tree passed in by qemu. This device tree doesn't have a clocks or clock-frequency property on clint, so we need to fall back on the timebase-frequency property. Perhaps in the future we can get a clock-frequency property added to the qemu dtb. Unlike with the Andes PLMT, the Sifive CLINT is also an IPI controller. RISCV_SYSCON_CLINT is retained for this purpose. Signed-off-by: Sean Anderson Reviewed-by: Pragnesh Patel --- This patch builds but has only been tested on the K210 and QEMU. It has NOT been tested on a HiFive. (no changes since v5) Changes in v5: - Don't add a dependency on REGMAP for SIFIVE_FU540_DDR. Instead, depend on Bin Meng's patch. Changes in v4: - Use timer_timebase_fallback Changes in v3: - Don't initialize the IPI in spl_invoke_opensbi. Further testing has revealed it to be unnecessary. arch/riscv/Kconfig | 4 --- arch/riscv/lib/sifive_clint.c | 66 +++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d9155b9bab..aaa3b833a5 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -155,10 +155,6 @@ config 64BIT config SIFIVE_CLINT bool depends on RISCV_MMODE || SPL_RISCV_MMODE - select REGMAP - select SYSCON - select SPL_REGMAP if SPL - select SPL_SYSCON if SPL help The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. diff --git a/arch/riscv/lib/sifive_clint.c b/arch/riscv/lib/sifive_clint.c index b9a2c649cc..c9704c596f 100644 --- a/arch/riscv/lib/sifive_clint.c +++ b/arch/riscv/lib/sifive_clint.c @@ -8,9 +8,9 @@ */ #include +#include #include -#include -#include +#include #include #include #include @@ -24,35 +24,19 @@ DECLARE_GLOBAL_DATA_PTR; -int riscv_get_time(u64 *time) -{ - /* ensure timer register base has a sane value */ - riscv_init_ipi(); - - *time = readq((void __iomem *)MTIME_REG(gd->arch.clint)); - - return 0; -} - -int riscv_set_timecmp(int hart, u64 cmp) -{ - /* ensure timer register base has a sane value */ - riscv_init_ipi(); - - writeq(cmp, (void __iomem *)MTIMECMP_REG(gd->arch.clint, hart)); - - return 0; -} - int riscv_init_ipi(void) { - if (!gd->arch.clint) { - long *ret = syscon_get_first_range(RISCV_SYSCON_CLINT); + int ret; + struct udevice *dev; - if (IS_ERR(ret)) - return PTR_ERR(ret); - gd->arch.clint = ret; - } + ret = uclass_get_device_by_driver(UCLASS_TIMER, + DM_GET_DRIVER(sifive_clint), &dev); + if (ret) + return ret; + + gd->arch.clint = dev_read_addr_ptr(dev); + if (!gd->arch.clint) + return -EINVAL; return 0; } @@ -78,14 +62,36 @@ int riscv_get_ipi(int hart, int *pending) return 0; } +static int sifive_clint_get_count(struct udevice *dev, u64 *count) +{ + *count = readq((void __iomem *)MTIME_REG(dev->priv)); + + return 0; +} + +static const struct timer_ops sifive_clint_ops = { + .get_count = sifive_clint_get_count, +}; + +static int sifive_clint_probe(struct udevice *dev) +{ + dev->priv = dev_read_addr_ptr(dev); + if (!dev->priv) + return -EINVAL; + + return timer_timebase_fallback(dev); +} + static const struct udevice_id sifive_clint_ids[] = { - { .compatible = "riscv,clint0", .data = RISCV_SYSCON_CLINT }, + { .compatible = "riscv,clint0" }, { } }; U_BOOT_DRIVER(sifive_clint) = { .name = "sifive_clint", - .id = UCLASS_SYSCON, + .id = UCLASS_TIMER, .of_match = sifive_clint_ids, + .probe = sifive_clint_probe, + .ops = &sifive_clint_ops, .flags = DM_FLAG_PRE_RELOC, }; From patchwork Mon Sep 28 14:52:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372687 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=g5DK8wd+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QX60yhhz9s0b for ; Tue, 29 Sep 2020 00:54:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A8DF823A7; Mon, 28 Sep 2020 16:53:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="g5DK8wd+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE0EE82371; Mon, 28 Sep 2020 16:52:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E561982294 for ; Mon, 28 Sep 2020 16:52:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x744.google.com with SMTP id d20so1186496qka.5 for ; Mon, 28 Sep 2020 07:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GdDDeQuHIwps9ZrFnwDjof7F6xk3pLbiKjZ8GijAJWc=; b=g5DK8wd+9rGe914Rssk7baUZnoRz+EMwFY1X8kkujGWyUlmlj8KdcWhDWLSZJX48XQ JPoYijouyRe1MgQ8kx/ExTJQRZQvmBtrEMUFHMYFIQWTDDiGk9TiRVcepEFcUHTLRrd6 tExEB2KopTwE2K845W0WQsCbIit2SX9WyddURYu8ivMvYvUH5cwYheY24WaGUB3Lg43G k9iST45fA4E1TF833vuCZX2usBntRkGKZ0EKrq9huhqaKuunjzYlVs9uT1ASKJ7culF2 iQ1JkQ5cFqkqxL9rJzJClmx1xd81YO2ISLb9P7FOIREjhEpakRmSA4IFNnM0/f6Wbuy+ /jSw== 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=GdDDeQuHIwps9ZrFnwDjof7F6xk3pLbiKjZ8GijAJWc=; b=a3aQ9ItbLj1G2izxK7WKttJS2lXrbhVlugypMtUzl0S3NOkFshJ8UJP96wzTGLZeJv 77aK6yiztZHjeGkNTOsFU21fHXIKlNR3bZAHIWGDxvpbnxgg6XoLRoRL59xuLHU8QVlF EusVVR2ZJg+iy5dPlb2EDfe1VU4N0JeS0sw5g5juCOxBBQpxueSP0Zm0LN9F6tgFTQzl MVh7jMN8QC9ii6YeU7/sqpZm5YDRNvo9axOHiAnSKoDVrhRE1r78ILHn3pjc0QXfs7GQ z+ru2z46KFQ74wD6shjQV0s74FTfzF0th/0BrmW52XI7uO+yVmR0db7+3b/9muQ7h0uT G5lg== X-Gm-Message-State: AOAM532Nm9q1hll/lA0qWyFg+wMKz13jHkdgP6dBrSNlexe+rfRkDOzE 4j7EOwhNq64j/tlM9VwhuPAdA5oIhunMLQ== X-Google-Smtp-Source: ABdhPJzqCfpVO83OvnQKjTQ0uabg/R5AYbpw0LxiBe62wab5kbQhgeoMPIJksS4OExb5CVl4bx3sPg== X-Received: by 2002:ae9:e8c2:: with SMTP id a185mr1810024qkg.435.1601304772621; Mon, 28 Sep 2020 07:52:52 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:52 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson Subject: [PATCH v6 7/9] riscv: clk: Add CLINT clock to kendryte clock driver Date: Mon, 28 Sep 2020 10:52:27 -0400 Message-Id: <20200928145229.449782-8-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Another "virtual" clock (in the sense that it isn't configurable). This could possibly be done as a clock in the device tree, but I think this is a bit cleaner. Signed-off-by: Sean Anderson --- checkpatch still complains about this one, but I don't see any reason to break it up even further. It doesn't make sense to me to split the header file change from everything else. (no changes since v2) Changes in v2: - Split Kendryte binding changes into their own commit drivers/clk/kendryte/clk.c | 4 ++++ include/dt-bindings/clock/k210-sysctl.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/clk/kendryte/clk.c b/drivers/clk/kendryte/clk.c index 981b3b7699..bb196961af 100644 --- a/drivers/clk/kendryte/clk.c +++ b/drivers/clk/kendryte/clk.c @@ -646,6 +646,10 @@ static int k210_clk_probe(struct udevice *dev) REGISTER_GATE(K210_CLK_RTC, "rtc", in0); #undef REGISTER_GATE + /* The MTIME register in CLINT runs at one 50th the CPU clock speed */ + clk_dm(K210_CLK_CLINT, + clk_register_fixed_factor(NULL, "clint", "cpu", 0, 1, 50)); + return 0; } diff --git a/include/dt-bindings/clock/k210-sysctl.h b/include/dt-bindings/clock/k210-sysctl.h index 0e3ed3fb9f..fe852bbd92 100644 --- a/include/dt-bindings/clock/k210-sysctl.h +++ b/include/dt-bindings/clock/k210-sysctl.h @@ -55,5 +55,6 @@ #define K210_CLK_OTP 43 #define K210_CLK_RTC 44 #define K210_CLK_ACLK 45 +#define K210_CLK_CLINT 46 #endif /* CLOCK_K210_SYSCTL_H */ From patchwork Mon Sep 28 14:52:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372688 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=dOQYfMIk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QXJ4VTTz9s0b for ; Tue, 29 Sep 2020 00:54:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C7E6823B0; Mon, 28 Sep 2020 16:53:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="dOQYfMIk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C0E6A8233E; Mon, 28 Sep 2020 16:52:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EC16D8234E for ; Mon, 28 Sep 2020 16:52:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x742.google.com with SMTP id w12so1178760qki.6 for ; Mon, 28 Sep 2020 07:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JMwKGTJ2h2M9Wi3TwqcuKxhjrbp9CTrE7pyxfgi9PH4=; b=dOQYfMIkOnuHyibqTI2Efm7pAka/NBQ7DA9Bzpjsrd/+Nn7C1dVEhP6pVj0kIuojq7 Ky6WXqft4jzFMbfMR0dZYdZlUMfdPnfqvLlke78ezxAANhSOmy5a2Epi+/ObS3L87JZY e63gUl1dRKG1s+jyOLg5uF1ntek3/Dxk2VtkQIfwYFh4THcx6E57r/dzo3AcOuQj2Oni KavBDZBxmVGjj3ikoNZSCPKChzetvrtw9i+L+VqdBbLMWuR8GVHfE1OYCFzuBP6/Z06B P09m1aXD/Vru1P4PmuO9Ep13M3hYLJD9zaZfNJp6b66g3CNidh/rpgrpIEyUCuFCgydR bz1w== 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=JMwKGTJ2h2M9Wi3TwqcuKxhjrbp9CTrE7pyxfgi9PH4=; b=ec+3Ds7izB4lqQGJnbH9irNOsEaEhPY65ppCRsPBRj+yNa9bKFCSnHve9QMqzT3wH9 TnXif4CyHxZ6N22/w67QHH3Ba1js0VGVzxqyTm4dqI+83rg/rut0H+doM2RPvkPF/K7S OYaQgUd2ZHG4U9h4jLHyTQjPqN8Y9hJ/3Be06IkOwo8jAPQF8UqCzSRbBh0fSA5pUb9e TR1X7zjxKM2bwbHMWoOttyvFrZNhJodTRItU/Y83eT3fcLxAakbxcZr6u3O7kqUhPjgi KiElCmh7+BiEl8BGk4pmZV1BAKLUfOcQ8TmSJSFdjH9wOAZQzzx5m/3KKqPPqEgdj5Ct y+AA== X-Gm-Message-State: AOAM530FCGM35nuCR3V1t5YFBHwT2XstXWYS01WBHenkznAmdSNDjt+V Sp2/dbpCdhiMLJ4ng49JJoFDlcYn6KZ1Vg== X-Google-Smtp-Source: ABdhPJx1X+nvdi2wTfLjbDPiXhVfQXYcpaDQGysu9Hjt8f8XJm9NQ0RugOoUSzgserSoJEP03DUarQ== X-Received: by 2002:ae9:e70c:: with SMTP id m12mr1723216qka.91.1601304773589; Mon, 28 Sep 2020 07:52:53 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:53 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Bin Meng Subject: [PATCH v6 8/9] riscv: Update Kendryte device tree for new CLINT driver Date: Mon, 28 Sep 2020 10:52:28 -0400 Message-Id: <20200928145229.449782-9-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The interrupt controller property is removed from the clint binding because the clint is not an interrupt-controller. That is, no other devices have an interrupt which is controlled by the clint. Signed-off-by: Sean Anderson Reviewed-by: Bin Meng --- (no changes since v4) Changes in v4: - Remove clock-frequency property from k210 clint binding because we fall back on timebase-frequency Changes in v2: - New arch/riscv/dts/k210.dtsi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/dts/k210.dtsi b/arch/riscv/dts/k210.dtsi index 2546c7d4e0..84cff51c36 100644 --- a/arch/riscv/dts/k210.dtsi +++ b/arch/riscv/dts/k210.dtsi @@ -17,6 +17,8 @@ compatible = "kendryte,k210"; aliases { + cpu0 = &cpu0; + cpu1 = &cpu1; dma0 = &dmac0; gpio0 = &gpio0; gpio1 = &gpio1_0; @@ -126,14 +128,13 @@ read-only; }; - clint0: interrupt-controller@2000000 { + clint0: clint@2000000 { #interrupt-cells = <1>; compatible = "kendryte,k210-clint", "riscv,clint0"; reg = <0x2000000 0xC000>; - interrupt-controller; interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>, <&cpu1_intc 3>, <&cpu1_intc 7>; - clocks = <&sysclk K210_CLK_CPU>; + clocks = <&sysclk K210_CLK_CLINT>; }; plic0: interrupt-controller@C000000 { From patchwork Mon Sep 28 14:52:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1372689 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=fIAmp718; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0QXW0sDJz9s0b for ; Tue, 29 Sep 2020 00:54:35 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 64559823BE; Mon, 28 Sep 2020 16:53:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="fIAmp718"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A7F2B8233E; Mon, 28 Sep 2020 16:52:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DA9AA82287 for ; Mon, 28 Sep 2020 16:52:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x742.google.com with SMTP id q5so1200174qkc.2 for ; Mon, 28 Sep 2020 07:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kklbT7TtQipnusqyJ/jUfVy8CIrlv2Vu/1HYeZN2/L8=; b=fIAmp7186QnIenPG20dwvzZb7Q1YaVLTLO573C6mq+wbogGzaQ5IZ2FmL0mdREsd2D WuuHJK7V6+WWw+/Np193NFgHUdGFpMDITejyZUbU3xK15p1/GBWTctfgI63Feyirr3l2 v992cMsnJBKyq5eQyc97xreJ9p7QlvjSSZotqZzu8zQvJHe/5YkYZysSm1CGL5bomyqw /2r24IPkR3UqHIlkvWXzO12F5NsD3Fy6fwNPmNgfyRuLejmL578Q5/XWjU3PQ53CEpDn ZEMlZ4nut5veQzln5XJQzTb9hujX2AeVGskhqRaJYks0RRMSxQOIByOn8fgSa8XzyI+q hLfQ== 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=kklbT7TtQipnusqyJ/jUfVy8CIrlv2Vu/1HYeZN2/L8=; b=Gn3y5tV5ips+GhaKuSnxK9IZpnvVOCsOD6Jy9G9j298+ruTmFD4SoW7vgB+3ZLka7k ALdGxXeAh2CB/H3toI705Qjewovc0KV+lka+GdkJwLGc4VrWURZPKTVgibkuWceku1mQ UbFr7l7eGLsGTI/aAKAvI/xMwJHBnO+cQXi8WvBGIudHzLwcCWaDcPVoP4p6scVPAVqz SuFCcd2Yu+TFG3gaSEymGZySBNUKb4VldOIf9mqJJdWygBfGtgWO0LuRq27EI/PLQY4B MCWadYT9acNHXrqRCCi00tt02PhaopxBLQBjRbpndEJCRjmVg0goAwXQlmqD6DkryLb7 YF8g== X-Gm-Message-State: AOAM532dU1m+HjrDsTUD67zJaerdmZU6QkwtBmimmpk8+LOKKUteelUC /vhUAihzWkTRjiYqC3zstCzNFwHF73G1BQ== X-Google-Smtp-Source: ABdhPJz0hHJ0VrWnjD2Jr0vsTBXqrl4BFwKEsNG3qzd3hRymk6wxiQyG/KupBuaqU18n23QPNYtRkg== X-Received: by 2002:a05:620a:48:: with SMTP id t8mr1871212qkt.368.1601304774613; Mon, 28 Sep 2020 07:52:54 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id e7sm1530651qtk.17.2020.09.28.07.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 07:52:54 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Pragnesh Patel , Rick Chen , Bin Meng , Anup Patel , Sean Anderson , Pragnesh Patel , Bin Meng Subject: [PATCH v6 9/9] riscv: Update SiFive device tree for new CLINT driver Date: Mon, 28 Sep 2020 10:52:29 -0400 Message-Id: <20200928145229.449782-10-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928145229.449782-1-seanga2@gmail.com> References: <20200928145229.449782-1-seanga2@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean We currently do this in a u-boot specific dts, but hopefully we can get these bindings added in Linux in the future. Signed-off-by: Sean Anderson Reviewed-by: Pragnesh Patel Reviewed-by: Bin Meng --- This patch builds but has NOT been tested. (no changes since v2) Changes in v2: - Fix SiFive CLINT not getting tick-rate from rtcclk arch/riscv/dts/fu540-c000-u-boot.dtsi | 8 ++++++-- arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/riscv/dts/fu540-c000-u-boot.dtsi b/arch/riscv/dts/fu540-c000-u-boot.dtsi index 5302677ee4..a06e1b11c6 100644 --- a/arch/riscv/dts/fu540-c000-u-boot.dtsi +++ b/arch/riscv/dts/fu540-c000-u-boot.dtsi @@ -55,9 +55,13 @@ reg = <0x0 0x10070000 0x0 0x1000>; fuse-count = <0x1000>; }; - clint@2000000 { + clint: clint@2000000 { compatible = "riscv,clint0"; - interrupts-extended = <&cpu0_intc 3 &cpu0_intc 7 &cpu1_intc 3 &cpu1_intc 7 &cpu2_intc 3 &cpu2_intc 7 &cpu3_intc 3 &cpu3_intc 7 &cpu4_intc 3 &cpu4_intc 7>; + interrupts-extended = <&cpu0_intc 3 &cpu0_intc 7 + &cpu1_intc 3 &cpu1_intc 7 + &cpu2_intc 3 &cpu2_intc 7 + &cpu3_intc 3 &cpu3_intc 7 + &cpu4_intc 3 &cpu4_intc 7>; reg = <0x0 0x2000000 0x0 0xc0000>; u-boot,dm-spl; }; diff --git a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi index 5d0c928b29..1996149c95 100644 --- a/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi +++ b/arch/riscv/dts/hifive-unleashed-a00-u-boot.dtsi @@ -34,6 +34,10 @@ }; +&clint { + clocks = <&rtcclk>; +}; + &qspi0 { u-boot,dm-spl;