From patchwork Tue Sep 22 18:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1369209 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=UoX7QHHM; 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 4Bwr863Bdxz9sTS for ; Wed, 23 Sep 2020 04:54:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1113C82689; Tue, 22 Sep 2020 20:48:46 +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="UoX7QHHM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB7F78260A; Tue, 22 Sep 2020 20:47:16 +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=-3.5 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-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) (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 3F06E825E6 for ; Tue, 22 Sep 2020 20:47:02 +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-oi1-x242.google.com with SMTP id z26so22126885oih.12 for ; Tue, 22 Sep 2020 11:47:02 -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=OX6TGhRxJU20QdleXLLGSsSHREgXOrnwb7kK1peP/po=; b=UoX7QHHM7KSuv13JSZE382q0qs4vFi7zu1u/ttVxUYuUQnQ4U17/oiF2pX7FIdmI21 YeFTkp0BB7awyFR7QHXc79P+r95ANj9VAEzLFtKeJfxIFzuR+0IAPMUp240iT0EUq7Ct 7urn3kDYSZyTxqo7+LXgMN9kIxPHN5XOFvoBs= 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=OX6TGhRxJU20QdleXLLGSsSHREgXOrnwb7kK1peP/po=; b=s7SXalFy1616YrEGMoL8A3hXbt/DLDYh+y/ApLXMJ5b+vFMOIYPeLIGFvcLJYZf95G ZzxAjzl59EHDWT4dps6TzR1x/OfhsUXXTCTgKn7tb8xKB220grRznLuavesbmHG+bElh 5OaJr0kcZsUmEKccErWK631TwlyNXwl9EYWzjMo6QtHpQjh/9auD35ouasFHYQnrM9Or h1hkMDp3IsQy1P7hJWxQERYKp40GC6LkAsXIr33SPFUWmnPMdBrlpKB5xyip/RvsVn0u MS3hnhBnrJiXxWPCLSCtb5zUu4MPusyw6I6/MYUOyMBZh5W7LB6PpDoxMiSAK97jXtQ9 2tbg== X-Gm-Message-State: AOAM5301l/WxoMqelrugE/CPuoXZGGZTt3/CJnJfKSZdGvqAFK4G/jRW OI5/Mwai1yVI+ja9WgacJz3nqlpWhnqhYvza X-Google-Smtp-Source: ABdhPJy2QpMyMujl23wFtDgPgyueRhj03IcQbq9/6OFULqGeAJtzJJAAtzjuaCSxSM1bKzz3dKX7vQ== X-Received: by 2002:aca:fc4f:: with SMTP id a76mr3338525oii.48.1600800420011; Tue, 22 Sep 2020 11:47:00 -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 q24sm7622663oij.19.2020.09.22.11.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 11:46:59 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Wolfgang Wallner , Bin Meng , Bernhard Messerklinger , Simon Glass Subject: [PATCH v4 36/59] x86: apl: Generate CPU tables Date: Tue, 22 Sep 2020 12:45:21 -0600 Message-Id: <20200922124521.v4.36.I2a86b43205b9beb2d6a9a77e9baff15f52fcf97e@changeid> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog In-Reply-To: <20200922184544.2920969-1-sjg@chromium.org> References: <20200922184544.2920969-1-sjg@chromium.org> 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 Add ACPI generation to the APL CPU driver. Signed-off-by: Simon Glass --- (no changes since v1) Changes in v1: - Capitalise ACPI_OPS_PTR - Handle table generation without callbacks arch/x86/cpu/apollolake/cpu.c | 77 ++++++++++++++++++++++++++++++ arch/x86/lib/Makefile | 3 +- configs/chromebook_coral_defconfig | 1 + 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index 0a6d2ad7a4a..8da2e64e226 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -6,14 +6,90 @@ #include #include #include +#include +#include +#include #include #include +#include +#include +#include + +#define CSTATE_RES(address_space, width, offset, address) \ + { \ + .space_id = address_space, \ + .bit_width = width, \ + .bit_offset = offset, \ + .addrl = address, \ + } + +static struct acpi_cstate cstate_map[] = { + { + /* C1 */ + .ctype = 1, /* ACPI C1 */ + .latency = 1, + .power = 1000, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_FIXED, + }, + }, { + .ctype = 2, /* ACPI C2 */ + .latency = 50, + .power = 10, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_IO, + .bit_width = 8, + .addrl = 0x415, + }, + }, { + .ctype = 3, /* ACPI C3 */ + .latency = 150, + .power = 10, + .resource = { + .space_id = ACPI_ADDRESS_SPACE_IO, + .bit_width = 8, + .addrl = 0x419, + }, + }, +}; static int apl_get_info(const struct udevice *dev, struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } +static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + uint core_id = dev->req_seq; + int cores_per_package; + int ret; + + cores_per_package = cpu_get_cores_per_package(); + ret = acpi_generate_cpu_header(ctx, core_id, cstate_map, + ARRAY_SIZE(cstate_map)); + + /* Generate P-state tables */ + generate_p_state_entries(ctx, core_id, cores_per_package); + + /* Generate T-state tables */ + generate_t_state_entries(ctx, core_id, cores_per_package, NULL, 0); + + acpigen_pop_len(ctx); + + if (device_is_last_sibling(dev)) { + ret = acpi_generate_cpu_package_final(ctx, cores_per_package); + + if (ret) + return ret; + } + + return 0; +} + +struct acpi_ops apl_cpu_acpi_ops = { + .fill_ssdt = acpi_cpu_fill_ssdt, +}; + static const struct cpu_ops cpu_x86_apl_ops = { .get_desc = cpu_x86_get_desc, .get_info = apl_get_info, @@ -32,5 +108,6 @@ U_BOOT_DRIVER(cpu_x86_apl_drv) = { .of_match = cpu_x86_apl_ids, .bind = cpu_x86_bind, .ops = &cpu_x86_apl_ops, + ACPI_OPS_PTR(&apl_cpu_acpi_ops) .flags = DM_FLAG_PRE_RELOC, }; diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index f04d275dd9a..1bcbb49a61f 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -38,7 +38,8 @@ obj-y += sfi.o obj-y += acpi.o obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o ifndef CONFIG_QEMU -obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o acpigen.o +obj-y += acpigen.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o endif obj-y += tables.o ifndef CONFIG_SPL_BUILD diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig index c9006e2f934..ef4dabbe26e 100644 --- a/configs/chromebook_coral_defconfig +++ b/configs/chromebook_coral_defconfig @@ -72,6 +72,7 @@ CONFIG_ENV_OVERWRITE=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_SPL_OF_TRANSLATE=y +CONFIG_INTEL_ACPIGEN=y CONFIG_CPU=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_DW=y