From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACAE8C4338F for ; Tue, 3 Aug 2021 04:45:37 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F01E60EE9 for ; Tue, 3 Aug 2021 04:45:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1F01E60EE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56A3682DC5; Tue, 3 Aug 2021 06:45:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.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=sifive.com header.i=@sifive.com header.b="PQC7zYnl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB8EA82DDE; Tue, 3 Aug 2021 06:45:04 +0200 (CEST) Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 D3F7B82D94 for ; Tue, 3 Aug 2021 06:44:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=zong.li@sifive.com Received: by mail-pj1-x1036.google.com with SMTP id u9-20020a17090a1f09b029017554809f35so2130249pja.5 for ; Mon, 02 Aug 2021 21:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=86CW7lrEF9unpGeRgMuhn5zv2wj8bF9oX5glPtNHP/A=; b=PQC7zYnlRt/HTx36tb4OVOpWF+fDLrpBQBd6Jr8qTAhA28XQfPO8If+DlYXzbP3+B0 Uz261QnVmn/1lnRYP0N3WJjaV+bT1E1Mv1u3iXegqfDWG0akIc63y7lNT7SBWM8u2TNr EMy9fv0QHXynSebFkRV4azs6Fa5EjJI/rCmw0XNxgbP7VKNNUHFI9y0IOt3Hdfnkabfr 6Xaqn2twF2C0hbsEtlTFYEBSvpOM6Jcu5tQl9Jr2zpjCq3iIGd3kZ6JAW2BZAF9qFGxF bEW/ZXAgKAKIVGn9tmG6rOQ1SXvYWktn5d0cbgl9lw74SBKO1MtG5UvrHVN+rlLY13sJ V/dg== 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=86CW7lrEF9unpGeRgMuhn5zv2wj8bF9oX5glPtNHP/A=; b=SAT3A/8ZF2S1vKHbqVEhyV3dmctI7+7j1TRIIfTldAzZkfH0c24TqFgh1cjnCEbDZt GYWj+excgZvZKmJZ/ows8JY/8gvUh0FybRRT74hiLVw8ATDr9PUQTIgASguv7cLZbKGr WI9u0nPm4B4kh40AhiHJL0iNB2Vx/lBVQobj24shnCblJRrLBkPh7jvoRv9yIKHiam8m CWp0gP6zIZEGAEScDtwEDuGpHzCv1hjDL7A4TibPk2p/N3Tk8yqg+MsCZa5G2+OjQ/QG 4d6hBFyte76KkhttqjZLYEY7NFNzRT6onMBdRLrqhcfmcdkSqgF9vQRUH8Nxl56bFp1B MeWA== X-Gm-Message-State: AOAM532UWgfT07wZrMRAoD+JYQDIwyf6h2hxJq+eWjotmVluWhruCGpU Me+SyZAp7ddSpY01tBbpvKcxwQ== X-Google-Smtp-Source: ABdhPJwMg6QD/JTWNYaDeAKiUYzi7r9zb3/ms+2xGPa/UuTka0cPpeSj0hDpY9rHiVSqfZoE6ZMxcQ== X-Received: by 2002:a17:90a:3f87:: with SMTP id m7mr20493079pjc.96.1627965896290; Mon, 02 Aug 2021 21:44:56 -0700 (PDT) Received: from hsinchu15.internal.sifive.com (59-124-168-89.HINET-IP.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d2sm15327998pgv.87.2021.08.02.21.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 21:44:55 -0700 (PDT) From: Zong Li To: rick@andestech.com, ycliang@andestech.com, bmeng.cn@gmail.com, seanga2@gmail.com, green.wan@sifive.com, paul.walmsley@sifive.com, sjg@chromium.org, u-boot@lists.denx.de Cc: Zong Li Subject: [PATCH v2 3/6] riscv: lib: introduce cache_init interface Date: Tue, 3 Aug 2021 12:44:41 +0800 Message-Id: <20210803044444.14032-4-zong.li@sifive.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210803044444.14032-1-zong.li@sifive.com> References: <20210803044444.14032-1-zong.li@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean Add an interface for cache initialization. Each platform can overwrite this weak function by their own implementation, such as sifive_cache in this patch. Signed-off-by: Zong Li --- arch/riscv/Kconfig | 5 +++++ arch/riscv/include/asm/cache.h | 1 + arch/riscv/lib/Makefile | 1 + arch/riscv/lib/cache.c | 5 +++++ arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 arch/riscv/lib/sifive_cache.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 4b0c3dffa6..ec651fe0a4 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -179,6 +179,11 @@ config SPL_SIFIVE_CLINT The SiFive CLINT block holds memory-mapped control and status registers associated with software and timer interrupts. +config SIFIVE_CACHE + bool + help + This enables the operations to configure SiFive cache + config ANDES_PLIC bool depends on RISCV_MMODE || SPL_RISCV_MMODE diff --git a/arch/riscv/include/asm/cache.h b/arch/riscv/include/asm/cache.h index ec8fe201d3..6ebb2b4329 100644 --- a/arch/riscv/include/asm/cache.h +++ b/arch/riscv/include/asm/cache.h @@ -9,6 +9,7 @@ /* cache */ void cache_flush(void); +int cache_init(void); /* * The current upper bound for RISCV L1 data cache line sizes is 32 bytes. diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index c4cc41434b..06020fcc2a 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o obj-$(CONFIG_CMD_GO) += boot.o obj-y += cache.o +obj-$(CONFIG_SIFIVE_CACHE) += sifive_cache.o ifeq ($(CONFIG_$(SPL_)RISCV_MMODE),y) obj-$(CONFIG_$(SPL_)SIFIVE_CLINT) += sifive_clint.o obj-$(CONFIG_ANDES_PLIC) += andes_plic.o diff --git a/arch/riscv/lib/cache.c b/arch/riscv/lib/cache.c index b1d42bcc2b..2cd66504c6 100644 --- a/arch/riscv/lib/cache.c +++ b/arch/riscv/lib/cache.c @@ -70,3 +70,8 @@ __weak int dcache_status(void) { return 0; } + +__weak int cache_init(void) +{ + return 0; +} diff --git a/arch/riscv/lib/sifive_cache.c b/arch/riscv/lib/sifive_cache.c new file mode 100644 index 0000000000..94e84e024e --- /dev/null +++ b/arch/riscv/lib/sifive_cache.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2021 SiFive, Inc + */ + +#include +#include +#include + +int cache_init(void) +{ + struct udevice *dev; + int ret; + + /* Enable ways of ccache */ + ret = uclass_get_device_by_driver(UCLASS_CACHE, + DM_DRIVER_GET(sifive_ccache), + &dev); + if (ret) + return log_msg_ret("Cannot enable cache ways", ret); + + ret = cache_enable(dev); + if (ret) + return log_msg_ret("ccache enable failed", ret); + + return 0; +} -- 2.32.0