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=-15.2 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,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 C4139C432BE for ; Tue, 31 Aug 2021 04:49:21 +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 06E6E6023E for ; Tue, 31 Aug 2021 04:49:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 06E6E6023E 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 724E8833FF; Tue, 31 Aug 2021 06:49:19 +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="DcXjaYHe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D349D83402; Tue, 31 Aug 2021 06:49:17 +0200 (CEST) Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) (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 B3326833F4 for ; Tue, 31 Aug 2021 06:49: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=seanga2@gmail.com Received: by mail-qk1-x731.google.com with SMTP id m21so18212150qkm.13 for ; Mon, 30 Aug 2021 21:49:13 -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=j9dQfX9bjswtVgQeWMlrUD3mBCT1dKPg5A64xz0KdBM=; b=DcXjaYHeD5XIH9pydddNjEXLQa/MsCqD4xPpaT1MI8r3Lt/b6VtVQ8M1m8tyPXhc/D hbagBNqM5CsxzJlncwnYl0tS1FyPri2BFv1YVKNgLqoQQAybKjAJQ29ef6oNAFI8Fm8n 4oUzTYhqKwkT63Klw+QxvMAqFrzYQGcXN2tb/qrqewpstisQJWWoRobScci6+TxhDWCh SbJoW9pVdxHeiRPJZtJm9r9alX9DEe/YX/Rp6aR7yAtf8M020MjFSW2gmZUcJYyS6dUN UGDTIJMzxYenroQ7Mhvj861xHhbTYTqtu1LoPTgvZUeC3/ShWgrxktzppZRGSG4LDbGd TC1A== 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=j9dQfX9bjswtVgQeWMlrUD3mBCT1dKPg5A64xz0KdBM=; b=d6OVaxeC5764mrQO8HHxOdNQcSQB0KYTS0zpKrA2AXDdLHXBeF/G8OEvaGyJenj9i5 EeEr9cpmaF95aDiKZx1zOSu+qmN46W4D/rUa3LUamt24r3mcU+qny4d8ab3eHGj2mwwo +cSbWiqOAxz6t/yoF+58T1K67LEZVQByVWCd4vPsmp7KxeYYTh4P+OgVt8Oxp3FvJqpU Mr2eM79go8EqI6j1Ul+bshV7EG5PAAp3gvW4UOLqpR7k1QFZR/cpnSU11Da3y9SC7/C3 HD1/1OStbAaqnNi0zSMTu4wRN8g1Wkj6F8xY5iT4hYoGTSpeYkcZf4DkK/Z78dva+wDx 8kCw== X-Gm-Message-State: AOAM533OgAbQHTivuhEpXOUVcMmHXHLXgPVALxIH8vlGunF3mevpirdD VxYAwc+msZVUZyzquQlDb5Be3wcWjw0= X-Google-Smtp-Source: ABdhPJyVxLmorllkH6vlZVQRHT05SPrKUKfJM9g4DNJxNXuNpsTd/CHmwrOpnmOhEi82u2IRhNZjOw== X-Received: by 2002:a05:620a:318e:: with SMTP id bi14mr1182001qkb.274.1630385352089; Mon, 30 Aug 2021 21:49:12 -0700 (PDT) Received: from [192.168.1.201] (pool-108-45-127-224.washdc.fios.verizon.net. [108.45.127.224]) by smtp.googlemail.com with ESMTPSA id t8sm9974012qtn.37.2021.08.30.21.49.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Aug 2021 21:49:11 -0700 (PDT) Subject: Re: [PATCH v3 3/4] board: sifive: use ccache driver instead of helper function 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: <20210817090852.17022-1-zong.li@sifive.com> <20210817090852.17022-4-zong.li@sifive.com> From: Sean Anderson Message-ID: <81f4a42a-f86c-d480-92b9-511b26262cb5@gmail.com> Date: Tue, 31 Aug 2021 00:49:10 -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: <20210817090852.17022-4-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/17/21 5:08 AM, Zong Li wrote: > Invokes the common cache_init function to initialize ccache. > > Signed-off-by: Zong Li > --- > arch/riscv/cpu/fu540/Kconfig | 2 + > arch/riscv/cpu/fu540/Makefile | 1 - > arch/riscv/cpu/fu540/cache.c | 55 ----------------------- > arch/riscv/cpu/fu740/Kconfig | 2 + > arch/riscv/cpu/fu740/Makefile | 1 - > arch/riscv/cpu/fu740/cache.c | 55 ----------------------- > arch/riscv/include/asm/arch-fu540/cache.h | 14 ------ > arch/riscv/include/asm/arch-fu740/cache.h | 14 ------ > board/sifive/unleashed/unleashed.c | 12 +---- > board/sifive/unmatched/unmatched.c | 11 +---- > 10 files changed, 8 insertions(+), 159 deletions(-) > delete mode 100644 arch/riscv/cpu/fu540/cache.c > delete mode 100644 arch/riscv/cpu/fu740/cache.c > delete mode 100644 arch/riscv/include/asm/arch-fu540/cache.h > delete mode 100644 arch/riscv/include/asm/arch-fu740/cache.h > > diff --git a/arch/riscv/cpu/fu540/Kconfig b/arch/riscv/cpu/fu540/Kconfig > index 05463b2625..1604b412b4 100644 > --- a/arch/riscv/cpu/fu540/Kconfig > +++ b/arch/riscv/cpu/fu540/Kconfig > @@ -19,6 +19,8 @@ config SIFIVE_FU540 > imply SMP > imply CLK_SIFIVE > imply CLK_SIFIVE_PRCI > + imply SIFIVE_CACHE > + imply SIFIVE_CCACHE > imply SIFIVE_SERIAL > imply MACB > imply MII > diff --git a/arch/riscv/cpu/fu540/Makefile b/arch/riscv/cpu/fu540/Makefile > index 088205ef57..043fb961a5 100644 > --- a/arch/riscv/cpu/fu540/Makefile > +++ b/arch/riscv/cpu/fu540/Makefile > @@ -8,5 +8,4 @@ obj-y += spl.o > else > obj-y += dram.o > obj-y += cpu.o > -obj-y += cache.o > endif > diff --git a/arch/riscv/cpu/fu540/cache.c b/arch/riscv/cpu/fu540/cache.c > deleted file mode 100644 > index 0fc4ef6c00..0000000000 > --- a/arch/riscv/cpu/fu540/cache.c > +++ /dev/null > @@ -1,55 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ > -/* > - * Copyright (C) 2020 SiFive, Inc > - * > - * Authors: > - * Pragnesh Patel > - */ > - > -#include > -#include > -#include > -#include > - > -/* Register offsets */ > -#define L2_CACHE_CONFIG 0x000 > -#define L2_CACHE_ENABLE 0x008 > - > -#define MASK_NUM_WAYS GENMASK(15, 8) > -#define NUM_WAYS_SHIFT 8 > - > -DECLARE_GLOBAL_DATA_PTR; > - > -int cache_enable_ways(void) > -{ > - const void *blob = gd->fdt_blob; > - int node; > - fdt_addr_t base; > - u32 config; > - u32 ways; > - > - volatile u32 *enable; > - > - node = fdt_node_offset_by_compatible(blob, -1, > - "sifive,fu540-c000-ccache"); > - > - if (node < 0) > - return node; > - > - base = fdtdec_get_addr_size_auto_parent(blob, 0, node, "reg", 0, > - NULL, false); > - if (base == FDT_ADDR_T_NONE) > - return FDT_ADDR_T_NONE; > - > - config = readl((volatile u32 *)base + L2_CACHE_CONFIG); > - ways = (config & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT; > - > - enable = (volatile u32 *)(base + L2_CACHE_ENABLE); > - > - /* memory barrier */ > - mb(); > - (*enable) = ways - 1; > - /* memory barrier */ > - mb(); > - return 0; > -} > diff --git a/arch/riscv/cpu/fu740/Kconfig b/arch/riscv/cpu/fu740/Kconfig > index 408195f149..049a0a0584 100644 > --- a/arch/riscv/cpu/fu740/Kconfig > +++ b/arch/riscv/cpu/fu740/Kconfig > @@ -19,6 +19,8 @@ config SIFIVE_FU740 > imply SMP > imply CLK_SIFIVE > imply CLK_SIFIVE_PRCI > + imply SIFIVE_CACHE > + imply SIFIVE_CCACHE > imply SIFIVE_SERIAL > imply MACB > imply MII > diff --git a/arch/riscv/cpu/fu740/Makefile b/arch/riscv/cpu/fu740/Makefile > index 5ef8ac18a7..1d1ad98ba7 100644 > --- a/arch/riscv/cpu/fu740/Makefile > +++ b/arch/riscv/cpu/fu740/Makefile > @@ -8,5 +8,4 @@ obj-y += spl.o > else > obj-y += dram.o > obj-y += cpu.o > -obj-y += cache.o > endif > diff --git a/arch/riscv/cpu/fu740/cache.c b/arch/riscv/cpu/fu740/cache.c > deleted file mode 100644 > index 680955c9e3..0000000000 > --- a/arch/riscv/cpu/fu740/cache.c > +++ /dev/null > @@ -1,55 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0+ > -/* > - * Copyright (C) 2020-2021 SiFive, Inc > - * > - * Authors: > - * Pragnesh Patel > - */ > - > -#include > -#include > -#include > -#include > - > -/* Register offsets */ > -#define L2_CACHE_CONFIG 0x000 > -#define L2_CACHE_ENABLE 0x008 > - > -#define MASK_NUM_WAYS GENMASK(15, 8) > -#define NUM_WAYS_SHIFT 8 > - > -DECLARE_GLOBAL_DATA_PTR; > - > -int cache_enable_ways(void) > -{ > - const void *blob = gd->fdt_blob; > - int node; > - fdt_addr_t base; > - u32 config; > - u32 ways; > - > - volatile u32 *enable; > - > - node = fdt_node_offset_by_compatible(blob, -1, > - "sifive,fu740-c000-ccache"); > - > - if (node < 0) > - return node; > - > - base = fdtdec_get_addr_size_auto_parent(blob, 0, node, "reg", 0, > - NULL, false); > - if (base == FDT_ADDR_T_NONE) > - return FDT_ADDR_T_NONE; > - > - config = readl((volatile u32 *)base + L2_CACHE_CONFIG); > - ways = (config & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT; > - > - enable = (volatile u32 *)(base + L2_CACHE_ENABLE); > - > - /* memory barrier */ > - mb(); > - (*enable) = ways - 1; > - /* memory barrier */ > - mb(); > - return 0; > -} > diff --git a/arch/riscv/include/asm/arch-fu540/cache.h b/arch/riscv/include/asm/arch-fu540/cache.h > deleted file mode 100644 > index 135a17c679..0000000000 > --- a/arch/riscv/include/asm/arch-fu540/cache.h > +++ /dev/null > @@ -1,14 +0,0 @@ > -/* SPDX-License-Identifier: GPL-2.0+ */ > -/* > - * Copyright (C) 2020 SiFive, Inc. > - * > - * Authors: > - * Pragnesh Patel > - */ > - > -#ifndef _CACHE_SIFIVE_H > -#define _CACHE_SIFIVE_H > - > -int cache_enable_ways(void); > - > -#endif /* _CACHE_SIFIVE_H */ > diff --git a/arch/riscv/include/asm/arch-fu740/cache.h b/arch/riscv/include/asm/arch-fu740/cache.h > deleted file mode 100644 > index 7d4fe9942b..0000000000 > --- a/arch/riscv/include/asm/arch-fu740/cache.h > +++ /dev/null > @@ -1,14 +0,0 @@ > -/* SPDX-License-Identifier: GPL-2.0+ */ > -/* > - * Copyright (C) 2020-2021 SiFive, Inc. > - * > - * Authors: > - * Pragnesh Patel > - */ > - > -#ifndef _CACHE_SIFIVE_H > -#define _CACHE_SIFIVE_H > - > -int cache_enable_ways(void); > - > -#endif /* _CACHE_SIFIVE_H */ > diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c > index 43027f0b54..6d697d797d 100644 > --- a/board/sifive/unleashed/unleashed.c > +++ b/board/sifive/unleashed/unleashed.c > @@ -15,7 +15,7 @@ > #include > #include > #include > -#include > +#include > #include > > /* > @@ -126,14 +126,6 @@ void *board_fdt_blob_setup(void) > > int board_init(void) > { > - int ret; > - > /* enable all cache ways */ > - ret = cache_enable_ways(); > - if (ret) { > - debug("%s: could not enable cache ways\n", __func__); > - return ret; > - } > - > - return 0; > + return cache_init(); > } > diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c > index 2f5629b578..f4fc2a793d 100644 > --- a/board/sifive/unmatched/unmatched.c > +++ b/board/sifive/unmatched/unmatched.c > @@ -8,7 +8,7 @@ > > #include > #include > -#include > +#include > #include > > #if defined(CONFIG_OF_SEPARATE) > @@ -23,13 +23,6 @@ void *board_fdt_blob_setup(void) > > int board_init(void) > { > - int ret; > - > /* enable all cache ways */ > - ret = cache_enable_ways(); > - if (ret) { > - debug("%s: could not enable cache ways\n", __func__); > - return ret; > - } > - return 0; > + return cache_init(); > } > Reviewed-by: Sean Anderson