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,URIBL_BLOCKED, 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 42D6EC432BE for ; Wed, 1 Sep 2021 07:02:44 +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 5881C61056 for ; Wed, 1 Sep 2021 07:02:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5881C61056 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 4C68983245; Wed, 1 Sep 2021 09:02:14 +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="WdgDtmBb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE4D983231; Wed, 1 Sep 2021 09:02:05 +0200 (CEST) Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (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 6E2BC83222 for ; Wed, 1 Sep 2021 09:01: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-pf1-x432.google.com with SMTP id 18so1281664pfh.9 for ; Wed, 01 Sep 2021 00:01: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=t/JURutpvnNmt/FSGjJggFIyqnpk/4AIwDscu2ItQ0c=; b=WdgDtmBbv22emlj0zBXauOZ61jJFzLko3E9LzQB/eEpPdOSo1XsQ4Ab5mWl04q3Myq E2OPBycORG59eT/HSZ0kbWl7DIdjwLwvaZhJSbxD7ELWjackMBIWyl9JCdlo6Mp4RnlS TrCg7NsqzTlWuZ2ZzE2HHhQA08F5OWoXAcdoW1ffVMj61cl2PlsgXcTgTQ8/LJ3SJ7Iz M4YDbKyD7wZRfr9xVDaHTuYIjCgFOWKI23jhqYiuOufWebA+CiyIoB6CIrR1uJMDTmND DT65nVM35RPyFswBVpHCmfZ+eLItzd9GQjA0lCF8LiGYfmVMMlfOC2414i5u9iu6QVIP z2dA== 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=t/JURutpvnNmt/FSGjJggFIyqnpk/4AIwDscu2ItQ0c=; b=oRE1YllrGWU3X5F61lesk+KtD78L6X+EUht0pzst7afAVoR5tJEmuVea2dgZDGIH+C 1OMlla34HqS8ftXP2rJmt6RtOENF7/yi9OpZhbbNSnYrk79bj52GpDVnBhDlTwrTfF7e V6mQrhodtYZAUoo+kec6qfeDks6SudSxk6ItKnK4sHXy/BmO4K4JG4NHCYnKblpnK7sb gv1J7WPKehrv/WQKFCrnu1YHcXj9uylBGysJkQwWea7iO0WKxV+v+/ierQPYgIlxQIHk H5h/v7/M0yZuJIyGC9Jd7xgDxGMars/ptbJhKjSoit53/K1c0KX3AmfBaNqroDVSvG4O Lg0Q== X-Gm-Message-State: AOAM531IHRFteDQ3p4OamjxNiaU/G8obq+vPPNZh2c0MxffprXcAdX8L nyyYitlDnjNRc0I75HwNu+EedA== X-Google-Smtp-Source: ABdhPJwV7ZjRkitfMA267NfCYbBr4dsC/KdnFZDNr11cthNh+rJKaRRApgzmeCf02/Kq2ioDYyZd7Q== X-Received: by 2002:a05:6a00:170d:b0:3f3:bcdb:4883 with SMTP id h13-20020a056a00170d00b003f3bcdb4883mr26225591pfc.68.1630479715803; Wed, 01 Sep 2021 00:01:55 -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 j23sm4833497pjn.12.2021.09.01.00.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 00:01: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 v5 3/5] riscv: lib: implement enable_caches for sifive cache Date: Wed, 1 Sep 2021 15:01:41 +0800 Message-Id: <20210901070143.15102-4-zong.li@sifive.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210901070143.15102-1-zong.li@sifive.com> References: <20210901070143.15102-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 The enable_caches is a generic hook for architecture-implemented, we define this function to enable composable cache of sifive platforms. In sifive_cache, it invokes the generic cache_enable interface of cache uclass to execute the relative implementation in SiFive ccache driver. Signed-off-by: Zong Li --- arch/riscv/Kconfig | 5 +++++ arch/riscv/lib/Makefile | 1 + arch/riscv/lib/sifive_cache.c | 27 +++++++++++++++++++++++++++ 3 files changed, 33 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/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/sifive_cache.c b/arch/riscv/lib/sifive_cache.c new file mode 100644 index 0000000000..28154878fc --- /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 +#include + +void enable_caches(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) { + log_debug("Cannot enable cache ways"); + } else { + ret = cache_enable(dev); + if (ret) + log_debug("ccache enable failed"); + } +} -- 2.32.0