From patchwork Mon Oct 12 18:13:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1381082 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=Svua1+7J; 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 4C96NQ4x4Zz9sT6 for ; Tue, 13 Oct 2020 05:17:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC1F882584; Mon, 12 Oct 2020 20:15:29 +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="Svua1+7J"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61ACA82560; Mon, 12 Oct 2020 20:15:23 +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-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 EE4EA8254C for ; Mon, 12 Oct 2020 20:15:20 +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 c5so14211184qtw.3 for ; Mon, 12 Oct 2020 11:15:20 -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=NZ6+i3lvRiYa8eftD3qAFx7SYi971lYS8xHaz1efuaw=; b=Svua1+7JtRA0g0e3CJb0Ycm2JBiXKhBh93C8RFjvK20ebfrwF+aQbXjfk27o6OUYnF MzDh1aIK9nCSsEYeT0vj7D50ZiSFoWc+fiHiQvikWLKikDBZbyvICVQA0A8NLmD1uWq3 BiWO/+GM/MJg63cGdhsNG4V+pemg3oWzCK8kx+BiZT4z7jH9+J+rtXb0exTrJW5T1Hjl GR43zDGsn08jc1hNTKx1kFfSlErX7PqGBPK9JhBCBvof2RDuegm5he8/wu5cov7bBRs7 NrDN/xNcK0ROjj5t5i8YKy01vO2qTMl70vpVpSkf1aIdcBV91oKX3PVnzooNjhrc+i2w WNUg== 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=NZ6+i3lvRiYa8eftD3qAFx7SYi971lYS8xHaz1efuaw=; b=Jl/4XyL4BoXnkegCe9VefZEnlNkS8esCir+ffXS5BQiBFOj5V7PIoxF+NxoEn3DHvU 3QDQArjSXY0woM7BvKN0k/a9LXFeRlEfSt92fojZWOh9e7WyA4T+8WeAmzJgz/CVi4sM dX+NQyz2wy6o54Y1sNYm42dJL8VPHnDrWYOklJgGUzOYFytxKQeWspe22Xo5oDdPfdTy 1Tl27Yt3inKyTgb5/AS/e04cIMl+SwX4ONYJ8xm9nOW/IkRXpfFIK81VFasTNQg1WgF1 2c06sMhLHw40RVzGVdwb8y387zo5yW2sDA4j3l2RrHk09A87boBAuQH7KjDrJEYSZQU0 Xtag== X-Gm-Message-State: AOAM5317xMN52w9mwsAwgmY+x8fbqUpiHQPWRUJLs9irFWj15J0RdiKg hq4fx7HAo3o2tki7QyBq47bktM6lwfdYRQ== X-Google-Smtp-Source: ABdhPJyhl3asVS4h7lgndIsAePUhYYY56WzGfHoFEwjxm7ss3dRiNqTL2oXEvKibytCOqRNXqz45wQ== X-Received: by 2002:ac8:50c:: with SMTP id u12mr10691861qtg.320.1602526519734; Mon, 12 Oct 2020 11:15:19 -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 t3sm12968651qtq.24.2020.10.12.11.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 11:15:19 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Rick Chen , Bin Meng , Sean Anderson Subject: [PATCH v2 12/16] riscv: Probe ram in dram_init Date: Mon, 12 Oct 2020 14:13:41 -0400 Message-Id: <20201012181345.338661-13-seanga2@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012181345.338661-1-seanga2@gmail.com> References: <20201012181345.338661-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 If CONFIG_RAM is enabled, use the ram device to get the base/size of memory. This provides an easy way for boards/cpus to hook into the dram_init logic, without needing to provide a second SYS_CPU. Signed-off-by: Sean Anderson Reviewed-by: Rick Chen --- (no changes since v1) arch/riscv/cpu/generic/dram.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c index 1dc77efeca..fbcd4ddf5f 100644 --- a/arch/riscv/cpu/generic/dram.c +++ b/arch/riscv/cpu/generic/dram.c @@ -4,15 +4,41 @@ */ #include +#include #include #include +#include +#include #include DECLARE_GLOBAL_DATA_PTR; int dram_init(void) { +#if CONFIG_IS_ENABLED(RAM) + int ret; + struct ram_info info; + struct udevice *dev; + + ret = uclass_get_device(UCLASS_RAM, 0, &dev); + if (ret) { + debug("DRAM init failed: %d\n", ret); + return ret; + } + + ret = ram_get_info(dev, &info); + if (ret) { + debug("Cannot get DRAM size: %d\n", ret); + return ret; + } + + gd->ram_base = info.base; + gd->ram_size = info.size; + + return 0; +#else return fdtdec_setup_mem_size_base(); +#endif } int dram_init_banksize(void)