From patchwork Sat Dec 7 04:43:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205422 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.b="hwO3ffUO"; 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 47VHQm6nNlz9sPL for ; Sat, 7 Dec 2019 16:03:12 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B8C9A817C4; Sat, 7 Dec 2019 05:54:44 +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="hwO3ffUO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0BF19817BB; Sat, 7 Dec 2019 05:54:39 +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-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (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 B066E817B8 for ; Sat, 7 Dec 2019 05:54:34 +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-io1-xd41.google.com with SMTP id z23so9438282iog.11 for ; Fri, 06 Dec 2019 20:54:34 -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=j1mpSq5IWFI9w/10xJZ0NyJDwVlGc3P2C9c0sFqj6/g=; b=hwO3ffUO5d1Jst4b3BJPCigi5RI+jpYLxOE58zYczRQx20JtHAEs1ZjpChwOF5Y8+l n4Tv7ugkzCzS773ExO/s+jBNZjcaGy1PwII4ohTDBdo5NBZMXXLft1TUeJt8fsU8wGES jE1F/3ALF4iY7IZqEccOQFp61WA82GaQknEA8= 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=j1mpSq5IWFI9w/10xJZ0NyJDwVlGc3P2C9c0sFqj6/g=; b=TGSU8Oq1VZDLxevP6qEf2eHMb28giCSU7GRtDVBBhzwpJD6dFT9dIfEmibFE77P80g OH0QMU9Ti+A9s4+BfDSWZCPBj3Oq0jSlS3pY6DrthZN//wpIZMRhmDqr6YXUOpSlGVHe ozFsdQh53ATTd2Ojsqfc6W1DWcLAEnS0EJjE84jJmTwUX4Az6qnHeS+s4dWROcHWMTTm mmuYHVQTdd3SBDrHjd+GpnSZkfJoOV8qfer+SLtvY7Jd3SfT1M0Blv4UXD+wQKkNWUbL RGy25agM8o+6ARyG+4wV7yyczBbGL+p7YYZBszka7Zs8nfRapeOin6J81VuQkuYw3gNy 2yoQ== X-Gm-Message-State: APjAAAUycHkpnRgpA/JjLXUyHgJtdHU9D3E0xJkIE71ZJP4GQIuO+p24 J04g4b/p9hUpTTVWLxCQMjn+kuoJbro= X-Google-Smtp-Source: APXvYqw+eir0n+inz2GDrteEV4ye6qAFLAdcdO+58aQ1Qi0cnzbRAxMjbzR89MyoXYUGlAoh/FnUmg== X-Received: by 2002:a02:9404:: with SMTP id a4mr17084656jai.67.1575694473502; Fri, 06 Dec 2019 20:54:33 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id o7sm4549410ilo.58.2019.12.06.20.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 20:54:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v6 088/102] x86: apl: Add systemagent driver Date: Fri, 6 Dec 2019 21:43:01 -0700 Message-Id: <20191207044315.51770-7-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191207044315.51770-1-sjg@chromium.org> References: <20191207044315.51770-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 This driver handles communication with the systemagent which needs to be told when U-Boot has completed its init. Signed-off-by: Simon Glass --- Changes in v6: None Changes in v5: None Changes in v4: - Add a comment for enable_bios_reset_cpl() - Tidy up header guards - use GENMASK() for VTBAR_MASK Changes in v3: None Changes in v2: None arch/x86/cpu/apollolake/Makefile | 2 + arch/x86/cpu/apollolake/systemagent.c | 19 ++++++++++ .../include/asm/arch-apollolake/systemagent.h | 37 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 arch/x86/cpu/apollolake/systemagent.c create mode 100644 arch/x86/include/asm/arch-apollolake/systemagent.h diff --git a/arch/x86/cpu/apollolake/Makefile b/arch/x86/cpu/apollolake/Makefile index fdda748ea3..3a8c2f66a3 100644 --- a/arch/x86/cpu/apollolake/Makefile +++ b/arch/x86/cpu/apollolake/Makefile @@ -2,5 +2,7 @@ # # Copyright 2019 Google LLC +obj-$(CONFIG_SPL_BUILD) += systemagent.o + obj-y += pmc.o obj-y += uart.o diff --git a/arch/x86/cpu/apollolake/systemagent.c b/arch/x86/cpu/apollolake/systemagent.c new file mode 100644 index 0000000000..3a41b329c3 --- /dev/null +++ b/arch/x86/cpu/apollolake/systemagent.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Intel Corporation. + * Take from coreboot project file of the same name + */ + +#include +#include +#include +#include + +void enable_bios_reset_cpl(void) +{ + /* + * Set bits 0+1 of BIOS_RESET_CPL to indicate to the CPU + * that BIOS has initialised memory and power management + */ + setbits_8(MCHBAR_REG(BIOS_RESET_CPL), 3); +} diff --git a/arch/x86/include/asm/arch-apollolake/systemagent.h b/arch/x86/include/asm/arch-apollolake/systemagent.h new file mode 100644 index 0000000000..206d8903fa --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/systemagent.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2017 Intel Corporation. + * Take from coreboot project file of the same name + */ + +#ifndef _ASM_ARCH_SYSTEMAGENT_H +#define _ASM_ARCH_SYSTEMAGENT_H + +/* Device 0:0.0 PCI configuration space */ +#define MCHBAR 0x48 + +/* RAPL Package Power Limit register under MCHBAR */ +#define PUNIT_THERMAL_DEVICE_IRQ 0x700C +#define PUINT_THERMAL_DEVICE_IRQ_VEC_NUMBER 0x18 +#define PUINT_THERMAL_DEVICE_IRQ_LOCK 0x80000000 +#define BIOS_RESET_CPL 0x7078 +#define PCODE_INIT_DONE BIT(8) +#define MCHBAR_RAPL_PPL 0x70A8 +#define CORE_DISABLE_MASK 0x7168 +#define CAPID0_A 0xE4 +#define VTD_DISABLE BIT(23) +#define DEFVTBAR 0x6c80 +#define GFXVTBAR 0x6c88 +#define VTBAR_ENABLED 0x01 +#define VTBAR_MASK GENMASK_ULL(39, 12) +#define VTBAR_SIZE 0x1000 + +/** + * enable_bios_reset_cpl() - Tell the system agent that memory/power are ready + * + * This should be called when U-Boot has set up the memory and power + * management. + */ +void enable_bios_reset_cpl(void); + +#endif