cpu: Support querying the address width
authorSimon Glass <sjg@chromium.org>
Wed, 8 Apr 2020 22:57:20 +0000 (16:57 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 16 Apr 2020 06:36:28 +0000 (14:36 +0800)
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 <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/cpu/cpu_sandbox.c
include/cpu.h
test/dm/cpu.c

index ff87e8adca3a0f9fb2d76d03efca57b537ba3709..05b384f6a4577127eabd5db3f3d65d8e382806c2 100644 (file)
@@ -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;
 }
index 28dd48feb8f0a6c1ce8aceaa2d8d15b8d49c39aa..6b1b6b37b3bf2446b1f840dc9beb3cd1f117e25a 100644 (file)
@@ -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 {
index f5f1caef716f9fdcae4d77c76038bb13b9beae2f..e6dc576ea3c3d9d262a8a0126ebe2f8bb0be998d 100644 (file)
@@ -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);