From patchwork Mon Jan 27 05:06: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: 1229588 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=mO0W1uLC; 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 485dVF585Lz9sR1 for ; Mon, 27 Jan 2020 16:24:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F5B081919; Mon, 27 Jan 2020 06:13:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mO0W1uLC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 736FA817B4; Mon, 27 Jan 2020 06:10:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=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-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (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 54EF2817DD for ; Mon, 27 Jan 2020 06:09:37 +0100 (CET) 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-il1-x142.google.com with SMTP id x2so2742450ila.9 for ; Sun, 26 Jan 2020 21:09:37 -0800 (PST) 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=f7DjgfNwRaRPY6rPilSpt2PVS82nC9FK0FnPj01qT8c=; b=mO0W1uLCtyHo7aeFKyJFCrn1EY+ikAwa3CgZErdsGu41JyyoITeFCEJjXcJ09OBf4z O5suFvzBFY+TC8sV4LmLdJ7/gh5fol4NlGg2R8CCdFeMGD6uX+OHsAJAYu2pjsss6x6O Fw8MVALrnBOtmYYecfCHuQpdb6X17WfLU8Xx8= 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=f7DjgfNwRaRPY6rPilSpt2PVS82nC9FK0FnPj01qT8c=; b=WEIOmr5NwBOOM/9lk1iGyhVReMkrrIUSTVZ2PIBxIt23EbEMATQNJD5lwpmsrgUgRl cwsYzBQUFRZS/HHFhVAx6qHTUuhqABcB+QeH1j5m2p1njHHqFGcC+JeQE1vz4Zu3T7LB IyI3PGoUKLFt35rNZg0wyGZcFqQM0sPRWp78OKjHf0RitZh9/Lqf0uYMx8EWVv8Irnqp icdyRRgayASAN29SEzuslrpL7x7rkczrezRthB4meLTeuC59PK8BCOGkkKKllUJ2ioYl ijVPubHgeVm2OabwRr1fZ21VUOl8P8sWedSsgO84TrRXDdLZu27p2ikoXTRAwLEdo+7I VQig== X-Gm-Message-State: APjAAAXKQDv1me0ZVrNQNs3PUMiWtzcheoPLAcj5lnz9iMPw+yHDUct/ e6bX1xfHceiBizDsLYO6mV809ImU0XNDWQ== X-Google-Smtp-Source: APXvYqwNnbPceHP6tOcGCd4HDqBelqaz5cp+AOiNpi6/I8JYT5jM21OVZtcM0RJzr1sO3p2OHeJ1dg== X-Received: by 2002:a92:79cc:: with SMTP id u195mr13237712ilc.304.1580101776071; Sun, 26 Jan 2020 21:09:36 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id h23sm4313195ilf.57.2020.01.26.21.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 090/108] x86: apl: Add support for hostbridge ACPI generation Date: Sun, 26 Jan 2020 22:06:37 -0700 Message-Id: <20200126220508.90.I986016a4667fb7ef9018d9ade3f48c76b9a3f7d3@changeid> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200127050655.170614-1-sjg@chromium.org> References: <20200127050655.170614-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 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.101.4 at phobos.denx.de X-Virus-Status: Clean Support generating a DMAR table and add a few helper routines as well. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/hostbridge.c | 104 ++++++++++++++++++ .../include/asm/arch-apollolake/systemagent.h | 6 + 2 files changed, 110 insertions(+) diff --git a/arch/x86/cpu/apollolake/hostbridge.c b/arch/x86/cpu/apollolake/hostbridge.c index 793853d5b5..5616d89950 100644 --- a/arch/x86/cpu/apollolake/hostbridge.c +++ b/arch/x86/cpu/apollolake/hostbridge.c @@ -1,16 +1,29 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright 2019 Google LLC + * Copyright (C) 2015 - 2017 Intel Corp. + * Copyright (C) 2017 - 2019 Siemens AG + * (Written by Alexandru Gagniuc for Intel Corp.) + * (Written by Andrey Petrov for Intel Corp.) + * + * Portions from coreboot soc/intel/apollolake/chip.c */ +#define LOG_CATEGORY UCLASS_NORTHBRIDGE + #include +#include #include #include #include +#include #include #include +#include #include +#include #include +#include /** * struct apl_hostbridge_platdata - platform data for hostbridge @@ -39,7 +52,9 @@ enum { PCIEXBAR_PCIEXBAREN = 1 << 0, + BGSM = 0xb4, /* Base GTT Stolen Memory */ TSEG = 0xb8, /* TSEG base */ + TOLUD = 0xbc, }; static int apl_hostbridge_early_init_pinctrl(struct udevice *dev) @@ -164,6 +179,92 @@ static int apl_hostbridge_probe(struct udevice *dev) return 0; } +static int apl_acpi_hb_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_return_name(out_name, "RHUB"); +} + +static int apl_acpi_hb_write_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct acpi_table_header *header; + struct acpi_dmar *dmar; + u32 val; + + /* + * Create DMAR table only if virtualization is enabled. Due to some + * constraints on Apollo Lake SoC (some stepping affected), VTD could + * not be enabled together with IPU. Doing so will override and disable + * VTD while leaving CAPID0_A still reporting that VTD is available. + * As in this case FSP will lock VTD to disabled state, we need to make + * sure that DMAR table generation only happens when at least DEFVTBAR + * is enabled. Otherwise the DMAR header will be generated while the + * content of the table will be missing. + */ + + dm_pci_read_config32(dev, CAPID0_A, &val); + if ((val & VTD_DISABLE) || + !(readl(MCHBAR_REG(DEFVTBAR)) & VTBAR_ENABLED)) + return 0; + + log_debug("ACPI: * DMAR\n"); + dmar = (struct acpi_dmar *)ctx->current; + header = &dmar->header; + acpi_create_dmar(dmar, DMAR_INTR_REMAP); + ctx->current += sizeof(struct acpi_dmar); + apl_acpi_fill_dmar(ctx); + + /* (Re)calculate length and checksum */ + header->length = ctx->current - (void *)dmar; + header->checksum = table_compute_checksum((void *)dmar, header->length); + + acpi_align(ctx); + acpi_add_table(ctx, dmar); + acpi_align(ctx); + + return 0; +} + +static int apl_hostbridge_remove(struct udevice *dev) +{ + /* + * TODO(sjg@chromium.org): Consider adding code from coreboot's + * platform_fsp_notify_status() + */ + + return 0; +} + +static ulong sa_read_reg(struct udevice *dev, int reg) +{ + u32 val; + + /* All regions concerned for have 1 MiB alignment */ + dm_pci_read_config32(dev, BGSM, &val); + + return ALIGN_DOWN(val, 1 << 20); +} + +ulong sa_get_tolud_base(struct udevice *dev) +{ + return sa_read_reg(dev, TOLUD); +} + +ulong sa_get_gsm_base(struct udevice *dev) +{ + return sa_read_reg(dev, BGSM); +} + +ulong sa_get_tseg_base(struct udevice *dev) +{ + return sa_read_reg(dev, TSEG); +} + +struct acpi_ops apl_hostbridge_acpi_ops = { + .get_name = apl_acpi_hb_get_name, + .write_tables = apl_acpi_hb_write_tables, +}; + static const struct udevice_id apl_hostbridge_ids[] = { { .compatible = "intel,apl-hostbridge" }, { } @@ -175,5 +276,8 @@ U_BOOT_DRIVER(apl_hostbridge_drv) = { .of_match = apl_hostbridge_ids, .ofdata_to_platdata = apl_hostbridge_ofdata_to_platdata, .probe = apl_hostbridge_probe, + .remove = apl_hostbridge_remove, .platdata_auto_alloc_size = sizeof(struct apl_hostbridge_platdata), + acpi_ops_ptr(&apl_hostbridge_acpi_ops) + .flags = DM_FLAG_OS_PREPARE, }; diff --git a/arch/x86/include/asm/arch-apollolake/systemagent.h b/arch/x86/include/asm/arch-apollolake/systemagent.h index 206d8903fa..1553ec1cf4 100644 --- a/arch/x86/include/asm/arch-apollolake/systemagent.h +++ b/arch/x86/include/asm/arch-apollolake/systemagent.h @@ -34,4 +34,10 @@ */ void enable_bios_reset_cpl(void); +/* API to get TOLUD base address */ +uintptr_t sa_get_tolud_base(struct udevice *dev); +/* API to get GSM base address */ +ulong sa_get_gsm_base(struct udevice *dev); +ulong sa_get_tseg_base(struct udevice *dev); + #endif