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=-14.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 5AFB7C4338F for ; Tue, 10 Aug 2021 04:39:19 +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 765DE60E76 for ; Tue, 10 Aug 2021 04:39:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 765DE60E76 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 D513382A01; Tue, 10 Aug 2021 06:39:15 +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="CrG48WdN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A08B782BCE; Tue, 10 Aug 2021 06:39:14 +0200 (CEST) Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) (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 30125829F9 for ; Tue, 10 Aug 2021 06:39:08 +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-xf2b.google.com with SMTP id f91so10325678qva.9 for ; Mon, 09 Aug 2021 21:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=jq3OxIt7hQ7zvbNixka6w8uka/ljoRPyMz71gQo1xYs=; b=CrG48WdNBMOa6T1V3/bXg5LakQO0EY9SWmFH58AOh1o5DQeH5wiGt6NHjCy7+QjH/U RNGoalTvH+ne+39+9KX03nU/Swe3o8vkph5AVxOHdqNDhZnwhhcDu5Tr9s6eVNdNm+AA 6oMNm37zEkYF0EUD/B0PF2hoEKBdK0rJ/nnb5qoX7ESxfQvXYLLdsTRjvb5IHpm0odbD 1JwunQmzC1JnbkXkato1Pe8PEH5LrU7uaZAvHHxkYfMXf5YvbHw6JUSEOkfsujFFOgxp WWBstPB4sw0rx2UPoRhJgmNeDi+u9Uc3e3xKhP/c6zRGLP0coVzAyU79jgTejDpcnV52 f4ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jq3OxIt7hQ7zvbNixka6w8uka/ljoRPyMz71gQo1xYs=; b=sNBt6FtY+LTAxzkp66mGqsN9SK2gbTMAg5QlYJcRFZi1oOL1LLen+fVnNrvI1SqsWv PLkSDFNS5i+DYoXTBIzGzw/bTvCBF5nB/CqgIH7CvwJIxpnbwIN5t736bPbB9Hpwcz5I 6TOM0b7gVy/UIZ4U8C0VSDgqvqL4yMinXPi1GE3QO6ZHw3jANY48NTCnji0KTDYyi3EW SaKQbTjdE6KDaB+YFDoIVASHBA0tpJqgqt2r99I175oo+H9iMxnIe9p5Fpxxo++0xlEF 8RIxBMHCsSX/7wneieg5Ro7lVqxy0XEDwT8gc3sL58A61NdGQjCeXbgJ9tNj7LDmyJmX /GNw== X-Gm-Message-State: AOAM530lqwM7STduDPLoF1XQDTZFdP7UTMDdC2/WS1PCcu4Dt0FxK7rZ kYTSEfRdc0i/Hs5XVhbp07rsFKPaDwg= X-Google-Smtp-Source: ABdhPJzU/Qrmz+ke3qgsjFxiU2tDWoL9K+AFt4fRcADIwZ4u6jHTShypVJ8lYtJ3EoD4qQshNGKEuw== X-Received: by 2002:a0c:e84a:: with SMTP id l10mr5023178qvo.3.1628570346480; Mon, 09 Aug 2021 21:39:06 -0700 (PDT) Received: from [192.168.1.201] (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.googlemail.com with ESMTPSA id h140sm7906901qke.112.2021.08.09.21.39.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Aug 2021 21:39:05 -0700 (PDT) Subject: Re: [PATCH v2 1/6] cache: add sifive composable cache driver To: Zong Li , rick@andestech.com, ycliang@andestech.com, bmeng.cn@gmail.com, green.wan@sifive.com, paul.walmsley@sifive.com, sjg@chromium.org, u-boot@lists.denx.de References: <20210803044444.14032-1-zong.li@sifive.com> <20210803044444.14032-2-zong.li@sifive.com> From: Sean Anderson Message-ID: Date: Tue, 10 Aug 2021 00:39:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20210803044444.14032-2-zong.li@sifive.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 On 8/3/21 12:44 AM, Zong Li wrote: > This driver is currently responsible for enabling all ccache ways. > Composable cache could be configure as RAM or cache, we will use it as > RAM at the beginning to put the u-boot SPL there. In u-boot proper > phrase, we will use the composable cache as cache, and try to enable the > cache ways. > > Signed-off-by: Zong Li > --- > drivers/cache/Kconfig | 7 +++ > drivers/cache/Makefile | 1 + > drivers/cache/cache-sifive-ccache.c | 75 +++++++++++++++++++++++++++++ > 3 files changed, 83 insertions(+) > create mode 100644 drivers/cache/cache-sifive-ccache.c > > diff --git a/drivers/cache/Kconfig b/drivers/cache/Kconfig > index 1e452ad6d9..40f41a817c 100644 > --- a/drivers/cache/Kconfig > +++ b/drivers/cache/Kconfig > @@ -39,4 +39,11 @@ config NCORE_CACHE > controller. The driver initializes cache directories and coherent > agent interfaces. > > +config SIFIVE_CCACHE > + bool "SiFive composable cache" > + select CACHE > + help > + This driver is for SiFive Composable L2/L3 cache. It enables cache > + ways of composable cache. > + > endmenu > diff --git a/drivers/cache/Makefile b/drivers/cache/Makefile > index fed50be3f9..ad765774e3 100644 > --- a/drivers/cache/Makefile > +++ b/drivers/cache/Makefile > @@ -4,3 +4,4 @@ obj-$(CONFIG_SANDBOX) += sandbox_cache.o > obj-$(CONFIG_L2X0_CACHE) += cache-l2x0.o > obj-$(CONFIG_NCORE_CACHE) += cache-ncore.o > obj-$(CONFIG_V5L2_CACHE) += cache-v5l2.o > +obj-$(CONFIG_SIFIVE_CCACHE) += cache-sifive-ccache.o > diff --git a/drivers/cache/cache-sifive-ccache.c b/drivers/cache/cache-sifive-ccache.c > new file mode 100644 > index 0000000000..76c0ab26ae > --- /dev/null > +++ b/drivers/cache/cache-sifive-ccache.c > @@ -0,0 +1,75 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2021 SiFive > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define SIFIVE_CCACHE_CONFIG 0x000 > +#define SIFIVE_CCACHE_CONFIG_WAYS GENMASK(15, 8) > + > +#define SIFIVE_CCACHE_WAY_ENABLE 0x008 > + > +struct sifive_ccache { > + void __iomem *base; > +}; > + > +static int sifive_ccache_enable(struct udevice *dev) > +{ > + struct sifive_ccache *priv = dev_get_priv(dev); > + u32 config; > + u32 ways; > + > + /* Enable all ways of composable cache */ > + config = readl(priv->base + SIFIVE_CCACHE_CONFIG); > + ways = FIELD_GET(SIFIVE_CCACHE_CONFIG_WAYS, config); > + > + writel(ways - 1, priv->base + SIFIVE_CCACHE_WAY_ENABLE); > + > + return 0; > +} > + > +static int sifive_ccache_get_info(struct udevice *dev, struct cache_info *info) > +{ > + struct sifive_ccache *priv = dev_get_priv(dev); > + > + info->base = (phys_addr_t)priv->base; > + > + return 0; > +} > + > +static const struct cache_ops sifive_ccache_ops = { > + .enable = sifive_ccache_enable, > + .get_info = sifive_ccache_get_info, > +}; > + > +static int sifive_ccache_probe(struct udevice *dev) > +{ > + struct sifive_ccache *priv = dev_get_priv(dev); > + > + priv->base = dev_read_addr_ptr(dev); > + if (!priv->base) > + return -EINVAL; > + > + return 0; > +} > + > +static const struct udevice_id sifive_ccache_ids[] = { > + { .compatible = "sifive,fu540-c000-ccache" }, > + { .compatible = "sifive,fu740-c000-ccache" }, > + {} > +}; > + > +U_BOOT_DRIVER(sifive_ccache) = { > + .name = "sifive_ccache", > + .id = UCLASS_CACHE, > + .of_match = sifive_ccache_ids, > + .probe = sifive_ccache_probe, > + .priv_auto = sizeof(struct sifive_ccache), > + .ops = &sifive_ccache_ops, > +}; > Reviewed-by: Sean Anderson