From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E2B6ECFD31D for ; Fri, 11 Oct 2024 10:37:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A20278932C; Fri, 11 Oct 2024 12:35:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=9elements.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; secure) header.d=9elements.com header.i=@9elements.com header.b="IEyaHzvb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6FFC5892FB; Fri, 11 Oct 2024 12:35:02 +0200 (CEST) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 5ECD3892FB for ; Fri, 11 Oct 2024 12:35:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=9elements.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=patrick.rudolph@9elements.com Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a9952ea05c5so295800366b.2 for ; Fri, 11 Oct 2024 03:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1728642900; x=1729247700; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uN5BnFsKMozjRRq3SSZ25lyYVWbfWWj0lagNsicv9cw=; b=IEyaHzvb7o8bUGp/Wq5S3RDnFkqlEeqgO5pFYvr0SDvdmdL/1IUTA5PvG6PcBJBEi9 oNeKpDN+w5Wh4NsRYwT5UdRhEqnuMrq+lLgnXVPOn39upk8ra0g3bD12uTxY2ERJrgq2 bZ/AmdYkCRV4KogJM90nvC0dVUUf9wPPiU4rjRUorTmPUEhf10z01ibOOKiSrZUB51gY KawGBokbqGtHKcmH8PTsShACmVN9mEQ3JqO9RD7ARNL9zQXHl0tTFPVzMW/oH9JIm43K XRAGC9o7xgyBKxjcnm6+hHynvfoXAssLy49Lxi6fsfNp+HhirYPDN1biWVXlxCw6H3dr HCDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728642900; x=1729247700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uN5BnFsKMozjRRq3SSZ25lyYVWbfWWj0lagNsicv9cw=; b=HHSYLW06hozJlspi3AYtzStU/7A4QBpLeFf99xV7wqHPIuLKtpODhkELsn+ciPcGx2 bHZlZeSBdeeloz5rYP+ohktY9TAYRzJ+CUmbjj96Tcvaf2Jd4vL7gdaw21fe4da1X2vG aaK7Jeo26IyiWflexL8+ID99w8YLcs17bI0LMyj8eRwLiPwCUmMDPzdzxG0yM0WW6Dkl MawNWJ0J10XYYEBnZnkw0pksX1uGDweD8Ehjn6OAi+hijUj9jsAwnEKI209Etut4N088 41Y5wONw0Rc+xsoiLduH15c2600lbRY+39IHt7pgT8zJf4+LIuaLsiiIVTCQ4vIWuICH ONgw== X-Gm-Message-State: AOJu0YxO7YgxeJbTx6oIDso3rGvNWPEQgVRttuoXdnhhOp2QbheL4EIO vqs58gNxFlf/oKpOYtSas5Xaaoh/r1n3JHqQzh/zFU3kKJ1y3P3KB8dur1VDr/3PPtcolzy9KYW kGN8= X-Google-Smtp-Source: AGHT+IHmIweIkLJye6Erb8jP3HC9O8b8p7BBTT5AwSNsII6eU8WVB7/0uOYMUP8NBJepkMNO3R3m1g== X-Received: by 2002:a17:906:cadf:b0:a99:78a5:77d7 with SMTP id a640c23a62f3a-a99b941f114mr173503566b.5.1728642899722; Fri, 11 Oct 2024 03:34:59 -0700 (PDT) Received: from fedora.sec.9e.network (ip-037-049-067-221.um09.pools.vodafone-ip.de. [37.49.67.221]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80f29besm195353466b.211.2024.10.11.03.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 03:34:59 -0700 (PDT) From: Patrick Rudolph To: u-boot@lists.denx.de, linux-kernel@vger.kernel.org Cc: Patrick Rudolph , Simon Glass , Tom Rini Subject: [PATCH v7 18/37] drivers/cpu: Add generic armv8 cpu driver Date: Fri, 11 Oct 2024 12:22:59 +0200 Message-ID: <20241011102419.12523-19-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241011102419.12523-1-patrick.rudolph@9elements.com> References: <20241011102419.12523-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Add a generic driver that binds to armv8 CPU nodes. The generic driver allows - to enumerate CPUs present in a system, even when no other driver binds it - generates ACPI SSDT code for each CPU - Fill the ACPI MADT table (implemented in a follow up patch) The newly introduced code could also be reused on other CPU drivers that are compatible with armv8. TEST: Booted on QEMU sbsa and verify the driver binds to CPU nodes. Confirmed with FWTS that all ACPI processor devices are present. Signed-off-by: Patrick Rudolph Reviewed-by: Simon Glass Cc: Tom Rini Cc: Simon Glass --- Changelog v4: - Export armv8_cpu_fill_ssdt to use it in other CPU drivers Changelog v6: - Update header order --- drivers/cpu/Kconfig | 6 ++++ drivers/cpu/Makefile | 2 ++ drivers/cpu/armv8_cpu.c | 73 +++++++++++++++++++++++++++++++++++++++++ drivers/cpu/armv8_cpu.h | 21 ++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 drivers/cpu/armv8_cpu.c create mode 100644 drivers/cpu/armv8_cpu.h diff --git a/drivers/cpu/Kconfig b/drivers/cpu/Kconfig index 5c06cd9f60..9c0df331d7 100644 --- a/drivers/cpu/Kconfig +++ b/drivers/cpu/Kconfig @@ -26,6 +26,12 @@ config CPU_RISCV help Support CPU cores for RISC-V architecture. +config CPU_ARMV8 + bool "Enable generic ARMv8 CPU driver" + depends on CPU && ARM64 + help + Support CPU cores for armv8 architecture. + config CPU_MICROBLAZE bool "Enable Microblaze CPU driver" depends on CPU && MICROBLAZE diff --git a/drivers/cpu/Makefile b/drivers/cpu/Makefile index bc75d9b974..773395693a 100644 --- a/drivers/cpu/Makefile +++ b/drivers/cpu/Makefile @@ -6,10 +6,12 @@ obj-$(CONFIG_CPU) += cpu-uclass.o + obj-$(CONFIG_ARCH_BMIPS) += bmips_cpu.o obj-$(CONFIG_ARCH_IMX8) += imx8_cpu.o obj-$(CONFIG_ARCH_AT91) += at91_cpu.o obj-$(CONFIG_ARCH_MEDIATEK) += mtk_cpu.o +obj-$(CONFIG_CPU_ARMV8) += armv8_cpu.o obj-$(CONFIG_CPU_IMX) += imx8_cpu.o obj-$(CONFIG_CPU_MPC83XX) += mpc83xx_cpu.o obj-$(CONFIG_CPU_RISCV) += riscv_cpu.o diff --git a/drivers/cpu/armv8_cpu.c b/drivers/cpu/armv8_cpu.c new file mode 100644 index 0000000000..19f072be43 --- /dev/null +++ b/drivers/cpu/armv8_cpu.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 9elements GmbH + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int armv8_cpu_get_desc(const struct udevice *dev, char *buf, int size) +{ + int cpuid; + + cpuid = (read_midr() & MIDR_PARTNUM_MASK) >> MIDR_PARTNUM_SHIFT; + + snprintf(buf, size, "CPU MIDR %04x", cpuid); + + return 0; +} + +static int armv8_cpu_get_info(const struct udevice *dev, + struct cpu_info *info) +{ + info->cpu_freq = 0; + info->features = BIT(CPU_FEAT_L1_CACHE) | BIT(CPU_FEAT_MMU); + + return 0; +} + +static int armv8_cpu_get_count(const struct udevice *dev) +{ + return uclass_id_count(UCLASS_CPU); +} + +#ifdef CONFIG_ACPIGEN +int armv8_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + uint core_id = dev_seq(dev); + + acpigen_write_processor_device(ctx, core_id); + + return 0; +} + +struct acpi_ops armv8_cpu_acpi_ops = { + .fill_ssdt = armv8_cpu_fill_ssdt, +}; +#endif + +static const struct cpu_ops cpu_ops = { + .get_count = armv8_cpu_get_count, + .get_desc = armv8_cpu_get_desc, + .get_info = armv8_cpu_get_info, +}; + +static const struct udevice_id cpu_ids[] = { + { .compatible = "arm,armv8" }, + {} +}; + +U_BOOT_DRIVER(arm_cpu) = { + .name = "arm-cpu", + .id = UCLASS_CPU, + .of_match = cpu_ids, + .ops = &cpu_ops, + .flags = DM_FLAG_PRE_RELOC, + ACPI_OPS_PTR(&armv8_cpu_acpi_ops) +}; diff --git a/drivers/cpu/armv8_cpu.h b/drivers/cpu/armv8_cpu.h new file mode 100644 index 0000000000..2c4b0252cf --- /dev/null +++ b/drivers/cpu/armv8_cpu.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 9elements GmbH + */ +#include +#include + +#ifndef _ARMV8_CPU_H_ +#define _ARMV8_CPU_H_ + +/** + * armv8_cpu_fill_ssdt() - Fill the SSDT + * Parses the FDT and writes the SSDT nodes. + * + * @dev: cpu device to generate ACPI tables for + * @ctx: ACPI context pointer + * @return: 0 if OK, or a negative error code. + */ +int armv8_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx); + +#endif \ No newline at end of file -- 2.46.2