From patchwork Wed Sep 9 20:09: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: 1361010 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=rETU1lvI; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmtRQ5rxbz9sTK for ; Thu, 10 Sep 2020 06:10:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A8EB0822C3; Wed, 9 Sep 2020 22:09: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=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="rETU1lvI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5E6C181B79; Wed, 9 Sep 2020 22:09: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-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 7134E81B79 for ; Wed, 9 Sep 2020 22:09: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-qt1-x843.google.com with SMTP id n18so3043209qtw.0 for ; Wed, 09 Sep 2020 13:09: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=aFnrXortEuEjmoCOhtk350G2rr7DXSvXV30I5eGILsU=; b=rETU1lvIjllp9guOuSxKlpmUFn9yCSsNEMp7Ww2ns9THSWRN45OLSLXyUpw6Ro6mgv 3Z3OBu0PQi1Pxjqk5NrNCOWbjN4/g3s63zHSiLzMLuCUwdlaasSeU7Ea2MRHnkYcyljg JdCRkDAYrlXy9HPU9G6A1yFR67M6Sl+HkfMThSXJ8BECWiQhtUJJpw2AlnJQ6V7vZLHe ik4pmoABhqx8PVaG6p7Cf169zg2HG6dwsIPhk8ONwE6T5o6MPI+n7x5EOq6F7HygG0rx nIalj9QAzp0q2sPz9VD7QRg4AG/n7pa3GEUv+YIE7UmsHvP0ZONBcty9ZdMbLSGx3MFh iqJw== 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=aFnrXortEuEjmoCOhtk350G2rr7DXSvXV30I5eGILsU=; b=DNEaWIJbZzKmRmCv+yRwY3TXLgXqpW/j2dTAbMRNOZz6bCExM+XbFW/2QVR76hRsR7 BYV/kNf/RDtXu/Z3+CDp1tUuyzwShffo+UrjHgrbec2/j/3qdTjKAdyX36FhBw5nsc6L tCUCFXoKP4uKbJITh8rvnHzDnrFJfC41yUG4gbGPIz8km91C0BbwnLUxnoP3uol3txgO g4w26VQAMbAaaUeMlQkglZVX4ffl6agGt4w+M5qg3OFP4GPjzYVbsE72Zz+uziVD2Spr ZEnFoxKMFN9wgr2yFQ9oZpWpSis87lhT25+Hvtc7NrBdinFRSHqJhLXzZF+14t51R71C LXKw== X-Gm-Message-State: AOAM532Fx7C//yJLxPEYTofLsBgemBgmTqwkzec9D0UMgJ7RKzp7saX7 W+6QPhOUpL0gdzTToUAhh3jNEd7QKQVqu30C X-Google-Smtp-Source: ABdhPJzDy6LeX3ehqupYb3ewdApojBxwj9Z+/XUnNz7dF9qTRF3PTM+Mlb6KJ+TPRZ2NmRTptye5zg== X-Received: by 2002:ac8:5317:: with SMTP id t23mr5066158qtn.354.1599682186868; Wed, 09 Sep 2020 13:09:46 -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 s30sm4342831qth.65.2020.09.09.13.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:46 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Bin Meng Subject: [PATCH v4 1/8] riscv: Rework riscv timer driver to only support S-mode Date: Wed, 9 Sep 2020 16:09:23 -0400 Message-Id: <20200909200930.232174-2-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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 --- 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 Wed Sep 9 20:09: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: 1361011 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=iK8aGF1r; 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 4BmtRY6b5sz9sTd for ; Thu, 10 Sep 2020 06:10:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2BA0822D7; Wed, 9 Sep 2020 22:09: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="iK8aGF1r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85CEC82189; Wed, 9 Sep 2020 22:09: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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (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 54A0E82189 for ; Wed, 9 Sep 2020 22:09: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-x842.google.com with SMTP id t20so2998726qtr.8 for ; Wed, 09 Sep 2020 13:09: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=fduAFZZ7RShP1Khm+aYntQ+R38wdzLOI5qosPo22h1A=; b=iK8aGF1rau42i30qgCAHemvWqwKTTj+yCycqPMFKoFGejWCqAcld9M6TYXKK/B3oUz 4jAi0QNGxowfruiOi1hOy7uCs1oh8bo+ezno/r/ZY0dWyf9AIIsmnPVJKLcAjwC/1iIt +oCnv807LM7pCQfSTqckeRo3P+aEr9eEirNeXQOCDlN2Hr8QvVddXBg+YPLtlsFNIrWC jZq0lhDremimdHSpZ71tWeL/vMBZ1tSyzIQoI2iiZF3/ile7mR+PcnjtKG5oXuec7wFO RvI5tEuV0x/S9PUlNpY2GaHVAVl61z1z2iF8WcYhDXlB4NVCCHr3hBqsDlMf6df8woMw PyQA== 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=fduAFZZ7RShP1Khm+aYntQ+R38wdzLOI5qosPo22h1A=; b=jXCbZ5mXH6gdL9BiXP0TCZ8F5EyVl61l+IRa7ZyqxkBt0D5We1fO/XlW8Ri3qBn/G9 dI9+vZE6MCHDWOFPq/E2Crs1ntYrAADLIt5MsHqynKcQNmo4UWRy+JsB0K9EP1bhfJ7N zAp/u+QHD0pEuzVUGfb3bWGJYSbPrT3IlxrPT8V0Mtm9mF41mx1u/xfbw3iwaXiiyXQP aD7jJ3WTfBJF47DhgdP+DNyYtH9+uKr93sJMVp0soOzV5j+RUROmcW50pIXIwAw759em szFJYWJU78iL6eQboF/yl75WWeEU9rUOOkpwgOe9Ilm9J8kyn879bQwk04kgCN8v4lcO wCNA== X-Gm-Message-State: AOAM5321JbFwPuaFNH04d+RKKwMYLicpPxs7diinourYcoXGB+YZifK/ s8OHVU8b2oQzLrUUtu3trz5/d/2BNo67OHDf X-Google-Smtp-Source: ABdhPJxaiY0BR4vOwiIz/wxPIrm8UJP2GiFtFI1QjDyKc0NHenvGJq4q2DmQ6ruLqnpBlS19IYjmAA== X-Received: by 2002:ac8:12c1:: with SMTP id b1mr5113247qtj.148.1599682188008; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:47 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Simon Glass Subject: [PATCH v4 2/8] timer: Add helper for drivers using timebase fallback Date: Wed, 9 Sep 2020 16:09:24 -0400 Message-Id: <20200909200930.232174-3-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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 --- Changes in v4: - New drivers/timer/timer-uclass.c | 25 +++++++++++++++++++++++++ include/timer.h | 15 +++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 14dde950a1..fb2f4c351a 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,30 @@ static int timer_post_probe(struct udevice *dev) return 0; } +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; +} + 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 Wed Sep 9 20:09: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: 1361012 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=UWCoTCQ6; 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 4BmtRn50lPz9sTK for ; Thu, 10 Sep 2020 06:10:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49D6D822EC; Wed, 9 Sep 2020 22:09: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="UWCoTCQ6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F6E782281; Wed, 9 Sep 2020 22:09: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-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (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 55B8F8158B for ; Wed, 9 Sep 2020 22:09: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-x844.google.com with SMTP id v54so3006709qtj.7 for ; Wed, 09 Sep 2020 13:09: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=Tx5XX8DoWXEa7UZg36I1JA3uHSj9aPCygy+z2Wh+Wgs=; b=UWCoTCQ6JlUVY6anp/3JD0s2OlGPvuLp3LGPIHU0hMmNbOQ0Gc+puFfKw/NvL98Vg9 /Wlzdc4JrovrP+8Dm2brsO93E9ZNuwkBIs89nsXcuuEU3O6mQBGiNdlPgDYxnfjnzAsd JDB4TLwFxAw3Rh4OGI7aGLcSLS3kcULhhhRVohi3e8dK58JUhFBc9U/K2blsINgmYmth uOVlDJNyh/UMWAYfEYmer2/XeK0EZYeIWobAV9qw0Qov11geMxeayrneOdYJ9DnYW1WJ BwQxkjzjEpAQ3IpkqwGX1rDKzA8X9AYPYPtg3BH17R0kzXy7wsHICUWoOuwMCYVFyemT ztbw== 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=Tx5XX8DoWXEa7UZg36I1JA3uHSj9aPCygy+z2Wh+Wgs=; b=rPjvOeljjFnvna3Lu/7ierM1pL5QB/P1+eLuYGEGjR7ao0fmvgNg8ANTUAHndKb4sN 14DyNEt0RB8LWU31z85RlyW3K+l3x/AEp6ddCa9kpPtm6OzPM5HCLa/8BRqAAEGJRHce jQhp51JXnJG1KJA7lnMlvZhfFGF7IvjgQ7TvTx+7c7pfGHdxnJ+Y1g9hyGHzjhdKRPGd dc6BW27zXuxzSr85So52ciUHErOIQloAI1Y8ib2IVgT+Vnp47ENRK4IU2vU/ZteTC7zP EQH8R8gqrCAim3O+bXrW4xy/rTuA20PwnKcLc9mlaH6VA8oDlafQe9GBI88j7HH1hntX TKsA== X-Gm-Message-State: AOAM532TOR5VY3G7wuT7s1wkr2Gu6J3PScqjM03id3MtZjLjLvsouj3O JTCMO1tei62EvfjjXRi2Q6kJPnDWpZLIq58P X-Google-Smtp-Source: ABdhPJywH/akq8vOFadZ65krJogSyb1ffog//33GvDXyqmaovyxxi2aBNFndVXQ8hyuq1lVAqqrZhQ== X-Received: by 2002:ac8:6ec2:: with SMTP id f2mr5024885qtv.159.1599682189035; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:48 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Rick Chen Subject: [PATCH v4 3/8] riscv: Rework Andes PLMT as a UCLASS_TIMER driver Date: Wed, 9 Sep 2020 16:09:25 -0400 Message-Id: <20200909200930.232174-4-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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. Changes in v4: - Use timer_timebase_fallback arch/riscv/Kconfig | 4 --- arch/riscv/dts/ae350_32.dts | 1 + arch/riscv/dts/ae350_64.dts | 1 + arch/riscv/include/asm/global_data.h | 3 -- arch/riscv/lib/andes_plmt.c | 44 +++++++++++++--------------- 5 files changed, 23 insertions(+), 30 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/dts/ae350_32.dts b/arch/riscv/dts/ae350_32.dts index 3f8525fe56..afcb9cfbbf 100644 --- a/arch/riscv/dts/ae350_32.dts +++ b/arch/riscv/dts/ae350_32.dts @@ -162,6 +162,7 @@ &CPU2_intc 7 &CPU3_intc 7>; reg = <0xe6000000 0x100000>; + clock-frequency = <60000000>; }; }; diff --git a/arch/riscv/dts/ae350_64.dts b/arch/riscv/dts/ae350_64.dts index 482c707503..1c37879049 100644 --- a/arch/riscv/dts/ae350_64.dts +++ b/arch/riscv/dts/ae350_64.dts @@ -162,6 +162,7 @@ &CPU2_intc 7 &CPU3_intc 7>; reg = <0x0 0xe6000000 0x0 0x100000>; + clock-frequency = <60000000>; }; }; diff --git a/arch/riscv/include/asm/global_data.h b/arch/riscv/include/asm/global_data.h index 2eb14815bc..0dec5e669e 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/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 Wed Sep 9 20:09: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: 1361013 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=cF23YhGZ; 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 4BmtS05BBTz9sTK for ; Thu, 10 Sep 2020 06:10:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C957822F8; Wed, 9 Sep 2020 22:09:58 +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="cF23YhGZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCD00822C3; Wed, 9 Sep 2020 22:09: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-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) (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 497A582284 for ; Wed, 9 Sep 2020 22:09: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-qt1-x842.google.com with SMTP id g3so3000077qtq.10 for ; Wed, 09 Sep 2020 13:09: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=cF23YhGZ0njLt6E1R5pIMMeN2bYlSLtjeBUTBbmbbxXzGbtSyV7FHdFn+R503TPYya m10pP6GN5eFPFsg1iRTZSWL0jLIsrMI0zEfa1AFZsa3/p71lQ37NoOhYFVgDdNNsUevY sRMvek+ewtGqRLPHsI+EipNYSPsoWdBEv3FcWVD1UbgCSqKfdyGdFN8cpQgiQMSrYDyX PUFP7Bdgen/Jd9hXw/wU78Zj3W46yjppfE9OhDAPsAY+a3BZRlzz46phsoXx7FkZcMx9 hValhjuKPNuJ6wvojMwrjtmvMvHZZ0V1P0YzARSeFTaCgSj0NJHzjzp0GxbI7TuKJhyk Ew9A== 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=t356txoNiB85UUep1Ft5fJYjeRm2k5yGRlQtt3dtC08URVES8uaHW+ouvxRzaRxNdL UFCwzbY8fkGDRB86xAmLL2xlc98A0o2n1SApu+uJSPmX0xHcccqylUOl3XTzDTi5aPuQ 2rI+YluCc7yq/xySiDHJ28s+Zd92JZfTF94hGKEyf/stnp3pvLhqUtkzx4CfJIW1T7Az TWXfYH5c3/ivNli+7Aebqnu16NZvJlPIztQsY4lvL6wBj+pfQ63/UlqgLjBS6N8xYggq +g5Ruvdy/cA2cD2xIfhxqi8DMRJlZN9a8dE9Z831uvnnqeaBROd1upP0kwhse9MFyken USwg== X-Gm-Message-State: AOAM5312ArdzhfE58AZxvGekuKgX2+V6qflcN/NWmk7yqbkGCQNcGgeu mHLg+r0e8/eiwUTs1vHqPsyKUzyyKeibMSiO X-Google-Smtp-Source: ABdhPJyofJfDIaCNLIwbDE5vJSeg9xEmdDyy2htj1YNFtkMAG5rrtKrEsuvtLolx4aqrq0WX3+iGfQ== X-Received: by 2002:ac8:3175:: with SMTP id h50mr4848844qtb.185.1599682189984; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:49 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Bin Meng Subject: [PATCH v4 4/8] riscv: Clean up initialization in Andes PLIC Date: Wed, 9 Sep 2020 16:09:26 -0400 Message-Id: <20200909200930.232174-5-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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 Wed Sep 9 20:09: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: 1361014 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=L1tl3zSO; 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 4BmtSC0tPdz9sTK for ; Thu, 10 Sep 2020 06:10:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFCAF822E8; Wed, 9 Sep 2020 22:10: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="L1tl3zSO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F631822D1; Wed, 9 Sep 2020 22:09: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-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (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 51D2F822A7 for ; Wed, 9 Sep 2020 22:09: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-qt1-x844.google.com with SMTP id g3so3000127qtq.10 for ; Wed, 09 Sep 2020 13:09: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=niyKpHCQkLFnOwx7Hakqk5XsRLJI2KhY2vLGqINCZ5c=; b=L1tl3zSOJaE1O7EcvNCXXfGY77r/wDFwRO9vn888LtaLy6ytIWV5SxrnoZ1GCLoqpn MIuD9o4CUK3CZ9AGE45lV71hAxN9m7XelV398F99MI+XmCDxl4hQsphuW9FmGDD115TL Ardvcj5r5clZZV3PBDAy+B9y3lvLdUuR34Frhez+ojRgXYZeFxgsP73XJ+m+9dTTzYaa hm+ZoDT9jFqhid4/QAK9y51XUUiP1YedZzbNgUP/KYpRIFET1yB5TnCMvBwbb3B6xcFP aivRDffoJQkC3slURXDs3WB7bFFnZ90GO7c4wlIAEjLiA46HEtyR6Jo7AEeErdvrKNxB z0zQ== 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=niyKpHCQkLFnOwx7Hakqk5XsRLJI2KhY2vLGqINCZ5c=; b=gp0lQ8aCG/2CgWgujNhxxjokuua8Mva3CiiVjRTTcjZoL2XbmiO+ISiE8VZBZfTyTA gvRL9DABAke7tOKDC5Vqr04KEbEDbZR/373RfArRiEn12wDCVhQ1UZ4vy+Z6tST2mMvV KF6HS3CWfFArM7QFu+JB4VADPIWYAkV7CGKXcp4XcVL0az0FMRgbritHxvoMwQsIgT/F IUJJsYleYILyJENIDs9mDuBBVUevKrhQtxgA26c2dkEnTgWE8ty7FYHKZZ5brES2vWSF gP7OhROqrr0OsuQcUivsJN/Cvs6RjKROvrk6UCIWCK+Sl7uNHMy5LXEXBQkfwXoJNDp1 KAgw== X-Gm-Message-State: AOAM530aTzPGygisZzUrtdm4HVMysy1yPNap/SjsrpqMFvpo7QoMSXcX uk1MEZN7rMAj9gwOD//xyEs4mJxBuIlnqEcI X-Google-Smtp-Source: ABdhPJzGV/ltEZsN44YEPGYy3DoA7kv9/rHM00J+B0GIEvrSmWI3uA/AxUaJIAf22YOfxJMh3ehRqA== X-Received: by 2002:aed:3b7a:: with SMTP id q55mr5025800qte.78.1599682191034; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:50 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Pragnesh Patel Subject: [PATCH v4 5/8] riscv: Rework Sifive CLINT as UCLASS_TIMER driver Date: Wed, 9 Sep 2020 16:09:27 -0400 Message-Id: <20200909200930.232174-6-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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. 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 +++++++++++++++++++---------------- drivers/ram/sifive/Kconfig | 2 ++ 3 files changed, 38 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, }; diff --git a/drivers/ram/sifive/Kconfig b/drivers/ram/sifive/Kconfig index 6aca22ab2a..31ad0a7e45 100644 --- a/drivers/ram/sifive/Kconfig +++ b/drivers/ram/sifive/Kconfig @@ -9,5 +9,7 @@ config SIFIVE_FU540_DDR bool "SiFive FU540 DDR driver" depends on RAM_SIFIVE default y if TARGET_SIFIVE_FU540 + select REGMAP + select SPL_REGMAP if SPL help This enables DDR support for the platforms based on SiFive FU540 SoC. From patchwork Wed Sep 9 20:09: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: 1361015 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=kOzgLGVx; 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 4BmtSP3GH0z9sTK for ; Thu, 10 Sep 2020 06:11:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10615822FF; Wed, 9 Sep 2020 22:10:04 +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="kOzgLGVx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3699822D2; Wed, 9 Sep 2020 22:09: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 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 370988158B for ; Wed, 9 Sep 2020 22:09: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-x742.google.com with SMTP id w186so3754507qkd.1 for ; Wed, 09 Sep 2020 13:09: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=kOzgLGVxlOcCH8L98BxvNTFhCLo8VTKazjRcSqw49sVC7kbkVgnXMJqPk1ib3CT4Kw AK+bCNhWacsMIf+YqtXRHrToqVBzVK6oeNKO3/LP3/NyvaS2sdQPbjXpEF50OFygTpYN NHOLftgxAcDIvoaBbo5p17dmJ9F7AjGInyxZI+gTjb/Ii9ltvQiHMUecR1er2j/toOZZ UnJK+QtxNdOACLb6xQAjgd60p97AKNsF8CcOZDljVZvUiREbpcBu6AXivzaRDY8w3ay0 4UA8XLSiGnqzE34PgngJ8BheGcU6z86aY0gvukHlo3z9ObhCT2kSrJUh3ioWYH5L7i+7 j13Q== 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=GPbrtDgARHho9B5aiMSpKFu6IQNMG83htKwhYm4ODQ1TxQceMUqmCtlGffcC6xeSgs s7yHY4uT9uXjK/ZF4joZqh2yyAYIyXa20OUeUFFB7elLDT7C4zNnGtomTyQ8fvzIGps2 3nzZExnFf1M41n2gF66h2FofFi8OmaFxZt6Tmkl5dNT/u8DkXu2BogPJff9dp7I9DJBX uUu64z7l0o280HUJclOYaHPn2drhuk+qLtaYcMULoNDw/m6S+YOEQpNA5rqVk5Knlf3X QB1zA9agooolYrr0s11T41HBD2AOc1juPwaXFe0xY3w6ULEIFp4ar55BglZBWaH9eN7n gnwQ== X-Gm-Message-State: AOAM532iNBrd5SBOEVzP087E8mZp0a1Qj5urQxwRVt+AaCO4Drw1iu7Z LJPgsOHjM77Kv+Ldtqs0f6WMmnznElOgq1iQ X-Google-Smtp-Source: ABdhPJzCPfIy9WISVVWRWgM+mbmQ+iHIueuaItyE91MiXb2sIsoAWt3rPkzm24ewLoEx29XhPUPecw== X-Received: by 2002:a05:620a:4d0:: with SMTP id 16mr4696639qks.200.1599682191947; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:51 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson Subject: [PATCH v4 6/8] riscv: clk: Add CLINT clock to kendryte clock driver Date: Wed, 9 Sep 2020 16:09:28 -0400 Message-Id: <20200909200930.232174-7-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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 Wed Sep 9 20:09: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: 1361016 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=Cky5C/fy; 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 4BmtSc1l65z9sTK for ; Thu, 10 Sep 2020 06:11:12 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BBC9082314; Wed, 9 Sep 2020 22:10:05 +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="Cky5C/fy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9C8C822EC; Wed, 9 Sep 2020 22:09: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 2B2C282281 for ; Wed, 9 Sep 2020 22:09: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-x744.google.com with SMTP id w186so3754565qkd.1 for ; Wed, 09 Sep 2020 13:09: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=C01Dtq3oVsndknX4KMD9QocjvLfi8gRbYPssgJz61OM=; b=Cky5C/fyU+liN1Uhv0JF4EC7dgetIf6igusLiPk/K9xVZCuuy4vJ/48V6ADvd4KiTD 4C01TC/TGbP5vzh+Wb0Ef2WB5AxF5np7iL+C54oNP9ZTN1V0zIKvw4c8Y4a+d+L6qn5S 34wqgo7cG0fRxIAA3yuCwI9TCGYQnKsdTzef6XYMufX5o/zwA3+mcPDBxeKLP0hQG846 naSHnk12LXldANrgCvVVuHARXM/mjuuieWMqS+60NFaN7Iqow9IZN+WIPm+VJTaBA9nY 8y0JvTo+dBdNTkm734PPSwbGYrMTBCmFrDgT4NBmD8Yx+FGWZ8QKF8ofGm7wj5UyCTG7 FJPg== 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=C01Dtq3oVsndknX4KMD9QocjvLfi8gRbYPssgJz61OM=; b=sZy28OLC9Q1qH24BfjgF11RIytyRI96CkjyfvXA3fyUp7upsLGPO/8jmu3Rm7CEP3w huHdDLBjaAmFv4j6FFhoLb7bEiq0ewmCgwB0vWhtXr1AQ3hSAoXmwa+HNxl3Ep8rwqbm x2ZAVrt56Ipa8A9eJWfL9th9rEO8onqFL8BnwmHwXsSWxVUoLt/NXjtLWDLm0jY+IECp cUSFWrNh7Q7b8fKGG0G1KQIzgPBiRi16hIy2n4qhZRwqFAeuWHvAt4+Mdbh0UmxZGuvF kl3JVsdoBCDWqJjXJyxZkiy3/RckGp5/NcsaSsWlmcgSanxZftNvSd+ZqirgUW8FLDnv PVYw== X-Gm-Message-State: AOAM533eMZl6YPBJRMC3xf2Ac6ZshwnrbWUW0t3dYHGBar4jMkxAY/HI 80MNPwzdCVn4/9d381Ys5z4VcDA7Tw5/vTgf X-Google-Smtp-Source: ABdhPJwjuY8AZ4AdB1qdLZsSjAKTLPlOCHlCwiJzvRk5qrQTcPlksAPd8pYBpEHX4WNGU3AI8qudgQ== X-Received: by 2002:a37:6848:: with SMTP id d69mr4727651qkc.80.1599682192976; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:52 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson Subject: [PATCH v4 7/8] riscv: Update Kendryte device tree for new CLINT driver Date: Wed, 9 Sep 2020 16:09:29 -0400 Message-Id: <20200909200930.232174-8-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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 --- 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 Wed Sep 9 20:09:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1361017 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=YUcQjRdx; 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 4BmtSq2tBzz9sTK for ; Thu, 10 Sep 2020 06:11:23 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BD7BB82323; Wed, 9 Sep 2020 22:10:07 +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="YUcQjRdx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C6005822F5; Wed, 9 Sep 2020 22:09: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-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) (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 1D6BE822CE for ; Wed, 9 Sep 2020 22:09: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-x741.google.com with SMTP id w186so3754612qkd.1 for ; Wed, 09 Sep 2020 13:09: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=hOYoWY85blkJRWWtXxtqjO7kR+53RwCc8nWI+ZZ/W0w=; b=YUcQjRdxrMjDLfgZCzch2RLD7ujv4FBiHd4954Ej8fiHLUUMR29q6Ik1AZPv3xp01f U0bdob7tmFJrvj15+6upLxT5M+Zqs79gLudeAmXfnQEV/8CiZOBl37NCQR3N6uC6Svv6 dESJIbCDgesCDvENBCftCAboil8K/nBrk7GUWH8YL2oKOp9otIUIxCJfCRjRQonBeyTj D9h1jeHIO8cyBup66yyZtFG+Amu/hk+ZLOacFiNIDSQPpocUkd+ojNPCfmG9RB8IoFrh xYf++nAF/BA+Th/XEWN/Gj+Zbl6NnnLfvtIPZg+HoLqOUIzeBYlgGCMXCeWqjon+LZlE XYnA== 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=hOYoWY85blkJRWWtXxtqjO7kR+53RwCc8nWI+ZZ/W0w=; b=kjArmqwFz0/RT2BP1z+aZxGnsX/1TErZ7/W+x2Gbs2rOTxW8ENueg1GTFuFpjW0Gkh Ufg04utz6pYmkHs1pA9ci+cgMuHTVLIRpJX/7YfhvSszo56FWMuSIei6Qfze98RI01eA EadoFRZb9bbrfkP3d74sGPODmEt/tBZ201sK0QggM7lnndv803pcKBpUIz9P1f/zHrLe JtThe8nNG4awS6vfKAWh3dpcDE9+gsnisEkLDmOSEzcQDhwxEX2KA+pAprs9FMqWg+oE neXdKHjOfA+siSdKHb6uxnS5ejoGr30I98I67X3nJFTf9nXBuoIx+G3kEIjJuSHu0KF4 3B8w== X-Gm-Message-State: AOAM531RmskH236eAFUkGczq+lCzZ0vFBFKQYKCoMyC2mi5fj14f1aWp Ye+3ZI5g6T9XJZ7mG3W4MX39tXbS5gSQW8y9 X-Google-Smtp-Source: ABdhPJwoqHPuFff2M50jHzLWA5CTFofWuWVAA8bhYKWRfJ12y56zH8cUwt/lgFvtNGz0FoKQyNunXg== X-Received: by 2002:ae9:e413:: with SMTP id q19mr4824995qkc.214.1599682193893; Wed, 09 Sep 2020 13:09: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 s30sm4342831qth.65.2020.09.09.13.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 13:09:53 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Anup Patel , Pragnesh Patel , Bin Meng , Rick Chen , Sean Anderson , Pragnesh Patel Subject: [PATCH v4 8/8] riscv: Update SiFive device tree for new CLINT driver Date: Wed, 9 Sep 2020 16:09:30 -0400 Message-Id: <20200909200930.232174-9-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909200930.232174-1-seanga2@gmail.com> References: <20200909200930.232174-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. Changes in v4: - Both the Andes PMLT and Sifive CLINT now fall back on timebase-frequency, per discussion with Anup Patel - Rebase Changes in v3: - Rebase 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;