From patchwork Tue Feb 25 12:19:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Wallner X-Patchwork-Id: 236792 List-Id: U-Boot discussion From: wolfgang.wallner at br-automation.com (Wolfgang Wallner) Date: Tue, 25 Feb 2020 13:19:47 +0100 Subject: [PATCH 1/2] x86: cpu_x86: Make cpu_x86_get_count() non-static In-Reply-To: <20200225121949.35950-1-wolfgang.wallner@br-automation.com> References: <20200225121949.35950-1-wolfgang.wallner@br-automation.com> Message-ID: <20200225121949.35950-2-wolfgang.wallner@br-automation.com> The function cpu_x86_get_count() is also useful for other modules. Make it non-static and add a prototype + description. Signed-off-by: Wolfgang Wallner Reviewed-by: Bin Meng --- arch/x86/cpu/cpu_x86.c | 2 +- arch/x86/include/asm/cpu_x86.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c index 1aaf851bb4..3f2ba0881e 100644 --- a/arch/x86/cpu/cpu_x86.c +++ b/arch/x86/cpu/cpu_x86.c @@ -52,7 +52,7 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int cpu_x86_get_count(struct udevice *dev) +int cpu_x86_get_count(struct udevice *dev) { int node, cpu; int num = 0; diff --git a/arch/x86/include/asm/cpu_x86.h b/arch/x86/include/asm/cpu_x86.h index 19223f2c3b..ae8f4dcd5d 100644 --- a/arch/x86/include/asm/cpu_x86.h +++ b/arch/x86/include/asm/cpu_x86.h @@ -30,6 +30,18 @@ int cpu_x86_bind(struct udevice *dev); */ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size); +/** + * cpu_x86_get_count() - Get the number of cores for an x86 CPU + * + * This function is suitable to use as the get_count() method for + * the CPU uclass. + * + * @dev: Device to check (UCLASS_CPU) + * @return: Number of cores if successful, + * -ENOENT if not "/cpus" entry is found in the device tree + */ +int cpu_x86_get_count(struct udevice *dev); + /** * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU * From patchwork Tue Feb 25 12:19:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Wallner X-Patchwork-Id: 236794 List-Id: U-Boot discussion From: wolfgang.wallner at br-automation.com (Wolfgang Wallner) Date: Tue, 25 Feb 2020 13:19:48 +0100 Subject: [PATCH 2/2] x86: apl: Use cpu_x86_get_count() for cpu_ops.get_count In-Reply-To: <20200225121949.35950-1-wolfgang.wallner@br-automation.com> References: <20200225121949.35950-1-wolfgang.wallner@br-automation.com> Message-ID: <20200225121949.35950-3-wolfgang.wallner@br-automation.com> Use cpu_x86_get_count() to read the number of cores. cpu_x86_get_count() reads the number of CPUs from the device tree. Using this function we can support multiple Apollo Lake variants, e.g.: E3940 (4 cores) and E3930 (2 cores). This was tested on the E3940 and E3930 Apollo Lake variants. Signed-off-by: Wolfgang Wallner Reviewed-by: Bin Meng --- arch/x86/cpu/apollolake/cpu.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index 3d05c82a5c..aa7a3dbd63 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -14,15 +14,10 @@ static int apl_get_info(struct udevice *dev, struct cpu_info *info) return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } -static int apl_get_count(struct udevice *dev) -{ - return 4; -} - static const struct cpu_ops cpu_x86_apl_ops = { .get_desc = cpu_x86_get_desc, .get_info = apl_get_info, - .get_count = apl_get_count, + .get_count = cpu_x86_get_count, .get_vendor = cpu_x86_get_vendor, };