From patchwork Mon Mar 30 23:12:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1264371 X-Patchwork-Delegate: bmeng.cn@gmail.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=85.214.62.61; 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=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=CoQOIs77; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 48rpGF4032z9sPJ for ; Tue, 31 Mar 2020 10:15:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 371DC81915; Tue, 31 Mar 2020 01:14:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CoQOIs77"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 49B208190C; Tue, 31 Mar 2020 01:14:30 +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.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 E075C8065F for ; Tue, 31 Mar 2020 01:14:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id q9so19758748iod.4 for ; Mon, 30 Mar 2020 16:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bAdVXQCz+39C0j9RtwezTfgudkfpr7Zi1L5YBJltyEQ=; b=CoQOIs77GI+pGzMaDdJJgXyG6Hvm9a8sKRENGX/tuGy8WqivJ2lUNFgfV9vvDQI18E 30ZzLeFb9Sek9s/3JzYS19IjqdCtlxPUBUqLJQ2GeRCu2/u3Ns6GTPxs3lDXtJXpHRz3 F++ZtpjA6xAlUNrV+Oap/IseX/hqUcqofQ2QM= 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=bAdVXQCz+39C0j9RtwezTfgudkfpr7Zi1L5YBJltyEQ=; b=DXXlkp6CLlKbj/ng+/O8oMPT94G+P93meNmrSz6gQpQSsXS7Pd400gTmxzoG7BUrIy 53w8LI0wTcsoW04swAy+etrqOvkUC0T9mO4hDXcjaquzR8bllRMTo50sctNfN/ikFWNM HLDNgNti6adS/tH97BO2P7u/cnA0y7FNNLFJP270jGs6BhXhN1aWp4Lmjmjh9ATQLzL/ 3w2jn8G65a8MCNmlvk3NVkCKkq3RlFJLnyf0SLnKbmrQdzgdTQYp+lchcvhe27Q0Cf9+ HK5bOhfyZ9jH6x74u3Cb0ID0GS0F5pl8Y6TQFKLTXBCFHEJI1cIVVFGFL2oHfuHMAMym YBaw== X-Gm-Message-State: ANhLgQ1qjEjuIuWrma1xDKYy7TECeULZnONUMcCRhcVX56x8xVs9ET0z IQpp2uiaD7KN2WUFjlZhN25KIz0Oyf4EBg== X-Google-Smtp-Source: ADFU+vuwpstouFSut0Vi1DKrObSHZrBut+PmY0QZAtwuirPnCeukSIhj8PaLiQRopbwJiMu7sl+xCw== X-Received: by 2002:a6b:cd4a:: with SMTP id d71mr12729711iog.5.1585610045338; Mon, 30 Mar 2020 16:14:05 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id c28sm5357898ilf.26.2020.03.30.16.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 16:14:05 -0700 (PDT) From: Simon Glass To: u-boot@lists.denx.de Cc: Andy Shevchenko , Wolfgang Wallner , Leif Lindholm , Simon Glass , Bin Meng Subject: [PATCH v3 01/29] cpu: Support querying the address width Date: Mon, 30 Mar 2020 17:12:37 -0600 Message-Id: <20200330171226.v3.1.I094ecfe5a8a83eabccd2ac9f6dc5f6fccbdcea5f@changeid> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog In-Reply-To: <20200330231305.130488-1-sjg@chromium.org> References: <20200330231305.130488-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean Different CPUs may support different address widths, meaning the amount of memory they can address. Add a property for this to the cpu_info struct. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v3: None Changes in v2: None drivers/cpu/cpu_sandbox.c | 1 + include/cpu.h | 2 ++ test/dm/cpu.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index ff87e8adca3..05b384f6a45 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -19,6 +19,7 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) { info->cpu_freq = 42 * 42 * 42 * 42 * 42; info->features = 0x42424242; + info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32; return 0; } diff --git a/include/cpu.h b/include/cpu.h index 28dd48feb8f..6b1b6b37b3b 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -44,10 +44,12 @@ enum { * * @cpu_freq: Current CPU frequency in Hz * @features: Flags for supported CPU features + * @address_width: Width of the CPU address space in bits (e.g. 32) */ struct cpu_info { ulong cpu_freq; ulong features; + uint address_width; }; struct cpu_ops { diff --git a/test/dm/cpu.c b/test/dm/cpu.c index f5f1caef716..e6dc576ea3c 100644 --- a/test/dm/cpu.c +++ b/test/dm/cpu.c @@ -33,6 +33,7 @@ static int dm_test_cpu(struct unit_test_state *uts) ut_assertok(cpu_get_info(dev, &info)); ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42); ut_asserteq(info.features, 0x42424242); + ut_asserteq(info.address_width, 32); ut_asserteq(cpu_get_count(dev), 42);