From patchwork Mon Jan 27 05:05:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229500 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=RsDjRsp4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d7X58Ckz9sRR for ; Mon, 27 Jan 2020 16:08:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1E72816D8; Mon, 27 Jan 2020 06:08:33 +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="RsDjRsp4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AA3F816D8; Mon, 27 Jan 2020 06:08:31 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 B3B9E80929 for ; Mon, 27 Jan 2020 06:08:28 +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-xd42.google.com with SMTP id n11so8551924iom.9 for ; Sun, 26 Jan 2020 21:08:28 -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=77eaa6We4RVSZqsNGr3xFT5XvKdKtZUy+ivL5mUEW+U=; b=RsDjRsp4eHLegRQNyBQuQTeprNcMQUtDgFAYA/GxYTWQziROjrBSDXO9JO2CcGCIRV 3lA7bD37T30Wl8iy1ZA6x/YiLvstorBJN7JZiVf+1l0E3W2nKVuBZCWTvmVFcjPn6nsi nGxM5fv9SRBL7mvQvjBIRSnXo+p2rnkbAdW88= 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=77eaa6We4RVSZqsNGr3xFT5XvKdKtZUy+ivL5mUEW+U=; b=kmyDIWwnpnTKb0GU923O35m5kgfkYxuyOYDsXtz4KM14IR4ZrjwPk6l6+HNPnremRw i5ahO+n/aIxVdzCnYUZBW6TxqxIyYun0dMWOOIQJp//XG2cM8cjBpVwp62ccHGFQEqZa whhs9a4Y1IAusdGguRBh6IS2izoDJ2+1DDMuvK5PFJvBtW71xdzosPTR93HFKZ20lUfq gP48i6pdIfSYuJF08OujEmgw01w+4Ax+L1sLaT15OLFwTPnz5cXm0ANEP1VntoWU/KYm gayQVM11JO3WYuyQisXKeFnHHBb+nJInTfGLyVplXxDf8Bpcs8/EDzY/3S0qcDb4v1AY DV4Q== X-Gm-Message-State: APjAAAWYoFfBZw0JEOkLseh6RHv0I5EOMmCAGhWZ+egCnwzaQKQ0n769 62/VAn+m5TV8ul7RoD5/bQG8M5hP03B8lA== X-Google-Smtp-Source: APXvYqzx8oPq4QMtx0Kmv2w0Kx1C0gPh0kt0+iNXiSy4bPJ9GElX0Xa4M47e0sQsy/NsqbFHzaAJzw== X-Received: by 2002:a5d:8f17:: with SMTP id f23mr11159678iof.265.1580101707332; Sun, 26 Jan 2020 21:08:27 -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.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 001/108] cpu: Support querying the address width Date: Sun, 26 Jan 2020 22:05:08 -0700 Message-Id: <20200126220508.1.I094ecfe5a8a83eabccd2ac9f6dc5f6fccbdcea5f@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 Different CPUs may support different address widths, meaning the amount of memory they can address. Add a property for this to the cpu_info struct. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/cpu/cpu_sandbox.c | 1 + include/cpu.h | 2 ++ test/dm/cpu.c | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index ff87e8adca..05b384f6a4 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -19,6 +19,7 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) { info->cpu_freq = 42 * 42 * 42 * 42 * 42; info->features = 0x42424242; + info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32; return 0; } diff --git a/include/cpu.h b/include/cpu.h index 28dd48feb8..6b1b6b37b3 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -44,10 +44,12 @@ enum { * * @cpu_freq: Current CPU frequency in Hz * @features: Flags for supported CPU features + * @address_width: Width of the CPU address space in bits (e.g. 32) */ struct cpu_info { ulong cpu_freq; ulong features; + uint address_width; }; struct cpu_ops { diff --git a/test/dm/cpu.c b/test/dm/cpu.c index f5f1caef71..e6dc576ea3 100644 --- a/test/dm/cpu.c +++ b/test/dm/cpu.c @@ -33,6 +33,7 @@ static int dm_test_cpu(struct unit_test_state *uts) ut_assertok(cpu_get_info(dev, &info)); ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42); ut_asserteq(info.features, 0x42424242); + ut_asserteq(info.address_width, 32); ut_asserteq(cpu_get_count(dev), 42); From patchwork Mon Jan 27 05:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229501 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=idh4IJHq; 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 485d7d10SNz9sRR for ; Mon, 27 Jan 2020 16:08:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E73980929; Mon, 27 Jan 2020 06:08:36 +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="idh4IJHq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7D369816D8; Mon, 27 Jan 2020 06:08:32 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 502288148F for ; Mon, 27 Jan 2020 06:08:29 +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-xd44.google.com with SMTP id s24so7028367iog.5 for ; Sun, 26 Jan 2020 21:08:29 -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=eyFYL3NXFbDgkUN+tNzXEyhlSk+tIMR9tUe7PYiDY00=; b=idh4IJHqTL/avreiy2rL/u1KGKqzeaobHqk8xol9jqNBHuSScND3j8maZUtHKvGINl olcOfb+eoTVPWhIKBetBTkoZiZQBOkQYuY/QOnUvQIuAwg8AR82/xKxmBApE6uBEfY/e XVym7AI3oVExjSzIO0PPaqjJD1TGxnFPfAnlk= 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=eyFYL3NXFbDgkUN+tNzXEyhlSk+tIMR9tUe7PYiDY00=; b=boh3+t+Ez2JjsmENbWs220KSO8Q7WOx9zFtnWIUuDUTgmfwKgPh+y1EST135YgpkEv e2XPFGESFSsbDSPBnL4+4DjCuUv0PldCMNWezaM3zJDOgyUjmaM/6L1+NyF5yeZ+ISxU MFgL/pCQAoGX/Up/uZUtxyZKihkgmBnlZzIrJweTLzf+sX11NlZuLskLoDDkwO2+UGZX E/lHLzoqFpkecJ+skMx44P93JSwozSjPhX6inTHN+pGdZeOaem0UNprM4MqHfE7YFQdH L3aJ69UUrGtKXKXHnAzNLBso7L6VBo9SXRzNA69pMaLRlnV1XKQeU+ekvTZDVmOJBSx3 ZnLw== X-Gm-Message-State: APjAAAUZOYGo/u3FaMJsBjnv4ThgimQboJFk/dyJNcBwp+ISvfvtTvPR nID6mR8qBlNLOo/IFcn18y2KPldtsGPQlQ== X-Google-Smtp-Source: APXvYqyWCOiSVCVFK+obOB/7vzQnGfQ5HXhS250Pa6nvsD0VnIIFua2VDFC0lQULE1q6YyRyty7u1g== X-Received: by 2002:a02:3312:: with SMTP id c18mr11792678jae.24.1580101708046; Sun, 26 Jan 2020 21:08:28 -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.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 002/108] spi: Add SPI mode enums Date: Sun, 26 Jan 2020 22:05:09 -0700 Message-Id: <20200126220508.2.I83a459a3914c56ca81dcdfa7e01d83c54f7ab914@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: , Cc: Jagannadha Sutradharudu Teki 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 With ACPI we need to describe the settings of the SPI bus. Add enums to handle this. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/spi.h b/include/spi.h index ef5d87f476..77fa3800fd 100644 --- a/include/spi.h +++ b/include/spi.h @@ -62,6 +62,39 @@ struct dm_spi_slave_platdata { uint mode; }; +/** + * enum spi_clock_phase - indicates the clock phase to use for SPI (CPHA) + * + * @SPI_CLOCK_PHASE_FIRST: Data sampled on the first phase + * @SPI_CLOCK_PHASE_SECOND: Data sampled on the second phase + */ +enum spi_clock_phase { + SPI_CLOCK_PHASE_FIRST, + SPI_CLOCK_PHASE_SECOND +}; + +/** + * enum spi_wire_mode - indicates the number of wires used for SPI + * + * @SPI_4_WIRE_MODE: Normal bidirectional mode with MOSI and MISO + * @SPI_3_WIRE_MODE: Unidirectional version with a single data line SISO + */ +enum spi_wire_mode { + SPI_4_WIRE_MODE, + SPI_3_WIRE_MODE +}; + +/** + * enum spi_polarity - indicates the polarity of the SPI bus (CPOL) + * + * @SPI_POLARITY_LOW: Clock is low in idle state + * @SPI_POLARITY_HIGH: Clock is high in idle state + */ +enum spi_polarity { + SPI_POLARITY_LOW, + SPI_POLARITY_HIGH +}; + #endif /* CONFIG_DM_SPI */ /** From patchwork Mon Jan 27 05:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229502 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=Wrkh6LK2; 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 485d7p4t21z9sR1 for ; Mon, 27 Jan 2020 16:08:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3F38B8177F; Mon, 27 Jan 2020 06:08:47 +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="Wrkh6LK2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D72C1814DA; Mon, 27 Jan 2020 06:08:34 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 063CB814DA for ; Mon, 27 Jan 2020 06:08:30 +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-x143.google.com with SMTP id g12so6459346ild.2 for ; Sun, 26 Jan 2020 21:08:29 -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=j+30PjrVv8QgQ8W9mShcbSU8YjrubZlaHkth+d6uJrU=; b=Wrkh6LK2Sf4s1woBE+RkD1LQSwDPvA/Rk9hBMGeFjC+wB7JasCBeYK11jvxYFSlAnl fDk5JS00p5ZaY/xM2DiTWT9k5yUPGrjTeRx6YnVaTzdPOxnuawMgH0HnLRBZUQXz5Bzv PfwKT5EpCIFFtr1DNnX5BljN80ce+8QEIcleU= 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=j+30PjrVv8QgQ8W9mShcbSU8YjrubZlaHkth+d6uJrU=; b=WPXqDE1+v13sxingWTMXOK4uswG0m4OQNZs1tBLKgEz/eZ8trhpmXcmNUV1o+4xMMQ 8wxMKnMAWoAIDW1v6soUrACAl3OJf+nN5PeQc64s3r105y7TZfZmIFOXyJe45Zvr+Zc4 5wgYhNMEqnux6Bgqy+MKZhJQLxPtqK1b1uFCEUVXBjAVX3sx00Wke8aHewO0I8Lb7c/n FFq/YD2s+xcVIL2ZgwkaqIyXGUu7Zn1nU4p4xJ43lShAqZsx2IrhwINb2rIh/mG5qqj9 VbQsQiQkYLhBELarlr/ZyeK8c341D/tOLn1XWd35jCGSS0XpnbwTmzye7eSvOKmudTUe NEZQ== X-Gm-Message-State: APjAAAUo3JlHmOyH6zx+UA1vpTzmkeIcE8TeGkemQZM/jLUL9UwYcQnS Kwms5lJzKcBY07yyxmZzRImLVAYIC33Urw== X-Google-Smtp-Source: APXvYqz4b+SDlMOcluet3LVmmTs83HWrN7ICljAYEQ6P1i1FNJFmUZ3rRWoYy0CQD/fs9+TTtbdY/A== X-Received: by 2002:a92:85c1:: with SMTP id f184mr13024715ilh.221.1580101708805; Sun, 26 Jan 2020 21:08:28 -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.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 003/108] tpm: cr50: Release locality on exit Date: Sun, 26 Jan 2020 22:05:10 -0700 Message-Id: <20200126220508.3.Ic7bc756f1622775532c4536a2dfd4ee783ee4a35@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 At present the cr50 driver claims the locality and does not release it for Linux. This causes problems. Fix this by tracking what is claimed, and adding a 'remove' method. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index 880da37835..42faee4d9b 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -208,7 +208,7 @@ static int release_locality(struct udevice *dev, int force) cr50_i2c_write(dev, addr, &buf, 1); } - priv->locality = 0; + priv->locality = -1; return 0; } @@ -500,6 +500,7 @@ static int process_reset(struct udevice *dev) static int claim_locality(struct udevice *dev, int loc) { const u8 mask = TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY; + struct cr50_priv *priv = dev_get_priv(dev); u8 access; int ret; @@ -526,6 +527,7 @@ static int claim_locality(struct udevice *dev, int loc) return -EPERM; } log_info("Claimed locality %d\n", loc); + priv->locality = loc; return 0; } @@ -560,7 +562,11 @@ static int cr50_i2c_open(struct udevice *dev) static int cr50_i2c_cleanup(struct udevice *dev) { - release_locality(dev, 1); + struct cr50_priv *priv = dev_get_priv(dev); + + printf("%s: cleanup %d\n", __func__, priv->locality); + if (priv->locality != -1) + release_locality(dev, 1); return 0; } @@ -632,6 +638,7 @@ static int cr50_i2c_probe(struct udevice *dev) return log_msg_ret("vendor-id", -EXDEV); } priv->vendor = vendor; + priv->locality = -1; return 0; } @@ -656,5 +663,7 @@ U_BOOT_DRIVER(cr50_i2c) = { .ops = &cr50_i2c_ops, .ofdata_to_platdata = cr50_i2c_ofdata_to_platdata, .probe = cr50_i2c_probe, + .remove = cr50_i2c_cleanup, .priv_auto_alloc_size = sizeof(struct cr50_priv), + .flags = DM_FLAG_OS_PREPARE, }; From patchwork Mon Jan 27 05:05:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229504 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=OqHGniZY; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d8J5848z9sR1 for ; Mon, 27 Jan 2020 16:09:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20EBA817BC; Mon, 27 Jan 2020 06:08:55 +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="OqHGniZY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E03AC8176E; Mon, 27 Jan 2020 06:08:35 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 B475C814F5 for ; Mon, 27 Jan 2020 06:08:30 +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-xd43.google.com with SMTP id m25so8555411ioo.8 for ; Sun, 26 Jan 2020 21:08:30 -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=3OXgFXrjsIqKsFGNpv1VxPI6HwCJWxb174mJ/BUnGFQ=; b=OqHGniZY15GVaoSRHodMDrvFQEAdxPZ9w+psO9KZK1WR27YX1gFI8KAYb39wbiwpyF sw4TDGYPGlwtrN+uTdzP1u4Hr5S3TDreUrnMC6aWWbDSzPwLWZP8xjXs/Alo1wEMmzDC ASITxRt5z3CmbtBURzdKEiGNi870z6T9geQVU= 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=3OXgFXrjsIqKsFGNpv1VxPI6HwCJWxb174mJ/BUnGFQ=; b=LqdhcvQ3r5nnZRbyp5tpdoifhutOAb2WYyg8J1ZzMX+JPV9XGHtXc01ZK9V2FgZkiJ X5Ks6WTFfIiCFFGG56vWOU6VO4+vrGAABn9b3RaQE1jx5A3zVw7o51M6mufHdLTT/OX1 A2TmhUqUthSgOLRcDbIzTGD1EpuGtWLWUIZtHWIhEGHiXOdkpDwan4c0BiQ3OBgJH0ZD Lo2yMUaSEcxtlNrp5q3VWWTeplIAvGpXiD92lMAE3kKUuuDosp6xrQ+OgCX5bPSVNo+t UaLjsBN4aoBUSu4GcyG8X0y9nvZMDlK6ZpyZjkgKRNQ2jkNUJ4kWOhoH9M7aGdg8xSrw XPfg== X-Gm-Message-State: APjAAAWEcO9rfFTSXzxEPnC/M3KFbd/9YfclBEnK4dJ0KL+xwh4Q/jUs mlMD2u90Glwjan7Cj6attC2uPFxxpNjXmg== X-Google-Smtp-Source: APXvYqxL4VZtwksa4aCagtSO05P34KVs71xL/TwVQD4yS53kZA7Iz3SJDiH5lkRgx2518Kkjy4CGTw== X-Received: by 2002:a02:c78f:: with SMTP id n15mr11983793jao.100.1580101709444; Sun, 26 Jan 2020 21:08:29 -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.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 004/108] tpm: cr50: Tidy up various comments Date: Sun, 26 Jan 2020 22:05:11 -0700 Message-Id: <20200126220508.4.I405998b384e2bb25cbfb3179a8375c586bf0ce7a@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 Add a comment for the private structure and drop the incorrect coreboot reference in one function. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/tpm/cr50_i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index 42faee4d9b..1af943d6ff 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -34,6 +34,15 @@ enum { CR50_MAX_BUF_SIZE = 63, }; +/** + * struct cr50_priv - Private driver data + * + * @ready_gpio: GPIO to use to check if the TPM is ready + * @irq: IRQ to use check if the TPM is ready (has priority over @ready_gpio) + * @locality: Currenttly claimed locality (-1 if none) + * @vendor: vendor: Vendor ID for TPM + * @use_irq: true to use @irq, false to use @ready if available + */ struct cr50_priv { struct gpio_desc ready_gpio; struct irq irq; @@ -493,8 +502,8 @@ static int process_reset(struct udevice *dev) } /* - * Locality could be already claimed (if this is a later coreboot stage and - * the RO did not release it), or not yet claimed, if this is verstage or the + * Locality could be already claimed (if this is a later U-Boot phase and + * RO did not release it), or not yet claimed, if this is TPL or the * older RO did release it. */ static int claim_locality(struct udevice *dev, int loc) From patchwork Mon Jan 27 05:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229506 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=XLXPEB5C; 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 485d8j3WXCz9sR1 for ; Mon, 27 Jan 2020 16:09:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 67A8C817EA; Mon, 27 Jan 2020 06:09:00 +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="XLXPEB5C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8BE0B816DA; Mon, 27 Jan 2020 06:08:37 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 7C4D7816DA for ; Mon, 27 Jan 2020 06:08:31 +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-x144.google.com with SMTP id f10so6437842ils.8 for ; Sun, 26 Jan 2020 21:08:31 -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=V+sHwovFI7fiAYo+guXgEXQcuWbiEoEG9ztiQb0bzUc=; b=XLXPEB5CcO2RrS/BkTspuyzGQjZbJunpBRZjxDZLVY04/4ZV4yDqsIAyfNe4Z3MW4N FPcfRO+bL/iWiPWMq1OXxeflmdhsD/UCszivrrVsEpJXE7T+3Q8dfu0PGZM2YUz1u40P i6y3q44AieR9BrVqxvNAFefL0Z/vlsY+6CiJU= 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=V+sHwovFI7fiAYo+guXgEXQcuWbiEoEG9ztiQb0bzUc=; b=ZpH+m8cJpFieLEa4856q+odFBVKCicO1I0t1btANUKuqIbsT3taEz+EU1BrXWf4deY MligJNC+icvs5ax1fUtF6p7mAzipL0gNLApP/RKkyzIQ0N+9tAE69Mvxuy65/NWXWm16 QM4YsnP3uRrKO/rDVMrmmZ9PO1PWKrTGo9kywVR41JoMvgu2vaJJZRfegKKAMhSOolXu 8Hpdv7wfYvCvR032yG5/erzIR5i6bXW5UcMEKG27t5vnkXbwbyH58z8lbij12hcVoYKx KzEyQY1Mzr6govVC/5sMJMWyX/r4lLhg0r0ANBCTOk2Q2MhRqJCUnS3YUnVUYIC3cVlT yL7A== X-Gm-Message-State: APjAAAVTTTRbrGCJZSdKe76uJ0PC/3kAMwIc0oLXJ4dgQ/Yi2Lu8twtJ JspU0GlnpVGaNbe9n6R3BLV7Y7ahIE+5+w== X-Google-Smtp-Source: APXvYqzrZwkIMyFh5H9Wus0LIHW+DvNrBE2bM5hAz8ePVXnF5m5OkryoewrWR6OgdrPLHqbEz9uBCQ== X-Received: by 2002:a92:8141:: with SMTP id e62mr13257904ild.119.1580101710160; Sun, 26 Jan 2020 21:08:30 -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.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 005/108] tpm: cr50: Use the correct GPIO binding Date: Sun, 26 Jan 2020 22:05:12 -0700 Message-Id: <20200126220508.5.Iffff549a1b63fedb9e8ec87cdc5e9e28478a4587@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 This device should use ready-gpios rather than ready-gpio. Fix it. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/dts/chromebook_coral.dts | 2 +- doc/device-tree-bindings/gpio/intel,apl-gpio.txt | 2 +- .../interrupt-controller/intel,acpi-gpe.txt | 2 +- drivers/tpm/cr50_i2c.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index 4e8c0a6c8a..7ba38d7791 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -292,7 +292,7 @@ reg = <0x50>; compatible = "google,cr50"; u-boot,i2c-offset-len = <0>; - ready-gpio = <&gpio_n 28 GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n 28 GPIO_ACTIVE_LOW>; interrupts-extended = <&acpi_gpe 0x3c 0>; }; }; diff --git a/doc/device-tree-bindings/gpio/intel,apl-gpio.txt b/doc/device-tree-bindings/gpio/intel,apl-gpio.txt index e27a40b437..e12dc37233 100644 --- a/doc/device-tree-bindings/gpio/intel,apl-gpio.txt +++ b/doc/device-tree-bindings/gpio/intel,apl-gpio.txt @@ -47,7 +47,7 @@ Example: reg = <0x50>; compatible = "google,cr50"; u-boot,i2c-offset-len = <0>; - ready-gpio = <&gpio_n GPIO_28 GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n GPIO_28 GPIO_ACTIVE_LOW>; }; }; diff --git a/doc/device-tree-bindings/interrupt-controller/intel,acpi-gpe.txt b/doc/device-tree-bindings/interrupt-controller/intel,acpi-gpe.txt index d9252bf29f..2fe02d8a22 100644 --- a/doc/device-tree-bindings/interrupt-controller/intel,acpi-gpe.txt +++ b/doc/device-tree-bindings/interrupt-controller/intel,acpi-gpe.txt @@ -25,6 +25,6 @@ Example: tpm@50 { reg = <0x50>; compatible = "google,cr50"; - ready-gpio = <&gpio_n 0x1c GPIO_ACTIVE_LOW>; + ready-gpios = <&gpio_n 0x1c GPIO_ACTIVE_LOW>; interrupts-extended = <&acpi_gpe 0x3c 0>; }; diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index 1af943d6ff..d68534e7a9 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -608,7 +608,7 @@ static int cr50_i2c_ofdata_to_platdata(struct udevice *dev) priv->irq = irq; priv->use_irq = true; } else { - ret = gpio_request_by_name(dev, "ready-gpio", 0, + ret = gpio_request_by_name(dev, "ready-gpios", 0, &priv->ready_gpio, GPIOD_IS_IN); if (ret) { log_warning("Cr50 does not have an ready GPIO/interrupt (err=%d)\n", From patchwork Mon Jan 27 05:05:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229503 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=k/SuCkQf; 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 485d845JSzz9sR1 for ; Mon, 27 Jan 2020 16:09:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B9CA817BF; Mon, 27 Jan 2020 06:08:50 +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="k/SuCkQf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FFB881764; Mon, 27 Jan 2020 06:08:35 +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 EE873815D3 for ; Mon, 27 Jan 2020 06:08:31 +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 t17so6409723ilm.13 for ; Sun, 26 Jan 2020 21:08:31 -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=bjaaMNZCftNwFAUQ8AO2JAtZtyespnlZkJBjfp0N+zw=; b=k/SuCkQftyyvkInxV6nsO8sV22shw2qJtyf7yuyrrWWJYoF8p5Ehn8PR4KtPS+4p+G 6ZgEwRo3JULLXbZ/aiyqMt8sftyGt0jOpJdEwvfIp7Vswj5BI2GP5oru9WvxUjcW9hfR F6iGRGNKfG64hrdsMzSAgv0kDv4Bqu8L5fL/I= 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=bjaaMNZCftNwFAUQ8AO2JAtZtyespnlZkJBjfp0N+zw=; b=guqBDyEQrX7Ok8GmPJ+Jzu6cYmkEV6sIjDDL5wgZzBbCFatVzRKtukJz2wPfDVbwZH KOT3K3kxYnjI/cdKa9zF1HF0W0454KFJUS560i3hp2ba3JTJs3xYjSQtRsypO0y1w7Hw 7zBXl/LE7cfLrtKK02KpTyFFLoFQaHbHfUT1nsHwtgWstOnEW5h/RQp51F7iUPaFDSgQ 7ztQd6gdS6XCpZv/7G7VQgGE14RfkiHy9RZMq4ubQUXxm4MLQDAd1zOWZLFKcsMtV4/X MoC/t45yO1rOWoUZ1VNuX64qIkUeEoDpa6xVHvgYsi1ZpcKC//CBhljzMBZIZkhqw4jD gNeg== X-Gm-Message-State: APjAAAXZkY42IbU6fVMkbZgaT9+f+r1kUHFU3THg8v/ZNvi9cv1L9kvH oG+Co0BT0W4Rzw1IBojYW8CGJkynOWdeqA== X-Google-Smtp-Source: APXvYqydHNjTNC4bnTiJY5JRiqj7kemNfZJg4+fHOIE3f/K5/CTJ0owMr164nV2nSceyFcMqNi/MVA== X-Received: by 2002:a92:3991:: with SMTP id h17mr14016371ilf.131.1580101710787; Sun, 26 Jan 2020 21:08:30 -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.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 006/108] tpm: Don't cleanup unless an error happens Date: Sun, 26 Jan 2020 22:05:13 -0700 Message-Id: <20200126220508.6.Ic7e63c1f960c3adab3a1c03a61a56c4199fc7074@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 At present the cleanup() method is called on every transfer. It should only be called on failing transfers. Fix this and tidy up the error handling a little. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/tpm/tpm-uclass.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c index 1b11c93194..71d5807006 100644 --- a/drivers/tpm/tpm-uclass.c +++ b/drivers/tpm/tpm-uclass.c @@ -72,7 +72,7 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size, struct tpm_ops *ops = tpm_get_ops(dev); ulong start, stop; uint count, ordinal; - int ret, ret2; + int ret, ret2 = 0; if (ops->xfer) return ops->xfer(dev, sendbuf, send_size, recvbuf, recv_size); @@ -120,9 +120,16 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size, } } while (ret); - ret2 = ops->cleanup ? ops->cleanup(dev) : 0; + if (ret) { + if (ops->cleanup) { + ret2 = ops->cleanup(dev); + if (ret2) + return log_msg_ret("cleanup", ret2); + } + return log_msg_ret("xfer", ret); + } - return ret2 ? ret2 : ret; + return 0; } UCLASS_DRIVER(tpm) = { From patchwork Mon Jan 27 05:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229505 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=IW2Y+OSy; 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 485d8V6H79z9sR1 for ; Mon, 27 Jan 2020 16:09:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE8E981764; Mon, 27 Jan 2020 06:08:57 +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="IW2Y+OSy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4AABD8172D; Mon, 27 Jan 2020 06:08:36 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 B2F9180929 for ; Mon, 27 Jan 2020 06:08:32 +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-x143.google.com with SMTP id p8so6410793iln.12 for ; Sun, 26 Jan 2020 21:08:32 -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=WJANM6128c6j6E7SPzFaeL924NwngJTvNzA4KXSqwk0=; b=IW2Y+OSy1ucbJANYxA+vi84mAMsedDmuhVEmiNIviZr8FKxCpd7m+OSYaSEmTGXwR1 U0AVh9ZEUYwN2OyrRYICqVh4ZaFk/JIuHRBq3B/8awcf/BxhEbTDhDi9AkbQYXK3GTdc whcSTYrW1Tr/NWuYjUzY+b7IhdOxrtsTtuBDE= 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=WJANM6128c6j6E7SPzFaeL924NwngJTvNzA4KXSqwk0=; b=PywpTW2EAalQUbtyrvvG+0UN5JdHtH3C2rtAqp5RTfAqG0KQ5N4W1UqjCc+RqoUg5Q faTa/KTgYucsIx8X7JqtzONPBuj1MIzNb+Mue68mt/w9qSBxleLN4XikB3NslN+khnST yUF3jT6RUc/OTR86PsoBCH8QoslfnGr7L/zzPORtS/UA/CDjniq/zFpvf44A/f8lehm3 opGUhTiwgHFH8jE6IVhKhFZjM4lUzZjeB94poMpkp2zm14GaVSRta73h9SovFULfSeHP fOaGqJHKSX85jxhgfgbYzCkaGBw+xuNwEaAqKTN/q8W4m2/tvyagbjknE29zNJLY8xF8 cXJw== X-Gm-Message-State: APjAAAWTOwcJ1NKlgaEtSTkwpWmtVjfho6BK6QRHhKGFDj74mmj20rAP PIHigHnga/xZH0WjSHkNUpAJun0K9yN0jg== X-Google-Smtp-Source: APXvYqzQIWPiw830zkePPq3NoLjDfcqZNmwNA1tox4iAyyv2WBngjK5ITD8HZ/9fgyk4p5dIbpFtbw== X-Received: by 2002:a92:4982:: with SMTP id k2mr4768032ilg.57.1580101711532; Sun, 26 Jan 2020 21:08:31 -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.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 007/108] dm: pci: Allow disabling auto-config for a device Date: Sun, 26 Jan 2020 22:05:14 -0700 Message-Id: <20200126220508.7.I66a7bcb7db931e196e8319d2dbca4e418274f39b@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: , Cc: Pavel Herrmann 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 Add a means to avoid configuring a device when needed. Add an explanation of why this is useful to the binding file. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- doc/device-tree-bindings/pci/x86-pci.txt | 24 ++++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 26 insertions(+) diff --git a/doc/device-tree-bindings/pci/x86-pci.txt b/doc/device-tree-bindings/pci/x86-pci.txt index 3aa5bd9a46..62b29a4e36 100644 --- a/doc/device-tree-bindings/pci/x86-pci.txt +++ b/doc/device-tree-bindings/pci/x86-pci.txt @@ -10,6 +10,17 @@ Optional properties: configuration in TPL/SPL to reduce code size and boot time, since these phases only know about a small subset of PCI devices. +For PCI devices the following optional property is available: + +- pci,no-autoconfig : Don't automatically configure this PCI device at all. + This is used when the device is statically configured and must maintain + this same config throughout the boot process. An example is a serial + UART being used to debug PCI configuration, since reconfiguring it stops + the UART from working until the driver is re-probed, and this can cause + output to be lost. This should not generally be used in production code, + although it is often harmless. + + Example: pci { @@ -21,4 +32,17 @@ pci { 0x42000000 0x0 0xb0000000 0xb0000000 0 0x10000000 0x01000000 0x0 0x1000 0x1000 0 0xefff>; u-boot,skip-auto-config-until-reloc; + + + serial: serial@18,2 { + reg = <0x0200c210 0 0 0 0>; + u-boot,dm-pre-reloc; + compatible = "intel,apl-ns16550"; + early-regs = <0xde000000 0x20>; + reg-shift = <2>; + clock-frequency = <1843200>; + current-speed = <115200>; + acpi,name = "URT3"; + pci,no-autoconfig; + }; }; diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index bb272b67a1..f5f713fdf4 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -535,6 +535,8 @@ int pci_auto_config_devices(struct udevice *bus) int ret; debug("%s: device %s\n", __func__, dev->name); + if (dev_read_bool(dev, "pci,no-autoconfig")) + continue; ret = dm_pciauto_config_device(dev); if (ret < 0) return ret; From patchwork Mon Jan 27 05:05:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229507 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=g154lt2f; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d8w2Frdz9sR1 for ; Mon, 27 Jan 2020 16:09:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 97426817E8; Mon, 27 Jan 2020 06:09:09 +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="g154lt2f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D66C481776; Mon, 27 Jan 2020 06:08:38 +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 71AC28148F for ; Mon, 27 Jan 2020 06:08:33 +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 b15so6446923iln.3 for ; Sun, 26 Jan 2020 21:08:33 -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=JrquB/xaiQvuJb534cGFEKTTM1qI0EbXQursaT9+jhU=; b=g154lt2fdbWpLWu3gtzB+S2Bg5CpZPo8CEvoh5PHqs7YVtmu74RtZNKTfYHI+kct58 06jbgW3OVj6TPRXzyv1zcRiF24yY851H/erMrqZ5RziscfJYaXrW6s9Lh/q2HVFk2h/6 yedYyMSiA/lrnOqlmebrQcr8JzWcdKJ8qSP8A= 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=JrquB/xaiQvuJb534cGFEKTTM1qI0EbXQursaT9+jhU=; b=odrnHRkVZfgos14DnRCkGyIoomkcU9Sc84kGzvqA82uB+fmLNVIb2pDnnKMcBnwh+k j2Dc6fUkxoDt3Mum3XbK9VKXsyPIgJeUTcALOqJOL9Dx+TF4k7WOFiXKHeRgpeau8gjU U9mawPkz6UF3FikqxVCW7ru4z9qchwKraEP1af43haZA3upqdjBr5LTuEnAuSqETrJJ/ 38Nf9XlrAXuB1K2PZ9ik2nJiXPh8SoHs/f1R6MgnR86Mhk5A1PkAO+8PCz/Sxf5/Q0Cw 3BO/tiMRjBB9UTFqa/DYoUoM5lP6mI9b20oCSIls9xEUoDZAQ9vFFPIsAqAGIrjlotMk Z4Fg== X-Gm-Message-State: APjAAAX89Ux7DjvMtwVNT73EvnrFELSZGbzc8740kZEK/hg8GHZ3Hm1T VkMf8zikSPkdUdcEoe8EWUIL3CTqh0Qgbg== X-Google-Smtp-Source: APXvYqzvKuJnxQrSnLtLB4oeR+rSZquZU+bu8RYIRbc9YBJm8E1FAoiCsKxf6vcrxOhwTDE09vh7kw== X-Received: by 2002:a92:79cc:: with SMTP id u195mr13235615ilc.304.1580101712211; Sun, 26 Jan 2020 21:08:32 -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.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 008/108] x86: Correct wording of coreboot source code Date: Sun, 26 Jan 2020 22:05:15 -0700 Message-Id: <20200126220508.8.I0e67688e96b62650b8218c3d536f9fc4de9d13b4@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 Some files are taken or modified from coreboot, but the files are no-longer part of the coreboot project. Fix the wording in a few places. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/cpu/coreboot/timestamp.c | 4 ++-- arch/x86/include/asm/arch-coreboot/timestamp.h | 4 ++-- arch/x86/include/asm/intel_pinctrl_defs.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/cpu/coreboot/timestamp.c b/arch/x86/cpu/coreboot/timestamp.c index e698200d70..e8ccaf2212 100644 --- a/arch/x86/cpu/coreboot/timestamp.c +++ b/arch/x86/cpu/coreboot/timestamp.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * This file is part of the coreboot project. - * * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. + * + * Modified from the coreboot version */ #include diff --git a/arch/x86/include/asm/arch-coreboot/timestamp.h b/arch/x86/include/asm/arch-coreboot/timestamp.h index 9320afba56..85d42c02c4 100644 --- a/arch/x86/include/asm/arch-coreboot/timestamp.h +++ b/arch/x86/include/asm/arch-coreboot/timestamp.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * This file is part of the coreboot project. - * * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. + * + * Taken from the coreboot version */ #ifndef __COREBOOT_TIMESTAMP_H__ diff --git a/arch/x86/include/asm/intel_pinctrl_defs.h b/arch/x86/include/asm/intel_pinctrl_defs.h index 6da06bb52b..1ea141f082 100644 --- a/arch/x86/include/asm/intel_pinctrl_defs.h +++ b/arch/x86/include/asm/intel_pinctrl_defs.h @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * This file is part of the coreboot project. - * * Copyright (C) 2015-2016 Intel Corp. * Copyright 2019 Google LLC * From patchwork Mon Jan 27 05:05:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229508 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=MwIqlFKr; 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 485d973v9Qz9sRR for ; Mon, 27 Jan 2020 16:10:03 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3B20817EC; Mon, 27 Jan 2020 06:09:13 +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="MwIqlFKr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7382D81793; Mon, 27 Jan 2020 06:08:40 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 2018881726 for ; Mon, 27 Jan 2020 06:08: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-xd43.google.com with SMTP id n21so8545403ioo.10 for ; Sun, 26 Jan 2020 21:08: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=ARbxkOsGJ0TZUHMAz/kWVV97K5mC+7wlsYdPki57UlQ=; b=MwIqlFKrqXQ0wJIDvAcLNXN8eHvjcrzYkhOnWGym3DHYV9GSiecSQy2GBJf4hhqMjK rujLbjcw/49dwF3iznS4EFVaA+M67lmv4oDQutib8hsKv2fEQBlbHZnl8WD1c8iF9/+i SubxA6ZBMRi3+biefKfDUcatu7Ofa7DWoeMe0= 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=ARbxkOsGJ0TZUHMAz/kWVV97K5mC+7wlsYdPki57UlQ=; b=f4LlfogVkJc7OH3empEG1nryN+cKhF0AxasDYAJooUUTXF5234xSby0jOS7z/ibA1i lZsuQy8XvY7YiezDavUvFI/BsPjpFlYqS5vm/Io0pOYlNBb7+xILnL9W3R8ThFH600JF u2HEqXTa/UZ+5Vg2F5M156JdP3SX2mx3THD5tnCdV5dgDjTCghDz6/FLPXIdYR6Bvp0i aHBvGAsWein3xJ6E6rxqYJHTcCxVSGVSVTBrRLu5OU15H32vg8Z3DHqTGOlZraIg7Z3j CMWaecuQqmLUbLBCtR2+zh+WTdde75jEbV7urm+XkFTmJ99xEuCcyNwinxpUCaCsq9Hv WxPA== X-Gm-Message-State: APjAAAWC/rrGnggPfqf3ExQrJMpaXtPn8qZl1dLvKyjgdEg3V9azlZKw cGK/PLkoXfAxQLK9vn1SzjgHcvrK9pf+Dw== X-Google-Smtp-Source: APXvYqyAQBXq4fe0+RUZRakcQQil/Sy3LRe4aBWA9OT99XLrPaylJ8W/o2GI9UF/LQVojpIcvYmB9A== X-Received: by 2002:a02:4004:: with SMTP id n4mr11574834jaa.99.1580101712890; Sun, 26 Jan 2020 21:08:32 -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.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 009/108] x86: apl: Move p2sb ofdata reading to the correct method Date: Sun, 26 Jan 2020 22:05:16 -0700 Message-Id: <20200126220508.9.Iff8dfbeef5f76f776cf3a84807b0ff3fd5a491ac@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 With P2SB the initial BAR (base-address register) is set up by TPL and this is used unchanged right through U-Boot. At present the reading of this address is split between the ofdata() and probe() methods. There are a few problems that are unique to the p2sb. One is that its children need to call pcr_read32(), etc. which needs to have the p2sb address correct. Also some of its children are pinctrl devices and pinctrl is used when any device is probed. So p2sb really needs to get its base address set up in ofdata_to_platdata(), before it is probed. Another point is that reading the p2sb BAR will not work if the p2sb is hidden. The FSP-S seems to hide it, presumably to avoid confusing PCI enumeration. Reading ofdata in ofdata_to_platdata() is the correct place anyway, so this is easy to fix. Move the code into one place and use the early-regs property in all cases for simplicity and to avoid needing to probe any PCI devices just to read the BAR. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner Tested-by: Wolfgang Wallner --- arch/x86/cpu/apollolake/p2sb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/arch/x86/cpu/apollolake/p2sb.c b/arch/x86/cpu/apollolake/p2sb.c index 7b5a473bbd..a3d8e094e7 100644 --- a/arch/x86/cpu/apollolake/p2sb.c +++ b/arch/x86/cpu/apollolake/p2sb.c @@ -92,27 +92,25 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev) #if !CONFIG_IS_ENABLED(OF_PLATDATA) int ret; + u32 base[2]; + ret = dev_read_u32_array(dev, "early-regs", base, ARRAY_SIZE(base)); + if (ret) + return log_msg_ret("Missing/short early-regs", ret); + plat->mmio_base = base[0]; + /* TPL sets up the initial BAR */ if (spl_phase() == PHASE_TPL) { - u32 base[2]; - - /* TPL sets up the initial BAR */ - ret = dev_read_u32_array(dev, "early-regs", base, - ARRAY_SIZE(base)); - if (ret) - return log_msg_ret("Missing/short early-regs", ret); - plat->mmio_base = base[0]; plat->bdf = pci_get_devfn(dev); if (plat->bdf < 0) return log_msg_ret("Cannot get p2sb PCI address", - plat->bdf); + plat->bdf); } + upriv->mmio_base = plat->mmio_base; #else plat->mmio_base = plat->dtplat.early_regs[0]; plat->bdf = pci_ofplat_get_devfn(plat->dtplat.reg[0]); -#endif upriv->mmio_base = plat->mmio_base; - debug("p2sb: mmio_base=%x\n", (uint)plat->mmio_base); +#endif return 0; } @@ -121,17 +119,8 @@ static int apl_p2sb_probe(struct udevice *dev) { if (spl_phase() == PHASE_TPL) return apl_p2sb_early_init(dev); - else { - struct p2sb_platdata *plat = dev_get_platdata(dev); - - plat->mmio_base = dev_read_addr_pci(dev); - /* Don't set BDF since it should not be used */ - if (!plat->mmio_base || plat->mmio_base == FDT_ADDR_T_NONE) - return -EINVAL; - - if (spl_phase() == PHASE_SPL) - return apl_p2sb_spl_init(dev); - } + else if (spl_phase() == PHASE_SPL) + return apl_p2sb_spl_init(dev); return 0; } From patchwork Mon Jan 27 05:05:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229511 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=Tns9PIRG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d9m289Jz9sR1 for ; Mon, 27 Jan 2020 16:10:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2E878181F; Mon, 27 Jan 2020 06:09:23 +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="Tns9PIRG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 02915815D3; Mon, 27 Jan 2020 06:08:41 +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 CDCBF81722 for ; Mon, 27 Jan 2020 06:08: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 t26so8540782ioi.13 for ; Sun, 26 Jan 2020 21:08: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=k3ZPy5JhVfu401FxH/ODYlXg25Dtyv7Fv0p3uWtnDvo=; b=Tns9PIRGhtkzibzlJdZv6QmcMXd7HUCwsuMPvIU7xEN34TmeTr7byFDEpe2iyqcL06 Bn5JhI0aeDYEcKrK5ObJuqEAfDS5m3J3xxl+24rbugAduXv61m34oalP0tATVrzrAWVm BnEPAQpkbCM03mqvq5LdhyVYFBzhEw25u79hU= 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=k3ZPy5JhVfu401FxH/ODYlXg25Dtyv7Fv0p3uWtnDvo=; b=m+2FaYkU6QTVI+8PkrzxjetzbQrxncocx7GFn86kTpJHXZ5f2yHF86uEiscR76PWBa YVcAX90aCLxRnXRQqHcSnFa4JkIejypMS+Z559L9KwI4QMrbn26rmvIdkXTZorXRLY8S XMDpZ2XeznN4I+oPA8EBxdooRnpC5BnJVglmY53HyDkI/BO5LM0vp6Z044OrMbYIGrN8 pU80Q5eR2euE+sG9pYzHxP72IvzDNRWQGrt8i3qR57Rq5cxA00NS8L5+ZriGufROaS3p kcEf/mKHMMBCv3UUVEZDd2FySfA7Kv5rPBy0XANYR0UQk5LEFUmIf0UpY+Juw4VhOzfS E5NA== X-Gm-Message-State: APjAAAUVvHF89xAC/Aqcw0Ufk/55ErllOj7qkq7wIfGFDT/FgbwOlm0K Vb3Mx9b9jiDU7yS/VkC3Vptgto1hIekI+Q== X-Google-Smtp-Source: APXvYqy7IhNnxJAqSpV5+XzRVQoMxN36LyHez4qqHvi4p3TbGsfIuYdpx/TSuZCVVzNzRETL2cYuMw== X-Received: by 2002:a02:a415:: with SMTP id c21mr11711163jal.45.1580101713555; Sun, 26 Jan 2020 21:08: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 h23sm4313195ilf.57.2020.01.26.21.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 010/108] pci: Adjust dm_pci_read_bar32() to return errors correctly Date: Sun, 26 Jan 2020 22:05:17 -0700 Message-Id: <20200126220508.10.I36321d5e30daf051900f01f6289dfc58439871ea@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 At present if reading a BAR returns 0xffffffff (e.g. the device is not present) then the value is masked and a different value is returned. This makes it harder to detect the problem when debugging. Update the function to avoid masking in this case. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/pci/pci-uclass.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index f5f713fdf4..ed57ff9ebe 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1210,7 +1210,14 @@ u32 dm_pci_read_bar32(const struct udevice *dev, int barnum) bar = PCI_BASE_ADDRESS_0 + barnum * 4; dm_pci_read_config32(dev, bar, &addr); - if (addr & PCI_BASE_ADDRESS_SPACE_IO) + + /* + * If we get an invalid address, return this so that comparisons with + * FDT_ADDR_T_NONE work correctly + */ + if (addr == 0xffffffff) + return addr; + else if (addr & PCI_BASE_ADDRESS_SPACE_IO) return addr & PCI_BASE_ADDRESS_IO_MASK; else return addr & PCI_BASE_ADDRESS_MEM_MASK; From patchwork Mon Jan 27 05:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229509 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GVqVXKB+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d9L0flVz9sR1 for ; Mon, 27 Jan 2020 16:10:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D1D181817; Mon, 27 Jan 2020 06:09:15 +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="GVqVXKB+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3453E8178D; Mon, 27 Jan 2020 06:08:41 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 8EF3B81740 for ; Mon, 27 Jan 2020 06:08:35 +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-xd42.google.com with SMTP id m25so8555555ioo.8 for ; Sun, 26 Jan 2020 21:08:35 -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=aZP9oMATkPXWXIgck8lVIjZqUjfl1H68kOQzynM+74w=; b=GVqVXKB+/oCzXj/V/1EIcTv4OGu15a3Izsq0NJX8edQxNrFt+QeSSwtC5j2RAGpdLk h80ewu1aQtPO2w154IImP1JbZ1o2Amr9pQvHZ9aky4pLoifR3JDG/RWFsEhrRzBuV2ys FMduN32GEBU/xLFfTyyu7RnSlEQRM+sDpo1sc= 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=aZP9oMATkPXWXIgck8lVIjZqUjfl1H68kOQzynM+74w=; b=mBntxjTwBocCwNqPjgvOtmQEeC149sHAFM1cmVwMpjtMbS0yv+Hx6UIbhqiSME14Z2 AHsfy4UIjdR6YXqQ8QwO4BGjk32AB+tw87H+YpjSBzrx+34MNV1YhEjCqBzDYGNyVir0 /sJbHLLqEjVzX3QUrwnCVCTuGw5bQtMrGy6H/8YCM6j8/9MAqgOmUSx6Jbv0yvtDnjXp DAuuTMVnh4QLtLRZdNtX9FCiC6+eScYMlv6nAIgjKwlYoreUL0a8ZIJYLZh4Rj0LOXCI /6QYwCMv8B0YgKPGMdN5ml0WZ5w/vAoDB6NO97sB/pn0J4NRf7ASgZ/5+P9FYXCPCC3W Go8A== X-Gm-Message-State: APjAAAVnHvBDmj+PiMMopLilCLTy5JPm39vsCdCC9auNXgVSW1l9l533 IopYtCP8cvfsdikM3+sgN6ZTh7hSHmV7bw== X-Google-Smtp-Source: APXvYqyQtDGL3hauGCOaA1Nf/VR2n67Sl77k9FUK/zkwPbUKZ/YSDk4GxoosiGyOllYcxD/LB/RJyg== X-Received: by 2002:a5e:840f:: with SMTP id h15mr11794947ioj.286.1580101714271; Sun, 26 Jan 2020 21:08:34 -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.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 011/108] x86: apl: Add Global NVS table header Date: Sun, 26 Jan 2020 22:05:18 -0700 Message-Id: <20200126220508.11.I4aa2fe09882dcf5a040603469bac136e4342d350@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 Add the C version of this header. It includes a few Chrome OS bits which are disabled for a normal build. Signed-off-by: Simon Glass --- .../include/asm/arch-apollolake/global_nvs.h | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/global_nvs.h diff --git a/arch/x86/include/asm/arch-apollolake/global_nvs.h b/arch/x86/include/asm/arch-apollolake/global_nvs.h new file mode 100644 index 0000000000..0ea6da5cf9 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/global_nvs.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2015-2017 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + * Copyright Google LLC 2019 + * + * Modified from coreboot apollolake/include/soc/nvs.h + */ + +#ifndef _GLOBAL_NVS_H_ +#define _GLOBAL_NVS_H_ + +struct __packed acpi_global_nvs { + /* Miscellaneous */ + u8 pcnt; /* 0x00 - Processor Count */ + u8 ppcm; /* 0x01 - Max PPC State */ + u8 lids; /* 0x02 - LID State */ + u8 pwrs; /* 0x03 - AC Power State */ + u8 dpte; /* 0x04 - Enable DPTF */ + u32 cbmc; /* 0x05 - 0x08 - coreboot Memory Console */ + u64 pm1i; /* 0x09 - 0x10 - System Wake Source - PM1 Index */ + u64 gpei; /* 0x11 - 0x18 - GPE Wake Source */ + u64 nhla; /* 0x19 - 0x20 - NHLT Address */ + u32 nhll; /* 0x21 - 0x24 - NHLT Length */ + u32 prt0; /* 0x25 - 0x28 - PERST_0 Address */ + u8 scdp; /* 0x29 - SD_CD GPIO portid */ + u8 scdo; /* 0x2A - GPIO pad offset relative to the community */ + u8 uior; /* 0x2B - UART debug controller init on S3 resume */ + u8 ecps; /* 0x2C - SGX Enabled status */ + u64 emna; /* 0x2D - 0x34 EPC base address */ + u64 elng; /* 0x35 - 0x3C EPC Length */ + u8 unused[195]; +#ifdef CONFIG_CHROMEOS + /* ChromeOS specific (0x100 - 0xfff) */ + struct chromeos_acpi chromeos; +#else + u8 unused2[0xf00]; +#endif +}; +#ifdef CONFIG_CHROMEOS +check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET); +#endif + +#endif /* _GLOBAL_NVS_H_ */ From patchwork Mon Jan 27 05:05:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229510 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=cbpb9btW; 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 485d9X69xnz9sR1 for ; Mon, 27 Jan 2020 16:10:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8E5B88181E; Mon, 27 Jan 2020 06:09:18 +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="cbpb9btW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A240E81780; Mon, 27 Jan 2020 06:08:41 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 99FCA815D3 for ; Mon, 27 Jan 2020 06:08:36 +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-xd44.google.com with SMTP id c16so8566206ioh.6 for ; Sun, 26 Jan 2020 21:08:36 -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=JFphTJAcQrr0gHHzH0hozRFnbZmS7rg/Itm+2T8jFHk=; b=cbpb9btWtMOqP3zcCRJkRVHwgj7Y21uTbhFUJzo/QJhPKs8xS3pcgqpFHUNx7cY3RZ aELp0lA6tmWyv0UmmiBChkusHN+zQ4lFNFfFz6k5mxNtp8yWhcRgKtW6g7Y9bCgKkKnY MrTzki4/w5I1CZ1nJzi46ApWgoTFgq7EscWds= 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=JFphTJAcQrr0gHHzH0hozRFnbZmS7rg/Itm+2T8jFHk=; b=E3IEpYSuZN9/OfaavVwQCJnTqq45FjtGjgy4FyZESMIf9/uaLjXltWBknn3Pp7tMBb Xhz7z6EDOz0rZr8XDabxVF0cdbx5L0Gksd/8uBvpmEArelwBaF6lgdmpWZuwAz+QC4vh RC2DT/9fI7qNlZu00vaExoMmL60slP+LxdFvy14PsgFk1qvzZckgaengB3WzdEX7G+V3 p8ZWlN3meap7qwZ+jGdRxcKyPxDeztkuPqIy5PDh5NWqYZkm/VmkB/UZcPVAL+URG/rw eLPuUIwyVQvG8nzdvWwCkaif/kVoXU/rasgUqnGh0cH3+kNNY8NDAosjC8EE87VSqWNv 3XZQ== X-Gm-Message-State: APjAAAWJ75RNFh+OfbuYCJDBRUxw+0m/C9qqNOj4ODYk9XpazChr0Lcc tZY0gNU9qCPD39gVU9ZWuKX46rLBE6hq1A== X-Google-Smtp-Source: APXvYqzP6g+SzHv+QX65cYuBsCtAxD3/ZGxJ9adhfwbPKoiNwUyTTgNmflhYi8Z2DJ8JdM5pqsVhOQ== X-Received: by 2002:a05:6602:210a:: with SMTP id x10mr9665840iox.151.1580101715212; Sun, 26 Jan 2020 21:08:35 -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.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 012/108] dm: core: Add basic ACPI support Date: Sun, 26 Jan 2020 22:05:19 -0700 Message-Id: <20200126220508.12.Ia5e9ba1f146567b18e9183395484bf04d2e5ba6a@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: , Cc: Pavel Herrmann 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 ACPI (Advanced Configuration and Power Interface) is an Intel standard for specifying information about a platform. It is a little like device tree but considerably more complicated and with more backslashes. A primary difference is that it supports an interpreted bytecode language. Driver model does not use ACPI for U-Boot's configuration, but it is convenient to have it support generation of ACPI tables for passing to Linux, etc. As a starting point, add an optional set of ACPI operations to each device. Initially only a single operation is available, to obtain the ACPI name for the device. More operations are added later. Enable ACPI for sandbox to ensure build coverage and so that we can add tests. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/core/Kconfig | 9 ++++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 32 +++++++++++++++++++ include/dm/acpi.h | 73 +++++++++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ 5 files changed, 120 insertions(+) create mode 100644 drivers/core/acpi.c create mode 100644 include/dm/acpi.h diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index 3b95b5387b..a3b0399342 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -261,4 +261,13 @@ config DM_DEV_READ_INLINE bool default y if !OF_LIVE +config ACPIGEN + bool "Support ACPI table generation in driver model" + default y if SANDBOX || GENERATE_ACPI_TABLE + help + This option enables generation of ACPI tables using driver-model + devices. It adds a new operation struct to each driver, to support + things like generating device-specific tables and returning the ACPI + name of a device. + endmenu diff --git a/drivers/core/Makefile b/drivers/core/Makefile index bce7467da1..c707026a3a 100644 --- a/drivers/core/Makefile +++ b/drivers/core/Makefile @@ -3,6 +3,7 @@ # Copyright (c) 2013 Google, Inc obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c new file mode 100644 index 0000000000..45542199f5 --- /dev/null +++ b/drivers/core/acpi.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Core driver model support for ACPI table generation + * + * Copyright 2019 Google LLC + * Written by Simon Glass + */ + +#define LOG_CATEOGRY LOGC_ACPI + +#include +#include +#include +#include + +int acpi_return_name(char *out_name, const char *name) +{ + strcpy(out_name, name); + + return 0; +} + +int acpi_get_name(const struct udevice *dev, char *out_name) +{ + struct acpi_ops *aops; + + aops = device_get_acpi_ops(dev); + if (aops && aops->get_name) + return aops->get_name(dev, out_name); + + return -ENOSYS; +} diff --git a/include/dm/acpi.h b/include/dm/acpi.h new file mode 100644 index 0000000000..120576adc0 --- /dev/null +++ b/include/dm/acpi.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Core ACPI (Advanced Configuration and Power Interface) support + * + * Copyright 2019 Google LLC + * Written by Simon Glass + */ + +#ifndef __DM_ACPI_H__ +#define __DM_ACPI_H__ + +/* Allow operations to be optional for ACPI */ +#if CONFIG_IS_ENABLED(ACPIGEN) +#define acpi_ops_ptr(_ptr) .acpi_ops = _ptr, +#else +#define acpi_ops_ptr(_ptr) +#endif + +/* Length of an ACPI name string, excluding nul terminator */ +#define ACPI_NAME_LEN 4 + +/* Length of an ACPI name string including nul terminator */ +#define ACPI_NAME_MAX 5 + +/** + * struct acpi_ops - ACPI operations supported by driver model + */ +struct acpi_ops { + /** + * get_name() - Obtain the ACPI name of a device + * + * @dev: Device to check + * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX + * bytes + * @return 0 if OK, -ENOENT if no name is available, other -ve value on + * other error + */ + int (*get_name)(const struct udevice *dev, char *out_name); +}; + +#define device_get_acpi_ops(dev) ((dev)->driver->acpi_ops) + +/** + * acpi_get_name() - Obtain the ACPI name of a device + * + * @dev: Device to check + * @out_name: Place to put the name, must hold at least ACPI_NAME_MAX + * bytes + * @return 0 if OK, -ENOENT if no name is available, other -ve value on + * other error + */ +int acpi_get_name(const struct udevice *dev, char *out_name); + +/** + * acpi_return_name() - Copy an ACPI name to an output buffer + * + * This convenience function can be used to return a literal string as a name + * in functions that implement the get_name() method. + * + * For example: + * + * static int mydev_get_name(const struct udevice *dev, char *out_name) + * { + * return acpi_return_name(out_name, "WIBB"); + * } + * + * @out_name: Place to put the name + * @name: Name to copy + * @return 0 (always) + */ +int acpi_return_name(char *out_name, const char *name); + +#endif diff --git a/include/dm/device.h b/include/dm/device.h index 1632b56b79..c2e12cd151 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -240,6 +240,8 @@ struct udevice_id { * pointers defined by the driver, to implement driver functions required by * the uclass. * @flags: driver flags - see DM_FLAGS_... + * @acpi_ops: Advanced Configuration and Power Interface (ACPI) operations, + * allowing the device to add things to the ACPI tables passed to Linux */ struct driver { char *name; @@ -259,6 +261,9 @@ struct driver { int per_child_platdata_auto_alloc_size; const void *ops; /* driver-specific operations */ uint32_t flags; +#if CONFIG_IS_ENABLED(ACPIGEN) + struct acpi_ops *acpi_ops; +#endif }; /* Declare a new U-Boot driver */ From patchwork Mon Jan 27 05:05:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229514 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=lE2RLtsc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dBQ0h21z9sR1 for ; Mon, 27 Jan 2020 16:11:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8779E817BF; Mon, 27 Jan 2020 06:10:20 +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="lE2RLtsc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C02468178D; Mon, 27 Jan 2020 06:08:43 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 308FA8177D for ; Mon, 27 Jan 2020 06:08: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-io1-xd44.google.com with SMTP id k24so8558400ioc.4 for ; Sun, 26 Jan 2020 21:08: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=xf8Ove7y9f0Alct+5DtIMhAeSqeDvYBU9CmoFcySMHc=; b=lE2RLtsctNkH0CwhsL7UKbTXWobx6bcsMBzxt1UHj3QE9q/23wpOrK/4RbaK17yYIv cUYNqhVJLYI6tpzT+W3fEH8hT9S4fVcZzJ5eLQWUHCnmUlzUwXSD940CVq4f3McI4xfc Z3kE9upjDLirjj7Czp3yf7EvnUNvgZCxH2DnE= 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=xf8Ove7y9f0Alct+5DtIMhAeSqeDvYBU9CmoFcySMHc=; b=e9amDuihyBegwTe+DizBfhZTqBO3lmuJ0X/G+UR4WmgxH33jzn96ThYpZRXJM8MXul HNgCtKxHUtcb6IQ//UwhaXOpPie5Ii3Awha/4ZhpsjzRM0ogOqLpWj6tw70VGboH+wV6 pcSlGYhtX5S7J1JXD/cL2XURq9A1yD03NC0sV9XDRJ1CZaykp5BZ4aXJocQpPYs4ybYO 0HZ6e8FdC5bydtX1a2hMpfldpp9dwodFlEOyLsnYGmkQUnGYgbUr3AzTCk9IRuhjt8kI Ha3yxXhoEWLLm/cf/P29yZuLO3o6zTB2ZO40geQ5hT5l1tSRGRF/iwTldZw5dmCUKGdY nvew== X-Gm-Message-State: APjAAAUwNbu2q1lhvTUsgz+crzbs8f72tfhqIVprjKAJYzjKDJ8bjomV uHh2eTTTbob52IoBrm1Ku/CCw6PB0KbvFg== X-Google-Smtp-Source: APXvYqz2B84YY/BwDRGjBb0lsKnt9mT7kRkNdGNtcjhopjBO3uagUoTlOLs1ZEKOigYtZFqznqHYCw== X-Received: by 2002:a05:6638:723:: with SMTP id j3mr12331960jad.131.1580101715977; Sun, 26 Jan 2020 21:08:35 -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.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:35 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 013/108] acpi: Add a binding for ACPI settings in the device tree Date: Sun, 26 Jan 2020 22:05:20 -0700 Message-Id: <20200126220508.13.I7842b2dd0d6b475301fc044c6640d8089873053f@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 Devices need to report various identifiers in the ACPI tables. Rather than hard-coding these in drivers it is typically better to put them in the device tree. Add a binding file to describe this. Signed-off-by: Simon Glass --- doc/device-tree-bindings/device.txt | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 doc/device-tree-bindings/device.txt diff --git a/doc/device-tree-bindings/device.txt b/doc/device-tree-bindings/device.txt new file mode 100644 index 0000000000..e625e67f43 --- /dev/null +++ b/doc/device-tree-bindings/device.txt @@ -0,0 +1,37 @@ +Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes a PRIC (ACPI PowerResource) to be written containing the + properties provided by this binding, to describe how to handle powering the + device up and down using GPIOs + - acpi,cid : Contains the string to use as the compatible ID (_CID) + - acpi,compatible : compatible string to report + - acpi,desc : Contains the string to use as the _DDN (DOS (Disk Operating + System) Device Name) + - acpi,hid : Contains the string to use as the HID (Human Interface Device) + identifier _HID + - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that + Linux will not re-init the device + - acpi,uid : _UID value for device + + +Example +------- + +synaptics_touchpad: synaptics-touchpad@2c { + compatible = "i2c-chip"; + reg = <0x2c>; + acpi,hid = "PNP0C50"; + acpi,cid = "PNP0C50"; + acpi,desc = "Synaptics Touchpad"; + interrupts-extended = <&acpi_gpe GPIO_18_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + acpi,hid-desc-reg-offset = <0x20>; +}; From patchwork Mon Jan 27 05:05: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: 1229515 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=VyQuN8JT; 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 485dBf57qpz9sRW for ; Mon, 27 Jan 2020 16:11:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 874FD808A5; Mon, 27 Jan 2020 06:10:22 +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="VyQuN8JT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3E798179D; Mon, 27 Jan 2020 06:08:46 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 F10C58172A for ; Mon, 27 Jan 2020 06:08: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-io1-xd42.google.com with SMTP id n11so8552200iom.9 for ; Sun, 26 Jan 2020 21:08: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=sS4zBdUwejwyT1R0ltTtFcUI4zepXhyW/zPyt+HbwcU=; b=VyQuN8JTm2aifruH6T/0cjyMukADjJdGgygT8nOXh8I6RZF6tn03Mn+nOdGN6hVzlq Nc1NItcVvW6LSUsiXdHzTrYFQJ+MnxPx7byO8ABoBZPF5vBx2HJUEQJslCtWKdNO3IJp 1fgAUeD8wUoo8l5cQ1Hn3HMcvA5hQw/LgEGHg= 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=sS4zBdUwejwyT1R0ltTtFcUI4zepXhyW/zPyt+HbwcU=; b=r9fEkfq3/0TTdnq4PfJCZjJSRbDrAJJ//rscjvM5yMNgWkNJT2CoYTGn2e0dBjzCCP XzvjHS48IePNMul4YaHe1TIdzySnTbVjvI7lfsJ13CnuRSm1l+0dJ4e6bNfR4DaE/w+w RbU2/vzYl3HdTGIoNFHlNtyxinviXQWofKct7g9GIkzEffPt6O7WvuYMlneqMR7jI1BF mvEdYayS0C86WeVvvnJ7Tt75hA79LnAfV4hmUvNWO+pQJZKx1xwkivOwpejC4vVWknGx RqCp80bDfzPWkTJiiWMXVeQ62d0WsecVEcebkJZ8K0QGwCbpnGFZyTkqjUrVQAmJ2qUW P+Ow== X-Gm-Message-State: APjAAAWw+e3y4RwmJU1t9Qzv9fePYDR336dIFKFEvqcNMed5+CqcF7AL M/qNPAIltGCBxzzoyXAQ88D/KWcZj86IBg== X-Google-Smtp-Source: APXvYqwipCM8bzGTZxBhj4TEC5kFfcEforp3M4l/IegwcBqpLWvqqP3Hivv0sp3cUpE2BqO3aMhzGw== X-Received: by 2002:a5d:824c:: with SMTP id n12mr11121456ioo.234.1580101716642; Sun, 26 Jan 2020 21:08: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.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 014/108] acpi: Add a simple sandbox test Date: Sun, 26 Jan 2020 22:05:21 -0700 Message-Id: <20200126220508.14.Ife90d6e6cfa90e642e73328168a00804b1dc6fd4@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 Add a sandbox test for the basic ACPI functionality we have so far. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/sandbox/dts/test.dts | 4 +++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 test/dm/acpi.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 1a8a50e27d..34dc7fda98 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -206,6 +206,10 @@ compatible = "denx,u-boot-devres-test"; }; + acpi-test { + compatible = "denx,u-boot-acpi-test"; + }; + clocks { clk_fixed: clk-fixed { compatible = "fixed-clock"; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index c9f49df3f2..f49ea5d852 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -20,6 +20,7 @@ enum uclass_id { UCLASS_TEST_PROBE, UCLASS_TEST_DUMMY, UCLASS_TEST_DEVRES, + UCLASS_TEST_ACPI, UCLASS_SPI_EMUL, /* sandbox SPI device emulator */ UCLASS_I2C_EMUL, /* sandbox I2C device emulator */ UCLASS_I2C_EMUL_PARENT, /* parent for I2C device emulators */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 85cc0f7fb8..fab157b5d8 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_UT_DM) += test-uclass.o # subsystem you must add sandbox tests here. obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) +obj-$(CONFIG_ACPIGEN) += acpi.o obj-$(CONFIG_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o diff --git a/test/dm/acpi.c b/test/dm/acpi.c new file mode 100644 index 0000000000..e3519d4689 --- /dev/null +++ b/test/dm/acpi.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for ACPI table generation + * + * Copyright 2019 Google LLC + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include + +#define ACPI_TEST_DEV_NAME "ABCD" + +static int testacpi_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_return_name(out_name, ACPI_TEST_DEV_NAME); +} + +struct acpi_ops testacpi_ops = { + .get_name = testacpi_get_name, +}; + +static const struct udevice_id testacpi_ids[] = { + { .compatible = "denx,u-boot-acpi-test" }, + { } +}; + +U_BOOT_DRIVER(testacpi_drv) = { + .name = "testacpi_drv", + .of_match = testacpi_ids, + .id = UCLASS_TEST_ACPI, + acpi_ops_ptr(&testacpi_ops) +}; + +UCLASS_DRIVER(testacpi) = { + .name = "testacpi", + .id = UCLASS_TEST_ACPI, +}; + +/* Test ACPI get_name() */ +static int dm_test_acpi_get_name(struct unit_test_state *uts) +{ + char name[ACPI_NAME_MAX]; + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); + ut_assertok(acpi_get_name(dev, name)); + ut_asserteq_str(ACPI_TEST_DEV_NAME, name); + + return 0; +} +DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229518 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=awq/3J3S; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dCP2jDgz9sR1 for ; Mon, 27 Jan 2020 16:12:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 861A7817F3; Mon, 27 Jan 2020 06:10:34 +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="awq/3J3S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A03FF817D8; Mon, 27 Jan 2020 06:08:51 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 239C881764 for ; Mon, 27 Jan 2020 06:08:39 +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-xd44.google.com with SMTP id e7so8539010iof.11 for ; Sun, 26 Jan 2020 21:08:39 -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=MyRh2qquPToZusjxYJqJ0Gj8vTTu2iI7C10aLOe+gxA=; b=awq/3J3Sf1Rzii/tEoN8QwO0EBwsccnY8muPlHfe3d/cu4RXV49NE72JAQ8U3x15HX ROP2YxKvZJ8DqknSeKKI8cWZ9HGAIg2Kk+DMGLuhqI9QhT3N5lv7+wI0rJDT5XrtryEL MtX7JlxrL+R/SNfWErnbSpFQR5qII4TjV+6Fs= 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=MyRh2qquPToZusjxYJqJ0Gj8vTTu2iI7C10aLOe+gxA=; b=g1TCj/CNIlf1MJ6mLJf1ZzVY/nE9WlgzOjEN2OPt1G4UHMEvX+xINiFgkf0cVQ+B3h DlsG/clRoSiPFEKwCh/fj+zx4ihkygTHL7bK1LOA0cvUwqyoXyvw6sNM/ieM9jVJqtSY wUci6fsR0+7sV76Lcxa9VpRMXFetVp9Rhuzj11nV9NXYUcGJrRW+8YzYGyLIdnso9GTX +run3N64Fs7y1SkRCcFIVG2lHqT9L+iE+q0QIyhSA+URqWF7YJNPno7dGGSkXQ5JWKwj unKoF9rbRpuEOeq+hpJol0kD/Ne5lsXFin5Bsrvul91eSyVon72QB6srHm5sPhCo1h6M kGKQ== X-Gm-Message-State: APjAAAVFPq9h+773V78PY1gYL7DB+TxQfoHO9Mj3uO6pw1y8zZPVSprM HR0XdqZlxg5kJlOmu32KYOC7kEVQC85oLQ== X-Google-Smtp-Source: APXvYqwqQK7e12n5db/sz/HR8d57H99PGb1G+ZD05o+v6bQInv9OvhOyaRtxoP0ceS3apcsB9l6aBA== X-Received: by 2002:a6b:ee07:: with SMTP id i7mr10685243ioh.244.1580101717380; Sun, 26 Jan 2020 21:08:37 -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.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 015/108] x86: Move acpi_table header to main include/ directory Date: Sun, 26 Jan 2020 22:05:22 -0700 Message-Id: <20200126220508.15.If8795289f9cb41804659b2b37b17185f588b3175@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 This file is potentially useful to other architectures saddled with ACPI so move it into a common location. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- arch/x86/cpu/baytrail/acpi.c | 2 +- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/quark/acpi.c | 2 +- arch/x86/cpu/tangier/acpi.c | 2 +- arch/x86/include/asm/acpi_table.h | 376 ---------------------------- arch/x86/lib/acpi.c | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/acpi_table.c | 2 +- arch/x86/lib/tables.c | 2 +- arch/x86/lib/zimage.c | 2 +- include/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 404 insertions(+), 386 deletions(-) create mode 100644 include/acpi_table.h diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c index f44228e693..856af95556 100644 --- a/arch/x86/cpu/baytrail/acpi.c +++ b/arch/x86/cpu/baytrail/acpi.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index d82305303a..3891de088f 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c index 7b6fc2f4a5..dd562a6e2f 100644 --- a/arch/x86/cpu/quark/acpi.c +++ b/arch/x86/cpu/quark/acpi.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c index 8b128138b0..768c4dcbc8 100644 --- a/arch/x86/cpu/tangier/acpi.c +++ b/arch/x86/cpu/tangier/acpi.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 7588913f93..22d54057f1 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -9,382 +9,6 @@ #ifndef __ASM_ACPI_TABLE_H__ #define __ASM_ACPI_TABLE_H__ -#define RSDP_SIG "RSD PTR " /* RSDP pointer signature */ -#define OEM_ID "U-BOOT" /* U-Boot */ -#define OEM_TABLE_ID "U-BOOTBL" /* U-Boot Table */ -#define ASLC_ID "INTL" /* Intel ASL Compiler */ - -#define ACPI_RSDP_REV_ACPI_1_0 0 -#define ACPI_RSDP_REV_ACPI_2_0 2 - -/* - * RSDP (Root System Description Pointer) - * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum - */ -struct acpi_rsdp { - char signature[8]; /* RSDP signature */ - u8 checksum; /* Checksum of the first 20 bytes */ - char oem_id[6]; /* OEM ID */ - u8 revision; /* 0 for ACPI 1.0, others 2 */ - u32 rsdt_address; /* Physical address of RSDT (32 bits) */ - u32 length; /* Total RSDP length (incl. extended part) */ - u64 xsdt_address; /* Physical address of XSDT (64 bits) */ - u8 ext_checksum; /* Checksum of the whole table */ - u8 reserved[3]; -}; - -/* Generic ACPI header, provided by (almost) all tables */ -struct __packed acpi_table_header { - char signature[4]; /* ACPI signature (4 ASCII characters) */ - u32 length; /* Table length in bytes (incl. header) */ - u8 revision; /* Table version (not ACPI version!) */ - volatile u8 checksum; /* To make sum of entire table == 0 */ - char oem_id[6]; /* OEM identification */ - char oem_table_id[8]; /* OEM table identification */ - u32 oem_revision; /* OEM revision number */ - char aslc_id[4]; /* ASL compiler vendor ID */ - u32 aslc_revision; /* ASL compiler revision number */ -}; - -/* A maximum number of 32 ACPI tables ought to be enough for now */ -#define MAX_ACPI_TABLES 32 - -/* RSDT (Root System Description Table) */ -struct acpi_rsdt { - struct acpi_table_header header; - u32 entry[MAX_ACPI_TABLES]; -}; - -/* XSDT (Extended System Description Table) */ -struct acpi_xsdt { - struct acpi_table_header header; - u64 entry[MAX_ACPI_TABLES]; -}; - -/* FADT Preferred Power Management Profile */ -enum acpi_pm_profile { - ACPI_PM_UNSPECIFIED = 0, - ACPI_PM_DESKTOP, - ACPI_PM_MOBILE, - ACPI_PM_WORKSTATION, - ACPI_PM_ENTERPRISE_SERVER, - ACPI_PM_SOHO_SERVER, - ACPI_PM_APPLIANCE_PC, - ACPI_PM_PERFORMANCE_SERVER, - ACPI_PM_TABLET -}; - -/* FADT flags for p_lvl2_lat and p_lvl3_lat */ -#define ACPI_FADT_C2_NOT_SUPPORTED 101 -#define ACPI_FADT_C3_NOT_SUPPORTED 1001 - -/* FADT Boot Architecture Flags */ -#define ACPI_FADT_LEGACY_FREE 0x00 -#define ACPI_FADT_LEGACY_DEVICES (1 << 0) -#define ACPI_FADT_8042 (1 << 1) -#define ACPI_FADT_VGA_NOT_PRESENT (1 << 2) -#define ACPI_FADT_MSI_NOT_SUPPORTED (1 << 3) -#define ACPI_FADT_NO_PCIE_ASPM_CONTROL (1 << 4) - -/* FADT Feature Flags */ -#define ACPI_FADT_WBINVD (1 << 0) -#define ACPI_FADT_WBINVD_FLUSH (1 << 1) -#define ACPI_FADT_C1_SUPPORTED (1 << 2) -#define ACPI_FADT_C2_MP_SUPPORTED (1 << 3) -#define ACPI_FADT_POWER_BUTTON (1 << 4) -#define ACPI_FADT_SLEEP_BUTTON (1 << 5) -#define ACPI_FADT_FIXED_RTC (1 << 6) -#define ACPI_FADT_S4_RTC_WAKE (1 << 7) -#define ACPI_FADT_32BIT_TIMER (1 << 8) -#define ACPI_FADT_DOCKING_SUPPORTED (1 << 9) -#define ACPI_FADT_RESET_REGISTER (1 << 10) -#define ACPI_FADT_SEALED_CASE (1 << 11) -#define ACPI_FADT_HEADLESS (1 << 12) -#define ACPI_FADT_SLEEP_TYPE (1 << 13) -#define ACPI_FADT_PCI_EXPRESS_WAKE (1 << 14) -#define ACPI_FADT_PLATFORM_CLOCK (1 << 15) -#define ACPI_FADT_S4_RTC_VALID (1 << 16) -#define ACPI_FADT_REMOTE_POWER_ON (1 << 17) -#define ACPI_FADT_APIC_CLUSTER (1 << 18) -#define ACPI_FADT_APIC_PHYSICAL (1 << 19) -#define ACPI_FADT_HW_REDUCED_ACPI (1 << 20) -#define ACPI_FADT_LOW_PWR_IDLE_S0 (1 << 21) - -enum acpi_address_space_type { - ACPI_ADDRESS_SPACE_MEMORY = 0, /* System memory */ - ACPI_ADDRESS_SPACE_IO, /* System I/O */ - ACPI_ADDRESS_SPACE_PCI, /* PCI config space */ - ACPI_ADDRESS_SPACE_EC, /* Embedded controller */ - ACPI_ADDRESS_SPACE_SMBUS, /* SMBus */ - ACPI_ADDRESS_SPACE_PCC = 0x0a, /* Platform Comm. Channel */ - ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */ -}; - -enum acpi_address_space_size { - ACPI_ACCESS_SIZE_UNDEFINED = 0, - ACPI_ACCESS_SIZE_BYTE_ACCESS, - ACPI_ACCESS_SIZE_WORD_ACCESS, - ACPI_ACCESS_SIZE_DWORD_ACCESS, - ACPI_ACCESS_SIZE_QWORD_ACCESS -}; - -struct acpi_gen_regaddr { - u8 space_id; /* Address space ID */ - u8 bit_width; /* Register size in bits */ - u8 bit_offset; /* Register bit offset */ - u8 access_size; /* Access size */ - u32 addrl; /* Register address, low 32 bits */ - u32 addrh; /* Register address, high 32 bits */ -}; - -/* FADT (Fixed ACPI Description Table) */ -struct __packed acpi_fadt { - struct acpi_table_header header; - u32 firmware_ctrl; - u32 dsdt; - u8 res1; - u8 preferred_pm_profile; - u16 sci_int; - u32 smi_cmd; - u8 acpi_enable; - u8 acpi_disable; - u8 s4bios_req; - u8 pstate_cnt; - u32 pm1a_evt_blk; - u32 pm1b_evt_blk; - u32 pm1a_cnt_blk; - u32 pm1b_cnt_blk; - u32 pm2_cnt_blk; - u32 pm_tmr_blk; - u32 gpe0_blk; - u32 gpe1_blk; - u8 pm1_evt_len; - u8 pm1_cnt_len; - u8 pm2_cnt_len; - u8 pm_tmr_len; - u8 gpe0_blk_len; - u8 gpe1_blk_len; - u8 gpe1_base; - u8 cst_cnt; - u16 p_lvl2_lat; - u16 p_lvl3_lat; - u16 flush_size; - u16 flush_stride; - u8 duty_offset; - u8 duty_width; - u8 day_alrm; - u8 mon_alrm; - u8 century; - u16 iapc_boot_arch; - u8 res2; - u32 flags; - struct acpi_gen_regaddr reset_reg; - u8 reset_value; - u16 arm_boot_arch; - u8 minor_revision; - u32 x_firmware_ctl_l; - u32 x_firmware_ctl_h; - u32 x_dsdt_l; - u32 x_dsdt_h; - struct acpi_gen_regaddr x_pm1a_evt_blk; - struct acpi_gen_regaddr x_pm1b_evt_blk; - struct acpi_gen_regaddr x_pm1a_cnt_blk; - struct acpi_gen_regaddr x_pm1b_cnt_blk; - struct acpi_gen_regaddr x_pm2_cnt_blk; - struct acpi_gen_regaddr x_pm_tmr_blk; - struct acpi_gen_regaddr x_gpe0_blk; - struct acpi_gen_regaddr x_gpe1_blk; -}; - -/* FACS flags */ -#define ACPI_FACS_S4BIOS_F (1 << 0) -#define ACPI_FACS_64BIT_WAKE_F (1 << 1) - -/* FACS (Firmware ACPI Control Structure) */ -struct acpi_facs { - char signature[4]; /* "FACS" */ - u32 length; /* Length in bytes (>= 64) */ - u32 hardware_signature; /* Hardware signature */ - u32 firmware_waking_vector; /* Firmware waking vector */ - u32 global_lock; /* Global lock */ - u32 flags; /* FACS flags */ - u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ - u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ - u8 version; /* Version 2 */ - u8 res1[3]; - u32 ospm_flags; /* OSPM enabled flags */ - u8 res2[24]; -}; - -/* MADT flags */ -#define ACPI_MADT_PCAT_COMPAT (1 << 0) - -/* MADT (Multiple APIC Description Table) */ -struct acpi_madt { - struct acpi_table_header header; - u32 lapic_addr; /* Local APIC address */ - u32 flags; /* Multiple APIC flags */ -}; - -/* MADT: APIC Structure Type*/ -enum acpi_apic_types { - ACPI_APIC_LAPIC = 0, /* Processor local APIC */ - ACPI_APIC_IOAPIC, /* I/O APIC */ - ACPI_APIC_IRQ_SRC_OVERRIDE, /* Interrupt source override */ - ACPI_APIC_NMI_SRC, /* NMI source */ - ACPI_APIC_LAPIC_NMI, /* Local APIC NMI */ - ACPI_APIC_LAPIC_ADDR_OVERRIDE, /* Local APIC address override */ - ACPI_APIC_IOSAPIC, /* I/O SAPIC */ - ACPI_APIC_LSAPIC, /* Local SAPIC */ - ACPI_APIC_PLATFORM_IRQ_SRC, /* Platform interrupt sources */ - ACPI_APIC_LX2APIC, /* Processor local x2APIC */ - ACPI_APIC_LX2APIC_NMI, /* Local x2APIC NMI */ -}; - -/* MADT: Processor Local APIC Structure */ - -#define LOCAL_APIC_FLAG_ENABLED (1 << 0) - -struct acpi_madt_lapic { - u8 type; /* Type (0) */ - u8 length; /* Length in bytes (8) */ - u8 processor_id; /* ACPI processor ID */ - u8 apic_id; /* Local APIC ID */ - u32 flags; /* Local APIC flags */ -}; - -/* MADT: I/O APIC Structure */ -struct acpi_madt_ioapic { - u8 type; /* Type (1) */ - u8 length; /* Length in bytes (12) */ - u8 ioapic_id; /* I/O APIC ID */ - u8 reserved; - u32 ioapic_addr; /* I/O APIC address */ - u32 gsi_base; /* Global system interrupt base */ -}; - -/* MADT: Interrupt Source Override Structure */ -struct __packed acpi_madt_irqoverride { - u8 type; /* Type (2) */ - u8 length; /* Length in bytes (10) */ - u8 bus; /* ISA (0) */ - u8 source; /* Bus-relative int. source (IRQ) */ - u32 gsirq; /* Global system interrupt */ - u16 flags; /* MPS INTI flags */ -}; - -/* MADT: Local APIC NMI Structure */ -struct __packed acpi_madt_lapic_nmi { - u8 type; /* Type (4) */ - u8 length; /* Length in bytes (6) */ - u8 processor_id; /* ACPI processor ID */ - u16 flags; /* MPS INTI flags */ - u8 lint; /* Local APIC LINT# */ -}; - -/* MCFG (PCI Express MMIO config space BAR description table) */ -struct acpi_mcfg { - struct acpi_table_header header; - u8 reserved[8]; -}; - -struct acpi_mcfg_mmconfig { - u32 base_address_l; - u32 base_address_h; - u16 pci_segment_group_number; - u8 start_bus_number; - u8 end_bus_number; - u8 reserved[4]; -}; - -/* PM1_CNT bit defines */ -#define PM1_CNT_SCI_EN (1 << 0) - -/* ACPI global NVS structure */ -struct acpi_global_nvs; - -/* CSRT (Core System Resource Table) */ -struct acpi_csrt { - struct acpi_table_header header; -}; - -struct acpi_csrt_group { - u32 length; - u32 vendor_id; - u32 subvendor_id; - u16 device_id; - u16 subdevice_id; - u16 revision; - u16 reserved; - u32 shared_info_length; -}; - -struct acpi_csrt_shared_info { - u16 major_version; - u16 minor_version; - u32 mmio_base_low; - u32 mmio_base_high; - u32 gsi_interrupt; - u8 interrupt_polarity; - u8 interrupt_mode; - u8 num_channels; - u8 dma_address_width; - u16 base_request_line; - u16 num_handshake_signals; - u32 max_block_size; -}; - -/* DBG2 definitions are partially used for SPCR interface_type */ - -/* Types for port_type field */ - -#define ACPI_DBG2_SERIAL_PORT 0x8000 -#define ACPI_DBG2_1394_PORT 0x8001 -#define ACPI_DBG2_USB_PORT 0x8002 -#define ACPI_DBG2_NET_PORT 0x8003 - -/* Subtypes for port_subtype field */ - -#define ACPI_DBG2_16550_COMPATIBLE 0x0000 -#define ACPI_DBG2_16550_SUBSET 0x0001 -#define ACPI_DBG2_ARM_PL011 0x0003 -#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D -#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E -#define ACPI_DBG2_ARM_DCC 0x000F -#define ACPI_DBG2_BCM2835 0x0010 - -#define ACPI_DBG2_1394_STANDARD 0x0000 - -#define ACPI_DBG2_USB_XHCI 0x0000 -#define ACPI_DBG2_USB_EHCI 0x0001 - -#define ACPI_DBG2_UNKNOWN 0x00FF - -/* SPCR (Serial Port Console Redirection table) */ -struct __packed acpi_spcr { - struct acpi_table_header header; - u8 interface_type; - u8 reserved[3]; - struct acpi_gen_regaddr serial_port; - u8 interrupt_type; - u8 pc_interrupt; - u32 interrupt; /* Global system interrupt */ - u8 baud_rate; - u8 parity; - u8 stop_bits; - u8 flow_control; - u8 terminal_type; - u8 reserved1; - u16 pci_device_id; /* Must be 0xffff if not PCI device */ - u16 pci_vendor_id; /* Must be 0xffff if not PCI device */ - u8 pci_bus; - u8 pci_device; - u8 pci_function; - u32 pci_flags; - u8 pci_segment; - u32 reserved2; -}; - /* These can be used by the target port */ void acpi_fill_header(struct acpi_table_header *header, char *signature); diff --git a/arch/x86/lib/acpi.c b/arch/x86/lib/acpi.c index cba9c24dd4..2f4cd736f7 100644 --- a/arch/x86/lib/acpi.c +++ b/arch/x86/lib/acpi.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include diff --git a/arch/x86/lib/acpi_s3.c b/arch/x86/lib/acpi_s3.c index 197636c4b5..74a78fd193 100644 --- a/arch/x86/lib/acpi_s3.c +++ b/arch/x86/lib/acpi_s3.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 0d69cf271f..71913b6f65 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index 99f1429363..e359828c8e 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include /** diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 9b5e767ccc..180b18349d 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/acpi_table.h b/include/acpi_table.h new file mode 100644 index 0000000000..b4404a632c --- /dev/null +++ b/include/acpi_table.h @@ -0,0 +1,394 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Helpers for ACPI table generation + * + * Based on acpi.c from coreboot + * + * Copyright 2019 Google LLC + * + * Copyright (C) 2015, Saket Sinha + * Copyright (C) 2016, Bin Meng + */ + +#ifndef __ACPI_TABLE_H__ +#define __ACPI_TABLE_H__ + +#define RSDP_SIG "RSD PTR " /* RSDP pointer signature */ +#define OEM_ID "U-BOOT" /* U-Boot */ +#define OEM_TABLE_ID "U-BOOTBL" /* U-Boot Table */ +#define ASLC_ID "INTL" /* Intel ASL Compiler */ + +#define ACPI_RSDP_REV_ACPI_1_0 0 +#define ACPI_RSDP_REV_ACPI_2_0 2 + +/* + * RSDP (Root System Description Pointer) + * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum + */ +struct acpi_rsdp { + char signature[8]; /* RSDP signature */ + u8 checksum; /* Checksum of the first 20 bytes */ + char oem_id[6]; /* OEM ID */ + u8 revision; /* 0 for ACPI 1.0, others 2 */ + u32 rsdt_address; /* Physical address of RSDT (32 bits) */ + u32 length; /* Total RSDP length (incl. extended part) */ + u64 xsdt_address; /* Physical address of XSDT (64 bits) */ + u8 ext_checksum; /* Checksum of the whole table */ + u8 reserved[3]; +}; + +/* Generic ACPI header, provided by (almost) all tables */ +struct __packed acpi_table_header { + char signature[4]; /* ACPI signature (4 ASCII characters) */ + u32 length; /* Table length in bytes (incl. header) */ + u8 revision; /* Table version (not ACPI version!) */ + volatile u8 checksum; /* To make sum of entire table == 0 */ + char oem_id[6]; /* OEM identification */ + char oem_table_id[8]; /* OEM table identification */ + u32 oem_revision; /* OEM revision number */ + char aslc_id[4]; /* ASL compiler vendor ID */ + u32 aslc_revision; /* ASL compiler revision number */ +}; + +/* A maximum number of 32 ACPI tables ought to be enough for now */ +#define MAX_ACPI_TABLES 32 + +/* RSDT (Root System Description Table) */ +struct acpi_rsdt { + struct acpi_table_header header; + u32 entry[MAX_ACPI_TABLES]; +}; + +/* XSDT (Extended System Description Table) */ +struct acpi_xsdt { + struct acpi_table_header header; + u64 entry[MAX_ACPI_TABLES]; +}; + +/* FADT Preferred Power Management Profile */ +enum acpi_pm_profile { + ACPI_PM_UNSPECIFIED = 0, + ACPI_PM_DESKTOP, + ACPI_PM_MOBILE, + ACPI_PM_WORKSTATION, + ACPI_PM_ENTERPRISE_SERVER, + ACPI_PM_SOHO_SERVER, + ACPI_PM_APPLIANCE_PC, + ACPI_PM_PERFORMANCE_SERVER, + ACPI_PM_TABLET +}; + +/* FADT flags for p_lvl2_lat and p_lvl3_lat */ +#define ACPI_FADT_C2_NOT_SUPPORTED 101 +#define ACPI_FADT_C3_NOT_SUPPORTED 1001 + +/* FADT Boot Architecture Flags */ +#define ACPI_FADT_LEGACY_FREE 0x00 +#define ACPI_FADT_LEGACY_DEVICES BIT(0) +#define ACPI_FADT_8042 BIT(1) +#define ACPI_FADT_VGA_NOT_PRESENT BIT(2) +#define ACPI_FADT_MSI_NOT_SUPPORTED BIT(3) +#define ACPI_FADT_NO_PCIE_ASPM_CONTROL BIT(4) + +/* FADT Feature Flags */ +#define ACPI_FADT_WBINVD BIT(0) +#define ACPI_FADT_WBINVD_FLUSH BIT(1) +#define ACPI_FADT_C1_SUPPORTED BIT(2) +#define ACPI_FADT_C2_MP_SUPPORTED BIT(3) +#define ACPI_FADT_POWER_BUTTON BIT(4) +#define ACPI_FADT_SLEEP_BUTTON BIT(5) +#define ACPI_FADT_FIXED_RTC BIT(6) +#define ACPI_FADT_S4_RTC_WAKE BIT(7) +#define ACPI_FADT_32BIT_TIMER BIT(8) +#define ACPI_FADT_DOCKING_SUPPORTED BIT(9) +#define ACPI_FADT_RESET_REGISTER BIT(10) +#define ACPI_FADT_SEALED_CASE BIT(11) +#define ACPI_FADT_HEADLESS BIT(12) +#define ACPI_FADT_SLEEP_TYPE BIT(13) +#define ACPI_FADT_PCI_EXPRESS_WAKE BIT(14) +#define ACPI_FADT_PLATFORM_CLOCK BIT(15) +#define ACPI_FADT_S4_RTC_VALID BIT(16) +#define ACPI_FADT_REMOTE_POWER_ON BIT(17) +#define ACPI_FADT_APIC_CLUSTER BIT(18) +#define ACPI_FADT_APIC_PHYSICAL BIT(19) +#define ACPI_FADT_HW_REDUCED_ACPI BIT(20) +#define ACPI_FADT_LOW_PWR_IDLE_S0 BIT(21) + +enum acpi_address_space_type { + ACPI_ADDRESS_SPACE_MEMORY = 0, /* System memory */ + ACPI_ADDRESS_SPACE_IO, /* System I/O */ + ACPI_ADDRESS_SPACE_PCI, /* PCI config space */ + ACPI_ADDRESS_SPACE_EC, /* Embedded controller */ + ACPI_ADDRESS_SPACE_SMBUS, /* SMBus */ + ACPI_ADDRESS_SPACE_PCC = 0x0a, /* Platform Comm. Channel */ + ACPI_ADDRESS_SPACE_FIXED = 0x7f /* Functional fixed hardware */ +}; + +enum acpi_address_space_size { + ACPI_ACCESS_SIZE_UNDEFINED = 0, + ACPI_ACCESS_SIZE_BYTE_ACCESS, + ACPI_ACCESS_SIZE_WORD_ACCESS, + ACPI_ACCESS_SIZE_DWORD_ACCESS, + ACPI_ACCESS_SIZE_QWORD_ACCESS +}; + +struct acpi_gen_regaddr { + u8 space_id; /* Address space ID */ + u8 bit_width; /* Register size in bits */ + u8 bit_offset; /* Register bit offset */ + u8 access_size; /* Access size */ + u32 addrl; /* Register address, low 32 bits */ + u32 addrh; /* Register address, high 32 bits */ +}; + +/* FADT (Fixed ACPI Description Table) */ +struct __packed acpi_fadt { + struct acpi_table_header header; + u32 firmware_ctrl; + u32 dsdt; + u8 res1; + u8 preferred_pm_profile; + u16 sci_int; + u32 smi_cmd; + u8 acpi_enable; + u8 acpi_disable; + u8 s4bios_req; + u8 pstate_cnt; + u32 pm1a_evt_blk; + u32 pm1b_evt_blk; + u32 pm1a_cnt_blk; + u32 pm1b_cnt_blk; + u32 pm2_cnt_blk; + u32 pm_tmr_blk; + u32 gpe0_blk; + u32 gpe1_blk; + u8 pm1_evt_len; + u8 pm1_cnt_len; + u8 pm2_cnt_len; + u8 pm_tmr_len; + u8 gpe0_blk_len; + u8 gpe1_blk_len; + u8 gpe1_base; + u8 cst_cnt; + u16 p_lvl2_lat; + u16 p_lvl3_lat; + u16 flush_size; + u16 flush_stride; + u8 duty_offset; + u8 duty_width; + u8 day_alrm; + u8 mon_alrm; + u8 century; + u16 iapc_boot_arch; + u8 res2; + u32 flags; + struct acpi_gen_regaddr reset_reg; + u8 reset_value; + u16 arm_boot_arch; + u8 minor_revision; + u32 x_firmware_ctl_l; + u32 x_firmware_ctl_h; + u32 x_dsdt_l; + u32 x_dsdt_h; + struct acpi_gen_regaddr x_pm1a_evt_blk; + struct acpi_gen_regaddr x_pm1b_evt_blk; + struct acpi_gen_regaddr x_pm1a_cnt_blk; + struct acpi_gen_regaddr x_pm1b_cnt_blk; + struct acpi_gen_regaddr x_pm2_cnt_blk; + struct acpi_gen_regaddr x_pm_tmr_blk; + struct acpi_gen_regaddr x_gpe0_blk; + struct acpi_gen_regaddr x_gpe1_blk; +}; + +/* FACS flags */ +#define ACPI_FACS_S4BIOS_F BIT(0) +#define ACPI_FACS_64BIT_WAKE_F BIT(1) + +/* FACS (Firmware ACPI Control Structure) */ +struct acpi_facs { + char signature[4]; /* "FACS" */ + u32 length; /* Length in bytes (>= 64) */ + u32 hardware_signature; /* Hardware signature */ + u32 firmware_waking_vector; /* Firmware waking vector */ + u32 global_lock; /* Global lock */ + u32 flags; /* FACS flags */ + u32 x_firmware_waking_vector_l; /* X FW waking vector, low */ + u32 x_firmware_waking_vector_h; /* X FW waking vector, high */ + u8 version; /* Version 2 */ + u8 res1[3]; + u32 ospm_flags; /* OSPM enabled flags */ + u8 res2[24]; +}; + +/* MADT flags */ +#define ACPI_MADT_PCAT_COMPAT BIT(0) + +/* MADT (Multiple APIC Description Table) */ +struct acpi_madt { + struct acpi_table_header header; + u32 lapic_addr; /* Local APIC address */ + u32 flags; /* Multiple APIC flags */ +}; + +/* MADT: APIC Structure Type*/ +enum acpi_apic_types { + ACPI_APIC_LAPIC = 0, /* Processor local APIC */ + ACPI_APIC_IOAPIC, /* I/O APIC */ + ACPI_APIC_IRQ_SRC_OVERRIDE, /* Interrupt source override */ + ACPI_APIC_NMI_SRC, /* NMI source */ + ACPI_APIC_LAPIC_NMI, /* Local APIC NMI */ + ACPI_APIC_LAPIC_ADDR_OVERRIDE, /* Local APIC address override */ + ACPI_APIC_IOSAPIC, /* I/O SAPIC */ + ACPI_APIC_LSAPIC, /* Local SAPIC */ + ACPI_APIC_PLATFORM_IRQ_SRC, /* Platform interrupt sources */ + ACPI_APIC_LX2APIC, /* Processor local x2APIC */ + ACPI_APIC_LX2APIC_NMI, /* Local x2APIC NMI */ +}; + +/* MADT: Processor Local APIC Structure */ + +#define LOCAL_APIC_FLAG_ENABLED BIT(0) + +struct acpi_madt_lapic { + u8 type; /* Type (0) */ + u8 length; /* Length in bytes (8) */ + u8 processor_id; /* ACPI processor ID */ + u8 apic_id; /* Local APIC ID */ + u32 flags; /* Local APIC flags */ +}; + +/* MADT: I/O APIC Structure */ +struct acpi_madt_ioapic { + u8 type; /* Type (1) */ + u8 length; /* Length in bytes (12) */ + u8 ioapic_id; /* I/O APIC ID */ + u8 reserved; + u32 ioapic_addr; /* I/O APIC address */ + u32 gsi_base; /* Global system interrupt base */ +}; + +/* MADT: Interrupt Source Override Structure */ +struct __packed acpi_madt_irqoverride { + u8 type; /* Type (2) */ + u8 length; /* Length in bytes (10) */ + u8 bus; /* ISA (0) */ + u8 source; /* Bus-relative int. source (IRQ) */ + u32 gsirq; /* Global system interrupt */ + u16 flags; /* MPS INTI flags */ +}; + +/* MADT: Local APIC NMI Structure */ +struct __packed acpi_madt_lapic_nmi { + u8 type; /* Type (4) */ + u8 length; /* Length in bytes (6) */ + u8 processor_id; /* ACPI processor ID */ + u16 flags; /* MPS INTI flags */ + u8 lint; /* Local APIC LINT# */ +}; + +/* MCFG (PCI Express MMIO config space BAR description table) */ +struct acpi_mcfg { + struct acpi_table_header header; + u8 reserved[8]; +}; + +struct acpi_mcfg_mmconfig { + u32 base_address_l; + u32 base_address_h; + u16 pci_segment_group_number; + u8 start_bus_number; + u8 end_bus_number; + u8 reserved[4]; +}; + +/* PM1_CNT bit defines */ +#define PM1_CNT_SCI_EN BIT(0) + +/* ACPI global NVS structure */ +struct acpi_global_nvs; + +/* CSRT (Core System Resource Table) */ +struct acpi_csrt { + struct acpi_table_header header; +}; + +struct acpi_csrt_group { + u32 length; + u32 vendor_id; + u32 subvendor_id; + u16 device_id; + u16 subdevice_id; + u16 revision; + u16 reserved; + u32 shared_info_length; +}; + +struct acpi_csrt_shared_info { + u16 major_version; + u16 minor_version; + u32 mmio_base_low; + u32 mmio_base_high; + u32 gsi_interrupt; + u8 interrupt_polarity; + u8 interrupt_mode; + u8 num_channels; + u8 dma_address_width; + u16 base_request_line; + u16 num_handshake_signals; + u32 max_block_size; +}; + +/* DBG2 definitions are partially used for SPCR interface_type */ + +/* Types for port_type field */ + +#define ACPI_DBG2_SERIAL_PORT 0x8000 +#define ACPI_DBG2_1394_PORT 0x8001 +#define ACPI_DBG2_USB_PORT 0x8002 +#define ACPI_DBG2_NET_PORT 0x8003 + +/* Subtypes for port_subtype field */ + +#define ACPI_DBG2_16550_COMPATIBLE 0x0000 +#define ACPI_DBG2_16550_SUBSET 0x0001 +#define ACPI_DBG2_ARM_PL011 0x0003 +#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D +#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E +#define ACPI_DBG2_ARM_DCC 0x000F +#define ACPI_DBG2_BCM2835 0x0010 + +#define ACPI_DBG2_1394_STANDARD 0x0000 + +#define ACPI_DBG2_USB_XHCI 0x0000 +#define ACPI_DBG2_USB_EHCI 0x0001 + +#define ACPI_DBG2_UNKNOWN 0x00FF + +/* SPCR (Serial Port Console Redirection table) */ +struct __packed acpi_spcr { + struct acpi_table_header header; + u8 interface_type; + u8 reserved[3]; + struct acpi_gen_regaddr serial_port; + u8 interrupt_type; + u8 pc_interrupt; + u32 interrupt; /* Global system interrupt */ + u8 baud_rate; + u8 parity; + u8 stop_bits; + u8 flow_control; + u8 terminal_type; + u8 reserved1; + u16 pci_device_id; /* Must be 0xffff if not PCI device */ + u16 pci_vendor_id; /* Must be 0xffff if not PCI device */ + u8 pci_bus; + u8 pci_device; + u8 pci_function; + u32 pci_flags; + u8 pci_segment; + u32 reserved2; +}; + +#include + +#endif /* __ACPI_TABLE_H__ */ diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c index a4e5e53d15..74d8f5567f 100644 --- a/lib/efi_loader/efi_acpi.c +++ b/lib/efi_loader/efi_acpi.c @@ -7,7 +7,7 @@ #include #include -#include +#include static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; From patchwork Mon Jan 27 05:05:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229516 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=ADlRrM9U; 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 485dBt6fCGz9sR1 for ; Mon, 27 Jan 2020 16:11:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B46B817E4; Mon, 27 Jan 2020 06:10:27 +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="ADlRrM9U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1431A8177D; Mon, 27 Jan 2020 06:08:47 +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-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (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 56D5C8177F for ; Mon, 27 Jan 2020 06:08:39 +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-xd35.google.com with SMTP id e7so8539017iof.11 for ; Sun, 26 Jan 2020 21:08:39 -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=y9bOh/rVPwxFLU1n4I6tCUloBvneIB+4z6ZTq//9osY=; b=ADlRrM9UmXngb9FKXfusuqYFJJ7od9rs8VF6o0WbthA5dWqjfQjqWnIMSsIYP1wH9M zGuzB5fSMe0siZQjMUhUuwLUWG6J0dI1eZBz8+FXY3QtvBsQQbvVWkvFnu3r45QTmkU9 dhiac/uZl3FnYVZufDmoB4fBxLYQDSggBDO7Y= 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=y9bOh/rVPwxFLU1n4I6tCUloBvneIB+4z6ZTq//9osY=; b=iLPc5/UGsW3kkjHq11aGXtjDbUk7HmXNmtNrkX2kNuPQCalklSNzspwVJgj3+HuLjF Lg3+lT0quytq62Nj5v6K55ZrIvruWvPOgo17duY/GlpxmzigBjXuqa3hChdbeqhK99E4 OqKdqnjRTVA5v5SOJGZgpvLPEqLkFYzPETGNLxpIeNqhrwyK5jahBM0KOwbhi4JGhEPb Uqi9Yhckix31V51XUVkQ/Ey3VneZT/7tWiM0aUFzcizA6NzPsOfyGLDajH3WCDcDuiAE 2YduhfetYTpZlxB1W6pEZGTvBzQpjGNtY8D6OON80tpxzdiYbCjuPVJ6xkDboOV5ZTjJ Hb1g== X-Gm-Message-State: APjAAAWly0Pzyw7PYXO3nn78HixQ7zdSlYCNyxtbH8WRGCPXhjLr5o27 miLD4bIF3euRmxqEa24F/a8hlCyvOspRQQ== X-Google-Smtp-Source: APXvYqz+gpqgpd+ikgglVFcFbJBvvpTBTouChnxykpctUS7R10YEIkn+UrG3DcdJKUy4Dc3AVGHt5Q== X-Received: by 2002:a05:6638:34c:: with SMTP id x12mr11258312jap.144.1580101718019; Sun, 26 Jan 2020 21:08:38 -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.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 016/108] acpi: Add an __ACPI__ preprocessor symbol Date: Sun, 26 Jan 2020 22:05:23 -0700 Message-Id: <20200126220508.16.I6e674b2388c5a74a6912deb2dcc9c8acc8875da0@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 The ASL compiler cannot handle C structures and the like so needs some sort of header guard around these. We already have an __ASSEMBLY__ #define but it seems best to create a new one for ACPI since the rules may be different. Add the check to a few files that ACPI always includes. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/acpi_table.h | 4 ++++ include/dm/acpi.h | 4 ++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/acpi_table.h b/include/acpi_table.h index b4404a632c..dd74895813 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -21,6 +21,8 @@ #define ACPI_RSDP_REV_ACPI_1_0 0 #define ACPI_RSDP_REV_ACPI_2_0 2 +#if !defined(__ACPI__) + /* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum @@ -389,6 +391,8 @@ struct __packed acpi_spcr { u32 reserved2; }; +#endif /* !__ACPI__*/ + #include #endif /* __ACPI_TABLE_H__ */ diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 120576adc0..8d6c3fd424 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -22,6 +22,8 @@ /* Length of an ACPI name string including nul terminator */ #define ACPI_NAME_MAX 5 +#if !defined(__ACPI__) + /** * struct acpi_ops - ACPI operations supported by driver model */ @@ -70,4 +72,6 @@ int acpi_get_name(const struct udevice *dev, char *out_name); */ int acpi_return_name(char *out_name, const char *name); +#endif /* __ACPI__ */ + #endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index c10cd83a0a..d466ef5be7 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -409,8 +409,8 @@ ASL_TMP = $(patsubst %.c,%.asl.tmp,$@) quiet_cmd_acpi_c_asl= ASL $< cmd_acpi_c_asl= \ - $(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -P $(UBOOTINCLUDE) \ - -o $(ASL_TMP) $< && \ + $(CPP) -x assembler-with-cpp -D__ASSEMBLY__ -D__ACPI__ \ + -P $(UBOOTINCLUDE) -o $(ASL_TMP) $< && \ iasl -p $@ -tc $(ASL_TMP) $(if $(KBUILD_VERBOSE:1=), >/dev/null) && \ mv $(patsubst %.c,%.hex,$@) $@ From patchwork Mon Jan 27 05:05:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229517 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=WPlgdZ26; 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 485dC76fvPz9sR1 for ; Mon, 27 Jan 2020 16:11:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 74D0D817B4; Mon, 27 Jan 2020 06:10:31 +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="WPlgdZ26"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD71081780; Mon, 27 Jan 2020 06:08:49 +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 181AE8178B for ; Mon, 27 Jan 2020 06:08:40 +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 k24so8558474ioc.4 for ; Sun, 26 Jan 2020 21:08:39 -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=jLLEDSbKMR/XUSyiWpP/XJ2XuYhMFP4WdE9Wl3yTG3I=; b=WPlgdZ26LO94wXLD++VutyRm7cqxFwlcEKnfJURW93TD2ea1Zf8mGHXhb2yM1RthKr c4x2lqd3Oid3KyFH/Fq3d0xjHgtRTtAWv5hC2b4HSECwhYDfp23FZCsP2ZW3DzKVjFXF ZFbD0s9bvsdL3eNRDn42poJTbrHXX0ofoY8rQ= 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=jLLEDSbKMR/XUSyiWpP/XJ2XuYhMFP4WdE9Wl3yTG3I=; b=EWNwhIDsMIURSLkp24Hn9KN+lk8dBsVl34s6Gql7UxVklZPH3Aa8ftrgcJBzfusKqz lli2n7PmyGC/Cy8wqAsjTfF6tPTNJRphyV2egVW7u/JGPN/olsIlKnQmxTaCR4i+181z uPxtBMFWW8TRNpeOpMpA7fixubeKJso+ADMcd3jpBIkFOuSgE4nWcfjBi3MVSvYUoZM6 sF3RJJLyXe78B1oFyMTXNh9lLUHkIt7Wo2NrpHFnusIVZOCRJeYvRPfv4eQMtmxzOn26 O9Z3FO5Pwx1cRE20L9iE4qMAe/jJ64HDN8DvF6ZFi89achoA0Jkd8T8N1GnoUqhhUUHy DASg== X-Gm-Message-State: APjAAAUSnYuXsH7Ga7YYWjNiN/gBbhkPWXPM00uqOPqqqOVFjGTTmPCP j/M8z9leMxLC3u+3+D6Vb+8XskERFEXvcA== X-Google-Smtp-Source: APXvYqzuP2KgirNLww64IiAOAFvE4EorEGmDcM06cXMhTqjVEXLvPovkl4iOBrdf0DCWlbcpgngyrg== X-Received: by 2002:a5e:c60a:: with SMTP id f10mr11315638iok.295.1580101718654; Sun, 26 Jan 2020 21:08:38 -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.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 017/108] acpi: Add a central location for table version numbers Date: Sun, 26 Jan 2020 22:05:24 -0700 Message-Id: <20200126220508.17.I19e38d6d49d8a7ac5fbe8a724e5ab3e71f857208@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 Each ACPI table has its own version number. Add the version numbers in a single function so we can keep them consistent and easily see what versions are supported. Start a new acpi_table file in a generic directory to house this function. We can move things over to this file from x86 as needed. Signed-off-by: Simon Glass --- arch/sandbox/include/asm/acpi_table.h | 9 ++++ include/acpi_table.h | 53 ++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 ++ lib/acpi/acpi_table.c | 59 +++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++ 6 files changed, 140 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c diff --git a/arch/sandbox/include/asm/acpi_table.h b/arch/sandbox/include/asm/acpi_table.h new file mode 100644 index 0000000000..921c7f4201 --- /dev/null +++ b/arch/sandbox/include/asm/acpi_table.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __ASM_ACPI_TABLE_H__ +#define __ASM_ACPI_TABLE_H__ + +#endif /* __ASM_ACPI_TABLE_H__ */ diff --git a/include/acpi_table.h b/include/acpi_table.h index dd74895813..91496ac047 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -202,6 +202,18 @@ struct __packed acpi_fadt { struct acpi_gen_regaddr x_gpe1_blk; }; +/* FADT TABLE Revision values */ +#define ACPI_FADT_REV_ACPI_1_0 1 +#define ACPI_FADT_REV_ACPI_2_0 3 +#define ACPI_FADT_REV_ACPI_3_0 4 +#define ACPI_FADT_REV_ACPI_4_0 4 +#define ACPI_FADT_REV_ACPI_5_0 5 +#define ACPI_FADT_REV_ACPI_6_0 6 + +/* IVRS Revision Field */ +#define IVRS_FORMAT_FIXED 0x01 /* Type 10h & 11h only */ +#define IVRS_FORMAT_MIXED 0x02 /* Type 10h, 11h, & 40h */ + /* FACS flags */ #define ACPI_FACS_S4BIOS_F BIT(0) #define ACPI_FACS_64BIT_WAKE_F BIT(1) @@ -391,6 +403,47 @@ struct __packed acpi_spcr { u32 reserved2; }; +/* Tables defined by ACPI and generated by U-Boot */ +enum acpi_tables { + ACPITAB_BERT, + ACPITAB_DBG2, + ACPITAB_DMAR, + ACPITAB_DSDT, + ACPITAB_FACS, + ACPITAB_FADT, + ACPITAB_HEST, + ACPITAB_HPET, + ACPITAB_IVRS, + ACPITAB_MADT, + ACPITAB_MCFG, + ACPITAB_RSDP, + ACPITAB_RSDT, + ACPITAB_SLIT, + ACPITAB_SRAT, + ACPITAB_SSDT, + ACPITAB_TCPA, + ACPITAB_TPM2, + ACPITAB_XSDT, + ACPITAB_ECDT, + + /* Additional proprietary tables */ + ACPITAB_VFCT, + ACPITAB_NHLT, + ACPITAB_SPMI, + + ACPITAB_COUNT, +}; + +/** + * acpi_get_table_revision() - Get the revision number generated for a table + * + * This keeps the version-number information in one place + * + * @table: ACPI table to check + * @return version number that U-Boot generates + */ +int acpi_get_table_revision(enum acpi_tables table); + #endif /* !__ACPI__*/ #include diff --git a/lib/Makefile b/lib/Makefile index e82e32dfe9..46fe03003d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -5,6 +5,7 @@ ifndef CONFIG_SPL_BUILD +obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi/ obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_driver/ obj-$(CONFIG_EFI_LOADER) += efi_loader/ diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile new file mode 100644 index 0000000000..660491ef71 --- /dev/null +++ b/lib/acpi/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += acpi_table.o diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c new file mode 100644 index 0000000000..971191f428 --- /dev/null +++ b/lib/acpi/acpi_table.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for ACPI table generation + * + * Copyright 2019 Google LLC + */ + +#include +#include + +int acpi_get_table_revision(enum acpi_tables table) +{ + switch (table) { + case ACPITAB_FADT: + return ACPI_FADT_REV_ACPI_3_0; + case ACPITAB_MADT: /* ACPI 3.0: 2, ACPI 4.0/5.0: 3, ACPI 6.2b/6.3: 5 */ + return 2; + case ACPITAB_MCFG: + return 1; + case ACPITAB_TCPA: + return 2; + case ACPITAB_TPM2: + return 4; + case ACPITAB_SSDT: /* ACPI 3.0 upto 6.3: 2 */ + return 2; + case ACPITAB_SRAT: /* ACPI 2.0: 1, ACPI 3.0: 2, ACPI 4.0 upto 6.3: 3 */ + return 1; /* TODO Should probably be upgraded to 2 */ + case ACPITAB_DMAR: + return 1; + case ACPITAB_SLIT: /* ACPI 2.0 upto 6.3: 1 */ + return 1; + case ACPITAB_SPMI: /* IMPI 2.0 */ + return 5; + case ACPITAB_HPET: /* Currently 1. Table added in ACPI 2.0. */ + return 1; + case ACPITAB_VFCT: /* ACPI 2.0/3.0/4.0: 1 */ + return 1; + case ACPITAB_IVRS: + return IVRS_FORMAT_FIXED; + case ACPITAB_DBG2: + return 0; + case ACPITAB_FACS: /* ACPI 2.0/3.0: 1, ACPI 4.0 upto 6.3: 2 */ + return 1; + case ACPITAB_RSDT: /* ACPI 1.0 upto 6.3: 1 */ + return 1; + case ACPITAB_XSDT: /* ACPI 2.0 upto 6.3: 1 */ + return 1; + case ACPITAB_RSDP: /* ACPI 2.0 upto 6.3: 2 */ + return 2; + case ACPITAB_HEST: + return 1; + case ACPITAB_NHLT: + return 5; + case ACPITAB_BERT: + return 1; + default: + return -EINVAL; + } +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index e3519d4689..e65295b7ca 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -53,3 +54,16 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_get_table_revision() */ +static int dm_test_acpi_get_table_revision(struct unit_test_state *uts) +{ + ut_asserteq(1, acpi_get_table_revision(ACPITAB_MCFG)); + ut_asserteq(2, acpi_get_table_revision(ACPITAB_RSDP)); + ut_asserteq(4, acpi_get_table_revision(ACPITAB_TPM2)); + ut_asserteq(-EINVAL, acpi_get_table_revision(ACPITAB_COUNT)); + + return 0; +} +DM_TEST(dm_test_acpi_get_table_revision, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229519 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=NcSt75Hj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dCf6dzMz9sR1 for ; Mon, 27 Jan 2020 16:12:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7478F8177D; Mon, 27 Jan 2020 06:10:38 +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="NcSt75Hj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 542F5817B6; Mon, 27 Jan 2020 06:08:50 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 A7E978172D for ; Mon, 27 Jan 2020 06:08:40 +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-xd43.google.com with SMTP id k24so8558492ioc.4 for ; Sun, 26 Jan 2020 21:08:40 -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=XxKWO/H9veem2ZFQOhdcuuv3rYnQo8iTiR7ZLYAuXrg=; b=NcSt75HjglknAu+9vo2UQZvdzwh/kcGJ9bUIkr2mK3CwskBWo94/Edd3q3wNkOKEHR E7I21IBuGxNH3KiRRfCE/+hV8tgIGFCiOLA9HWlTYWGshCFKelhKH0ONVtELruDiICsD 3LW1kBuDp9kPet/Q0j737HxPhrpYB22Gtxd+w= 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=XxKWO/H9veem2ZFQOhdcuuv3rYnQo8iTiR7ZLYAuXrg=; b=ZrpZgzGHrwfmpFMUvEl5gik3e56ccRVMiNxqGy+2Aff2DmizYG8m4TvJv0rCCIMTp8 PmSMn8ep07fmWuiuml55uiIZ/h5dwLXIkqx00qMe+My5SrHfeXMk9/LPHZreul924P2P VelA5jtlf4t8VPOELzyKtYMWGx5OrV5zVTIjAY8h553NohvKGy7BG2hUd0HSV9cp8XLT gD+gyMF5dpkgaWNzwdzqVd4iUHJMYLXicgaaJT+7AmfYlXYldbsMWXItSObKYSjCxvEB +3z/Ax7e1LTMYJjkdBxHtm2hMZxVdYunPMAxXM/MKmGzEmlLYnYmxE+DGu4d7BPAVbhR S0MA== X-Gm-Message-State: APjAAAVpOS4fxgoLT89HXjeIlBhGRmQgrmayt+hgrFuteZmiaTDQYGLX PnSL7nNpbo9FjZqaUWle75KQmmDt7gMZPQ== X-Google-Smtp-Source: APXvYqzj72o9qZi7eRqpDidwqznKRsDYTg3mx8EJdzFBqELTvAbDvVhzKPUtjSfWGZPiHt3vPxccuw== X-Received: by 2002:a6b:fc02:: with SMTP id r2mr10618769ioh.183.1580101719394; Sun, 26 Jan 2020 21:08:39 -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.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 018/108] acpi: Add support for DMAR Date: Sun, 26 Jan 2020 22:05:25 -0700 Message-Id: <20200126220508.18.Iffd9fd365ee53abc99a8f1e85c40d30c9368c19d@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 The DMA Remapping Reporting (DMAR) table contains information about DMA remapping. Add a version simple version of this table with only the minimum fields filled out. i.e. no entries. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/acpi_table.h | 57 +++++++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 26 ++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++++ 3 files changed, 97 insertions(+) diff --git a/include/acpi_table.h b/include/acpi_table.h index 91496ac047..d5a9e1c96f 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -21,6 +21,9 @@ #define ACPI_RSDP_REV_ACPI_1_0 0 #define ACPI_RSDP_REV_ACPI_2_0 2 +/* TODO(sjg@chromium.org): Figure out how to get compiler revision */ +#define ASL_REVISION 0 + #if !defined(__ACPI__) /* @@ -352,6 +355,51 @@ struct acpi_csrt_shared_info { u32 max_block_size; }; +enum dmar_type { + DMAR_DRHD = 0, + DMAR_RMRR = 1, + DMAR_ATSR = 2, + DMAR_RHSA = 3, + DMAR_ANDD = 4 +}; + +enum { + DRHD_INCLUDE_PCI_ALL = 1 +}; + +enum dmar_flags { + DMAR_INTR_REMAP = 1 << 0, + DMAR_X2APIC_OPT_OUT = 1 << 1, + DMA_CTRL_PLATFORM_OPT_IN_FLAG = 1 << 2, +}; + +struct __packed dmar_entry { + u16 type; + u16 length; + u8 flags; + u8 reserved; + u16 segment; + u64 bar; +}; + +struct __packed dmar_rmrr_entry { + u16 type; + u16 length; + u16 reserved; + u16 segment; + u64 bar; + u64 limit; +}; + +/* DMAR (DMA Remapping Reporting Structure) */ +struct acpi_dmar { + struct acpi_table_header header; + u8 host_address_width; + u8 flags; + u8 reserved[10]; + struct dmar_entry structure[0]; +} __packed; + /* DBG2 definitions are partially used for SPCR interface_type */ /* Types for port_type field */ @@ -444,6 +492,15 @@ enum acpi_tables { */ int acpi_get_table_revision(enum acpi_tables table); +/** + * acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table + * + * @dmar: Place to put the table + * @flags: DMAR flags to use + * @return 0 if OK, -ve on error + */ +int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); + #endif /* !__ACPI__*/ #include diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 971191f428..85147ac61a 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -6,7 +6,33 @@ */ #include +#include #include +#include + +int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) +{ + struct acpi_table_header *header = &dmar->header; + struct cpu_info info; + struct udevice *cpu; + int ret; + + ret = uclass_first_device(UCLASS_CPU, &cpu); + if (ret) + return log_msg_ret("cpu", ret); + ret = cpu_get_info(cpu, &info); + memset((void *)dmar, 0, sizeof(struct acpi_dmar)); + + /* Fill out header fields. */ + acpi_fill_header(&dmar->header, "DMAR"); + header->length = sizeof(struct acpi_dmar); + header->revision = acpi_get_table_revision(ACPITAB_DMAR); + + dmar->host_address_width = info.address_width - 1; + dmar->flags = flags; + + return 0; +} int acpi_get_table_revision(enum acpi_tables table) { diff --git a/test/dm/acpi.c b/test/dm/acpi.c index e65295b7ca..2737896643 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -67,3 +67,17 @@ static int dm_test_acpi_get_table_revision(struct unit_test_state *uts) } DM_TEST(dm_test_acpi_get_table_revision, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_create_dmar() */ +static int dm_test_acpi_create_dmar(struct unit_test_state *uts) +{ + struct acpi_dmar dmar; + + ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP)); + ut_asserteq(DMAR_INTR_REMAP, dmar.flags); + ut_asserteq(DMAR_INTR_REMAP, dmar.flags); + ut_asserteq(32 - 1, dmar.host_address_width); + + return 0; +} +DM_TEST(dm_test_acpi_create_dmar, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229512 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=h+QMh28d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485d9y4Fwvz9sRR for ; Mon, 27 Jan 2020 16:10:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 17F068177A; Mon, 27 Jan 2020 06:10:14 +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="h+QMh28d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7749B817C1; Mon, 27 Jan 2020 06:08:53 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 4A3D081776 for ; Mon, 27 Jan 2020 06:08:41 +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-xd44.google.com with SMTP id k24so8558505ioc.4 for ; Sun, 26 Jan 2020 21:08:41 -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=/4509TLcxYJqd16UbEw1t/g9eSBJ6B/VY8mxxTEch4w=; b=h+QMh28d0FxiCtc6GbAn2YDjaVDjuJ1UW3+nSgj178kjhQNYuurjNOAd8pi+ptXFcy NwV5D7aoa+iqDkFTfOux1sdaXuAUXb2Sp7+oa8HlB2H6kscfg8WL1WLGnAOVOZS2CQdA GrA3+trdlsHCRX3L7vsO4LuH3Mr0pg9jNh3kA= 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=/4509TLcxYJqd16UbEw1t/g9eSBJ6B/VY8mxxTEch4w=; b=TAhU3iV1srywB9A97tVinuC6aUWQfo56N0rFIP2qBSdsb775SJlh5hmqjmvFTKpgmR OYrpQnvgbhk5zjb4xZBUydJgk2VBMwpOBDpuqZPFLh7MCyY7V3Nb1hGTcl6WVx7ySAsz fvXIZrQf3MbkDSJ86gqF2tEOt9VrmlpwfXAjr1W3VgSK2CHAQuQexbqe87meyLh5VPrp FLgcXfp22mtWQVqh56jtq/npC8pqPBwIClAe0YaDrtl8GWVZ3rAFPuTcDbsJj+MrEHll yMCIuNicRKQ50LbZ7pIO7TeewCerLFO+N4T+sGW4sUq6KSzoqnxo6GqTsCJA2Go8ZzPf x3zA== X-Gm-Message-State: APjAAAWD5F1JsvqYW95WvQ3qNiTCEPI10AWxlo9s+1dPPmUGuNZG83ke AQvb/ZF0c2xQ4DCa7FThh6n5Pt/99oXSxg== X-Google-Smtp-Source: APXvYqzjWWUZ21mrtQmBtdbWo78uuIONbYRi2btj2CIk4eWKpYoPWsCO+yoi4jQpzMy7XU+7TtNUUA== X-Received: by 2002:a6b:f716:: with SMTP id k22mr10945256iog.297.1580101720084; Sun, 26 Jan 2020 21:08:40 -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.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 019/108] acpi: Move acpi_fill_header() to generic code Date: Sun, 26 Jan 2020 22:05:26 -0700 Message-Id: <20200126220508.19.Iadbc6a54ae1387847aabfdb8e2c10e040fb1bf77@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 This function needs to be used by sandbox for tests. Move it into the generic directory. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- include/acpi_table.h | 10 ++++++++++ lib/acpi/acpi_table.c | 10 ++++++++++ test/dm/acpi.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/include/acpi_table.h b/include/acpi_table.h index d5a9e1c96f..9904e421c3 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -501,6 +501,16 @@ int acpi_get_table_revision(enum acpi_tables table); */ int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); +/** + * acpi_fill_header() - Set up a new table header + * + * This sets all fields except length, revision, checksum and aslc_revision + * + * @header: ACPI header to update + * @signature: Table signature to use (4 characters) + */ +void acpi_fill_header(struct acpi_table_header *header, char *signature); + #endif /* !__ACPI__*/ #include diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 85147ac61a..771a3580ce 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -9,6 +9,7 @@ #include #include #include +#include int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) { @@ -83,3 +84,12 @@ int acpi_get_table_revision(enum acpi_tables table) return -EINVAL; } } + +void acpi_fill_header(struct acpi_table_header *header, char *signature) +{ + memcpy(header->signature, signature, 4); + memcpy(header->oem_id, OEM_ID, 6); + memcpy(header->oem_table_id, OEM_TABLE_ID, 8); + header->oem_revision = U_BOOT_BUILD_DATE; + memcpy(header->aslc_id, ASLC_ID, 4); +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 2737896643..e28ebf4f90 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -81,3 +82,30 @@ static int dm_test_acpi_create_dmar(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_create_dmar, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_fill_header() */ +static int dm_test_acpi_fill_header(struct unit_test_state *uts) +{ + struct acpi_table_header hdr; + + /* Make sure these 5 fields are not changed */ + hdr.length = 0x11; + hdr.revision = 0x22; + hdr.checksum = 0x33; + hdr.aslc_revision = 0x44; + acpi_fill_header(&hdr, "ABCD"); + + ut_assertok(memcmp("ABCD", hdr.signature, sizeof(hdr.signature))); + ut_asserteq(0x11, hdr.length); + ut_asserteq(0x22, hdr.revision); + ut_asserteq(0x33, hdr.checksum); + ut_assertok(memcmp(OEM_ID, hdr.oem_id, sizeof(hdr.oem_id))); + ut_assertok(memcmp(OEM_TABLE_ID, hdr.oem_table_id, + sizeof(hdr.oem_table_id))); + ut_asserteq(U_BOOT_BUILD_DATE, hdr.oem_revision); + ut_assertok(memcmp(ASLC_ID, hdr.aslc_id, sizeof(hdr.aslc_id))); + ut_asserteq(0x44, hdr.aslc_revision); + + return 0; +} +DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229513 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=gr5WlT3n; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dBB259pz9sRR for ; Mon, 27 Jan 2020 16:10:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4AA00817C1; Mon, 27 Jan 2020 06:10:17 +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="gr5WlT3n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A7236817D1; Mon, 27 Jan 2020 06:08:54 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 24E958148F for ; Mon, 27 Jan 2020 06:08:42 +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-xd44.google.com with SMTP id m25so8555715ioo.8 for ; Sun, 26 Jan 2020 21:08:42 -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=lWmczqvEg2+4FiiIs/TSsoEN0ABRqZOBSX35zMSiVFk=; b=gr5WlT3ntl0ppITCDTUUSQtk4V/wUXpD+Vya/VeMjBxO2rd1W1JTDAlMwWuBvKcR7U MqNq10989D9WAta8QMXNq2mYCdSFMUCgDGP8OECp4JrQUaXv9Kte36EPUynZvcacGYdy wyTgzN+3xLDrIPADhTeEe7nKsSj1yVoXmcOFY= 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=lWmczqvEg2+4FiiIs/TSsoEN0ABRqZOBSX35zMSiVFk=; b=pSIuUIFG7uMJtBCV8XkhYWJLXw95rEQabXhWJVoCbRePKGJEBc8VrQSJKEnec8gQw9 kbPZhUv4g8CbNnUb4V9jhNFW/KF9AdtYRMrlOhUYPL81pnLP/fd2YnzlsPNPRx/ndoCt FCR2wUx17sCvto1wNhvHuUZnvLpl1Op1598vMOsPyq3zCGsqRLOVJQMMAspQM73G2cOY wiACos0Xm3n/qX+4EQ8ZUItzkK6RTBBnpiZowMLj+Gqu7xhw1VNuyxj1lGwkaEBV8UHi opYKaNAYhhXG9UrIXrReNa2LbCOiNMsCPWP+m/e2iL8eRm8EyYWbq3C//KsGo23dT52E p4yw== X-Gm-Message-State: APjAAAXP/p0e02pjR7HPiQX7gbq92Web1emQZItnUE5z6ZyTS9fZuD3V 1Zc8GugmiUw+WqyFa7dpvq5alevuZJyHEg== X-Google-Smtp-Source: APXvYqyPw2YWRCdJQ6IWEAWufM2cJJm7Y3MSqPCJRcwdiOms6vUmNPA+jScMu25tVCTHldSYOqDlug== X-Received: by 2002:a6b:b7d5:: with SMTP id h204mr11528106iof.238.1580101720907; Sun, 26 Jan 2020 21:08:40 -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.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 020/108] acpi: Add a method to write tables for a device Date: Sun, 26 Jan 2020 22:05:27 -0700 Message-Id: <20200126220508.20.I04c496e973a0d5eb09ed6f6e4674c300fc34b605@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 A device may want to write out ACPI tables to describe itself to Linux. Add a method to permit this. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 4 ++++ drivers/core/acpi.c | 33 ++++++++++++++++++++++++++++++ include/acpi_table.h | 1 + include/dm/acpi.h | 30 +++++++++++++++++++++++++++ test/dm/acpi.c | 43 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 111 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 34dc7fda98..82208de5a8 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -210,6 +210,10 @@ compatible = "denx,u-boot-acpi-test"; }; + acpi-test2 { + compatible = "denx,u-boot-acpi-test"; + }; + clocks { clk_fixed: clk-fixed { compatible = "fixed-clock"; diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 45542199f5..f748aa3f33 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -30,3 +30,36 @@ int acpi_get_name(const struct udevice *dev, char *out_name) return -ENOSYS; } + +int _acpi_write_dev_tables(struct acpi_ctx *ctx, const struct udevice *parent) +{ + struct acpi_ops *aops; + struct udevice *dev; + int ret; + + aops = device_get_acpi_ops(parent); + if (aops && aops->write_tables) { + log_debug("- %s\n", parent->name); + ret = aops->write_tables(parent, ctx); + if (ret) + return ret; + } + device_foreach_child(dev, parent) { + ret = _acpi_write_dev_tables(ctx, dev); + if (ret) + return ret; + } + + return 0; +} + +int acpi_write_dev_tables(struct acpi_ctx *ctx) +{ + int ret; + + log_debug("Writing device tables\n"); + ret = _acpi_write_dev_tables(ctx, dm_root()); + log_debug("Writing finished, err=%d\n", ret); + + return ret; +} diff --git a/include/acpi_table.h b/include/acpi_table.h index 9904e421c3..20b8904fe7 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -17,6 +17,7 @@ #define OEM_ID "U-BOOT" /* U-Boot */ #define OEM_TABLE_ID "U-BOOTBL" /* U-Boot Table */ #define ASLC_ID "INTL" /* Intel ASL Compiler */ +#define ACPI_TABLE_CREATOR OEM_TABLE_ID #define ACPI_RSDP_REV_ACPI_1_0 0 #define ACPI_RSDP_REV_ACPI_2_0 2 diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 8d6c3fd424..dcfcf5c347 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -24,6 +24,17 @@ #if !defined(__ACPI__) +/** + * struct acpi_ctx - Context used for writing ACPI tables + * + * This contains a few useful pieces of information used when writing + * + * @current: Current address for writing + */ +struct acpi_ctx { + void *current; +}; + /** * struct acpi_ops - ACPI operations supported by driver model */ @@ -38,6 +49,15 @@ struct acpi_ops { * other error */ int (*get_name)(const struct udevice *dev, char *out_name); + + /** + * write_tables() - Write out any tables required by this device + * + * @dev: Device to write + * @ctx: ACPI context to use + * @return 0 if OK, -ve on error + */ + int (*write_tables)(const struct udevice *dev, struct acpi_ctx *ctx); }; #define device_get_acpi_ops(dev) ((dev)->driver->acpi_ops) @@ -72,6 +92,16 @@ int acpi_get_name(const struct udevice *dev, char *out_name); */ int acpi_return_name(char *out_name, const char *name); +/** + * acpi_write_dev_tables() - Write ACPI tables required by devices + * + * This scans through all devices and tells them to write any tables they want + * to write. + * + * @return 0 if OK, -ve if any device returned an error + */ +int acpi_write_dev_tables(struct acpi_ctx *ctx); + #endif /* __ACPI__ */ #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index e28ebf4f90..b87fbd16b0 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -15,6 +15,19 @@ #include #define ACPI_TEST_DEV_NAME "ABCD" +#define BUF_SIZE 4096 + +static int testacpi_write_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct acpi_dmar *dmar; + + dmar = (struct acpi_dmar *)ctx->current; + acpi_create_dmar(dmar, DMAR_INTR_REMAP); + ctx->current += sizeof(struct acpi_dmar); + + return 0; +} static int testacpi_get_name(const struct udevice *dev, char *out_name) { @@ -23,6 +36,7 @@ static int testacpi_get_name(const struct udevice *dev, char *out_name) struct acpi_ops testacpi_ops = { .get_name = testacpi_get_name, + .write_tables = testacpi_write_tables, }; static const struct udevice_id testacpi_ids[] = { @@ -109,3 +123,32 @@ static int dm_test_acpi_fill_header(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test ACPI write_tables() */ +static int dm_test_acpi_write_tables(struct unit_test_state *uts) +{ + struct acpi_dmar *dmar; + struct acpi_ctx ctx; + void *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + ut_assertok(acpi_write_dev_tables(&ctx)); + dmar = buf; + + /* + * We should have two dmar tables, one for each "denx,u-boot-acpi-test" + * device + */ + ut_asserteq_ptr(dmar + 2, ctx.current); + ut_asserteq(DMAR_INTR_REMAP, dmar->flags); + ut_asserteq(32 - 1, dmar->host_address_width); + + ut_asserteq(DMAR_INTR_REMAP, dmar[1].flags); + ut_asserteq(32 - 1, dmar[1].host_address_width); + + return 0; +} +DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229520 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=Tql+lF2k; 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 485dCv0Bk4z9sR1 for ; Mon, 27 Jan 2020 16:12:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A87981803; Mon, 27 Jan 2020 06:10:41 +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="Tql+lF2k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B391C817E4; Mon, 27 Jan 2020 06:08:55 +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 E63B481740 for ; Mon, 27 Jan 2020 06:08:42 +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 x2so2741266ila.9 for ; Sun, 26 Jan 2020 21:08:42 -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=GCmkKHu5PrXebe2gtmYwci6rEDH3eT10sKvzrJDDSPk=; b=Tql+lF2kPc4DOHOrhHtdlp7D3bjlJ5JFsI/lhgECV/DUUTbaTAISKM9+2uFXb1Oq2b ruQfPmVwXwGWKw4WuclWzjCHlHm1sAAYPtcQzXKdNQzX8PDpuPPFN1qfhD3jyDG3MKQt 3L5FeyPHjwdxP4kueH40SCOxwXCZcmVrkw4PE= 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=GCmkKHu5PrXebe2gtmYwci6rEDH3eT10sKvzrJDDSPk=; b=n/eiEjpKSjxKh3+Cp8yrH+gxsB/OgrPagn/N4gwenELCvGAmRiUb0/KgclWx0uM1nS hNozBjA5M6jrTr7DXYzXR4h2zYvbKjS3KvWiBoaGFq5uftmGRtjVVH1Nyj8DRz+Vga2U eh7yDvoZ+BSBzj4cXej1U7xzMjAfPaWkYt2jiG2gLhDL0wnrMkT37QzWV1oYawCrbxrS MMbMN1Q+LnTU7l5Ozwqy4C/UYpMUZg3rXlw644D8xvZzliifP81xriZoDjqL82Fm29H6 RkTAlVGTFIiQcMP8blYoDaArHohfOt4LfYYdN/npzXmZUZdn1ps7QrPfquPd6y7Rd86Y 9AWw== X-Gm-Message-State: APjAAAVaEGa9hiVRc0hGRJH32qPflAu9PolTW6OIAYGqXFrlSUkouKMv FdIatpFukKU8WC2ivpwargrPv+3vXTKqsg== X-Google-Smtp-Source: APXvYqxGIZKNkQWxbPyfbyqQXvMLMg+lVkJPKla5c0evPGF6HhLJB3cCwyohvg/yoU9A6K1cux5nbw== X-Received: by 2002:a92:afc5:: with SMTP id v66mr12483814ill.123.1580101721588; Sun, 26 Jan 2020 21:08:41 -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.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 021/108] acpi: Convert part of acpi_table to use acpi_ctx Date: Sun, 26 Jan 2020 22:05:28 -0700 Message-Id: <20200126220508.21.I93e1e33891714417335e1dd517982b18bf9f882f@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 The current code uses an address but a pointer would result in fewer casts. Also it repeats the alignment code in a lot of places so this would be better done in a helper function. Update write_acpi_tables() to make use of the new acpi_ctx structure, adding a few helpers to clean things up. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 88 +++++++++++++++++++-------------------- include/acpi_table.h | 36 ++++++++++++++++ lib/acpi/acpi_table.c | 22 ++++++++++ test/dm/acpi.c | 28 +++++++++++++ 4 files changed, 129 insertions(+), 45 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 71913b6f65..4bd331f20f 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include /* * IASL compiles the dsdt entries and writes the hex values @@ -477,9 +479,9 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) /* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ -ulong write_acpi_tables(ulong start) +ulong write_acpi_tables(ulong start_addr) { - u32 current; + struct acpi_ctx sctx, *ctx = &sctx; struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; struct acpi_xsdt *xsdt; @@ -490,60 +492,61 @@ ulong write_acpi_tables(ulong start) struct acpi_madt *madt; struct acpi_csrt *csrt; struct acpi_spcr *spcr; + void *start; + ulong addr; int i; - current = start; + start = map_sysmem(start_addr, 0); + ctx->current = start; /* Align ACPI tables to 16 byte */ - current = ALIGN(current, 16); + acpi_align(ctx); - debug("ACPI: Writing ACPI tables at %lx\n", start); + debug("ACPI: Writing ACPI tables at %lx\n", start_addr); /* We need at least an RSDP and an RSDT Table */ - rsdp = (struct acpi_rsdp *)current; - current += sizeof(struct acpi_rsdp); - current = ALIGN(current, 16); - rsdt = (struct acpi_rsdt *)current; - current += sizeof(struct acpi_rsdt); - current = ALIGN(current, 16); - xsdt = (struct acpi_xsdt *)current; - current += sizeof(struct acpi_xsdt); + rsdp = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); + rsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + xsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); /* * Per ACPI spec, the FACS table address must be aligned to a 64 byte * boundary (Windows checks this, but Linux does not). */ - current = ALIGN(current, 64); + acpi_align_large(ctx); /* clear all table memory */ - memset((void *)start, 0, current - start); + memset((void *)start, 0, ctx->current - start); acpi_write_rsdp(rsdp, rsdt, xsdt); acpi_write_rsdt(rsdt); acpi_write_xsdt(xsdt); debug("ACPI: * FACS\n"); - facs = (struct acpi_facs *)current; - current += sizeof(struct acpi_facs); - current = ALIGN(current, 16); + facs = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_facs)); acpi_create_facs(facs); debug("ACPI: * DSDT\n"); - dsdt = (struct acpi_table_header *)current; + dsdt = ctx->current; memcpy(dsdt, &AmlCode, sizeof(struct acpi_table_header)); - current += sizeof(struct acpi_table_header); - memcpy((char *)current, + acpi_inc(ctx, sizeof(struct acpi_table_header)); + memcpy(ctx->current, (char *)&AmlCode + sizeof(struct acpi_table_header), dsdt->length - sizeof(struct acpi_table_header)); - current += dsdt->length - sizeof(struct acpi_table_header); - current = ALIGN(current, 16); + acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header)); /* Pack GNVS into the ACPI table area */ for (i = 0; i < dsdt->length; i++) { u32 *gnvs = (u32 *)((u32)dsdt + i); if (*gnvs == ACPI_GNVS_ADDR) { - debug("Fix up global NVS in DSDT to 0x%08x\n", current); - *gnvs = current; + ulong addr = (ulong)map_to_sysmem(ctx->current); + + debug("Fix up global NVS in DSDT to %#08lx\n", addr); + *gnvs = addr; break; } } @@ -553,51 +556,46 @@ ulong write_acpi_tables(ulong start) dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length); /* Fill in platform-specific global NVS variables */ - acpi_create_gnvs((struct acpi_global_nvs *)current); - current += sizeof(struct acpi_global_nvs); - current = ALIGN(current, 16); + acpi_create_gnvs(ctx->current); + acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); debug("ACPI: * FADT\n"); - fadt = (struct acpi_fadt *)current; - current += sizeof(struct acpi_fadt); - current = ALIGN(current, 16); + fadt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_fadt)); acpi_create_fadt(fadt, facs, dsdt); acpi_add_table(rsdp, fadt); debug("ACPI: * MADT\n"); - madt = (struct acpi_madt *)current; + madt = ctx->current; acpi_create_madt(madt); - current += madt->header.length; + acpi_inc_align(ctx, madt->header.length); acpi_add_table(rsdp, madt); - current = ALIGN(current, 16); debug("ACPI: * MCFG\n"); - mcfg = (struct acpi_mcfg *)current; + mcfg = ctx->current; acpi_create_mcfg(mcfg); - current += mcfg->header.length; + acpi_inc_align(ctx, mcfg->header.length); acpi_add_table(rsdp, mcfg); - current = ALIGN(current, 16); debug("ACPI: * CSRT\n"); - csrt = (struct acpi_csrt *)current; + csrt = ctx->current; acpi_create_csrt(csrt); - current += csrt->header.length; + acpi_inc_align(ctx, csrt->header.length); acpi_add_table(rsdp, csrt); - current = ALIGN(current, 16); debug("ACPI: * SPCR\n"); - spcr = (struct acpi_spcr *)current; + spcr = ctx->current; acpi_create_spcr(spcr); - current += spcr->header.length; + acpi_inc_align(ctx, spcr->header.length); acpi_add_table(rsdp, spcr); - current = ALIGN(current, 16); - debug("current = %x\n", current); + addr = map_to_sysmem(ctx->current); + debug("current = %lx\n", addr); acpi_rsdp_addr = (unsigned long)rsdp; debug("ACPI: done\n"); - return current; + return addr; } ulong acpi_get_rsdp_addr(void) diff --git a/include/acpi_table.h b/include/acpi_table.h index 20b8904fe7..6b6b4c671b 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -27,6 +27,8 @@ #if !defined(__ACPI__) +struct acpi_ctx; + /* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum @@ -512,6 +514,40 @@ int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); */ void acpi_fill_header(struct acpi_table_header *header, char *signature); +/** + * acpi_align() - Align the ACPI output pointer to a 16-byte boundary + * + * @ctx: ACPI context + */ +void acpi_align(struct acpi_ctx *ctx); + +/** + * acpi_align_large() - Align the ACPI output pointer to a 64-byte boundary + * + * @ctx: ACPI context + */ +void acpi_align_large(struct acpi_ctx *ctx); + +/** + * acpi_inc() - Increment the ACPI output pointer by a bit + * + * The pointer is NOT aligned afterwards. + * + * @ctx: ACPI context + * @amount: Amount to increment by + */ +void acpi_inc(struct acpi_ctx *ctx, uint amount); + +/** + * acpi_inc_align() - Increment the ACPI output pointer by a bit and align + * + * The pointer is aligned afterwards. + * + * @ctx: ACPI context + * @amount: Amount to increment by + */ +void acpi_inc_align(struct acpi_ctx *ctx, uint amount); + #endif /* !__ACPI__*/ #include diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 771a3580ce..87187fef3c 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -10,6 +10,7 @@ #include #include #include +#include int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) { @@ -93,3 +94,24 @@ void acpi_fill_header(struct acpi_table_header *header, char *signature) header->oem_revision = U_BOOT_BUILD_DATE; memcpy(header->aslc_id, ASLC_ID, 4); } + +void acpi_align(struct acpi_ctx *ctx) +{ + ctx->current = (void *)ALIGN((ulong)ctx->current, 16); +} + +void acpi_align_large(struct acpi_ctx *ctx) +{ + ctx->current = (void *)ALIGN((ulong)ctx->current, 64); +} + +void acpi_inc(struct acpi_ctx *ctx, uint amount) +{ + ctx->current += amount; +} + +void acpi_inc_align(struct acpi_ctx *ctx, uint amount) +{ + ctx->current += amount; + acpi_align(ctx); +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index b87fbd16b0..0bd7e51ac9 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -152,3 +152,31 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test basic ACPI functions */ +static int dm_test_acpi_basic(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + + /* Check align works */ + ctx.current = (void *)5; + acpi_align(&ctx); + ut_asserteq_ptr((void *)16, ctx.current); + + /* Check that align does nothing if already aligned */ + acpi_align(&ctx); + ut_asserteq_ptr((void *)16, ctx.current); + acpi_align_large(&ctx); + ut_asserteq_ptr((void *)64, ctx.current); + acpi_align_large(&ctx); + ut_asserteq_ptr((void *)64, ctx.current); + + /* Check incrementing */ + acpi_inc(&ctx, 3); + ut_asserteq_ptr((void *)67, ctx.current); + acpi_inc_align(&ctx, 3); + ut_asserteq_ptr((void *)80, ctx.current); + + return 0; +} +DM_TEST(dm_test_acpi_basic, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229521 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=gFnp4ins; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dD71lthz9sR1 for ; Mon, 27 Jan 2020 16:12:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5110A817F8; Mon, 27 Jan 2020 06:10: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="gFnp4ins"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 50431817DD; Mon, 27 Jan 2020 06:08:56 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 BB91F81722 for ; Mon, 27 Jan 2020 06:08:43 +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-xd44.google.com with SMTP id t26so8541037ioi.13 for ; Sun, 26 Jan 2020 21:08:43 -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=g1FqnGYC7UV1tcrliiYizH9hMnBNFRNglMNdIYAk+TQ=; b=gFnp4ins3iywS3DLq5O+mNigNz8EGY2L0TqtgmCqit0HMitKfDT3C09As0qrV/4pz3 bCNzP88oeN7D74ygIK7z8HMEVyK+FHiyJubCe8rDVYOo3y17gJd/qq4bQ7Z5DqjRavmz RDyKq9ktFYKe/GSHalxL79GFUZsSZPdn9+ufA= 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=g1FqnGYC7UV1tcrliiYizH9hMnBNFRNglMNdIYAk+TQ=; b=TPRAow0aG5HpUFtGILdJlFFpCyEBZNEPqJfj/bW2IGViRByi07qPVSydfuKQ9Y7yY6 Pyac5/zZhQpRbhZngvJrc6n7kzRkE7D2qh4nO3C1XG32Uo7RlKqcpoqzuF7vCxy/yZ8V mswMGpaq2faqlFrNdpWCSra9ULVpRjJV31kbwqjaMIwnYocAT24Ix7Mzwo7W6V98ln0B GqpeM3UTWh5TD1CQ7FZb9jH2tbKn8dF6RADCsienjvEVhskK07kOflTkD+0935Q/cYlK ETaSca+7/r4XbPk8MVHNuNWXDRWvfL8pQI4ejVHShqVZjwd5Q8P5idC0e//9vUqaa1df EFRg== X-Gm-Message-State: APjAAAV/fjnxMycatQzivp9xMGPl/eqwpV0PHdGA7J2ye6ifILojic7W sCx/JIoH5eaW64DF7kYOugFzddg2GcqAgQ== X-Google-Smtp-Source: APXvYqzIEUffVovbWESH5FvVJ4MX8uQDXCmqcQttHUajXji6yARDSPjbfi9I+3TluO6KSA98YthfpA== X-Received: by 2002:a5e:9609:: with SMTP id a9mr11800439ioq.78.1580101722472; Sun, 26 Jan 2020 21:08:42 -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.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 022/108] x86: Allow devices to write ACPI tables Date: Sun, 26 Jan 2020 22:05:29 -0700 Message-Id: <20200126220508.22.I6f54ae1deb9a3f954441d072e5d591d7cdb4ed5d@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 Call the new core function to permit devices to write their own ACPI tables. These tables will appear after all other tables. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 4bd331f20f..b7bdd86e91 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -589,6 +589,8 @@ ulong write_acpi_tables(ulong start_addr) acpi_inc_align(ctx, spcr->header.length); acpi_add_table(rsdp, spcr); + acpi_write_dev_tables(ctx); + addr = map_to_sysmem(ctx->current); debug("current = %lx\n", addr); From patchwork Mon Jan 27 05:05:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229522 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=OiYbozVc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dDM2bsRz9sR1 for ; Mon, 27 Jan 2020 16:12:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D8A3E8178D; Mon, 27 Jan 2020 06:10:47 +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="OiYbozVc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 553D1817DC; Mon, 27 Jan 2020 06:08:59 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 5D0568176E for ; Mon, 27 Jan 2020 06:08:44 +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-xd42.google.com with SMTP id i11so8534931ioi.12 for ; Sun, 26 Jan 2020 21:08:44 -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=MpA/QvF9AURc7guFAiCerO9UFfjsVAWKKLB/fmLcezs=; b=OiYbozVcNM1h6OLVrJW4cZNdrRzbUxSXg9IKx8tkz326+2Kga10nvytZC3HOz5R2Xz CQO6xY1WCKetNBHi67ODfYe5Nk/aJ7JG7Ylm76D2QBwI7ZrZHpIyXnlJjBS46mwwIexT 76AtdSISBsGANNygZDPhGUBnj6D1b3yIRkrs4= 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=MpA/QvF9AURc7guFAiCerO9UFfjsVAWKKLB/fmLcezs=; b=q5ZLi0+AfSq5ociq8RPaq85UwckqJZ3kYSinuKE7VK2x5uotqUwP7dmNr2DaASs8af 7fRokWGQBNeuKAAsmUOFTDgBFKbpkdxsDmUqINApB9pn2mkdg93czSQ6Eh7vHxk6dYIl Qi+m/Gn8lTPIhuMtVPIbmaRYqXcORKSwZE7iQKlda2AJX7UvB34Wm1dkS8rAUPqRnb1T NZoj+NohTnDfsAYrMob/Ct5WLkR4UTIBZu9p9ZFKBpmVaJ+/LRY1J4HIsSMnMUKgHDSR p3Sps8tU9W1AcoyryFTcP5qo+H/a5kQfESoMwHMgxngmarwyoZcWW4ukqr5Dq2lpdKbv CEew== X-Gm-Message-State: APjAAAV3vobs2SMmLyxj3JNWsredF/GMxXb2zmF3nnH+2JkWCzC6E2yZ vBd62SM7FzBPAkpQvTpT2jQnP9vTj09DIg== X-Google-Smtp-Source: APXvYqy8rAWU/teuWPmbxzaEMfg1Mr7pnX6ZC5sVNNIb+Uz0YK/reUKPGXR9QieJ9wnBWzDmwN81vg== X-Received: by 2002:a6b:6018:: with SMTP id r24mr10072259iog.284.1580101723174; Sun, 26 Jan 2020 21:08:43 -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.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 023/108] acpi: Drop code for missing XSDT from acpi_write_rsdp() Date: Sun, 26 Jan 2020 22:05:30 -0700 Message-Id: <20200126220508.23.I4566efe7db4c618499115f6973d851e0aa502da9@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 We don't actually support tables without an XSDT so we can drop this dead code. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index b7bdd86e91..bc6d19ea2e 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -42,19 +42,8 @@ static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, rsdp->length = sizeof(struct acpi_rsdp); rsdp->rsdt_address = (u32)rsdt; - /* - * Revision: ACPI 1.0: 0, ACPI 2.0/3.0/4.0: 2 - * - * Some OSes expect an XSDT to be present for RSD PTR revisions >= 2. - * If we don't have an ACPI XSDT, force ACPI 1.0 (and thus RSD PTR - * revision 0) - */ - if (xsdt == NULL) { - rsdp->revision = ACPI_RSDP_REV_ACPI_1_0; - } else { - rsdp->xsdt_address = (u64)(u32)xsdt; - rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; - } + rsdp->xsdt_address = (u64)(u32)xsdt; + rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; /* Calculate checksums */ rsdp->checksum = table_compute_checksum((void *)rsdp, 20); From patchwork Mon Jan 27 05:05:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229523 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=gmHWxlay; 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 485dDc16HKz9sR1 for ; Mon, 27 Jan 2020 16:13:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93353817D4; Mon, 27 Jan 2020 06:10:51 +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="gmHWxlay"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5250A817DC; Mon, 27 Jan 2020 06:09:00 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 345C481726 for ; Mon, 27 Jan 2020 06:08:45 +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-xd43.google.com with SMTP id x1so8554877iop.7 for ; Sun, 26 Jan 2020 21:08:45 -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=2seNfns5VVJscZVsGTP1jXCLzpLcc1dd6z0+6CDUyvQ=; b=gmHWxlay4ox90vjGTAomioyFyc7RuiDvcio8dvXV+8RQB0bCqNSncDUYCNDdqaK7c2 aVi2xHSreRjTGnhOYFMMgorK6zsZIFzhHvgImrmB7mrYOUPUP7qy6hFAw9EjzQsIQZu9 E/++Y8LO9bNJCNeMateeHo2OsTEADeBiMmJYk= 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=2seNfns5VVJscZVsGTP1jXCLzpLcc1dd6z0+6CDUyvQ=; b=PBqbUnFuD7jlXFdRgItK/O0XZc1hOKqGr3GnJqPJtC6oHA/PXIFYMNGpwFg8No2QDn BZdqWM7+1iYCLL2O22y2PQlBvyrRJmpw9cbeC/LDyqL16Xd8q8W6A0HLAM3UFW+tY2fr HjPqO7bAn4ogS3ZtMu7qRTqbcP2EfvMQLG04MjENi6Cezo+lZmpShF7Kch9HqFdwy5qJ +90MRhpEdilwG3B0yKbbzfHxlJAFkmRWUXBdWy065Z84wYmTbPMgulfm2koZOoszZ0Cb xBBr2sO09nrYJI1AUVjM23nrh0AAZAbetQEuRDa2n2OtXzMkqQcQycbedm7i1mAY2znK CFHA== X-Gm-Message-State: APjAAAWCgWyPFWyDP6ianZ/hns8ulx3HGPUjaxRMYaWICIDPl142a/Ft ggnATPCOIRhODKDM3WwDuiL8Oq97FVaKAg== X-Google-Smtp-Source: APXvYqxjEpvsDJnBQGDeusrC0Nawep7uPvvrhwMXL5/1dUD4r6z0C8LYguqL3jaAmDENoX+B6bzgwQ== X-Received: by 2002:a6b:c304:: with SMTP id t4mr45350iof.100.1580101723853; Sun, 26 Jan 2020 21:08:43 -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.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 024/108] acpi: Move acpi_add_table() to generic code Date: Sun, 26 Jan 2020 22:05:31 -0700 Message-Id: <20200126220508.24.Ie9d79ce7293bd55022f7c6e940ce3583d38353da@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 Move this code to a generic location so that we can test it with sandbox. This requires adding a few new fields to acpi_ctx, so drop the local variables used in the original code. Also use mapmem to avoid pointer-to-address casts which don't work on sandbox. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 82 +++++---------------------------------- include/acpi_table.h | 9 +++++ include/dm/acpi.h | 5 +++ lib/acpi/acpi_table.c | 64 ++++++++++++++++++++++++++++++ test/dm/acpi.c | 4 ++ 5 files changed, 92 insertions(+), 72 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index bc6d19ea2e..920b6bd847 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -92,66 +92,6 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt) sizeof(struct acpi_xsdt)); } -/** - * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length - * and checksum. - */ -static void acpi_add_table(struct acpi_rsdp *rsdp, void *table) -{ - int i, entries_num; - struct acpi_rsdt *rsdt; - struct acpi_xsdt *xsdt = NULL; - - /* The RSDT is mandatory while the XSDT is not */ - rsdt = (struct acpi_rsdt *)rsdp->rsdt_address; - - if (rsdp->xsdt_address) - xsdt = (struct acpi_xsdt *)((u32)rsdp->xsdt_address); - - /* This should always be MAX_ACPI_TABLES */ - entries_num = ARRAY_SIZE(rsdt->entry); - - for (i = 0; i < entries_num; i++) { - if (rsdt->entry[i] == 0) - break; - } - - if (i >= entries_num) { - debug("ACPI: Error: too many tables\n"); - return; - } - - /* Add table to the RSDT */ - rsdt->entry[i] = (u32)table; - - /* Fix RSDT length or the kernel will assume invalid entries */ - rsdt->header.length = sizeof(struct acpi_table_header) + - (sizeof(u32) * (i + 1)); - - /* Re-calculate checksum */ - rsdt->header.checksum = 0; - rsdt->header.checksum = table_compute_checksum((u8 *)rsdt, - rsdt->header.length); - - /* - * And now the same thing for the XSDT. We use the same index as for - * now we want the XSDT and RSDT to always be in sync in U-Boot - */ - if (xsdt) { - /* Add table to the XSDT */ - xsdt->entry[i] = (u64)(u32)table; - - /* Fix XSDT length */ - xsdt->header.length = sizeof(struct acpi_table_header) + - (sizeof(u64) * (i + 1)); - - /* Re-calculate checksum */ - xsdt->header.checksum = 0; - xsdt->header.checksum = table_compute_checksum((u8 *)xsdt, - xsdt->header.length); - } -} - static void acpi_create_facs(struct acpi_facs *facs) { memset((void *)facs, 0, sizeof(struct acpi_facs)); @@ -471,8 +411,6 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) ulong write_acpi_tables(ulong start_addr) { struct acpi_ctx sctx, *ctx = &sctx; - struct acpi_rsdp *rsdp; - struct acpi_rsdt *rsdt; struct acpi_xsdt *xsdt; struct acpi_facs *facs; struct acpi_table_header *dsdt; @@ -494,9 +432,9 @@ ulong write_acpi_tables(ulong start_addr) debug("ACPI: Writing ACPI tables at %lx\n", start_addr); /* We need at least an RSDP and an RSDT Table */ - rsdp = ctx->current; + ctx->rsdp = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); - rsdt = ctx->current; + ctx->rsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); xsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); @@ -509,8 +447,8 @@ ulong write_acpi_tables(ulong start_addr) /* clear all table memory */ memset((void *)start, 0, ctx->current - start); - acpi_write_rsdp(rsdp, rsdt, xsdt); - acpi_write_rsdt(rsdt); + acpi_write_rsdp(ctx->rsdp, ctx->rsdt, xsdt); + acpi_write_rsdt(ctx->rsdt); acpi_write_xsdt(xsdt); debug("ACPI: * FACS\n"); @@ -552,38 +490,38 @@ ulong write_acpi_tables(ulong start_addr) fadt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_fadt)); acpi_create_fadt(fadt, facs, dsdt); - acpi_add_table(rsdp, fadt); + acpi_add_table(ctx, fadt); debug("ACPI: * MADT\n"); madt = ctx->current; acpi_create_madt(madt); acpi_inc_align(ctx, madt->header.length); - acpi_add_table(rsdp, madt); + acpi_add_table(ctx, madt); debug("ACPI: * MCFG\n"); mcfg = ctx->current; acpi_create_mcfg(mcfg); acpi_inc_align(ctx, mcfg->header.length); - acpi_add_table(rsdp, mcfg); + acpi_add_table(ctx, mcfg); debug("ACPI: * CSRT\n"); csrt = ctx->current; acpi_create_csrt(csrt); acpi_inc_align(ctx, csrt->header.length); - acpi_add_table(rsdp, csrt); + acpi_add_table(ctx, csrt); debug("ACPI: * SPCR\n"); spcr = ctx->current; acpi_create_spcr(spcr); acpi_inc_align(ctx, spcr->header.length); - acpi_add_table(rsdp, spcr); + acpi_add_table(ctx, spcr); acpi_write_dev_tables(ctx); addr = map_to_sysmem(ctx->current); debug("current = %lx\n", addr); - acpi_rsdp_addr = (unsigned long)rsdp; + acpi_rsdp_addr = (unsigned long)ctx->rsdp; debug("ACPI: done\n"); return addr; diff --git a/include/acpi_table.h b/include/acpi_table.h index 6b6b4c671b..29b7bb73c4 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -548,6 +548,15 @@ void acpi_inc(struct acpi_ctx *ctx, uint amount); */ void acpi_inc_align(struct acpi_ctx *ctx, uint amount); +/** + * acpi_add_table() - Add a new table to the RSDP and XSDT + * + * @ctx: ACPI context + * @table: Table to add + * @return 0 if OK, -E2BIG if too many tables + */ +int acpi_add_table(struct acpi_ctx *ctx, void *table); + #endif /* !__ACPI__*/ #include diff --git a/include/dm/acpi.h b/include/dm/acpi.h index dcfcf5c347..4465e62848 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -30,9 +30,14 @@ * This contains a few useful pieces of information used when writing * * @current: Current address for writing + * @rsdp: Pointer to the Root System Description Pointer, typically used when + * adding a new table. The RSDP holds pointers to the RSDP and XSDT. + * @rsdt: Pointer to the Root System Description Table */ struct acpi_ctx { void *current; + struct acpi_rsdp *rsdp; + struct acpi_rsdt *rsdt; }; /** diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 87187fef3c..dd66895815 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include @@ -115,3 +117,65 @@ void acpi_inc_align(struct acpi_ctx *ctx, uint amount) ctx->current += amount; acpi_align(ctx); } + +/** + * Add an ACPI table to the RSDT (and XSDT) structure, recalculate length + * and checksum. + */ +int acpi_add_table(struct acpi_ctx *ctx, void *table) +{ + int i, entries_num; + struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt = NULL; + + /* The RSDT is mandatory while the XSDT is not */ + rsdt = ctx->rsdt; + + if (ctx->rsdp->xsdt_address) + xsdt = map_sysmem(ctx->rsdp->xsdt_address, 0); + + /* This should always be MAX_ACPI_TABLES */ + entries_num = ARRAY_SIZE(rsdt->entry); + + for (i = 0; i < entries_num; i++) { + if (rsdt->entry[i] == 0) + break; + } + + if (i >= entries_num) { + debug("ACPI: Error: too many tables\n"); + return -E2BIG; + } + + /* Add table to the RSDT */ + rsdt->entry[i] = map_to_sysmem(table); + + /* Fix RSDT length or the kernel will assume invalid entries */ + rsdt->header.length = sizeof(struct acpi_table_header) + + (sizeof(u32) * (i + 1)); + + /* Re-calculate checksum */ + rsdt->header.checksum = 0; + rsdt->header.checksum = table_compute_checksum((u8 *)rsdt, + rsdt->header.length); + + /* + * And now the same thing for the XSDT. We use the same index as for + * now we want the XSDT and RSDT to always be in sync in U-Boot + */ + if (xsdt) { + /* Add table to the XSDT */ + xsdt->entry[i] = map_to_sysmem(table); + + /* Fix XSDT length */ + xsdt->header.length = sizeof(struct acpi_table_header) + + (sizeof(u64) * (i + 1)); + + /* Re-calculate checksum */ + xsdt->header.checksum = 0; + xsdt->header.checksum = + table_compute_checksum((u8 *)xsdt, xsdt->header.length); + } + + return 0; +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 0bd7e51ac9..a2a57a29a6 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -21,10 +21,14 @@ static int testacpi_write_tables(const struct udevice *dev, struct acpi_ctx *ctx) { struct acpi_dmar *dmar; + int ret; dmar = (struct acpi_dmar *)ctx->current; acpi_create_dmar(dmar, DMAR_INTR_REMAP); ctx->current += sizeof(struct acpi_dmar); + ret = acpi_add_table(ctx, dmar); + if (ret) + return log_msg_ret("add", ret); return 0; } From patchwork Mon Jan 27 05:05:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229527 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=nZL83AQ4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dFd1LGHz9sR1 for ; Mon, 27 Jan 2020 16:13:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8CC3F816E1; Mon, 27 Jan 2020 06:11:03 +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="nZL83AQ4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 19DC18178D; Mon, 27 Jan 2020 06:09:11 +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 E0AE68178D for ; Mon, 27 Jan 2020 06:08:45 +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 k24so8558642ioc.4 for ; Sun, 26 Jan 2020 21:08:45 -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=jdDFlIQphiRgSh7n/3KTt2crg0K+uRZFePs3/4lySTo=; b=nZL83AQ4mjmA2KCY3dyMnfIxqXYTh8akbRbmJ0NMBoslAk99aLIuoIBb8ir/aNoCBV tfiSCbl+oWm55PNlhDGjh4PLDTZYPc67coGALImo0xTdP5pIhVWcWUzmUX6FECfy0hJY q0LFCGeX7FRFSPhXoDoY7Yo981lPgTH89GN2c= 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=jdDFlIQphiRgSh7n/3KTt2crg0K+uRZFePs3/4lySTo=; b=b/NjFvU0wtjJfTikid525Y2PeDt+9bx/gqDErNR/xgce9jrFckZrTdUBIlRC6ASTxz tVLzJJEpQmSFF7T9bfOZ2yrHXm9aP9MVUK4HSKxmNpLQduL3S3wqukHjrUCBGE7oh/RO 1+l6cCCacBeM2874EYXix08mFCzsalxAmfHBhu7KsC62d6VR01g+Z2Da3MbbYG+BDRdr OLnrrQuKmkFTzWYqiDRw95047EewdbfwNzhYpnCduPDHwQTO0AxRbS/f3bP5Rj8nA2ZM r609GtM9GSj8tGUqXknS/zEtSX2PAvvfhtNsCtkvfNOnB/O69cS9N3YoLRj1PcxnZ+rU Xrkg== X-Gm-Message-State: APjAAAWKXvsL0F5LNwGwOv3VGvpz/xdlc2cf1oCl2fSeRYbAYp2t5hac +j8h2IU9eYMJFIYK7vhKPDz8aTYONpj7qg== X-Google-Smtp-Source: APXvYqxRnum5EtJvqOGxwK2wsggjd3kHCt1sJ4qlIBX/Ci2XX08o6e699oshxiKKJ7bZCFiVoAUIRQ== X-Received: by 2002:a05:6602:2188:: with SMTP id b8mr6017099iob.248.1580101724552; Sun, 26 Jan 2020 21:08:44 -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.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 025/108] acpi: Put table-setup code in its own function Date: Sun, 26 Jan 2020 22:05:32 -0700 Message-Id: <20200126220508.25.I34e9fcd28119cc2fcb87ad8679efb582a4c611df@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 We always write three basic tables to ACPI at the start. Move this into its own function, along with acpi_fill_header(), so we can write a test for this code. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 86 +-------------------------------------- include/acpi_table.h | 10 +++++ lib/acpi/acpi_table.c | 86 ++++++++++++++++++++++++++++++++++++++- test/dm/acpi.c | 55 ++++++++++++++++++++++++- 4 files changed, 148 insertions(+), 89 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 920b6bd847..83b92e2a4c 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -31,67 +31,6 @@ extern const unsigned char AmlCode[]; /* ACPI RSDP address to be used in boot parameters */ static ulong acpi_rsdp_addr; -static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, - struct acpi_xsdt *xsdt) -{ - memset(rsdp, 0, sizeof(struct acpi_rsdp)); - - memcpy(rsdp->signature, RSDP_SIG, 8); - memcpy(rsdp->oem_id, OEM_ID, 6); - - rsdp->length = sizeof(struct acpi_rsdp); - rsdp->rsdt_address = (u32)rsdt; - - rsdp->xsdt_address = (u64)(u32)xsdt; - rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; - - /* Calculate checksums */ - rsdp->checksum = table_compute_checksum((void *)rsdp, 20); - rsdp->ext_checksum = table_compute_checksum((void *)rsdp, - sizeof(struct acpi_rsdp)); -} - -void acpi_fill_header(struct acpi_table_header *header, char *signature) -{ - memcpy(header->signature, signature, 4); - memcpy(header->oem_id, OEM_ID, 6); - memcpy(header->oem_table_id, OEM_TABLE_ID, 8); - header->oem_revision = U_BOOT_BUILD_DATE; - memcpy(header->aslc_id, ASLC_ID, 4); -} - -static void acpi_write_rsdt(struct acpi_rsdt *rsdt) -{ - struct acpi_table_header *header = &(rsdt->header); - - /* Fill out header fields */ - acpi_fill_header(header, "RSDT"); - header->length = sizeof(struct acpi_rsdt); - header->revision = 1; - - /* Entries are filled in later, we come with an empty set */ - - /* Fix checksum */ - header->checksum = table_compute_checksum((void *)rsdt, - sizeof(struct acpi_rsdt)); -} - -static void acpi_write_xsdt(struct acpi_xsdt *xsdt) -{ - struct acpi_table_header *header = &(xsdt->header); - - /* Fill out header fields */ - acpi_fill_header(header, "XSDT"); - header->length = sizeof(struct acpi_xsdt); - header->revision = 1; - - /* Entries are filled in later, we come with an empty set */ - - /* Fix checksum */ - header->checksum = table_compute_checksum((void *)xsdt, - sizeof(struct acpi_xsdt)); -} - static void acpi_create_facs(struct acpi_facs *facs) { memset((void *)facs, 0, sizeof(struct acpi_facs)); @@ -411,7 +350,6 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) ulong write_acpi_tables(ulong start_addr) { struct acpi_ctx sctx, *ctx = &sctx; - struct acpi_xsdt *xsdt; struct acpi_facs *facs; struct acpi_table_header *dsdt; struct acpi_fadt *fadt; @@ -424,32 +362,10 @@ ulong write_acpi_tables(ulong start_addr) int i; start = map_sysmem(start_addr, 0); - ctx->current = start; - - /* Align ACPI tables to 16 byte */ - acpi_align(ctx); debug("ACPI: Writing ACPI tables at %lx\n", start_addr); - /* We need at least an RSDP and an RSDT Table */ - ctx->rsdp = ctx->current; - acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); - ctx->rsdt = ctx->current; - acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); - xsdt = ctx->current; - acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); - /* - * Per ACPI spec, the FACS table address must be aligned to a 64 byte - * boundary (Windows checks this, but Linux does not). - */ - acpi_align_large(ctx); - - /* clear all table memory */ - memset((void *)start, 0, ctx->current - start); - - acpi_write_rsdp(ctx->rsdp, ctx->rsdt, xsdt); - acpi_write_rsdt(ctx->rsdt); - acpi_write_xsdt(xsdt); + acpi_setup_base_tables(ctx, start); debug("ACPI: * FACS\n"); facs = ctx->current; diff --git a/include/acpi_table.h b/include/acpi_table.h index 29b7bb73c4..373c193f4a 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -557,6 +557,16 @@ void acpi_inc_align(struct acpi_ctx *ctx, uint amount); */ int acpi_add_table(struct acpi_ctx *ctx, void *table); +/** + * acpi_setup_base_tables() - Set up context along with RSDP, RSDT and XDST + * + * Set up the context with the given start position. Some basic tables are + * always needed, so set them up as well. + * + * @ctx: Context to set up + */ +void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start); + #endif /* !__ACPI__*/ #include diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index dd66895815..92df07ac99 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -156,7 +156,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) /* Re-calculate checksum */ rsdt->header.checksum = 0; - rsdt->header.checksum = table_compute_checksum((u8 *)rsdt, + rsdt->header.checksum = table_compute_checksum(rsdt, rsdt->header.length); /* @@ -174,8 +174,90 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) /* Re-calculate checksum */ xsdt->header.checksum = 0; xsdt->header.checksum = - table_compute_checksum((u8 *)xsdt, xsdt->header.length); + table_compute_checksum((xsdt, xsdt->header.length); } return 0; } + +static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, + struct acpi_xsdt *xsdt) +{ + memset(rsdp, 0, sizeof(struct acpi_rsdp)); + + memcpy(rsdp->signature, RSDP_SIG, 8); + memcpy(rsdp->oem_id, OEM_ID, 6); + + rsdp->length = sizeof(struct acpi_rsdp); + rsdp->rsdt_address = map_to_sysmem(rsdt); + + rsdp->xsdt_address = map_to_sysmem(xsdt); + rsdp->revision = ACPI_RSDP_REV_ACPI_2_0; + + /* Calculate checksums */ + rsdp->checksum = table_compute_checksum(rsdp, 20); + rsdp->ext_checksum = table_compute_checksum(rsdp, + sizeof(struct acpi_rsdp)); +} + +static void acpi_write_rsdt(struct acpi_rsdt *rsdt) +{ + struct acpi_table_header *header = &rsdt->header; + + /* Fill out header fields */ + acpi_fill_header(header, "RSDT"); + header->length = sizeof(struct acpi_rsdt); + header->revision = 1; + + /* Entries are filled in later, we come with an empty set */ + + /* Fix checksum */ + header->checksum = table_compute_checksum(rsdt, + sizeof(struct acpi_rsdt)); +} + +static void acpi_write_xsdt(struct acpi_xsdt *xsdt) +{ + struct acpi_table_header *header = &xsdt->header; + + /* Fill out header fields */ + acpi_fill_header(header, "XSDT"); + header->length = sizeof(struct acpi_xsdt); + header->revision = 1; + + /* Entries are filled in later, we come with an empty set */ + + /* Fix checksum */ + header->checksum = table_compute_checksum(xsdt, + sizeof(struct acpi_xsdt)); +} + +void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start) +{ + struct acpi_xsdt *xsdt; + + ctx->current = start; + + /* Align ACPI tables to 16 byte */ + acpi_align(ctx); + + /* We need at least an RSDP and an RSDT Table */ + ctx->rsdp = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); + ctx->rsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); + xsdt = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); + /* + * Per ACPI spec, the FACS table address must be aligned to a 64 byte + * boundary (Windows checks this, but Linux does not). + */ + acpi_align_large(ctx); + + /* clear all table memory */ + memset((void *)start, '\0', ctx->current - start); + + acpi_write_rsdp(ctx->rsdp, ctx->rsdt, xsdt); + acpi_write_rsdt(ctx->rsdt); + acpi_write_xsdt(xsdt); +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index a2a57a29a6..bb66c7229c 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -9,6 +9,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -138,9 +141,9 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts) buf = malloc(BUF_SIZE); ut_assertnonnull(buf); - ctx.current = buf; + acpi_setup_base_tables(&ctx, buf); + dmar = ctx.current; ut_assertok(acpi_write_dev_tables(&ctx)); - dmar = buf; /* * We should have two dmar tables, one for each "denx,u-boot-acpi-test" @@ -153,6 +156,11 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts) ut_asserteq(DMAR_INTR_REMAP, dmar[1].flags); ut_asserteq(32 - 1, dmar[1].host_address_width); + /* Check that the pointers were added correctly */ + ut_asserteq(map_to_sysmem(dmar), ctx.rsdt->entry[0]); + ut_asserteq(map_to_sysmem(dmar + 1), ctx.rsdt->entry[1]); + ut_asserteq(0, ctx.rsdt->entry[2]); + return 0; } DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); @@ -184,3 +192,46 @@ static int dm_test_acpi_basic(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_basic, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_setup_base_tables */ +static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts) +{ + struct acpi_rsdp *rsdp; + struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt; + struct acpi_ctx ctx; + void *buf, *end; + + /* Use an unaligned address deliberately */ + buf = memalign(64, BUF_SIZE); + ut_assertnonnull(buf); + acpi_setup_base_tables(&ctx, buf + 4); + + rsdp = buf + 16; + ut_asserteq_ptr(rsdp, ctx.rsdp); + ut_assertok(memcmp(RSDP_SIG, rsdp->signature, sizeof(rsdp->signature))); + ut_asserteq(sizeof(*rsdp), rsdp->length); + ut_assertok(table_compute_checksum(rsdp, 20)); + ut_assertok(table_compute_checksum(rsdp, sizeof(*rsdp))); + + rsdt = PTR_ALIGN((void *)rsdp + sizeof(*rsdp), 16); + ut_asserteq_ptr(rsdt, ctx.rsdt); + ut_assertok(memcmp("RSDT", rsdt->header.signature, ACPI_NAME_LEN)); + ut_asserteq(sizeof(*rsdt), rsdt->header.length); + ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt))); + + xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16); + ut_assertok(memcmp("XSDT", xsdt->header.signature, ACPI_NAME_LEN)); + ut_asserteq(sizeof(*xsdt), xsdt->header.length); + ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt))); + + end = PTR_ALIGN((void *)xsdt + sizeof(*xsdt), 64); + ut_asserteq_ptr(end, ctx.current); + + ut_asserteq(map_to_sysmem(rsdt), rsdp->rsdt_address); + ut_asserteq(map_to_sysmem(xsdt), rsdp->xsdt_address); + + return 0; +} +DM_TEST(dm_test_acpi_setup_base_tables, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229524 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=Zz+4GHG4; 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 485dDs1GZMz9sR1 for ; Mon, 27 Jan 2020 16:13:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C766E817A7; Mon, 27 Jan 2020 06:10:53 +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="Zz+4GHG4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDA08817E8; Mon, 27 Jan 2020 06:09:07 +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 8826781790 for ; Mon, 27 Jan 2020 06:08:46 +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 x1so8554911iop.7 for ; Sun, 26 Jan 2020 21:08:46 -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=PS+gk3L0+Hyy6aRZAjxlK11B9KoE8CE4KPPye7rYx+s=; b=Zz+4GHG4dM+zRZWiHcSCyYYAPTdyur5Fs1oL/ZLE+E/rZviTWxvl6hqychTDBRlKRn UO5a69YN6puGL48K+C9FdPMakhnKa19kHG5BfXNcQ6ujHPmNsEC7Zj1WEW9dogIeaI2d 4vmlY74PeFf5h6YEL1EXH/AvGgLyk1Rw7WwLo= 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=PS+gk3L0+Hyy6aRZAjxlK11B9KoE8CE4KPPye7rYx+s=; b=IOOKPxP167+0dsGD8+H7oVWzoXRpBfmOPitQ5e+Ymh/FUw2E9mmjikCiJvdXLUTGMn Ses9KgrTCC/aksF6xm/Y0OwKDu0BhCx7Ahwljut1OkkAJwe42aDtup51lBlQSzR/WFRQ HRWFenCkESRgMC+dB1xsHpMGhCtItlzJuCGWfTyTxonie9X4GMfyPobtN/pSqwI+z17w 75dgopAo717IOqQJIkHkPxonFUPBNkYiddFqRYhCMpLo3A//xhJY20LIN5X7mxgXkWZp DarlgzuYwHwbaVt6PuXJp+aAmeyTGMNuComh4DwDV3EucTO9v0SOC1EdqvfVVoiI99Cm Kb6g== X-Gm-Message-State: APjAAAXtwSKvJXHSpWiWCzzwGeA1VeiN4W8p2KrgnkkDfzaqm1ygRepq OMfsAurUIVdztbs9YTTNBLpfysQdwDPjWw== X-Google-Smtp-Source: APXvYqybhR3yAlZ3KFWzTdPNH9N95z9J3DmKyVrsFIpS1yjzwmAd0Ri7/aPxvIFtRZePzimriESdDQ== X-Received: by 2002:a5d:8448:: with SMTP id w8mr11449324ior.161.1580101725265; Sun, 26 Jan 2020 21:08:45 -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.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 026/108] acpi: Move the xsdt pointer to acpi_ctx Date: Sun, 26 Jan 2020 22:05:33 -0700 Message-Id: <20200126220508.26.Ib392027f44b50a6cfdad4ce529b8479958cb302d@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 Put this in the context along with the other important pointers. Signed-off-by: Simon Glass --- include/dm/acpi.h | 2 ++ lib/acpi/acpi_table.c | 38 ++++++++++++++++---------------------- test/dm/acpi.c | 5 +++++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 4465e62848..f3e9d73b78 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -33,11 +33,13 @@ * @rsdp: Pointer to the Root System Description Pointer, typically used when * adding a new table. The RSDP holds pointers to the RSDP and XSDT. * @rsdt: Pointer to the Root System Description Table + * @xsdt: Pointer to the Extended System Description Table */ struct acpi_ctx { void *current; struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt; }; /** diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 92df07ac99..92466276d1 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -126,13 +126,11 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) { int i, entries_num; struct acpi_rsdt *rsdt; - struct acpi_xsdt *xsdt = NULL; + struct acpi_xsdt *xsdt; /* The RSDT is mandatory while the XSDT is not */ rsdt = ctx->rsdt; - - if (ctx->rsdp->xsdt_address) - xsdt = map_sysmem(ctx->rsdp->xsdt_address, 0); + xsdt = ctx->xsdt; /* This should always be MAX_ACPI_TABLES */ entries_num = ARRAY_SIZE(rsdt->entry); @@ -163,19 +161,17 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) * And now the same thing for the XSDT. We use the same index as for * now we want the XSDT and RSDT to always be in sync in U-Boot */ - if (xsdt) { - /* Add table to the XSDT */ - xsdt->entry[i] = map_to_sysmem(table); - - /* Fix XSDT length */ - xsdt->header.length = sizeof(struct acpi_table_header) + - (sizeof(u64) * (i + 1)); - - /* Re-calculate checksum */ - xsdt->header.checksum = 0; - xsdt->header.checksum = - table_compute_checksum((xsdt, xsdt->header.length); - } + /* Add table to the XSDT */ + xsdt->entry[i] = map_to_sysmem(table); + + /* Fix XSDT length */ + xsdt->header.length = sizeof(struct acpi_table_header) + + (sizeof(u64) * (i + 1)); + + /* Re-calculate checksum */ + xsdt->header.checksum = 0; + xsdt->header.checksum = table_compute_checksum(xsdt, + xsdt->header.length); return 0; } @@ -234,8 +230,6 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt) void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start) { - struct acpi_xsdt *xsdt; - ctx->current = start; /* Align ACPI tables to 16 byte */ @@ -246,7 +240,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start) acpi_inc_align(ctx, sizeof(struct acpi_rsdp)); ctx->rsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_rsdt)); - xsdt = ctx->current; + ctx->xsdt = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_xsdt)); /* * Per ACPI spec, the FACS table address must be aligned to a 64 byte @@ -257,7 +251,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start) /* clear all table memory */ memset((void *)start, '\0', ctx->current - start); - acpi_write_rsdp(ctx->rsdp, ctx->rsdt, xsdt); + acpi_write_rsdp(ctx->rsdp, ctx->rsdt, ctx->xsdt); acpi_write_rsdt(ctx->rsdt); - acpi_write_xsdt(xsdt); + acpi_write_xsdt(ctx->xsdt); } diff --git a/test/dm/acpi.c b/test/dm/acpi.c index bb66c7229c..a60f67e73d 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -161,6 +161,10 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts) ut_asserteq(map_to_sysmem(dmar + 1), ctx.rsdt->entry[1]); ut_asserteq(0, ctx.rsdt->entry[2]); + ut_asserteq(map_to_sysmem(dmar), ctx.xsdt->entry[0]); + ut_asserteq(map_to_sysmem(dmar + 1), ctx.xsdt->entry[1]); + ut_asserteq(0, ctx.xsdt->entry[2]); + return 0; } DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); @@ -221,6 +225,7 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts) ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt))); xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16); + ut_asserteq_ptr(xsdt, ctx.xsdt); ut_assertok(memcmp("XSDT", xsdt->header.signature, ACPI_NAME_LEN)); ut_asserteq(sizeof(*xsdt), xsdt->header.length); ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt))); From patchwork Mon Jan 27 05:05:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229526 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=koDuFn+B; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dFN742fz9sR1 for ; Mon, 27 Jan 2020 16:13:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 795508181F; Mon, 27 Jan 2020 06:10:59 +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="koDuFn+B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FF3A817F8; Mon, 27 Jan 2020 06:09:10 +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 7370981782 for ; Mon, 27 Jan 2020 06:08:47 +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 n11so8552432iom.9 for ; Sun, 26 Jan 2020 21:08:47 -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=eAn9fN8vfP4kI8LV/fJrIAdGOC7W0r8O7zWm/UyGu0E=; b=koDuFn+B/8ExupAQcVq8N0gpQzfo2KhhHRd8eZ63J6GOzfLmuSH2JQmHb8enGdXvJZ MuLDMI/xWhADKUQarrHrdGTYCe1i6YD555lSvgbTIFwGPC9Cefl5CCaz47TEHq7c/EGS AaI6zp5LZXvU+SenzH+bVfGQvArLNgp478HuA= 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=eAn9fN8vfP4kI8LV/fJrIAdGOC7W0r8O7zWm/UyGu0E=; b=A5TdzcgWAEAril3sz2E9T12MT1B1fUXKUP8FhkPFidBWe7OF4+iHxcDEm0+IJWcWIZ Ttue9Rxsp62okn7coOisTkouO8ljb2tkE/4Z3rtA9l7eJS8gfCdoAcV0f6r3r8QA/hVg CgKtEFQDcy3A8h26xYOVXqyGWx9UerMlFExfPamR4VJI8p9F60KiAP9njRdhNrx8HMB1 9Cjb32CEgEosRTdk3GYJybllwNXggfLnSHS8mezPGzTe/uG/4q8oQrz6D0CHPZt5d8dD uEk9FhG0Zc/IwhL/GvDqrdJbP8ZNpxr4BVMIcZIG/3snfT0dvc8JT+lpytgz7oJPTlfq eAtg== X-Gm-Message-State: APjAAAUwcvC8cr+JUnhhZq5k4ylSSpXoQ4wC8YJdncqURUbTTpS69LVH ZD8QJvA3ZYtT90BwAsADFCL/W2lLFDzp/g== X-Google-Smtp-Source: APXvYqyNu3Cx+b8AkXCqcHLQDYJhp0k4hUvJ593woB08YxAC/8t4SCwM5UZRF+roazAa9J1s6m0RXw== X-Received: by 2002:a5d:8a10:: with SMTP id w16mr499347iod.216.1580101725951; Sun, 26 Jan 2020 21:08:45 -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.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 027/108] acpi: Add an acpi command Date: Sun, 26 Jan 2020 22:05:34 -0700 Message-Id: <20200126220508.27.I5894252b8fe4522e409528c497d882226f34ab9b@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 It is useful to dump ACPI tables in U-Boot to see what has been generated. Add a command to handle this. To allow the command to find the tables, add a position into the global data. Support subcommands to list and dump the tables. Signed-off-by: Simon Glass --- arch/sandbox/include/asm/global_data.h | 1 + arch/x86/include/asm/global_data.h | 1 + cmd/Kconfig | 14 ++ cmd/Makefile | 1 + cmd/acpi.c | 179 +++++++++++++++++++++++++ lib/acpi/acpi_table.c | 1 + test/dm/acpi.c | 73 ++++++++++ 7 files changed, 270 insertions(+) create mode 100644 cmd/acpi.c diff --git a/arch/sandbox/include/asm/global_data.h b/arch/sandbox/include/asm/global_data.h index f4ce72d566..f95ddb058a 100644 --- a/arch/sandbox/include/asm/global_data.h +++ b/arch/sandbox/include/asm/global_data.h @@ -13,6 +13,7 @@ struct arch_global_data { uint8_t *ram_buf; /* emulated RAM buffer */ void *text_base; /* pointer to base of text region */ + ulong acpi_start; /* Start address of ACPI tables */ }; #include diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index f4c1839104..4aee2f3e8c 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -123,6 +123,7 @@ struct arch_global_data { #ifdef CONFIG_FSP_VERSION2 struct fsp_header *fsp_s_hdr; /* Pointer to FSP-S header */ #endif + ulong acpi_start; /* Start address of ACPI tables */ }; #endif diff --git a/cmd/Kconfig b/cmd/Kconfig index 4e29e7b3c5..5c30c0ef3f 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -190,6 +190,20 @@ comment "Commands" menu "Info commands" +config CMD_ACPI + bool "acpi" + default y if ACPIGEN + help + List and dump ACPI tables. ACPI (Advanced Configuration and Power + Interface) is used mostly on x86 for providing information to the + Operating System about devices in the system. The tables are set up + by the firmware, typically U-Boot but possibly an earlier firmware + module, if U-Boot is chain-loaded from something else. ACPI tables + can also include code, to perform hardware-specific tasks required + by the Operating Systems. This allows some amount of separation + between the firmware and OS, and is particularly useful when you + want to make hardware changes without the OS needing to be adjusted. + config CMD_BDI bool "bdinfo" default y diff --git a/cmd/Makefile b/cmd/Makefile index 12e898d962..16bec7b05c 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -11,6 +11,7 @@ obj-y += help.o obj-y += version.o # command +obj-$(CONFIG_CMD_ACPI) += acpi.o obj-$(CONFIG_CMD_AES) += aes.o obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o diff --git a/cmd/acpi.c b/cmd/acpi.c new file mode 100644 index 0000000000..b66c26265b --- /dev/null +++ b/cmd/acpi.c @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass + */ +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +static void dump_hdr(struct acpi_table_header *hdr) +{ + bool has_hdr = memcmp(hdr->signature, "FACS", ACPI_NAME_LEN); + + printf("%.*s %08lx %06x", ACPI_NAME_LEN, hdr->signature, + (ulong)map_to_sysmem(hdr), hdr->length); + if (has_hdr) { + printf(" (v%02d %.6s %.8s %u %.4s %d)\n", hdr->revision, + hdr->oem_id, hdr->oem_table_id, hdr->oem_revision, + hdr->aslc_id, hdr->aslc_revision); + } else { + printf("\n"); + } +} + +/** + * find_table() - Look up an ACPI table + * + * @sig: Signature of table (4 characters, upper case) + * @return pointer to table header, or NULL if not found + */ +struct acpi_table_header *find_table(const char *sig) +{ + struct acpi_rsdp *rsdp; + struct acpi_rsdt *rsdt; + int len, i, count; + + rsdp = map_sysmem(gd->arch.acpi_start, 0); + if (!rsdp) + return NULL; + rsdt = map_sysmem(rsdp->rsdt_address, 0); + len = rsdt->header.length - sizeof(rsdt->header); + count = len / sizeof(u32); + for (i = 0; i < count; i++) { + struct acpi_table_header *hdr; + + hdr = map_sysmem(rsdt->entry[i], 0); + if (!memcmp(hdr->signature, sig, ACPI_NAME_LEN)) + return hdr; + if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) { + struct acpi_fadt *fadt = (struct acpi_fadt *)hdr; + + if (!memcmp(sig, "DSDT", ACPI_NAME_LEN) && fadt->dsdt) + return map_sysmem(fadt->dsdt, 0); + if (!memcmp(sig, "FACS", ACPI_NAME_LEN) && + fadt->firmware_ctrl) + return map_sysmem(fadt->firmware_ctrl, 0); + } + } + + return NULL; +} + +static int dump_table_name(const char *sig) +{ + struct acpi_table_header *hdr; + + hdr = find_table(sig); + if (!hdr) + return -ENOENT; + printf("%.*s @ %08lx\n", ACPI_NAME_LEN, hdr->signature, + (ulong)map_to_sysmem(hdr)); + print_buffer(0, hdr, 1, hdr->length, 0); + + return 0; +} + +static void list_fact(struct acpi_fadt *fadt) +{ + if (fadt->dsdt) + dump_hdr(map_sysmem(fadt->dsdt, 0)); + if (fadt->firmware_ctrl) + dump_hdr(map_sysmem(fadt->firmware_ctrl, 0)); +} + +static int list_rsdt(struct acpi_rsdt *rsdt, struct acpi_xsdt *xsdt) +{ + int len, i, count; + + dump_hdr(&rsdt->header); + if (xsdt) + dump_hdr(&xsdt->header); + len = rsdt->header.length - sizeof(rsdt->header); + count = len / sizeof(u32); + for (i = 0; i < count; i++) { + struct acpi_table_header *hdr; + + if (!rsdt->entry[i]) + break; + hdr = map_sysmem(rsdt->entry[i], 0); + dump_hdr(hdr); + if (!memcmp(hdr->signature, "FACP", ACPI_NAME_LEN)) + list_fact((struct acpi_fadt *)hdr); + if (xsdt) { + if (xsdt->entry[i] != rsdt->entry[i]) { + printf(" (xsdt mismatch %llx)\n", + xsdt->entry[i]); + } + } + } + + return 0; +} + +static int list_rsdp(struct acpi_rsdp *rsdp) +{ + struct acpi_rsdt *rsdt; + struct acpi_xsdt *xsdt; + + printf("RSDP %08lx %06x (v%02d %.6s)\n", (ulong)map_to_sysmem(rsdp), + rsdp->length, rsdp->revision, rsdp->oem_id); + rsdt = map_sysmem(rsdp->rsdt_address, 0); + xsdt = map_sysmem(rsdp->xsdt_address, 0); + list_rsdt(rsdt, xsdt); + + return 0; +} + +static int do_acpi_list(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct acpi_rsdp *rsdp; + + rsdp = map_sysmem(gd->arch.acpi_start, 0); + if (!rsdp) { + printf("No ACPI tables present\n"); + return 0; + } + printf("ACPI tables start at %lx\n", gd->arch.acpi_start); + list_rsdp(rsdp); + + return 0; +} + +static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + const char *name; + char sig[ACPI_NAME_LEN]; + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + name = argv[1]; + if (strlen(name) != ACPI_NAME_LEN) { + printf("Table name '%s' must be four characters\n", name); + return CMD_RET_FAILURE; + } + str_to_upper(name, sig, -1); + ret = dump_table_name(sig); + if (ret) { + printf("Table '%.*s' not found\n", ACPI_NAME_LEN, sig); + return CMD_RET_FAILURE; + } + + return 0; +} + +static char acpi_help_text[] = + "list - list ACPI tables\n" + "acpi dump - Dump ACPI table"; + +U_BOOT_CMD_WITH_SUBCMDS(acpi, "ACPI tables", acpi_help_text, + U_BOOT_SUBCMD_MKENT(list, 1, 1, do_acpi_list), + U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_acpi_dump)); diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 92466276d1..1cefe02ca7 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -234,6 +234,7 @@ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start) /* Align ACPI tables to 16 byte */ acpi_align(ctx); + gd->arch.acpi_start = map_to_sysmem(ctx->current); /* We need at least an RSDP and an RSDT Table */ ctx->rsdp = ctx->current; diff --git a/test/dm/acpi.c b/test/dm/acpi.c index a60f67e73d..feb380b26c 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -8,9 +8,11 @@ #include #include +#include #include #include #include +#include #include #include #include @@ -210,6 +212,7 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts) buf = memalign(64, BUF_SIZE); ut_assertnonnull(buf); acpi_setup_base_tables(&ctx, buf + 4); + ut_asserteq(map_to_sysmem(PTR_ALIGN(buf + 4, 16)), gd->arch.acpi_start); rsdp = buf + 16; ut_asserteq_ptr(rsdp, ctx.rsdp); @@ -240,3 +243,73 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts) } DM_TEST(dm_test_acpi_setup_base_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test 'acpi list' command */ +static int dm_test_acpi_cmd_list(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + ulong addr; + void *buf; + + buf = memalign(16, BUF_SIZE); + ut_assertnonnull(buf); + acpi_setup_base_tables(&ctx, buf); + + ut_assertok(acpi_write_dev_tables(&ctx)); + + console_record_reset(); + run_command("acpi list", 0); + addr = (ulong)map_to_sysmem(buf); + ut_assert_nextline("ACPI tables start at %lx", addr); + ut_assert_nextline("RSDP %08lx %06lx (v02 U-BOOT)", addr, + sizeof(struct acpi_rsdp)); + addr = ALIGN(addr + sizeof(struct acpi_rsdp), 16); + ut_assert_nextline("RSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)", + addr, sizeof(struct acpi_table_header) + + 2 * sizeof(u32), U_BOOT_BUILD_DATE); + addr = ALIGN(addr + sizeof(struct acpi_rsdt), 16); + ut_assert_nextline("XSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)", + addr, sizeof(struct acpi_table_header) + + 2 * sizeof(u64), U_BOOT_BUILD_DATE); + addr = ALIGN(addr + sizeof(struct acpi_xsdt), 64); + ut_assert_nextline("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)", + addr, sizeof(struct acpi_dmar), U_BOOT_BUILD_DATE); + addr = ALIGN(addr + sizeof(struct acpi_dmar), 16); + ut_assert_nextline("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)", + addr, sizeof(struct acpi_dmar), U_BOOT_BUILD_DATE); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_acpi_cmd_list, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test 'acpi dump' command */ +static int dm_test_acpi_cmd_dump(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + ulong addr; + void *buf; + + buf = memalign(16, BUF_SIZE); + ut_assertnonnull(buf); + acpi_setup_base_tables(&ctx, buf); + + ut_assertok(acpi_write_dev_tables(&ctx)); + + /* First search for a non-existent table */ + console_record_reset(); + run_command("acpi dump rdst", 0); + ut_assert_nextline("Table 'RDST' not found"); + ut_assert_console_end(); + + /* Now a real table */ + console_record_reset(); + run_command("acpi dump dmar", 0); + addr = ALIGN(map_to_sysmem(ctx.xsdt) + sizeof(struct acpi_xsdt), 64); + ut_assert_nextline("DMAR @ %08lx", addr); + ut_assert_nextlines_are_dump(0x30); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_acpi_cmd_dump, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229525 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=RELqSPuQ; 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 485dF90fLZz9sR1 for ; Mon, 27 Jan 2020 16:13:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 671CD817FB; Mon, 27 Jan 2020 06:10:56 +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="RELqSPuQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7F34B80929; Mon, 27 Jan 2020 06:09:09 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 0107E8179D for ; Mon, 27 Jan 2020 06:08:47 +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-xd42.google.com with SMTP id k24so8558703ioc.4 for ; Sun, 26 Jan 2020 21:08:47 -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=9S+ibv6Ye6vPjbj2LSTNyQI7SCNsn18Kqf+9vbGgs2o=; b=RELqSPuQbWqcZ6clXEbjcODO7RF4glPmgYVJn7zav2bMNOX7m2swTI97AiaENtSY87 i3w+qGddHu5OKQ81pRI7twFuzq96SCWH1x0lyibp2FuaqEg4DmaX1FPBSZXNQT8oFcbg V27JJZcZhehJcxtGAjgEoboC2opcr9qYHeYhw= 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=9S+ibv6Ye6vPjbj2LSTNyQI7SCNsn18Kqf+9vbGgs2o=; b=tetSLkQ60SNJ4Ng+2LPsoP0PRfDmWCo4U570iIWNWwGhlOkvfO0yx3CUuILhCfDmXR N9vENOzWEf2CJu7rsoRisxJt34YQoPsfGYosmGnLab2fTNG1bPxnHfw3i9+anSBWb8OE lWbgqO7O0483Q7W871++YHWeSUMhAzENbzjbTbcOoK/tz9OuPoug07t24JIfw3//TkE7 ksdvowuOtQDzQzoLKmDPsY7KNeStGCzifB74qeacPIpKdx9SOIr7Uu/6qbA6T56dc96r mvlWJum2sb1ghXpQqlLd2VJcsP+pMfVdPHevwplYfAZPWjkCn86iP9LfICkFTI2wAKwr RtRQ== X-Gm-Message-State: APjAAAWbkKqbTYoRaDhU4g66Zr/9vjuyN8tFgOfZ5/5IGkq892qZOGE2 IMfKAV1CxhFoRlyrboTKscTM4zpDGVpz1w== X-Google-Smtp-Source: APXvYqzhVbQMVGaGiXmfXA56tsZCbLT4TYKvuLAkx55fmI2k4KOAI+fk6NBOmsSHKVTeLAbaRN3Hmw== X-Received: by 2002:a5e:df47:: with SMTP id g7mr11307182ioq.31.1580101726764; Sun, 26 Jan 2020 21:08:46 -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.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 028/108] acpi: Add some tables required by the generation code Date: Sun, 26 Jan 2020 22:05:35 -0700 Message-Id: <20200126220508.28.I0e2a72f2eafe37b48ffe957baa419baab129b5b4@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 The code which generates ACPI tables programmatically, add a few ACPI definitions required by that code. Signed-off-by: Simon Glass --- include/acpi_table.h | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/acpi_table.h b/include/acpi_table.h index 373c193f4a..e3dedc2496 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -29,6 +29,18 @@ struct acpi_ctx; +/* + * The assigned ACPI ID for the coreboot project is 'BOOT' + * http://www.uefi.org/acpi_id_list + */ +#define COREBOOT_ACPI_ID "BOOT" /* ACPI ID for coreboot HIDs */ + +/* List of ACPI HID that use the coreboot ACPI ID */ +enum coreboot_acpi_ids { + COREBOOT_ACPI_ID_CBTABLE = 0x0000, /* BOOT0000 */ + COREBOOT_ACPI_ID_MAX = 0xFFFF, /* BOOTFFFF */ +}; + /* * RSDP (Root System Description Pointer) * Note: ACPI 1.0 didn't have length, xsdt_address, and ext_checksum @@ -358,6 +370,44 @@ struct acpi_csrt_shared_info { u32 max_block_size; }; +struct __packed acpi_cstate { + u8 ctype; + u16 latency; + u32 power; + struct acpi_gen_regaddr resource; +}; + +struct __packed acpi_tstate { + u32 percent; + u32 power; + u32 latency; + u32 control; + u32 status; +}; + +/* Port types for ACPI _UPC object */ +enum acpi_upc_type { + UPC_TYPE_A, + UPC_TYPE_MINI_AB, + UPC_TYPE_EXPRESSCARD, + UPC_TYPE_USB3_A, + UPC_TYPE_USB3_B, + UPC_TYPE_USB3_MICRO_B, + UPC_TYPE_USB3_MICRO_AB, + UPC_TYPE_USB3_POWER_B, + UPC_TYPE_C_USB2_ONLY, + UPC_TYPE_C_USB2_SS_SWITCH, + UPC_TYPE_C_USB2_SS, + UPC_TYPE_PROPRIETARY = 0xff, + /* + * The following types are not directly defined in the ACPI + * spec but are used by coreboot to identify a USB device type. + */ + UPC_TYPE_INTERNAL = 0xff, + UPC_TYPE_UNUSED, + UPC_TYPE_HUB +}; + enum dmar_type { DMAR_DRHD = 0, DMAR_RMRR = 1, From patchwork Mon Jan 27 05:05:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229528 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=Oicvl0Ou; 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 485dFs5S7Rz9sR1 for ; Mon, 27 Jan 2020 16:14:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7E70981813; Mon, 27 Jan 2020 06:11:07 +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="Oicvl0Ou"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8145E817FC; Mon, 27 Jan 2020 06:09:12 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 05DE18177D for ; Mon, 27 Jan 2020 06:08:49 +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-xd44.google.com with SMTP id h8so8565365iob.2 for ; Sun, 26 Jan 2020 21:08:49 -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=ZAb3jUxrgjKZ1PTbCETl0WaPCw49PkN7u1sgpoAlck8=; b=Oicvl0Ouk17He6IqSor5wXpl+l5lsIqqod9Qh5LVwoFquemdk9TzOOHlrpumL5VvCx lIqE8PaxTnaIhFaHFZyxLEMmF2lYAxEV/oKiBBmuvJ7Xjf1HaWpOhmc49GechOx1XB2s mrhFzjCvIH558q9WqpWhpzZWvygoERGS9AO2Q= 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=ZAb3jUxrgjKZ1PTbCETl0WaPCw49PkN7u1sgpoAlck8=; b=rqQdH7UMv8zEmniURnONmIAIHrgkd91jB21LymZSmAY5PK+873huxVaew8UNLi5+VW /G/oJ/iSofZZTna1YZg8uwAl7kyzl48aCCBC8WNJ0Vw7i9SsJrS/4A1thq8KwcM1gKve T9IFO/0oFw8yZ9SyKy959aHx+wrYDFbVRqC9VfDa3cwSX06qBgoFtUrlRptHTSynZuqE R1UlBHHoIdfs+MYDh1z8KzXd9+uOLVnVCGpiY2clazDCzAfWXqu19VtP+7tWgDJ+tZ8R isWWTvoWsD2VlpQh5Rye83Y2GiCgYyXMy7oeUeptR2P2lgB9n+83kEoAziyELHTwvOsS oPiQ== X-Gm-Message-State: APjAAAWsDF/QkYfyCdbAW/aVfQT2pZXQe6cNiu06+OojyQOJPdmGNVYg gB1gj8sL3V7fYgTQPUGPGA0sf1XRcl7Eqg== X-Google-Smtp-Source: APXvYqy7V/H8PwKlX0Np0vhvdV4yHE6tPHxyUHno0y2xweKNSjTkvJiS9YWytYxOP+NSDWveMhq+Jg== X-Received: by 2002:a6b:c742:: with SMTP id x63mr11271892iof.162.1580101727580; Sun, 26 Jan 2020 21:08:47 -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.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 029/108] acpi: Add generation code for devices Date: Sun, 26 Jan 2020 22:05:36 -0700 Message-Id: <20200126220508.29.I06704ecd3c988c7826720a7f447e0388bfe85808@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 Some devices need to create ACPI tables to communcate their parameters to Linux. Add support for this. Signed-off-by: Simon Glass --- include/acpi_device.h | 707 ++++++++++++++++++++++++++ lib/acpi/acpi_device.c | 1093 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1800 insertions(+) create mode 100644 include/acpi_device.h create mode 100644 lib/acpi/acpi_device.c diff --git a/include/acpi_device.h b/include/acpi_device.h new file mode 100644 index 0000000000..919e6bcdaa --- /dev/null +++ b/include/acpi_device.h @@ -0,0 +1,707 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Generation of tables for particular device types + * + * Copyright 2019 Google LLC + * Mostly taken from coreboot file of the same name + */ + +#ifndef __ACPI_DEVICE_H +#define __ACPI_DEVICE_H + +#include +#include +#include +#include + +struct acpi_ctx; +struct irq; +struct gpio_desc; +struct udevice; + +/** + * enum acpi_dp_type - types of device property objects + * + * These refer to the types defined by struct acpi_dp below + * + * @ACPI_DP_TYPE_UNKNOWN: Unknown / do not use + * @ACPI_DP_TYPE_INTEGER: Integer value (u64) in @integer + * @ACPI_DP_TYPE_STRING: String value in @string + * @ACPI_DP_TYPE_REFERENCE: Reference to another object, with value in @string + * @ACPI_DP_TYPE_TABLE: Type for a top-level table which may have children + * @ACPI_DP_TYPE_ARRAY: Array of items with first item in @array and following + * items linked from that item's @next + * @ACPI_DP_TYPE_CHILD: Child object, with siblings in that child's @next + */ +enum acpi_dp_type { + ACPI_DP_TYPE_UNKNOWN, + ACPI_DP_TYPE_INTEGER, + ACPI_DP_TYPE_STRING, + ACPI_DP_TYPE_REFERENCE, + ACPI_DP_TYPE_TABLE, + ACPI_DP_TYPE_ARRAY, + ACPI_DP_TYPE_CHILD, +}; + +/* ACPI descriptor values for common descriptors: SERIAL_BUS means I2C */ +#define ACPI_DESCRIPTOR_LARGE BIT(7) +#define ACPI_DESCRIPTOR_INTERRUPT (ACPI_DESCRIPTOR_LARGE | 9) +#define ACPI_DESCRIPTOR_GPIO (ACPI_DESCRIPTOR_LARGE | 12) +#define ACPI_DESCRIPTOR_SERIAL_BUS (ACPI_DESCRIPTOR_LARGE | 14) + +/* + * PRP0001 is a special DT namespace link device ID. It provides a means to use + * existing DT-compatible device identification in ACPI. When this _HID is used + * by an ACPI device, the ACPI subsystem in OS looks up "compatible" property in + * the device object's _DSD and will use the value of that property to identify + * the corresponding device in analogy with the original DT device + * identification algorithm. + * More details can be found in Linux kernel documentation: + * Documentation/acpi/enumeration.txt + */ +#define ACPI_DT_NAMESPACE_HID "PRP0001" + +/* Length of a full path to an ACPI device */ +#define ACPI_PATH_MAX 30 + +/** + * acpi_device_name() - Locate and return the ACPI name for this device + * + * @dev: Device to check + * @name: Returns the character name, must be at least ACPI_NAME_MAX long + * @return 0 if OK, -ve on error + */ +int acpi_device_name(const struct udevice *dev, char *name); + +/** + * acpi_device_path() - Get the full path to an ACPI device + * + * This gets the full path in the form XXXX.YYYY.ZZZZ where XXXX is the root + * and ZZZZ is the device. All parent devices are added to the path. + * + * @dev: Device to check + * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) + * @maxlen: Size of buffer (typically ACPI_PATH_MAX) + * @return 0 if OK, -ve on error + */ +int acpi_device_path(const struct udevice *dev, char *buf, int maxlen); + +/** + * acpi_device_scope() - Get the scope of an ACPI device + * + * This gets the scope which is the full path of the parent device, as per + * acpi_device_path(). + * + * @dev: Device to check + * @buf: Buffer to place the path in (should be ACPI_PATH_MAX long) + * @maxlen: Size of buffer (typically ACPI_PATH_MAX) + * @return 0 if OK, -EINVAL if the device has no parent, other -ve on other + * error + */ +int acpi_device_scope(const struct udevice *dev, char *scope, int maxlen); + +/** + * acpi_device_status() - Get the status of a device + * + * This currently just returns ACPI_STATUS_DEVICE_ALL_ON. It does not support + * inactive or hidden devices. + * + * @dev: Device to check + * @return device status, as ACPI_STATUS_DEVICE_... + */ +int acpi_device_status(const struct udevice *dev); + +/** enum acpi_irq_mode - edge/level trigger mode */ +enum acpi_irq_mode { + ACPI_IRQ_EDGE_TRIGGERED, + ACPI_IRQ_LEVEL_TRIGGERED, +}; + +/** + * enum acpi_irq_polarity - polarity of interrupt + * + * @ACPI_IRQ_ACTIVE_LOW - for ACPI_IRQ_EDGE_TRIGGERED this means falling edge + * @ACPI_IRQ_ACTIVE_HIGH - for ACPI_IRQ_EDGE_TRIGGERED this means rising edge + * @ACPI_IRQ_ACTIVE_BOTH - not meaningful for ACPI_IRQ_EDGE_TRIGGERED + */ +enum acpi_irq_polarity { + ACPI_IRQ_ACTIVE_LOW, + ACPI_IRQ_ACTIVE_HIGH, + ACPI_IRQ_ACTIVE_BOTH, +}; + +/** + * enum acpi_irq_shared - whether interrupt is shared or not + * + * @ACPI_IRQ_EXCLUSIVE: only this device uses the interrupt + * @ACPI_IRQ_SHARED: other devices may use this interrupt + */ +enum acpi_irq_shared { + ACPI_IRQ_EXCLUSIVE, + ACPI_IRQ_SHARED, +}; + +/** enum acpi_irq_wake - indicates whether this interrupt can wake the device */ +enum acpi_irq_wake { + ACPI_IRQ_NO_WAKE, + ACPI_IRQ_WAKE, +}; + +/** + * struct acpi_irq - representation of an ACPI interrupt + * + * @pin: ACPI pin that is monitored for the interrupt + * @mode: Edge/level triggering + * @polarity: Interrupt polarity + * @shared: Whether interrupt is shared or not + * @wake: Whether interrupt can wake the device from sleep + */ +struct acpi_irq { + unsigned int pin; + enum acpi_irq_mode mode; + enum acpi_irq_polarity polarity; + enum acpi_irq_shared shared; + enum acpi_irq_wake wake; +}; + +/** + * enum acpi_gpio_type - type of the descriptor + * + * @ACPI_GPIO_TYPE_INTERRUPT: GpioInterrupt + * @ACPI_GPIO_TYPE_IO: GpioIo + */ +enum acpi_gpio_type { + ACPI_GPIO_TYPE_INTERRUPT, + ACPI_GPIO_TYPE_IO, +}; + +/** + * enum acpi_gpio_pull - pull direction + * + * @ACPI_GPIO_PULL_DEFAULT: Use default value for pin + * @ACPI_GPIO_PULL_UP: Pull up + * @ACPI_GPIO_PULL_DOWN: Pull down + * @ACPI_GPIO_PULL_NONE: No pullup/pulldown + */ +enum acpi_gpio_pull { + ACPI_GPIO_PULL_DEFAULT, + ACPI_GPIO_PULL_UP, + ACPI_GPIO_PULL_DOWN, + ACPI_GPIO_PULL_NONE, +}; + +/** + * enum acpi_gpio_io_restrict - controls input/output of pin + * + * @ACPI_GPIO_IO_RESTRICT_NONE: no restrictions + * @ACPI_GPIO_IO_RESTRICT_INPUT: input only (no output) + * @ACPI_GPIO_IO_RESTRICT_OUTPUT: output only (no input) + * @ACPI_GPIO_IO_RESTRICT_PRESERVE: preserve settings when driver not active + */ +enum acpi_gpio_io_restrict { + ACPI_GPIO_IO_RESTRICT_NONE, + ACPI_GPIO_IO_RESTRICT_INPUT, + ACPI_GPIO_IO_RESTRICT_OUTPUT, + ACPI_GPIO_IO_RESTRICT_PRESERVE, +}; + +/** enum acpi_gpio_polarity - controls the GPIO polarity */ +enum acpi_gpio_polarity { + ACPI_GPIO_ACTIVE_HIGH = 0, + ACPI_GPIO_ACTIVE_LOW = 1, +}; + +#define ACPI_GPIO_REVISION_ID 1 +#define ACPI_GPIO_MAX_PINS 2 + +/** + * struct acpi_gpio - representation of an ACPI GPIO + * + * @pin_count: Number of pins represented + * @pins: List of pins + * @type: GPIO type + * @pull: Pullup/pulldown setting + * @resource: Resource name for this GPIO controller + * For GpioInt: + * @interrupt_debounce_timeout: Debounce timeout in units of 10us + * @irq: Interrupt + * + * For GpioIo: + * @output_drive_strength: Drive strength in units of 10uA + * @io_shared; true if GPIO is shared + * @io_restrict: I/O restriction setting + * @polarity: GPIO polarity + */ +struct acpi_gpio { + int pin_count; + u16 pins[ACPI_GPIO_MAX_PINS]; + + enum acpi_gpio_type type; + enum acpi_gpio_pull pull; + char resource[ACPI_PATH_MAX]; + + /* GpioInt */ + u16 interrupt_debounce_timeout; + struct acpi_irq irq; + + /* GpioIo */ + u16 output_drive_strength; + bool io_shared; + enum acpi_gpio_io_restrict io_restrict; + enum acpi_gpio_polarity polarity; +}; + +/* ACPI Descriptors for Serial Bus interfaces */ +#define ACPI_SERIAL_BUS_TYPE_I2C 1 +#define ACPI_SERIAL_BUS_TYPE_SPI 2 +#define ACPI_I2C_SERIAL_BUS_REVISION_ID 1 /* TODO: upgrade to 2 */ +#define ACPI_I2C_TYPE_SPECIFIC_REVISION_ID 1 +#define ACPI_SPI_SERIAL_BUS_REVISION_ID 1 +#define ACPI_SPI_TYPE_SPECIFIC_REVISION_ID 1 + +/** + * struct acpi_gpio - representation of an ACPI I2C device + * + * @address: 7-bit or 10-bit I2C address + * @mode_10bit: Which address size is used + * @speed: Bus speed in Hz + * @resource: Resource name for the I2C controller + */ +struct acpi_i2c { + u16 address; + enum i2c_address_mode mode_10bit; + enum i2c_speed_rate speed; + const char *resource; +}; + +/** + * struct acpi_spi - representation of an ACPI SPI device + * + * @device_select: Chip select used by this device (typically 0) + * @device_select_polarity: Polarity for the device + * @wire_mode: Number of wires used for SPI + * @speed: Bus speed in Hz + * @data_bit_length: Word length for SPI (typically 8) + * @clock_phase: Clock phase to capture data + * @clock_polarity: Bus polarity + * @resource: Resource name for the SPI controller + */ +struct acpi_spi { + u16 device_select; + enum spi_polarity device_select_polarity; + enum spi_wire_mode wire_mode; + unsigned int speed; + u8 data_bit_length; + enum spi_clock_phase clock_phase; + enum spi_polarity clock_polarity; + const char *resource; +}; + +/** + * struct acpi_power_res_params - power on/off sequence information + * + * This provides GPIOs and timing information for powering a device on and off. + * This can be applied to any device that has power control, so is fairly + * generic. + * + * @reset_gpio: GPIO used to take device out of reset or to put it into reset + * @reset_delay_ms: Delay to be inserted after device is taken out of reset + * (_ON method delay) + * @reset_off_delay_ms: Delay to be inserted after device is put into reset + * (_OFF method delay) + * @enable_gpio: GPIO used to enable device + * @enable_delay_ms: Delay to be inserted after device is enabled + * @enable_off_delay_ms: Delay to be inserted after device is disabled + * (_OFF method delay) + * @stop_gpio: GPIO used to stop operation of device + * @stop_delay_ms: Delay to be inserted after disabling stop (_ON method delay) + * @stop_off_delay_ms: Delay to be inserted after enabling stop. + * (_OFF method delay) + */ +struct acpi_power_res_params { + struct acpi_gpio *reset_gpio; + unsigned int reset_delay_ms; + unsigned int reset_off_delay_ms; + struct acpi_gpio *enable_gpio; + unsigned int enable_delay_ms; + unsigned int enable_off_delay_ms; + struct acpi_gpio *stop_gpio; + unsigned int stop_delay_ms; + unsigned int stop_off_delay_ms; +}; + +/** + * struct acpi_dp - ACPI device properties + * + * Writing Device Properties objects via _DSD + * + * This provides a structure to handle nested device-specific data which ends + * up in a _DSD table. + * + * https://www.kernel.org/doc/html/latest/firmware-guide/acpi/DSD-properties-rules.html + * https://uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf + * https://uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.1.pdf + * + * The Device Property Hierarchy can be multiple levels deep with multiple + * children possible in each level. In order to support this flexibility + * the device property hierarchy must be built up before being written out. + * + * For example: + * + * // Child table with string and integer + * struct acpi_dp *child = acpi_dp_new_table("CHLD"); + * acpi_dp_add_string(child, "childstring", "CHILD"); + * acpi_dp_add_integer(child, "childint", 100); + * + * // _DSD table with integer and gpio and child pointer + * struct acpi_dp *dsd = acpi_dp_new_table("_DSD"); + * acpi_dp_add_integer(dsd, "number1", 1); + * acpi_dp_add_gpio(dsd, "gpio", "\_SB.PCI0.GPIO", 0, 0, 1); + * acpi_dp_add_child(dsd, "child", child); + * + * // Write entries into SSDT and clean up resources + * acpi_dp_write(dsd); + * + * Name(_DSD, Package() { + * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") + * Package() { + * Package() { "gpio", Package() { \_SB.PCI0.GPIO, 0, 0, 0 } } + * Package() { "number1", 1 } + * } + * ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b") + * Package() { + * Package() { "child", CHLD } + * } + * } + * Name(CHLD, Package() { + * ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") + * Package() { + * Package() { "childstring", "CHILD" } + * Package() { "childint", 100 } + * } + * } + * + * @type: Table type + * @name: Name of object, typically _DSD but could be CHLD for a child object + * @next: Next object in list (next array element or next sibling) + * @child: Pointer to first child, if @type == ACPI_DP_TYPE_CHILD, else NULL + * @array: First array element, if @type == ACPI_DP_TYPE_ARRAY, else NULL + * @integer: Integer value of the property, if @type == ACPI_DP_TYPE_INTEGER + * @string: String value of the property, if @type == ACPI_DP_TYPE_STRING; + * child name if @type == ACPI_DP_TYPE_CHILD; + * reference name if @type == ACPI_DP_TYPE_REFERENCE; + */ +struct acpi_dp { + enum acpi_dp_type type; + const char *name; + struct acpi_dp *next; + union { + struct acpi_dp *child; + struct acpi_dp *array; + }; + union { + u64 integer; + const char *string; + }; +}; + +/** + * acpi_dp_new_table() - Start a new Device Property table + * + * @ref: ACPI reference (e.g. "_DSD") + * @return pointer to table, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_new_table(const char *ref); + +/** + * acpi_dp_add_integer() - Add integer Device Property + * + * A new node is added to the end of the property list of @dp + * + * @dp: Table to add this property to + * @name: Name of property + * @value: Integer value + * @return pointer to new node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_integer(struct acpi_dp *dp, const char *name, + u64 value); + +/** + * acpi_dp_add_string() - Add string Device Property + * + * A new node is added to the end of the property list of @dp + * + * @dp: Table to add this property to + * @name: Name of property + * @string: String value + * @return pointer to new node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_string(struct acpi_dp *dp, const char *name, + const char *string); + +/** + * acpi_dp_add_reference() - Add reference Device Property + * + * A new node is added to the end of the property list of @dp + * + * @dp: Table to add this property to + * @name: Name of property + * @reference: Reference value + * @return pointer to new node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_reference(struct acpi_dp *dp, const char *name, + const char *reference); + +/** + * acpi_dp_add_array() - Add array Device Property + * + * A new node is added to the end of the property list of @dp, with the array + * attached to that. + * + * @dp: Table to add this property to + * @name: Name of property + * @return pointer to new node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_array(struct acpi_dp *dp, struct acpi_dp *array); + +/** + * acpi_dp_add_integer_array() - Add an array of integers + * + * A new node is added to the end of the property list of @dp, with the array + * attached to that. Each element of the array becomes a new node. + * + * @dp: Table to add this property to + * @name: Name of property + * @return pointer to new array node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_integer_array(struct acpi_dp *dp, const char *name, + u64 *array, int len); + +/** + * acpi_dp_add_gpio() - Add a GPIO binding Device Property + * + * A new node is added to the end of the property list of @dp, with the + * GPIO properties added to the the new node + * + * @dp: Table to add this property to + * @name: Name of property + * @ref: Reference of the device that has _CRS containing GpioIO()/GpioInt() + * @index: Index of the GPIO resource in _CRS starting from zero + * @pin: Pin in the GPIO resource, typically zero + * @active_low: true if pin is active low + * @return pointer to new node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name, + const char *ref, int index, int pin, + bool active_low); + +/** + * acpi_dp_add_child() - Add a child table of Device Properties + * + * A new node is added as a child of @dp + * + * @dp: Table to add this child to + * @name: Name of child + * @child: Child node to add + * @return pointer to new array node, or NULL if out of memory + */ +struct acpi_dp *acpi_dp_add_child(struct acpi_dp *dp, const char *name, + struct acpi_dp *child); + +/** + * acpi_dp_add_property_list() - Add a list of of Device Properties + * + * This adds a list of properties to @dp. Any properties without a name or of + * type ACPI_DP_TYPE_UNKNOWN are ignored. + * + * @dp: Table to add properties to + * @property_list: List of properties to add + * @property_count: Number of properties in the list + * @return number of properties added + */ +size_t acpi_dp_add_property_list(struct acpi_dp *dp, + const struct acpi_dp *property_list, + size_t property_count); + +/** + * acpi_dp_write() - Write Device Property hierarchy and clean up resources + * + * This writes the table using acpigen and then frees it + * + * @table: Table to write + * @return 0 if OK, -ve on error + */ +int acpi_dp_write(struct acpi_ctx *ctx, struct acpi_dp *table); + +/** + * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including + * information ACPI needs to use it. + * + * This writes a serial bus descriptor for the I2C device so that ACPI can + */ +int acpi_device_write_i2c_dev(struct acpi_ctx *ctx, const struct udevice *dev); + +/** + * struct acpi_i2c_priv - Information read from device tree + * + * This is used by devices which want to specify various pieces of ACPI + * information, including power control. It allows a generic function to + * generate the information for ACPI, based on device-tree properties. + * + * @disable_gpio_export_in_crs: Don't export GPIOs in the CRS + * @reset_gpio: GPIO used to assert reset to the device + * @enable_gpio: GPIO used to enable the device + * @stop_gpio: GPIO used to stop the device + * @irq_gpio: GPIO used for interrupt (if @irq is not used) + * @irq: IRQ used for interrupt (if @irq_gpio is not used) + * @hid: _HID value for device (required) + * @cid: _CID value for device + * @uid: _UID value for device + * @desc: _DDN value for device + * @wake: Wake event, e.g. GPE0_DW1_15; 0 if none + * @property_count: Number of other DSD properties (currently always 0) + * @probed: true set set 'linux,probed' property + * @compat_string: Device tree compatible string to report through ACPI + * @has_power_resource: true if this device has a power resource + * @reset_delay_ms: Delay after de-asserting reset, in ms + * @reset_off_delay_ms: Delay after asserting reset (during power off) + * @enable_delay_ms: Delay after asserting enable + * @enable_off_delay_ms: Delay after de-asserting enable (during power off) + * @stop_delay_ms: Delay after de-aserting stop + * @stop_off_delay_ms: Delay after asserting stop (during power off) + * @hid_desc_reg_offset: HID register offset (for Human Interface Devices) + */ +struct acpi_i2c_priv { + bool disable_gpio_export_in_crs; + struct gpio_desc reset_gpio; + struct gpio_desc enable_gpio; + struct gpio_desc irq_gpio; + struct gpio_desc stop_gpio; + struct irq irq; + const char *hid; + const char *cid; + u32 uid; + const char *desc; + u32 wake; + u32 property_count; + bool probed; + const char *compat_string; + bool has_power_resource; + u32 reset_delay_ms; + u32 reset_off_delay_ms; + u32 enable_delay_ms; + u32 enable_off_delay_ms; + u32 stop_delay_ms; + u32 stop_off_delay_ms; + u32 hid_desc_reg_offset; +}; + +/** + * I2C Human-Interface Devices configuration + * + * @hid_desc_reg_offset: HID register offset + */ +struct dsm_i2c_hid_config { + u8 hid_desc_reg_offset; +}; + +/** + * acpi_device_write_gpio() - Write GpioIo() or GpioInt() descriptor + * + * @gpio: GPIO information to write + * @return 0 if OK, -ve on error + */ +int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio); + +/* + * acpi_device_add_power_res() - Add a basic PowerResource block for a device + * + * This includes GPIOs to control enable, reset and stop operation of the + * device. Each GPIO is optional, but at least one must be provided. + * + * Reset - Put the device into / take the device out of reset. + * Enable - Enable / disable power to device. + * Stop - Stop / start operation of device. + * + * @return 0 if OK, -ve if at least one GPIO is not provided + */ +int acpi_device_add_power_res(struct acpi_ctx *ctx, + const struct acpi_power_res_params *params); + +/** + * gpio_get_acpi() - Convert a GPIO description into an ACPI GPIO + * + * At present this is fairly limited. It only supports ACPI_GPIO_TYPE_IO and + * has hard-coded settings for type, pull, IO restrict and polarity. These + * could come from pinctrl potentially. + * + * @desc: GPIO description to convert + * @gpio: Place to put ACPI GPIO information + * @return 0 if OK, -ENOENT if @desc is invalid + */ +int gpio_get_acpi(const struct gpio_desc *desc, struct acpi_gpio *gpio); + +/** + * acpi_device_write_dsm_i2c_hid() - Write a device-specific method for HID + * + * This writes a DSM for an I2C Human-Interface Device based on the config + * provided + * + * @config: Config information to write + */ +void acpi_device_write_dsm_i2c_hid(struct acpi_ctx *ctx, + struct dsm_i2c_hid_config *config); + +/** + * acpi_dp_ofnode_copy_int() - Copy a property from device tree to DP + * + * This copies an integer property from the device tree to the ACPI DP table. + * + * @dev: Device to copy from + * @dp: DP to copy to + * @prop: Property name to copy + * @return 0 if OK, -ve on error + */ +int acpi_dp_ofnode_copy_int(ofnode node, struct acpi_dp *dp, const char *prop); + +/** + * acpi_dp_dev_copy_str() - Copy a property from device tree to DP + * + * This copies a string property from the device tree to the ACPI DP table. + * + * @dev: Device to copy from + * @dp: DP to copy to + * @prop: Property name to copy + * @return 0 if OK, -ve on error + */ +int acpi_dp_ofnode_copy_str(ofnode node, struct acpi_dp *dp, const char *prop); + +/** + * acpi_dp_dev_copy_int() - Copy a property from device tree to DP + * + * This copies an integer property from the device tree to the ACPI DP table. + * + * @dev: Device to copy from + * @dp: DP to copy to + * @prop: Property name to copy + * @return 0 if OK, -ve on error + */ +int acpi_dp_dev_copy_int(const struct udevice *dev, struct acpi_dp *dp, + const char *prop); + +/** + * acpi_dp_dev_copy_str() - Copy a property from device tree to DP + * + * This copies a string property from the device tree to the ACPI DP table. + * + * @dev: Device to copy from + * @dp: DP to copy to + * @prop: Property name to copy + * @return 0 if OK, -ve on error + */ +int acpi_dp_dev_copy_str(const struct udevice *dev, struct acpi_dp *dp, + const char *prop); + +int acpi_device_get_name(const struct udevice *dev, char *out_name); + +#endif diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c new file mode 100644 index 0000000000..2d03639714 --- /dev/null +++ b/lib/acpi/acpi_device.c @@ -0,0 +1,1093 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Generation of tables for particular device types + * + * Copyright 2019 Google LLC + * Mostly taken from coreboot file of the same name + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define ACPI_DP_UUID "daffd814-6eba-4d8c-8a91-bc9bbf4aa301" +#define ACPI_DP_CHILD_UUID "dbb8e3e6-5886-4ba6-8795-1319f52a966b" +#define ACPI_DSM_I2C_HID_UUID "3cdff6f7-4267-4555-ad05-b30a3d8938de" + +/** + * acpi_device_write_zero_len() - Write a placeholder word value + * + * @return pointer to the zero word (for fixing up later) + */ +static void *acpi_device_write_zero_len(struct acpi_ctx *ctx) +{ + char *p = acpigen_get_current(ctx); + + acpigen_emit_word(ctx, 0); + + return p; +} + +/** + * acpi_device_fill_from_len() - Fill in a length value + * + * This calculated the number of bytes since the provided @start and writes it + * to @ptr, which was previous returned by acpi_device_write_zero_len(). + * + * @ptr: Word to update + * @start: Start address to count from to calculated the length + */ +static void acpi_device_fill_from_len(struct acpi_ctx *ctx, char *ptr, + char *start) +{ + u16 len = acpigen_get_current(ctx) - start; + + ptr[0] = len & 0xff; + ptr[1] = (len >> 8) & 0xff; +} + +/** + * acpi_device_fill_len() - Fill in a length value, excluding the length itself + * + * Fill in the length field with the value calculated from after the 16bit + * field to acpigen current. This is useful since the length value does not + * include the length field itself. + * + * This calls acpi_device_fill_from_len() passing @ptr + 2 as @start + * + * @ptr: Word to update. + */ +static void acpi_device_fill_len(struct acpi_ctx *ctx, void *ptr) +{ + acpi_device_fill_from_len(ctx, ptr, ptr + sizeof(u16)); +} + +int acpi_device_name(const struct udevice *dev, char *name) +{ + int ret; + + ret = acpi_get_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + return 0; +} + +/** + * acpi_device_path_fill() - Find the root device and build a path from there + * + * This recursively reaches back to the root device and progressively adds path + * elements until the device is reached. + * + * @dev: Device to return path of + * @buf: Buffer to hold the path + * @buf_len: Length of buffer + * @cur: Current position in the buffer + * @return new position in buffer after adding @dev, or -ve on error + */ +static int acpi_device_path_fill(const struct udevice *dev, char *buf, + size_t buf_len, int cur) +{ + char name[ACPI_NAME_MAX]; + int next = 0; + int ret; + + ret = acpi_device_name(dev, name); + if (ret) + return ret; + + /* + * Make sure this name segment will fit, including the path segment + * separator and possible NUL terminator if this is the last segment. + */ + if (!dev || (cur + strlen(name) + 2) > buf_len) + return cur; + + /* Walk up the tree to the root device */ + if (dev_get_parent(dev)) { + next = acpi_device_path_fill(dev_get_parent(dev), buf, buf_len, + cur); + if (next < 0) + return next; + } + + /* Fill in the path from the root device */ + next += snprintf(buf + next, buf_len - next, "%s%s", + dev_get_parent(dev) && *name ? "." : "", name); + + return next; +} + +int acpi_device_path(const struct udevice *dev, char *buf, int maxlen) +{ + int ret; + + ret = acpi_device_path_fill(dev, buf, maxlen, 0); + if (ret < 0) + return ret; + + return 0; +} + +int acpi_device_scope(const struct udevice *dev, char *scope, int maxlen) +{ + int ret; + + if (!dev_get_parent(dev)) + return log_msg_ret("noparent", -EINVAL); + + ret = acpi_device_path_fill(dev_get_parent(dev), scope, maxlen, 0); + if (ret < 0) + return log_msg_ret("fill", ret); + + return 0; +} + +int acpi_device_status(const struct udevice *dev) +{ + return ACPI_STATUS_DEVICE_ALL_ON; +} + +/* ACPI 6.1 section 6.4.3.8.1 - GPIO Interrupt or I/O */ +int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio) +{ + void *start, *desc_length; + void *pin_table_offset, *vendor_data_offset, *resource_offset; + u16 flags = 0; + int pin; + + if (!gpio || gpio->type > ACPI_GPIO_TYPE_IO) + return -EINVAL; + + start = acpigen_get_current(ctx); + + /* Byte 0: Descriptor Type */ + acpigen_emit_byte(ctx, ACPI_DESCRIPTOR_GPIO); + + /* Byte 1-2: Length (fill in later) */ + desc_length = acpi_device_write_zero_len(ctx); + + /* Byte 3: Revision ID */ + acpigen_emit_byte(ctx, ACPI_GPIO_REVISION_ID); + + /* Byte 4: GpioIo or GpioInt */ + acpigen_emit_byte(ctx, gpio->type); + + /* + * Byte 5-6: General Flags + * [15:1]: 0 => Reserved + * [0]: 1 => ResourceConsumer + */ + acpigen_emit_word(ctx, 1 << 0); + + switch (gpio->type) { + case ACPI_GPIO_TYPE_INTERRUPT: + /* + * Byte 7-8: GPIO Interrupt Flags + * [15:5]: 0 => Reserved + * [4]: Wake (0=NO_WAKE 1=WAKE) + * [3]: Sharing (0=EXCLUSIVE 1=SHARED) + * [2:1]: Polarity (0=HIGH 1=LOW 2=BOTH) + * [0]: Mode (0=LEVEL 1=EDGE) + */ + if (gpio->irq.mode == ACPI_IRQ_EDGE_TRIGGERED) + flags |= 1 << 0; + if (gpio->irq.shared == ACPI_IRQ_SHARED) + flags |= 1 << 3; + if (gpio->irq.wake == ACPI_IRQ_WAKE) + flags |= 1 << 4; + + switch (gpio->irq.polarity) { + case ACPI_IRQ_ACTIVE_HIGH: + flags |= 0 << 1; + break; + case ACPI_IRQ_ACTIVE_LOW: + flags |= 1 << 1; + break; + case ACPI_IRQ_ACTIVE_BOTH: + flags |= 2 << 1; + break; + } + break; + + case ACPI_GPIO_TYPE_IO: + /* + * Byte 7-8: GPIO IO Flags + * [15:4]: 0 => Reserved + * [3]: Sharing (0=EXCLUSIVE 1=SHARED) + * [2]: 0 => Reserved + * [1:0]: IO Restriction + * 0 => IoRestrictionNone + * 1 => IoRestrictionInputOnly + * 2 => IoRestrictionOutputOnly + * 3 => IoRestrictionNoneAndPreserve + */ + flags |= gpio->io_restrict & 3; + if (gpio->io_shared) + flags |= 1 << 3; + break; + } + acpigen_emit_word(ctx, flags); + + /* + * Byte 9: Pin Configuration + * 0x01 => Default (no configuration applied) + * 0x02 => Pull-up + * 0x03 => Pull-down + * 0x04-0x7F => Reserved + * 0x80-0xff => Vendor defined + */ + acpigen_emit_byte(ctx, gpio->pull); + + /* Byte 10-11: Output Drive Strength in 1/100 mA */ + acpigen_emit_word(ctx, gpio->output_drive_strength); + + /* Byte 12-13: Debounce Timeout in 1/100 ms */ + acpigen_emit_word(ctx, gpio->interrupt_debounce_timeout); + + /* Byte 14-15: Pin Table Offset, relative to start */ + pin_table_offset = acpi_device_write_zero_len(ctx); + + /* Byte 16: Reserved */ + acpigen_emit_byte(ctx, 0); + + /* Byte 17-18: Resource Source Name Offset, relative to start */ + resource_offset = acpi_device_write_zero_len(ctx); + + /* Byte 19-20: Vendor Data Offset, relative to start */ + vendor_data_offset = acpi_device_write_zero_len(ctx); + + /* Byte 21-22: Vendor Data Length */ + acpigen_emit_word(ctx, 0); + + /* Fill in Pin Table Offset */ + acpi_device_fill_from_len(ctx, pin_table_offset, start); + + /* Pin Table, one word for each pin */ + for (pin = 0; pin < gpio->pin_count; pin++) + acpigen_emit_word(ctx, gpio->pins[pin]); + + /* Fill in Resource Source Name Offset */ + acpi_device_fill_from_len(ctx, resource_offset, start); + + /* Resource Source Name String */ + acpigen_emit_string(ctx, gpio->resource); + + /* Fill in Vendor Data Offset */ + acpi_device_fill_from_len(ctx, vendor_data_offset, start); + + /* Fill in GPIO Descriptor Length (account for len word) */ + acpi_device_fill_len(ctx, desc_length); + + return 0; +} + +/* ACPI 6.1 section 6.4.3.8.2.1 - I2cSerialBus() */ +static void acpi_device_write_i2c(struct acpi_ctx *ctx, + const struct acpi_i2c *i2c) +{ + void *desc_length, *type_length; + + /* Byte 0: Descriptor Type */ + acpigen_emit_byte(ctx, ACPI_DESCRIPTOR_SERIAL_BUS); + + /* Byte 1+2: Length (filled in later) */ + desc_length = acpi_device_write_zero_len(ctx); + + /* Byte 3: Revision ID */ + acpigen_emit_byte(ctx, ACPI_I2C_SERIAL_BUS_REVISION_ID); + + /* Byte 4: Resource Source Index is Reserved */ + acpigen_emit_byte(ctx, 0); + + /* Byte 5: Serial Bus Type is I2C */ + acpigen_emit_byte(ctx, ACPI_SERIAL_BUS_TYPE_I2C); + + /* + * Byte 6: Flags + * [7:2]: 0 => Reserved + * [1]: 1 => ResourceConsumer + * [0]: 0 => ControllerInitiated + */ + acpigen_emit_byte(ctx, 1 << 1); + + /* + * Byte 7-8: Type Specific Flags + * [15:1]: 0 => Reserved + * [0]: 0 => 7bit, 1 => 10bit + */ + acpigen_emit_word(ctx, i2c->mode_10bit); + + /* Byte 9: Type Specific Revision ID */ + acpigen_emit_byte(ctx, ACPI_I2C_TYPE_SPECIFIC_REVISION_ID); + + /* Byte 10-11: I2C Type Data Length */ + type_length = acpi_device_write_zero_len(ctx); + + /* Byte 12-15: I2C Bus Speed */ + acpigen_emit_dword(ctx, i2c->speed); + + /* Byte 16-17: I2C Slave Address */ + acpigen_emit_word(ctx, i2c->address); + + /* Fill in Type Data Length */ + acpi_device_fill_len(ctx, type_length); + + /* Byte 18+: ResourceSource */ + acpigen_emit_string(ctx, i2c->resource); + + /* Fill in I2C Descriptor Length */ + acpi_device_fill_len(ctx, desc_length); +} + +/* ACPI 6.1 section 6.4.3.8.2.2 - SpiSerialBus() */ +void acpi_device_write_spi(struct acpi_ctx *ctx, const struct acpi_spi *spi) +{ + void *desc_length, *type_length; + u16 flags = 0; + + /* Byte 0: Descriptor Type */ + acpigen_emit_byte(ctx, ACPI_DESCRIPTOR_SERIAL_BUS); + + /* Byte 1+2: Length (filled in later) */ + desc_length = acpi_device_write_zero_len(ctx); + + /* Byte 3: Revision ID */ + acpigen_emit_byte(ctx, ACPI_SPI_SERIAL_BUS_REVISION_ID); + + /* Byte 4: Resource Source Index is Reserved */ + acpigen_emit_byte(ctx, 0); + + /* Byte 5: Serial Bus Type is SPI */ + acpigen_emit_byte(ctx, ACPI_SERIAL_BUS_TYPE_SPI); + + /* + * Byte 6: Flags + * [7:2]: 0 => Reserved + * [1]: 1 => ResourceConsumer + * [0]: 0 => ControllerInitiated + */ + acpigen_emit_byte(ctx, 1 << 1); + + /* + * Byte 7-8: Type Specific Flags + * [15:2]: 0 => Reserveda + * [1]: 0 => ActiveLow, 1 => ActiveHigh + * [0]: 0 => FourWire, 1 => ThreeWire + */ + if (spi->wire_mode == SPI_3_WIRE_MODE) + flags |= 1 << 0; + if (spi->device_select_polarity == SPI_POLARITY_HIGH) + flags |= 1 << 1; + acpigen_emit_word(ctx, flags); + + /* Byte 9: Type Specific Revision ID */ + acpigen_emit_byte(ctx, ACPI_SPI_TYPE_SPECIFIC_REVISION_ID); + + /* Byte 10-11: SPI Type Data Length */ + type_length = acpi_device_write_zero_len(ctx); + + /* Byte 12-15: Connection Speed */ + acpigen_emit_dword(ctx, spi->speed); + + /* Byte 16: Data Bit Length */ + acpigen_emit_byte(ctx, spi->data_bit_length); + + /* Byte 17: Clock Phase */ + acpigen_emit_byte(ctx, spi->clock_phase); + + /* Byte 18: Clock Polarity */ + acpigen_emit_byte(ctx, spi->clock_polarity); + + /* Byte 19-20: Device Selection */ + acpigen_emit_word(ctx, spi->device_select); + + /* Fill in Type Data Length */ + acpi_device_fill_len(ctx, type_length); + + /* Byte 21+: ResourceSource String */ + acpigen_emit_string(ctx, spi->resource); + + /* Fill in SPI Descriptor Length */ + acpi_device_fill_len(ctx, desc_length); +} + +/* PowerResource() with Enable and/or Reset control */ +int acpi_device_add_power_res(struct acpi_ctx *ctx, + const struct acpi_power_res_params *params) +{ + static const char *const power_res_dev_states[] = { "_PR0", "_PR3" }; + unsigned int reset_gpio = params->reset_gpio->pins[0]; + unsigned int enable_gpio = params->enable_gpio->pins[0]; + unsigned int stop_gpio = params->stop_gpio->pins[0]; + int ret; + + if (!reset_gpio && !enable_gpio && !stop_gpio) + return -EINVAL; + + /* PowerResource (PRIC, 0, 0) */ + acpigen_write_power_res(ctx, "PRIC", 0, 0, power_res_dev_states, + ARRAY_SIZE(power_res_dev_states)); + + /* Method (_STA, 0, NotSerialized) { Return (0x1) } */ + acpigen_write_sta(ctx, 0x1); + + /* Method (_ON, 0, Serialized) */ + acpigen_write_method_serialized(ctx, "_ON", 0); + if (reset_gpio) { + ret = acpigen_enable_tx_gpio(ctx, params->reset_gpio); + if (ret) + return log_msg_ret("reset1", ret); + } + if (enable_gpio) { + ret = acpigen_enable_tx_gpio(ctx, params->enable_gpio); + if (ret) + return log_msg_ret("enable1", ret); + if (params->enable_delay_ms) + acpigen_write_sleep(ctx, params->enable_delay_ms); + } + if (reset_gpio) { + ret = acpigen_disable_tx_gpio(ctx, params->reset_gpio); + if (ret) + return log_msg_ret("reset2", ret); + if (params->reset_delay_ms) + acpigen_write_sleep(ctx, params->reset_delay_ms); + } + if (stop_gpio) { + ret = acpigen_disable_tx_gpio(ctx, params->stop_gpio); + if (ret) + return log_msg_ret("stop1", ret); + if (params->stop_delay_ms) + acpigen_write_sleep(ctx, params->stop_delay_ms); + } + acpigen_pop_len(ctx); /* _ON method */ + + /* Method (_OFF, 0, Serialized) */ + acpigen_write_method_serialized(ctx, "_OFF", 0); + if (stop_gpio) { + ret = acpigen_enable_tx_gpio(ctx, params->stop_gpio); + if (ret) + return log_msg_ret("stop2", ret); + if (params->stop_off_delay_ms) + acpigen_write_sleep(ctx, params->stop_off_delay_ms); + } + if (reset_gpio) { + ret = acpigen_enable_tx_gpio(ctx, params->reset_gpio); + if (ret) + return log_msg_ret("reset3", ret); + if (params->reset_off_delay_ms) + acpigen_write_sleep(ctx, params->reset_off_delay_ms); + } + if (enable_gpio) { + ret = acpigen_disable_tx_gpio(ctx, params->enable_gpio); + if (ret) + return log_msg_ret("enable2", ret); + if (params->enable_off_delay_ms) + acpigen_write_sleep(ctx, params->enable_off_delay_ms); + } + acpigen_pop_len(ctx); /* _OFF method */ + + acpigen_pop_len(ctx); /* PowerResource PRIC */ + + return 0; +} + +static void acpi_dp_write_array(struct acpi_ctx *ctx, + const struct acpi_dp *array); + +static void acpi_dp_write_value(struct acpi_ctx *ctx, + const struct acpi_dp *prop) +{ + switch (prop->type) { + case ACPI_DP_TYPE_INTEGER: + acpigen_write_integer(ctx, prop->integer); + break; + case ACPI_DP_TYPE_STRING: + case ACPI_DP_TYPE_CHILD: + acpigen_write_string(ctx, prop->string); + break; + case ACPI_DP_TYPE_REFERENCE: + acpigen_emit_namestring(ctx, prop->string); + break; + case ACPI_DP_TYPE_ARRAY: + acpi_dp_write_array(ctx, prop->array); + break; + default: + break; + } +} + +/* Package (2) { "prop->name", VALUE } */ +static void acpi_dp_write_property(struct acpi_ctx *ctx, + const struct acpi_dp *prop) +{ + acpigen_write_package(ctx, 2); + acpigen_write_string(ctx, prop->name); + acpi_dp_write_value(ctx, prop); + acpigen_pop_len(ctx); +} + +/* Write array of Device Properties */ +static void acpi_dp_write_array(struct acpi_ctx *ctx, + const struct acpi_dp *array) +{ + const struct acpi_dp *dp; + char *pkg_count; + + /* Package element count determined as it is populated */ + pkg_count = acpigen_write_package(ctx, 0); + + /* + * Only acpi_dp of type DP_TYPE_TABLE is allowed to be an array. + * DP_TYPE_TABLE does not have a value to be written. Thus, start + * the loop from next type in the array. + */ + for (dp = array->next; dp; dp = dp->next) { + acpi_dp_write_value(ctx, dp); + (*pkg_count)++; + } + + acpigen_pop_len(ctx); +} + +static void acpi_dp_free(struct acpi_dp *dp) +{ + while (dp) { + struct acpi_dp *p = dp->next; + + switch (dp->type) { + case ACPI_DP_TYPE_CHILD: + acpi_dp_free(dp->child); + break; + case ACPI_DP_TYPE_ARRAY: + acpi_dp_free(dp->array); + break; + default: + break; + } + + free(dp); + dp = p; + } +} + +int acpi_dp_write(struct acpi_ctx *ctx, struct acpi_dp *table) +{ + struct acpi_dp *dp, *prop; + char *dp_count, *prop_count = NULL; + int child_count = 0; + int ret; + + if (!table || table->type != ACPI_DP_TYPE_TABLE) + return 0; + + /* Name (name) */ + acpigen_write_name(ctx, table->name); + + /* Device Property list starts with the next entry */ + prop = table->next; + + /* Package (DP), default to assuming no properties or children */ + dp_count = acpigen_write_package(ctx, 0); + + /* Print base properties */ + for (dp = prop; dp; dp = dp->next) { + if (dp->type == ACPI_DP_TYPE_CHILD) { + child_count++; + } else { + /* + * The UUID and package is only added when + * we come across the first property. This + * is to avoid creating a zero-length package + * in situations where there are only children. + */ + if (!prop_count) { + *dp_count += 2; + /* ToUUID (ACPI_DP_UUID) */ + ret = acpigen_write_uuid(ctx, ACPI_DP_UUID); + if (ret) + return log_msg_ret("touuid", ret); + /* + * Package (PROP), element count determined as + * it is populated + */ + prop_count = acpigen_write_package(ctx, 0); + } + (*prop_count)++; + acpi_dp_write_property(ctx, dp); + } + } + + if (prop_count) { + /* Package (PROP) length, if a package was written */ + acpigen_pop_len(ctx); + } + + if (child_count) { + /* Update DP package count to 2 or 4 */ + *dp_count += 2; + /* ToUUID (ACPI_DP_CHILD_UUID) */ + ret = acpigen_write_uuid(ctx, ACPI_DP_CHILD_UUID); + if (ret) + return log_msg_ret("child uuid", ret); + + /* Print child pointer properties */ + acpigen_write_package(ctx, child_count); + + for (dp = prop; dp; dp = dp->next) + if (dp->type == ACPI_DP_TYPE_CHILD) + acpi_dp_write_property(ctx, dp); + /* Package (CHILD) length */ + acpigen_pop_len(ctx); + } + + /* Package (DP) length */ + acpigen_pop_len(ctx); + + /* Recursively parse children into separate tables */ + for (dp = prop; dp; dp = dp->next) { + if (dp->type == ACPI_DP_TYPE_CHILD) { + ret = acpi_dp_write(ctx, dp->child); + if (ret) + return log_msg_ret("dp child", ret); + } + } + + /* Clean up */ + acpi_dp_free(table); + + return 0; +} + +static struct acpi_dp *acpi_dp_new(struct acpi_dp *dp, enum acpi_dp_type type, + const char *name) +{ + struct acpi_dp *new; + + new = malloc(sizeof(struct acpi_dp)); + if (!new) + return NULL; + + memset(new, '\0', sizeof(*new)); + new->type = type; + new->name = name; + + if (dp) { + /* Add to end of property list */ + while (dp->next) + dp = dp->next; + dp->next = new; + } + + return new; +} + +struct acpi_dp *acpi_dp_new_table(const char *name) +{ + return acpi_dp_new(NULL, ACPI_DP_TYPE_TABLE, name); +} + +size_t acpi_dp_add_property_list(struct acpi_dp *dp, + const struct acpi_dp *property_list, + size_t property_count) +{ + const struct acpi_dp *prop; + size_t i, properties_added = 0; + + if (!dp || !property_list) + return 0; + + for (i = 0; i < property_count; i++) { + prop = &property_list[i]; + + if (prop->type == ACPI_DP_TYPE_UNKNOWN || !prop->name) + continue; + + switch (prop->type) { + case ACPI_DP_TYPE_INTEGER: + acpi_dp_add_integer(dp, prop->name, prop->integer); + break; + case ACPI_DP_TYPE_STRING: + acpi_dp_add_string(dp, prop->name, prop->string); + break; + case ACPI_DP_TYPE_REFERENCE: + acpi_dp_add_reference(dp, prop->name, prop->string); + break; + case ACPI_DP_TYPE_ARRAY: + acpi_dp_add_array(dp, prop->array); + break; + case ACPI_DP_TYPE_CHILD: + acpi_dp_add_child(dp, prop->name, prop->child); + break; + default: + continue; + } + + ++properties_added; + } + + return properties_added; +} + +struct acpi_dp *acpi_dp_add_integer(struct acpi_dp *dp, const char *name, + u64 value) +{ + struct acpi_dp *new = acpi_dp_new(dp, ACPI_DP_TYPE_INTEGER, name); + + if (new) + new->integer = value; + + return new; +} + +struct acpi_dp *acpi_dp_add_string(struct acpi_dp *dp, const char *name, + const char *string) +{ + struct acpi_dp *new = acpi_dp_new(dp, ACPI_DP_TYPE_STRING, name); + + if (new) + new->string = string; + + return new; +} + +struct acpi_dp *acpi_dp_add_reference(struct acpi_dp *dp, const char *name, + const char *reference) +{ + if (!dp) + return NULL; + + struct acpi_dp *new = acpi_dp_new(dp, ACPI_DP_TYPE_REFERENCE, name); + + if (new) + new->string = reference; + + return new; +} + +struct acpi_dp *acpi_dp_add_child(struct acpi_dp *dp, const char *name, + struct acpi_dp *child) +{ + struct acpi_dp *new; + + if (!dp || !child || child->type != ACPI_DP_TYPE_TABLE) + return NULL; + + new = acpi_dp_new(dp, ACPI_DP_TYPE_CHILD, name); + if (new) { + new->child = child; + new->string = child->name; + } + + return new; +} + +struct acpi_dp *acpi_dp_add_array(struct acpi_dp *dp, struct acpi_dp *array) +{ + struct acpi_dp *new; + + if (!dp || !array || array->type != ACPI_DP_TYPE_TABLE) + return NULL; + + new = acpi_dp_new(dp, ACPI_DP_TYPE_ARRAY, array->name); + if (new) + new->array = array; + + return new; +} + +struct acpi_dp *acpi_dp_add_integer_array(struct acpi_dp *dp, const char *name, + u64 *array, int len) +{ + struct acpi_dp *dp_array; + int i; + + if (!dp || len <= 0) + return NULL; + + dp_array = acpi_dp_new_table(name); + if (!dp_array) + return NULL; + + for (i = 0; i < len; i++) + if (!acpi_dp_add_integer(dp_array, NULL, array[i])) + break; + + acpi_dp_add_array(dp, dp_array); + + return dp_array; +} + +struct acpi_dp *acpi_dp_add_gpio(struct acpi_dp *dp, const char *name, + const char *ref, int index, int pin, + bool active_low) +{ + if (!dp) + return NULL; + + struct acpi_dp *gpio = acpi_dp_new_table(name); + + if (!gpio) + return NULL; + + /* The device that has _CRS containing GpioIO()/GpioInt() */ + acpi_dp_add_reference(gpio, NULL, ref); + + /* Index of the GPIO resource in _CRS starting from zero */ + acpi_dp_add_integer(gpio, NULL, index); + + /* Pin in the GPIO resource, typically zero */ + acpi_dp_add_integer(gpio, NULL, pin); + + /* Set if pin is active low */ + acpi_dp_add_integer(gpio, NULL, active_low); + + acpi_dp_add_array(dp, gpio); + + return gpio; +} + +/** + * acpi_device_set_i2c() - Set up an ACPI I2C struct from a device + * + * @dev: I2C device to convert + * @i2c: Place to put the new structure + * @scope: Scope of the I2C device (this is the controller path) + * @return 0 (always) + */ +static int acpi_device_set_i2c(const struct udevice *dev, struct acpi_i2c *i2c, + const char *scope) +{ + struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct udevice *bus = dev_get_parent(dev); + + memset(i2c, '\0', sizeof(i2c)); + i2c->address = chip->chip_addr; + i2c->mode_10bit = 0; + + /* + * i2c_bus->speed_hz is set if this device is probed, but if not we + * must use the device tree + */ + i2c->speed = dev_read_u32_default(bus, "clock-frequency", 100000); + i2c->resource = scope; + + return 0; +} + +int acpi_device_write_i2c_dev(struct acpi_ctx *ctx, const struct udevice *dev) +{ + char scope[ACPI_PATH_MAX]; + struct acpi_i2c i2c; + int ret; + + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + ret = acpi_device_set_i2c(dev, &i2c, scope); + if (ret) + return log_msg_ret("set", ret); + acpi_device_write_i2c(ctx, &i2c); + + return 0; +} + +static void i2c_hid_func0_cb(struct acpi_ctx *ctx, void *arg) +{ + /* ToInteger (Arg1, Local2) */ + acpigen_write_to_integer(ctx, ARG1_OP, LOCAL2_OP); + /* If (LEqual (Local2, 0x0)) */ + acpigen_write_if_lequal_op_int(ctx, LOCAL2_OP, 0x0); + /* Return (Buffer (One) { 0x1f }) */ + acpigen_write_return_singleton_buffer(ctx, 0x1f); + acpigen_pop_len(ctx); /* Pop : If */ + /* Else */ + acpigen_write_else(ctx); + /* If (LEqual (Local2, 0x1)) */ + acpigen_write_if_lequal_op_int(ctx, LOCAL2_OP, 0x1); + /* Return (Buffer (One) { 0x3f }) */ + acpigen_write_return_singleton_buffer(ctx, 0x3f); + acpigen_pop_len(ctx); /* Pop : If */ + /* Else */ + acpigen_write_else(ctx); + /* Return (Buffer (One) { 0x0 }) */ + acpigen_write_return_singleton_buffer(ctx, 0x0); + acpigen_pop_len(ctx); /* Pop : Else */ + acpigen_pop_len(ctx); /* Pop : Else */ +} + +static void i2c_hid_func1_cb(struct acpi_ctx *ctx, void *arg) +{ + struct dsm_i2c_hid_config *config = arg; + + acpigen_write_return_byte(ctx, config->hid_desc_reg_offset); +} + +static hid_callback_func i2c_hid_callbacks[2] = { + i2c_hid_func0_cb, + i2c_hid_func1_cb, +}; + +void acpi_device_write_dsm_i2c_hid(struct acpi_ctx *ctx, + struct dsm_i2c_hid_config *config) +{ + acpigen_write_dsm(ctx, ACPI_DSM_I2C_HID_UUID, i2c_hid_callbacks, + ARRAY_SIZE(i2c_hid_callbacks), config); +} + +static const char *acpi_name_from_id(enum uclass_id id) +{ + switch (id) { + case UCLASS_USB_HUB: + /* Root Hub */ + return "RHUB"; + /* DSDT: acpi/northbridge.asl */ + case UCLASS_NORTHBRIDGE: + return "MCHC"; + /* DSDT: acpi/lpc.asl */ + case UCLASS_LPC: + return "LPCB"; + /* DSDT: acpi/xhci.asl */ + case UCLASS_USB: + return "XHCI"; + case UCLASS_PWM: + return "PWM"; + default: + return NULL; + } +} + +static int acpi_check_seq(const struct udevice *dev) +{ + if (dev->req_seq == -1) { + log_warning("Device '%s' has no seq\n", dev->name); + return log_msg_ret("no seq", -ENXIO); + } + + return dev->req_seq; +} + +/* If you change this function, add test cases to dm_test_acpi_get_name() */ +int acpi_device_get_name(const struct udevice *dev, char *out_name) +{ + enum uclass_id parent_id = UCLASS_INVALID; + enum uclass_id id; + const char *name = NULL; + + id = device_get_uclass_id(dev); + if (dev_get_parent(dev)) + parent_id = device_get_uclass_id(dev_get_parent(dev)); + + if (id == UCLASS_SOUND) + name = "HDAS"; + else if (id == UCLASS_PCI) + name = "PCI0"; + else if (device_is_on_pci_bus(dev)) + name = acpi_name_from_id(id); + if (!name) { + switch (parent_id) { + case UCLASS_USB: { + struct usb_device *udev = dev_get_parent_priv(dev); + + sprintf(out_name, udev->speed >= USB_SPEED_SUPER ? + "HS%02d" : "FS%02d", + udev->portnr); + name = out_name; + break; + } + default: + break; + } + } + if (!name) { + int num; + + switch (id) { + /* DSDT: acpi/lpss.asl */ + case UCLASS_SERIAL: + num = acpi_check_seq(dev); + if (num < 0) + return num; + sprintf(out_name, "URT%d", num); + name = out_name; + break; + case UCLASS_I2C: + num = acpi_check_seq(dev); + if (num < 0) + return num; + sprintf(out_name, "I2C%d", num); + name = out_name; + break; + case UCLASS_SPI: + num = acpi_check_seq(dev); + if (num < 0) + return num; + sprintf(out_name, "SPI%d", num); + name = out_name; + break; + default: + break; + } + } + if (!name) { + log_warning("No name for device '%s'\n", dev->name); + return -ENOENT; + } + if (name != out_name) + memcpy(out_name, name, ACPI_NAME_MAX); + + return 0; +} + +int acpi_dp_ofnode_copy_int(ofnode node, struct acpi_dp *dp, const char *prop) +{ + int ret; + u32 val = 0; + + ret = ofnode_read_u32(node, prop, &val); + acpi_dp_add_integer(dp, prop, val); + + return ret; +} + +int acpi_dp_ofnode_copy_str(ofnode node, struct acpi_dp *dp, const char *prop) +{ + const char *val; + + val = ofnode_read_string(node, prop); + if (!val) + return -ENOENT; + acpi_dp_add_string(dp, prop, val); + + return 0; +} + +int acpi_dp_dev_copy_int(const struct udevice *dev, struct acpi_dp *dp, + const char *prop) +{ + int ret; + u32 val = 0; + + ret = dev_read_u32(dev, prop, &val); + acpi_dp_add_integer(dp, prop, val); + + return ret; +} + +int acpi_dp_dev_copy_str(const struct udevice *dev, struct acpi_dp *dp, + const char *prop) +{ + const char *val; + + val = dev_read_string(dev, prop); + if (!val) + return -ENOENT; + acpi_dp_add_string(dp, prop, val); + + return 0; +} From patchwork Mon Jan 27 05:05: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: 1229533 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=kAKRgiCk; 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 485dGz50Xlz9sR1 for ; Mon, 27 Jan 2020 16:15:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ECBC381846; Mon, 27 Jan 2020 06:11:19 +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="kAKRgiCk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 543A481834; Mon, 27 Jan 2020 06:09:25 +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 C3A9A817B4 for ; Mon, 27 Jan 2020 06:08:50 +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 x1so8555025iop.7 for ; Sun, 26 Jan 2020 21:08:50 -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=cHbQ5RfOa6UtAMpw6tjWbk5/5q/dfR8TfQAdea62XA0=; b=kAKRgiCkbQBQNWARPHWES5qawqHQtn2CmD2Fy/WqGyAcEV6b7Y37QjfG3UPlq6lXA3 /rMpSKjjbyzaU2VpDYSuUap2yr4igVWSGyv4n/uDA6mWQk0wCVHT9kmZ8f4oBfAehrDr Kx9oi5iTTVPw/VErrr/ZTnjqFvLE975z2e5CI= 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=cHbQ5RfOa6UtAMpw6tjWbk5/5q/dfR8TfQAdea62XA0=; b=q5z2t+GTqZtiQV50b99xxnjzHLGpM6eS2AfaotEJSR5MlNowjEt8sTofVjni8qxfb4 Zt6ga3OUBgqDlC0JGRBh0CIYOGZdxAbSg6np7/lQdnIaAVbTg3VMCEPFuiHrl+P59SA5 nTMJpP7af8CtfR3KCY29ivMjFZxVCjbSSKvcztth99WUJQhUO/yDMnv2CtBDHeWQk971 zl1ngA8buRtqFysHiR0BquSZzurSvn/GllN+2m1Bjpev/1D3L57+L/p8SVGlDJ7Bw4N9 LhkMyCemEf5OixI9Tr7/13vzuR95ZfsIEVlsFSaDq4fjwmPimAGyeLzCZ5zOMbKLzNx/ Wa2A== X-Gm-Message-State: APjAAAUrr9MMtQzPDxCmP9Zp+Wxuqln0Dc+iU3+V1oe08z+Qz8YLyUuy H/nBh1QRd2qXz95NsCPA+87FJZTils1jxA== X-Google-Smtp-Source: APXvYqzdspjvrnPuMNb8NYNTBRDfpAarIEH8/VjreFBXyp7WApE16Epx8Pf/goW2dFmHTsK5S+w8eg== X-Received: by 2002:a5e:8612:: with SMTP id z18mr11630076ioj.206.1580101728420; Sun, 26 Jan 2020 21:08:48 -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.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 030/108] acpi: Add functions to generate ACPI code Date: Sun, 26 Jan 2020 22:05:37 -0700 Message-Id: <20200126220508.30.Ie25c3492416531983761521cbc51e188052e18b4@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 Sometimes we need to generate ACPI code on the fly based on things only known at run time. Add a new 'acpigen' library to handle this. This code comes from coreboot and has been modified to support the acpi_ctx struct. Also add acpi_device.c to the build, since these files are co-dependent. Signed-off-by: Simon Glass --- include/acpigen.h | 482 +++++++++++++ include/dm/acpi.h | 7 + include/irq.h | 2 + include/log.h | 2 + lib/acpi/Makefile | 2 + lib/acpi/acpigen.c | 1683 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 2178 insertions(+) create mode 100644 include/acpigen.h create mode 100644 lib/acpi/acpigen.c diff --git a/include/acpigen.h b/include/acpigen.h new file mode 100644 index 0000000000..08000831b9 --- /dev/null +++ b/include/acpigen.h @@ -0,0 +1,482 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Core ACPI (Advanced Configuration and Power Interface) support + * + * Copyright 2019 Google LLC + * + * Modified from coreboot file acpigen.h + */ + +#ifndef _ACPIGEN_H +#define _ACPIGEN_H + +#include + +struct acpi_cstate; +struct acpi_pld; +struct acpi_gpio; +struct acpi_tstate; + +/* Values that can be returned for ACPI Device _STA method */ +#define ACPI_STATUS_DEVICE_PRESENT BIT(0) +#define ACPI_STATUS_DEVICE_ENABLED BIT(1) +#define ACPI_STATUS_DEVICE_SHOW_IN_UI BIT(2) +#define ACPI_STATUS_DEVICE_STATE_OK BIT(3) + +#define ACPI_STATUS_DEVICE_ALL_OFF 0 +#define ACPI_STATUS_DEVICE_ALL_ON (ACPI_STATUS_DEVICE_PRESENT |\ + ACPI_STATUS_DEVICE_ENABLED |\ + ACPI_STATUS_DEVICE_SHOW_IN_UI |\ + ACPI_STATUS_DEVICE_STATE_OK) +#define ACPI_STATUS_DEVICE_HIDDEN_ON (ACPI_STATUS_DEVICE_PRESENT |\ + ACPI_STATUS_DEVICE_ENABLED |\ + ACPI_STATUS_DEVICE_STATE_OK) + +/* ACPI Op/Prefix Codes */ +enum { + ZERO_OP = 0x00, + ONE_OP = 0x01, + ALIAS_OP = 0x06, + NAME_OP = 0x08, + BYTE_PREFIX = 0x0A, + WORD_PREFIX = 0x0B, + DWORD_PREFIX = 0x0C, + STRING_PREFIX = 0x0D, + QWORD_PREFIX = 0x0E, + SCOPE_OP = 0x10, + BUFFER_OP = 0x11, + PACKAGE_OP = 0x12, + VARIABLE_PACKAGE_OP = 0x13, + METHOD_OP = 0x14, + EXTERNAL_OP = 0x15, + DUAL_NAME_PREFIX = 0x2E, + MULTI_NAME_PREFIX = 0x2F, + EXT_OP_PREFIX = 0x5B, + + MUTEX_OP = 0x01, + EVENT_OP = 0x01, + SF_RIGHT_OP = 0x10, + SF_LEFT_OP = 0x11, + COND_REFOF_OP = 0x12, + CREATEFIELD_OP = 0x13, + LOAD_TABLE_OP = 0x1f, + LOAD_OP = 0x20, + STALL_OP = 0x21, + SLEEP_OP = 0x22, + ACQUIRE_OP = 0x23, + SIGNAL_OP = 0x24, + WAIT_OP = 0x25, + RST_OP = 0x26, + RELEASE_OP = 0x27, + FROM_BCD_OP = 0x28, + TO_BCD_OP = 0x29, + UNLOAD_OP = 0x2A, + REVISON_OP = 0x30, + DEBUG_OP = 0x31, + FATAL_OP = 0x32, + TIMER_OP = 0x33, + OPREGION_OP = 0x80, + FIELD_OP = 0x81, + DEVICE_OP = 0x82, + PROCESSOR_OP = 0x83, + POWER_RES_OP = 0x84, + THERMAL_ZONE_OP = 0x85, + INDEX_FIELD_OP = 0x86, + BANK_FIELD_OP = 0x87, + DATA_REGION_OP = 0x88, + + ROOT_PREFIX = 0x5C, + PARENT_PREFIX = 0x5D, + LOCAL0_OP = 0x60, + LOCAL1_OP = 0x61, + LOCAL2_OP = 0x62, + LOCAL3_OP = 0x63, + LOCAL4_OP = 0x64, + LOCAL5_OP = 0x65, + LOCAL6_OP = 0x66, + LOCAL7_OP = 0x67, + ARG0_OP = 0x68, + ARG1_OP = 0x69, + ARG2_OP = 0x6A, + ARG3_OP = 0x6B, + ARG4_OP = 0x6C, + ARG5_OP = 0x6D, + ARG6_OP = 0x6E, + STORE_OP = 0x70, + REF_OF_OP = 0x71, + ADD_OP = 0x72, + CONCATENATE_OP = 0x73, + SUBTRACT_OP = 0x74, + INCREMENT_OP = 0x75, + DECREMENT_OP = 0x76, + MULTIPLY_OP = 0x77, + DIVIDE_OP = 0x78, + SHIFT_LEFT_OP = 0x79, + SHIFT_RIGHT_OP = 0x7A, + AND_OP = 0x7B, + NAND_OP = 0x7C, + OR_OP = 0x7D, + NOR_OP = 0x7E, + XOR_OP = 0x7F, + NOT_OP = 0x80, + FD_SHIFT_LEFT_BIT_OR = 0x81, + FD_SHIFT_RIGHT_BIT_OR = 0x82, + DEREF_OP = 0x83, + CONCATENATE_TEMP_OP = 0x84, + MOD_OP = 0x85, + NOTIFY_OP = 0x86, + SIZEOF_OP = 0x87, + INDEX_OP = 0x88, + MATCH_OP = 0x89, + CREATE_DWORD_OP = 0x8A, + CREATE_WORD_OP = 0x8B, + CREATE_BYTE_OP = 0x8C, + CREATE_BIT_OP = 0x8D, + OBJ_TYPE_OP = 0x8E, + CREATE_QWORD_OP = 0x8F, + LAND_OP = 0x90, + LOR_OP = 0x91, + LNOT_OP = 0x92, + LEQUAL_OP = 0x93, + LGREATER_OP = 0x94, + LLESS_OP = 0x95, + TO_BUFFER_OP = 0x96, + TO_DEC_STRING_OP = 0x97, + TO_HEX_STRING_OP = 0x98, + TO_INTEGER_OP = 0x99, + TO_STRING_OP = 0x9C, + CP_OBJ_OP = 0x9D, + MID_OP = 0x9E, + CONTINUE_OP = 0x9F, + IF_OP = 0xA0, + ELSE_OP = 0xA1, + WHILE_OP = 0xA2, + NOOP_OP = 0xA3, + RETURN_OP = 0xA4, + BREAK_OP = 0xA5, + COMMENT_OP = 0xA9, + BREAKPIONT_OP = 0xCC, + ONES_OP = 0xFF, +}; + +#define FIELDLIST_OFFSET(_bits) { .type = OFFSET, \ + .name = "", \ + .bits = _bits * 8, \ + } +#define FIELDLIST_NAMESTR(_name, _bits) { .type = NAME_STRING, \ + .name = _name, \ + .bits = _bits, \ + } + +#define FIELD_ANYACC 0 +#define FIELD_BYTEACC 1 +#define FIELD_WORDACC 2 +#define FIELD_DWORDACC 3 +#define FIELD_QWORDACC 4 +#define FIELD_BUFFERACC 5 +#define FIELD_NOLOCK (0 << 4) +#define FIELD_LOCK (1 << 4) +#define FIELD_PRESERVE (0 << 5) +#define FIELD_WRITEASONES (1 << 5) +#define FIELD_WRITEASZEROS (2 << 5) + +enum field_type { + OFFSET, + NAME_STRING, + FIELD_TYPE_MAX, +}; + +struct fieldlist { + enum field_type type; + const char *name; + u32 bits; +}; + +#define OPREGION(rname, space, offset, len) {.name = rname, \ + .regionspace = space, \ + .regionoffset = offset, \ + .regionlen = len, \ + } + +enum region_space { + SYSTEMMEMORY, + SYSTEMIO, + PCI_CONFIG, + EMBEDDEDCONTROL, + SMBUS, + CMOS, + PCIBARTARGET, + IPMI, + GPIO_REGION, + GPSERIALBUS, + PCC, + FIXED_HARDWARE = 0x7F, + REGION_SPACE_MAX, +}; + +struct opregion { + const char *name; + enum region_space regionspace; + unsigned long regionoffset; + unsigned long regionlen; +}; + +#define DSM_UUID(DSM_UUID, DSM_CALLBACKS, DSM_COUNT, DSM_ARG) \ + { .uuid = DSM_UUID, \ + .callbacks = DSM_CALLBACKS, \ + .count = DSM_COUNT, \ + .arg = DSM_ARG, \ + } + +typedef void (*hid_callback_func)(struct acpi_ctx *ctx, void *arg); + +struct dsm_uuid { + const char *uuid; + hid_callback_func *callbacks; + size_t count; + void *arg; +}; + +/* version 1 has 15 fields, version 2 has 19, and version 3 has 21 */ +enum cppc_fields { + CPPC_HIGHEST_PERF, /* can be DWORD */ + CPPC_NOMINAL_PERF, /* can be DWORD */ + CPPC_LOWEST_NONL_PERF, /* can be DWORD */ + CPPC_LOWEST_PERF, /* can be DWORD */ + CPPC_GUARANTEED_PERF, + CPPC_DESIRED_PERF, + CPPC_MIN_PERF, + CPPC_MAX_PERF, + CPPC_PERF_REDUCE_TOLERANCE, + CPPC_TIME_WINDOW, + CPPC_COUNTER_WRAP, /* can be DWORD */ + CPPC_REF_PERF_COUNTER, + CPPC_DELIVERED_PERF_COUNTER, + CPPC_PERF_LIMITED, + CPPC_ENABLE, /* can be System I/O */ + CPPC_MAX_FIELDS_VER_1, + CPPC_AUTO_SELECT = /* can be DWORD */ + CPPC_MAX_FIELDS_VER_1, + CPPC_AUTO_ACTIVITY_WINDOW, + CPPC_PERF_PREF, + CPPC_REF_PERF, /* can be DWORD */ + CPPC_MAX_FIELDS_VER_2, + CPPC_LOWEST_FREQ = /* can be DWORD */ + CPPC_MAX_FIELDS_VER_2, + CPPC_NOMINAL_FREQ, /* can be DWORD */ + CPPC_MAX_FIELDS_VER_3, +}; + +struct cppc_config { + u32 version; /* must be 1, 2, or 3 */ + /* + * The generic struct acpi_gen_regaddr structure is being used, though + * anything besides PPC or FFIXED generally requires checking + * if the OS has advertised support for it (via _OSC). + * + * NOTE: some fields permit DWORDs to be used. If you + * provide a System Memory register with all zeros (which + * represents unsupported) then this will be used as-is. + * Otherwise, a System Memory register with a 32-bit + * width will be converted into a DWORD field (the value + * of which will be the value of 'addrl'. Any other use + * of System Memory register is currently undefined. + * (i.e., if you have an actual need for System Memory + * then you'll need to adjust this kludge). + */ + struct acpi_gen_regaddr regs[CPPC_MAX_FIELDS_VER_3]; +}; + +void acpigen_write_return_integer(struct acpi_ctx *ctx, u64 arg); +void acpigen_write_return_string(struct acpi_ctx *ctx, const char *arg); +void acpigen_write_len_f(struct acpi_ctx *ctx); +void acpigen_pop_len(struct acpi_ctx *ctx); +void acpigen_set_current(struct acpi_ctx *ctx, char *curr); +char *acpigen_get_current(struct acpi_ctx *ctx); +char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el); +void acpigen_write_zero(struct acpi_ctx *ctx); +void acpigen_write_one(struct acpi_ctx *ctx); +void acpigen_write_ones(struct acpi_ctx *ctx); +void acpigen_write_byte(struct acpi_ctx *ctx, unsigned int data); +void acpigen_emit_byte(struct acpi_ctx *ctx, unsigned char data); +void acpigen_emit_ext_op(struct acpi_ctx *ctx, u8 op); +void acpigen_emit_word(struct acpi_ctx *ctx, unsigned int data); +void acpigen_emit_dword(struct acpi_ctx *ctx, unsigned int data); +void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size); +void acpigen_emit_string(struct acpi_ctx *ctx, const char *string); +void acpigen_emit_namestring(struct acpi_ctx *ctx, const char *namepath); +void acpigen_emit_eisaid(struct acpi_ctx *ctx, const char *eisaid); +void acpigen_write_word(struct acpi_ctx *ctx, unsigned int data); +void acpigen_write_dword(struct acpi_ctx *ctx, unsigned int data); +void acpigen_write_qword(struct acpi_ctx *ctx, u64 data); +void acpigen_write_integer(struct acpi_ctx *ctx, u64 data); +void acpigen_write_string(struct acpi_ctx *ctx, const char *string); +void acpigen_write_coreboot_hid(struct acpi_ctx *ctx, + enum coreboot_acpi_ids id); +void acpigen_write_name(struct acpi_ctx *ctx, const char *name); +void acpigen_write_name_zero(struct acpi_ctx *ctx, const char *name); +void acpigen_write_name_one(struct acpi_ctx *ctx, const char *name); +void acpigen_write_name_string(struct acpi_ctx *ctx, const char *name, + const char *string); +void acpigen_write_name_dword(struct acpi_ctx *ctx, const char *name, u32 val); +void acpigen_write_name_qword(struct acpi_ctx *ctx, const char *name, u64 val); +void acpigen_write_name_byte(struct acpi_ctx *ctx, const char *name, u8 val); +void acpigen_write_name_integer(struct acpi_ctx *ctx, const char *name, + u64 val); +void acpigen_write_scope(struct acpi_ctx *ctx, const char *name); +void acpigen_write_method(struct acpi_ctx *ctx, const char *name, int nargs); +void acpigen_write_method_serialized(struct acpi_ctx *ctx, const char *name, + int nargs); +void acpigen_write_device(struct acpi_ctx *ctx, const char *name); +void acpigen_write_ppc(struct acpi_ctx *ctx, u8 nr); +void acpigen_write_ppc_nvs(struct acpi_ctx *ctx); +void acpigen_write_empty_pct(struct acpi_ctx *ctx); +void acpigen_write_empty_ptc(struct acpi_ctx *ctx); +void acpigen_write_prw(struct acpi_ctx *ctx, u32 wake, u32 level); +void acpigen_write_sta(struct acpi_ctx *ctx, u8 status); +void acpigen_write_tpc(struct acpi_ctx *ctx, const char *gnvs_tpc_limit); +void acpigen_write_pss_package(struct acpi_ctx *ctx, u32 corefreq, u32 power, + u32 translat, + u32 busmlat, u32 control, u32 status); +enum psd_coord { + SW_ALL = 0xfc, + SW_ANY = 0xfd, + HW_ALL = 0xfe +}; + +void acpigen_write_psd_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum psd_coord coordtype); +void acpigen_write_cst_package_entry(struct acpi_ctx *ctx, + struct acpi_cstate *cstate); +void acpigen_write_cst_package(struct acpi_ctx *ctx, struct acpi_cstate *entry, + int nentries); + +enum csd_coord { + CSD_HW_ALL = 0xfe, +}; + +void acpigen_write_CSD_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum csd_coord coordtype, u32 index); +void acpigen_write_processor(struct acpi_ctx *ctx, u8 cpuindex, u32 pblock_addr, + u8 pblock_len); +void acpigen_write_processor_package(struct acpi_ctx *ctx, const char *name, + uint first_core, uint core_count); +void acpigen_write_processor_cnot(struct acpi_ctx *ctx, const uint num_cores); +void acpigen_write_tss_package(struct acpi_ctx *ctx, int entries, + struct acpi_tstate *tstate_list); +void acpigen_write_tsd_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum psd_coord coordtype); +void acpigen_write_mem32fixed(struct acpi_ctx *ctx, int readwrite, u32 base, + u32 size); +void acpigen_write_register_resource(struct acpi_ctx *ctx, + const struct acpi_gen_regaddr *addr); +void acpigen_write_irq(struct acpi_ctx *ctx, u16 mask); +void acpigen_write_resourcetemplate_header(struct acpi_ctx *ctx); +void acpigen_write_resourcetemplate_footer(struct acpi_ctx *ctx); +int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid); +void acpigen_write_power_res(struct acpi_ctx *ctx, const char *name, u8 level, + u16 order, const char *const dev_states[], + size_t dev_states_count); +void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms); +void acpigen_write_store(struct acpi_ctx *ctx); +void acpigen_write_store_ops(struct acpi_ctx *ctx, u8 src, u8 dst); +void acpigen_write_or(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res); +void acpigen_write_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res); +void acpigen_write_not(struct acpi_ctx *ctx, u8 arg, u8 res); +void acpigen_write_debug_string(struct acpi_ctx *ctx, const char *str); +void acpigen_write_debug_integer(struct acpi_ctx *ctx, u64 val); +void acpigen_write_debug_op(struct acpi_ctx *ctx, u8 op); +void acpigen_write_if(struct acpi_ctx *ctx); +void acpigen_write_if_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2); +void acpigen_write_if_lequal_op_int(struct acpi_ctx *ctx, u8 op, u64 val); +void acpigen_write_else(struct acpi_ctx *ctx); +void acpigen_write_to_buffer(struct acpi_ctx *ctx, u8 src, u8 dst); +void acpigen_write_to_integer(struct acpi_ctx *ctx, u8 src, u8 dst); +void acpigen_write_byte_buffer(struct acpi_ctx *ctx, u8 *arr, size_t size); +void acpigen_write_return_byte_buffer(struct acpi_ctx *ctx, u8 *arr, + size_t size); +void acpigen_write_return_singleton_buffer(struct acpi_ctx *ctx, u8 arg); +void acpigen_write_return_byte(struct acpi_ctx *ctx, u8 arg); +void acpigen_write_upc(struct acpi_ctx *ctx, enum acpi_upc_type type); + +/* + * Generate ACPI AML code for _DSM method. + * This function takes as input uuid for the device, set of callbacks and + * argument to pass into the callbacks. Callbacks should ensure that Local0 and + * Local1 are left untouched. Use of Local2-Local7 is permitted in callbacks. + */ +int acpigen_write_dsm(struct acpi_ctx *ctx, const char *uuid, + hid_callback_func callbacks[], size_t count, void *arg); +int acpigen_write_dsm_uuid_arr(struct acpi_ctx *ctx, struct dsm_uuid *ids, + size_t count); + +/* + * Generate ACPI AML code for _CPC (struct acpi_ctx *ctx, Continuous Perfmance + * Control). Execute the package function once to create a global table, then + * execute the method function within each processor object to + * create a method that points to the global table. + */ +int acpigen_write_cppc_package(struct acpi_ctx *ctx, + const struct cppc_config *config); +void acpigen_write_cppc_method(struct acpi_ctx *ctx); + +/* + * Generate ACPI AML code for _ROM method. + * This function takes as input ROM data and ROM length. + * The ROM length has to be multiple of 4096 and has to be less + * than the current implementation limit of 0x40000. + */ +int acpigen_write_rom(struct acpi_ctx *ctx, void *bios, const size_t length); +/* + * Generate ACPI AML code for OperationRegion + * This function takes input region name, region space, region offset & region + * length. + */ +void acpigen_write_opregion(struct acpi_ctx *ctx, struct opregion *opreg); +/* + * Generate ACPI AML code for Field + * This function takes input region name, fieldlist, count & flags. + */ +int acpigen_write_field(struct acpi_ctx *ctx, const char *name, + struct fieldlist *l, size_t count, uint flags); +/* + * Generate ACPI AML code for IndexField + * This function takes input index name, data name, fieldlist, count & flags. + */ +int acpigen_write_indexfield(struct acpi_ctx *ctx, const char *idx, + const char *data, struct fieldlist *l, + size_t count, uint flags); + +/* + * Soc-implemented functions for generating ACPI AML code for GPIO handling. All + * these functions are expected to use only Local5, Local6 and Local7 + * variables. If the functions call into another ACPI method, then there is no + * restriction on the use of Local variables. In case of get/read functions, + * return value is expected to be stored in Local0 variable. + * + * All functions return 0 on success and -1 on error. + */ + +/* Generate ACPI AML code to return Rx value of GPIO in Local0. */ +int acpigen_soc_read_rx_gpio(struct acpi_ctx *ctx, uint gpio_num); + +/* Generate ACPI AML code to return Tx value of GPIO in Local0. */ +int acpigen_soc_get_tx_gpio(struct acpi_ctx *ctx, uint gpio_num); + +/* Generate ACPI AML code to set Tx value of GPIO to 1. */ +int acpigen_soc_set_tx_gpio(struct acpi_ctx *ctx, uint gpio_num); + +/* Generate ACPI AML code to set Tx value of GPIO to 0. */ +int acpigen_soc_clear_tx_gpio(struct acpi_ctx *ctx, uint gpio_num); + +/* + * Helper functions for enabling/disabling Tx GPIOs based on the GPIO + * polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to + * make callbacks into SoC acpigen code. + * + * Returns 0 on success and -1 on error. + */ +int acpigen_enable_tx_gpio(struct acpi_ctx *ctx, struct acpi_gpio *gpio); +int acpigen_disable_tx_gpio(struct acpi_ctx *ctx, struct acpi_gpio *gpio); + +#endif diff --git a/include/dm/acpi.h b/include/dm/acpi.h index f3e9d73b78..0f78a506da 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -22,6 +22,9 @@ /* Length of an ACPI name string including nul terminator */ #define ACPI_NAME_MAX 5 +/* Number of nested objects supported */ +#define ACPIGEN_LENSTACK_SIZE 10 + #if !defined(__ACPI__) /** @@ -34,12 +37,16 @@ * adding a new table. The RSDP holds pointers to the RSDP and XSDT. * @rsdt: Pointer to the Root System Description Table * @xsdt: Pointer to the Extended System Description Table + * @len_stack: Stack of 'length' words to fix up later + * @ltop: Points to current top of stack (0 = empty) */ struct acpi_ctx { void *current; struct acpi_rsdp *rsdp; struct acpi_rsdt *rsdt; struct acpi_xsdt *xsdt; + char *len_stack[ACPIGEN_LENSTACK_SIZE]; + int ltop; }; /** diff --git a/include/irq.h b/include/irq.h index 632f48ff40..eeeef5b56c 100644 --- a/include/irq.h +++ b/include/irq.h @@ -8,6 +8,8 @@ #ifndef __irq_H #define __irq_H +struct ofnode_phandle_args; + /* * Interupt controller types available. You can find a particular one with * irq_first_device_type() diff --git a/include/log.h b/include/log.h index 559ea7e933..90fdb6bf2d 100644 --- a/include/log.h +++ b/include/log.h @@ -50,6 +50,8 @@ enum log_category_t { LOGC_SANDBOX, /* Related to the sandbox board */ LOGC_BLOBLIST, /* Bloblist */ LOGC_DEVRES, /* Device resources (devres_... functions) */ + /* Intel Advanced Configuration and Power Interface (ACPI) */ + LOGC_ACPI, LOGC_COUNT, /* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */ diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile index 660491ef71..85a1f774ad 100644 --- a/lib/acpi/Makefile +++ b/lib/acpi/Makefile @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-y += acpigen.o +obj-y += acpi_device.o obj-y += acpi_table.o diff --git a/lib/acpi/acpigen.c b/lib/acpi/acpigen.c new file mode 100644 index 0000000000..4e7d1ce51e --- /dev/null +++ b/lib/acpi/acpigen.c @@ -0,0 +1,1683 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Generation of ACPI (Advanced Configuration and Power Interface) tables + * + * Copyright 2019 Google LLC + * Mostly taken from coreboot + */ + +#define LOG_CATEGORY LOGC_ACPI + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Maximum length for an ACPI object generated by this code, + * + * If you need to change this, change acpigen_write_len_f(ctx) and + * acpigen_pop_len(ctx) + */ +#define ACPIGEN_MAXLEN 0xfffff + +/* CPU path format */ +#define ACPI_CPU_STRING "\\_PR.CP%02d" + +void acpigen_write_len_f(struct acpi_ctx *ctx) +{ + assert(ctx->ltop < (ACPIGEN_LENSTACK_SIZE - 1)); + ctx->len_stack[ctx->ltop++] = ctx->current; + acpigen_emit_byte(ctx, 0); + acpigen_emit_byte(ctx, 0); + acpigen_emit_byte(ctx, 0); +} + +void acpigen_pop_len(struct acpi_ctx *ctx) +{ + int len; + char *p; + + assert(ctx->ltop > 0); + p = ctx->len_stack[--ctx->ltop]; + len = ctx->current - (void *)p; + assert(len <= ACPIGEN_MAXLEN); + /* generate store length for 0xfffff max */ + p[0] = (0x80 | (len & 0xf)); + p[1] = (len >> 4 & 0xff); + p[2] = (len >> 12 & 0xff); +} + +void acpigen_set_current(struct acpi_ctx *ctx, char *curr) +{ + ctx->current = curr; +} + +char *acpigen_get_current(struct acpi_ctx *ctx) +{ + return ctx->current; +} + +void acpigen_emit_byte(struct acpi_ctx *ctx, unsigned char b) +{ + *(u8 *)ctx->current++ = b; +} + +void acpigen_emit_ext_op(struct acpi_ctx *ctx, u8 op) +{ + acpigen_emit_byte(ctx, EXT_OP_PREFIX); + acpigen_emit_byte(ctx, op); +} + +void acpigen_emit_word(struct acpi_ctx *ctx, unsigned int data) +{ + acpigen_emit_byte(ctx, data & 0xff); + acpigen_emit_byte(ctx, (data >> 8) & 0xff); +} + +void acpigen_emit_dword(struct acpi_ctx *ctx, unsigned int data) +{ + acpigen_emit_byte(ctx, data & 0xff); + acpigen_emit_byte(ctx, (data >> 8) & 0xff); + acpigen_emit_byte(ctx, (data >> 16) & 0xff); + acpigen_emit_byte(ctx, (data >> 24) & 0xff); +} + +char *acpigen_write_package(struct acpi_ctx *ctx, int nr_el) +{ + char *p; + + acpigen_emit_byte(ctx, PACKAGE_OP); + acpigen_write_len_f(ctx); + p = ctx->current; + acpigen_emit_byte(ctx, nr_el); + + return p; +} + +void acpigen_write_byte(struct acpi_ctx *ctx, unsigned int data) +{ + acpigen_emit_byte(ctx, BYTE_PREFIX); + acpigen_emit_byte(ctx, data & 0xff); +} + +void acpigen_write_word(struct acpi_ctx *ctx, unsigned int data) +{ + acpigen_emit_byte(ctx, WORD_PREFIX); + acpigen_emit_word(ctx, data); +} + +void acpigen_write_dword(struct acpi_ctx *ctx, unsigned int data) +{ + acpigen_emit_byte(ctx, DWORD_PREFIX); + acpigen_emit_dword(ctx, data); +} + +void acpigen_write_qword(struct acpi_ctx *ctx, u64 data) +{ + acpigen_emit_byte(ctx, QWORD_PREFIX); + acpigen_emit_dword(ctx, data & 0xffffffff); + acpigen_emit_dword(ctx, (data >> 32) & 0xffffffff); +} + +void acpigen_write_zero(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, ZERO_OP); +} + +void acpigen_write_one(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, ONE_OP); +} + +void acpigen_write_ones(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, ONES_OP); +} + +void acpigen_write_integer(struct acpi_ctx *ctx, u64 data) +{ + if (data == 0) + acpigen_write_zero(ctx); + else if (data == 1) + acpigen_write_one(ctx); + else if (data <= 0xff) + acpigen_write_byte(ctx, (unsigned char)data); + else if (data <= 0xffff) + acpigen_write_word(ctx, (unsigned int)data); + else if (data <= 0xffffffff) + acpigen_write_dword(ctx, (unsigned int)data); + else + acpigen_write_qword(ctx, data); +} + +void acpigen_write_name_zero(struct acpi_ctx *ctx, const char *name) +{ + acpigen_write_name(ctx, name); + acpigen_write_one(ctx); +} + +void acpigen_write_name_one(struct acpi_ctx *ctx, const char *name) +{ + acpigen_write_name(ctx, name); + acpigen_write_zero(ctx); +} + +void acpigen_write_name_byte(struct acpi_ctx *ctx, const char *name, u8 val) +{ + acpigen_write_name(ctx, name); + acpigen_write_byte(ctx, val); +} + +void acpigen_write_name_dword(struct acpi_ctx *ctx, const char *name, u32 val) +{ + acpigen_write_name(ctx, name); + acpigen_write_dword(ctx, val); +} + +void acpigen_write_name_qword(struct acpi_ctx *ctx, const char *name, u64 val) +{ + acpigen_write_name(ctx, name); + acpigen_write_qword(ctx, val); +} + +void acpigen_write_name_integer(struct acpi_ctx *ctx, const char *name, u64 val) +{ + acpigen_write_name(ctx, name); + acpigen_write_integer(ctx, val); +} + +void acpigen_write_name_string(struct acpi_ctx *ctx, const char *name, + const char *string) +{ + acpigen_write_name(ctx, name); + acpigen_write_string(ctx, string); +} + +void acpigen_emit_stream(struct acpi_ctx *ctx, const char *data, int size) +{ + int i; + + for (i = 0; i < size; i++) + acpigen_emit_byte(ctx, data[i]); +} + +void acpigen_emit_string(struct acpi_ctx *ctx, const char *string) +{ + acpigen_emit_stream(ctx, string, string ? strlen(string) : 0); + acpigen_emit_byte(ctx, '\0'); /* NUL */ +} + +void acpigen_write_string(struct acpi_ctx *ctx, const char *string) +{ + acpigen_emit_byte(ctx, STRING_PREFIX); + acpigen_emit_string(ctx, string); +} + +void acpigen_write_coreboot_hid(struct acpi_ctx *ctx, enum coreboot_acpi_ids id) +{ + char hid[9]; /* BOOTxxxx */ + + snprintf(hid, sizeof(hid), "%.4s%04X", COREBOOT_ACPI_ID, id); + acpigen_write_name_string(ctx, "_HID", hid); +} + +/* + * The naming conventions for ACPI namespace names are a bit tricky as + * each element has to be 4 chars wide ("All names are a fixed 32 bits.") + * and "By convention, when an ASL compiler pads a name shorter than 4 + * characters, it is done so with trailing underscores ('_')". + * + * Check sections 5.3, 18.2.2 and 18.4 of ACPI spec 3.0 for details. + */ + +static void acpigen_emit_simple_namestring(struct acpi_ctx *ctx, + const char *name) +{ + char ud[] = "____"; + int i; + + for (i = 0; i < 4; i++) { + if ((name[i] == '\0') || (name[i] == '.')) { + acpigen_emit_stream(ctx, ud, 4 - i); + break; + } + acpigen_emit_byte(ctx, name[i]); + } +} + +static void acpigen_emit_double_namestring(struct acpi_ctx *ctx, + const char *name, int dotpos) +{ + acpigen_emit_byte(ctx, DUAL_NAME_PREFIX); + acpigen_emit_simple_namestring(ctx, name); + acpigen_emit_simple_namestring(ctx, &name[dotpos + 1]); +} + +static void acpigen_emit_multi_namestring(struct acpi_ctx *ctx, + const char *name) +{ + int count = 0; + unsigned char *pathlen; + + acpigen_emit_byte(ctx, MULTI_NAME_PREFIX); + acpigen_emit_byte(ctx, ZERO_OP); + pathlen = ((unsigned char *)ctx->current) - 1; + + while (name[0] != '\0') { + acpigen_emit_simple_namestring(ctx, name); + /* find end or next entity */ + while ((name[0] != '.') && (name[0] != '\0')) + name++; + /* forward to next */ + if (name[0] == '.') + name++; + count++; + } + + pathlen[0] = count; +} + +void acpigen_emit_namestring(struct acpi_ctx *ctx, const char *namepath) +{ + int dotcount = 0, i; + int dotpos = 0; + + /* We can start with a '\'. */ + if (namepath[0] == '\\') { + acpigen_emit_byte(ctx, '\\'); + namepath++; + } + + /* And there can be any number of '^' */ + while (namepath[0] == '^') { + acpigen_emit_byte(ctx, '^'); + namepath++; + } + + /* + * If we have only \\ or only ^...^ then we need to add a null name + * (0x00) + */ + if (namepath[0] == '\0') { + acpigen_emit_byte(ctx, ZERO_OP); + return; + } + + i = 0; + while (namepath[i] != '\0') { + if (namepath[i] == '.') { + dotcount++; + dotpos = i; + } + i++; + } + + if (dotcount == 0) + acpigen_emit_simple_namestring(ctx, namepath); + else if (dotcount == 1) + acpigen_emit_double_namestring(ctx, namepath, dotpos); + else + acpigen_emit_multi_namestring(ctx, namepath); +} + +void acpigen_write_name(struct acpi_ctx *ctx, const char *name) +{ + acpigen_emit_byte(ctx, NAME_OP); + acpigen_emit_namestring(ctx, name); +} + +void acpigen_write_scope(struct acpi_ctx *ctx, const char *name) +{ + acpigen_emit_byte(ctx, SCOPE_OP); + acpigen_write_len_f(ctx); + acpigen_emit_namestring(ctx, name); +} + +void acpigen_write_processor(struct acpi_ctx *ctx, u8 cpuindex, u32 pblock_addr, + u8 pblock_len) +{ + /* + * Processor (\_PR.CPcpuindex, cpuindex, pblock_addr, pblock_len) + * { + */ + char pscope[16]; + + acpigen_emit_ext_op(ctx, PROCESSOR_OP); + acpigen_write_len_f(ctx); + + snprintf(pscope, sizeof(pscope), ACPI_CPU_STRING, (uint)cpuindex); + acpigen_emit_namestring(ctx, pscope); + acpigen_emit_byte(ctx, cpuindex); + acpigen_emit_dword(ctx, pblock_addr); + acpigen_emit_byte(ctx, pblock_len); +} + +void acpigen_write_processor_package(struct acpi_ctx *ctx, + const char *const name, + const uint first_core, + const uint core_count) +{ + uint i; + char pscope[16]; + + acpigen_write_name(ctx, name); + acpigen_write_package(ctx, core_count); + for (i = first_core; i < first_core + core_count; ++i) { + snprintf(pscope, sizeof(pscope), ACPI_CPU_STRING, i); + acpigen_emit_namestring(ctx, pscope); + } + acpigen_pop_len(ctx); +} + +/* Method to notify all CPU cores */ +void acpigen_write_processor_cnot(struct acpi_ctx *ctx, const uint num_cores) +{ + int core_id; + + acpigen_write_method(ctx, "\\_PR.CNOT", 1); + for (core_id = 0; core_id < num_cores; core_id++) { + char buffer[30]; + + snprintf(buffer, sizeof(buffer), ACPI_CPU_STRING, core_id); + acpigen_emit_byte(ctx, NOTIFY_OP); + acpigen_emit_namestring(ctx, buffer); + acpigen_emit_byte(ctx, ARG0_OP); + } + acpigen_pop_len(ctx); +} + +/* + * Generate ACPI AML code for OperationRegion + * Arg0: Pointer to struct opregion opreg = OPREGION(rname, space, offset, len) + * where rname is region name, space is region space, offset is region offset & + * len is region length. + * OperationRegion(regionname, regionspace, regionoffset, regionlength) + */ +void acpigen_write_opregion(struct acpi_ctx *ctx, struct opregion *opreg) +{ + /* OpregionOp */ + acpigen_emit_ext_op(ctx, OPREGION_OP); + /* NameString 4 chars only */ + acpigen_emit_simple_namestring(ctx, opreg->name); + /* RegionSpace */ + acpigen_emit_byte(ctx, opreg->regionspace); + /* RegionOffset & RegionLen, it can be byte word or double word */ + acpigen_write_integer(ctx, opreg->regionoffset); + acpigen_write_integer(ctx, opreg->regionlen); +} + +static void acpigen_write_field_length(struct acpi_ctx *ctx, u32 len) +{ + u8 i, j; + u8 emit[4]; + + i = 1; + if (len < 0x40) { + emit[0] = len & 0x3F; + } else { + emit[0] = len & 0xF; + len >>= 4; + while (len) { + emit[i] = len & 0xFF; + i++; + len >>= 8; + } + } + /* Update bit 7:6 : Number of bytes followed by emit[0] */ + emit[0] |= (i - 1) << 6; + + for (j = 0; j < i; j++) + acpigen_emit_byte(ctx, emit[j]); +} + +static int acpigen_write_field_offset(struct acpi_ctx *ctx, u32 offset, + u32 current_bit_pos) +{ + u32 diff_bits; + + if (offset < current_bit_pos) { + log_warning("Cannot move offset backward"); + return -ESPIPE; + } + + diff_bits = offset - current_bit_pos; + /* Upper limit */ + if (diff_bits > 0xFFFFFFF) { + log_warning("Offset very large to encode"); + return E2BIG; + } + + acpigen_emit_byte(ctx, 0); + acpigen_write_field_length(ctx, diff_bits); + + return 0; +} + +static void acpigen_write_field_name(struct acpi_ctx *ctx, const char *name, + u32 size) +{ + acpigen_emit_simple_namestring(ctx, name); + acpigen_write_field_length(ctx, size); +} + +/* + * Generate ACPI AML code for Field + * Arg0: region name + * Arg1: Pointer to struct fieldlist. + * Arg2: no. of entries in Arg1 + * Arg3: flags which indicate filed access type, lock rule & update rule. + * Example with fieldlist + * struct fieldlist l[] = { + * FIELDLIST_OFFSET(0x84), + * FIELDLIST_NAMESTR("PMCS", 2), + * }; + * acpigen_write_field("UART", l, ARRAY_SIZE(l), FIELD_ANYACC | FIELD_NOLOCK | + * FIELD_PRESERVE); + * Output: + * Field (UART, AnyAcc, NoLock, Preserve) + * { + * Offset (0x84), + * PMCS, 2 + * } + */ +int acpigen_write_field(struct acpi_ctx *ctx, const char *name, + struct fieldlist *l, size_t count, uint flags) +{ + int i; + u32 current_bit_pos = 0; + int ret; + + /* FieldOp */ + acpigen_emit_ext_op(ctx, FIELD_OP); + /* Package Length */ + acpigen_write_len_f(ctx); + /* NameString 4 chars only */ + acpigen_emit_simple_namestring(ctx, name); + /* Field Flag */ + acpigen_emit_byte(ctx, flags); + + for (i = 0; i < count; i++) { + switch (l[i].type) { + case NAME_STRING: + acpigen_write_field_name(ctx, l[i].name, l[i].bits); + current_bit_pos += l[i].bits; + break; + case OFFSET: + ret = acpigen_write_field_offset(ctx, l[i].bits, + current_bit_pos); + if (ret) + return log_msg_ret("field", ret); + current_bit_pos = l[i].bits; + break; + default: + log_err("Invalid field type %#x\n", l[i].type); + return -EDOM; + } + } + acpigen_pop_len(ctx); + + return 0; +} + +/* + * Generate ACPI AML code for IndexField + * Arg0: region name + * Arg1: Pointer to struct fieldlist. + * Arg2: no. of entries in Arg1 + * Arg3: flags which indicate filed access type, lock rule & update rule. + * Example with fieldlist + * struct fieldlist l[] = { + * FIELDLIST_OFFSET(0x84), + * FIELDLIST_NAMESTR("PMCS", 2), + * }; + * acpigen_write_field("IDX", "DATA" l, ARRAY_SIZE(l), FIELD_ANYACC | + * FIELD_NOLOCK | + * FIELD_PRESERVE); + * Output: + * IndexField (IDX, DATA, AnyAcc, NoLock, Preserve) + * { + * Offset (0x84), + * PMCS, 2 + * } + */ +int acpigen_write_indexfield(struct acpi_ctx *ctx, const char *idx, + const char *data, struct fieldlist *l, + size_t count, uint flags) +{ + u16 i; + u32 current_bit_pos = 0; + int ret; + + /* FieldOp */ + acpigen_emit_ext_op(ctx, INDEX_FIELD_OP); + /* Package Length */ + acpigen_write_len_f(ctx); + /* NameString 4 chars only */ + acpigen_emit_simple_namestring(ctx, idx); + /* NameString 4 chars only */ + acpigen_emit_simple_namestring(ctx, data); + /* Field Flag */ + acpigen_emit_byte(ctx, flags); + + for (i = 0; i < count; i++) { + switch (l[i].type) { + case NAME_STRING: + acpigen_write_field_name(ctx, l[i].name, l[i].bits); + current_bit_pos += l[i].bits; + break; + case OFFSET: + ret = acpigen_write_field_offset(ctx, l[i].bits, + current_bit_pos); + if (ret) + return log_msg_ret("field", ret); + current_bit_pos = l[i].bits; + break; + default: + log_err("Invalid field type 0x%X\n", l[i].type); + return -EDOM; + } + } + acpigen_pop_len(ctx); + + return 0; +} + +void acpigen_write_empty_pct(struct acpi_ctx *ctx) +{ + /* + * Name (_PCT, Package (0x02) + * { + * ResourceTemplate () + * { + * Register (FFixedHW, + * 0x00, // Bit Width + * 0x00, // Bit Offset + * 0x0000000000000000, // Address + * ,) + * }, + * + * ResourceTemplate () + * { + * Register (FFixedHW, + * 0x00, // Bit Width + * 0x00, // Bit Offset + * 0x0000000000000000, // Address + * ,) + * } + * }) + */ + static char stream[] = { + /* 00000030 "0._PCT.," */ + 0x08, 0x5F, 0x50, 0x43, 0x54, 0x12, 0x2C, + /* 00000038 "........" */ + 0x02, 0x11, 0x14, 0x0A, 0x11, 0x82, 0x0C, 0x00, + /* 00000040 "........" */ + 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 00000048 "....y..." */ + 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x11, 0x14, + /* 00000050 "........" */ + 0x0A, 0x11, 0x82, 0x0C, 0x00, 0x7F, 0x00, 0x00, + /* 00000058 "........" */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x79, 0x00 + }; + acpigen_emit_stream(ctx, stream, ARRAY_SIZE(stream)); +} + +void acpigen_write_empty_ptc(struct acpi_ctx *ctx) +{ + /* + * Name (_PTC, Package (0x02) + * { + * ResourceTemplate () + * { + * Register (FFixedHW, + * 0x00, // Bit Width + * 0x00, // Bit Offset + * 0x0000000000000000, // Address + * ,) + * }, + * + * ResourceTemplate () + * { + * Register (FFixedHW, + * 0x00, // Bit Width + * 0x00, // Bit Offset + * 0x0000000000000000, // Address + * ,) + * } + * }) + */ + struct acpi_gen_regaddr addr = { + .space_id = ACPI_ADDRESS_SPACE_FIXED, + .bit_width = 0, + .bit_offset = 0, + .access_size = 0, + .addrl = 0, + .addrh = 0, + }; + + acpigen_write_name(ctx, "_PTC"); + acpigen_write_package(ctx, 2); + + /* ControlRegister */ + acpigen_write_register_resource(ctx, &addr); + + /* StatusRegister */ + acpigen_write_register_resource(ctx, &addr); + + acpigen_pop_len(ctx); +} + +static void __acpigen_write_method(struct acpi_ctx *ctx, const char *name, + u8 flags) +{ + acpigen_emit_byte(ctx, METHOD_OP); + acpigen_write_len_f(ctx); + acpigen_emit_namestring(ctx, name); + acpigen_emit_byte(ctx, flags); +} + +/* Method (name, nargs, NotSerialized) */ +void acpigen_write_method(struct acpi_ctx *ctx, const char *name, int nargs) +{ + __acpigen_write_method(ctx, name, (nargs & 7)); +} + +/* Method (name, nargs, Serialized) */ +void acpigen_write_method_serialized(struct acpi_ctx *ctx, const char *name, + int nargs) +{ + __acpigen_write_method(ctx, name, (nargs & 7) | (1 << 3)); +} + +void acpigen_write_device(struct acpi_ctx *ctx, const char *name) +{ + acpigen_emit_ext_op(ctx, DEVICE_OP); + acpigen_write_len_f(ctx); + acpigen_emit_namestring(ctx, name); +} + +void acpigen_write_sta(struct acpi_ctx *ctx, u8 status) +{ + /* Method (_STA, 0, NotSerialized) { Return (status) } */ + acpigen_write_method(ctx, "_STA", 0); + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_write_byte(ctx, status); + acpigen_pop_len(ctx); +} + +/* + * Generates a func with max supported P-states. + */ +void acpigen_write_ppc(struct acpi_ctx *ctx, u8 nr) +{ + /* + * Method (_PPC, 0, NotSerialized) + * { + * Return (nr) + * } + */ + acpigen_write_method(ctx, "_PPC", 0); + acpigen_emit_byte(ctx, RETURN_OP); + /* arg */ + acpigen_write_byte(ctx, nr); + acpigen_pop_len(ctx); +} + +/* + * Generates a func with max supported P-states saved + * in the variable PPCM. + */ +void acpigen_write_ppc_nvs(struct acpi_ctx *ctx) +{ + /* + * Method (_PPC, 0, NotSerialized) + * { + * Return (PPCM) + * } + */ + acpigen_write_method(ctx, "_PPC", 0); + acpigen_emit_byte(ctx, RETURN_OP); + /* arg */ + acpigen_emit_namestring(ctx, "PPCM"); + acpigen_pop_len(ctx); +} + +void acpigen_write_tpc(struct acpi_ctx *ctx, const char *gnvs_tpc_limit) +{ + /* + * // Sample _TPC method + * Method (_TPC, 0, NotSerialized) + * { + * Return (\TLVL) + * } + */ + acpigen_write_method(ctx, "_TPC", 0); + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_emit_namestring(ctx, gnvs_tpc_limit); + acpigen_pop_len(ctx); +} + +void acpigen_write_prw(struct acpi_ctx *ctx, u32 wake, u32 level) +{ + /* + * Name (_PRW, Package () { wake, level } + */ + acpigen_write_name(ctx, "_PRW"); + acpigen_write_package(ctx, 2); + acpigen_write_integer(ctx, wake); + acpigen_write_integer(ctx, level); + acpigen_pop_len(ctx); +} + +void acpigen_write_pss_package(struct acpi_ctx *ctx, u32 core_freq, u32 power, + u32 trans_lat, u32 busm_lat, u32 control, + u32 status) +{ + acpigen_write_package(ctx, 6); + acpigen_write_dword(ctx, core_freq); + acpigen_write_dword(ctx, power); + acpigen_write_dword(ctx, trans_lat); + acpigen_write_dword(ctx, busm_lat); + acpigen_write_dword(ctx, control); + acpigen_write_dword(ctx, status); + acpigen_pop_len(ctx); + + log_debug("PSS: %uMHz power %u control 0x%x status 0x%x\n", + core_freq, power, control, status); +} + +void acpigen_write_psd_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum psd_coord coordtype) +{ + acpigen_write_name(ctx, "_PSD"); + acpigen_write_package(ctx, 1); + acpigen_write_package(ctx, 5); + acpigen_write_byte(ctx, 5); // 5 values + acpigen_write_byte(ctx, 0); // revision 0 + acpigen_write_dword(ctx, domain); + acpigen_write_dword(ctx, coordtype); + acpigen_write_dword(ctx, numprocs); + acpigen_pop_len(ctx); + acpigen_pop_len(ctx); +} + +void acpigen_write_cst_package_entry(struct acpi_ctx *ctx, + struct acpi_cstate *cstate) +{ + acpigen_write_package(ctx, 4); + acpigen_write_register_resource(ctx, &cstate->resource); + acpigen_write_dword(ctx, cstate->ctype); + acpigen_write_dword(ctx, cstate->latency); + acpigen_write_dword(ctx, cstate->power); + acpigen_pop_len(ctx); +} + +void acpigen_write_cst_package(struct acpi_ctx *ctx, struct acpi_cstate *cstate, + int nentries) +{ + int i; + + acpigen_write_name(ctx, "_CST"); + acpigen_write_package(ctx, nentries + 1); + acpigen_write_dword(ctx, nentries); + + for (i = 0; i < nentries; i++) + acpigen_write_cst_package_entry(ctx, cstate + i); + + acpigen_pop_len(ctx); +} + +void acpigen_write_csd_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum csd_coord coordtype, u32 index) +{ + acpigen_write_name(ctx, "_CSD"); + acpigen_write_package(ctx, 1); + acpigen_write_package(ctx, 6); + acpigen_write_byte(ctx, 6); // 6 values + acpigen_write_byte(ctx, 0); // revision 0 + acpigen_write_dword(ctx, domain); + acpigen_write_dword(ctx, coordtype); + acpigen_write_dword(ctx, numprocs); + acpigen_write_dword(ctx, index); + acpigen_pop_len(ctx); + acpigen_pop_len(ctx); +} + +void acpigen_write_tss_package(struct acpi_ctx *ctx, int entries, + struct acpi_tstate *tstate_list) +{ + /* + * Sample _TSS package with 100% and 50% duty cycles + * Name (_TSS, Package (0x02) + * { + * Package(){100, 1000, 0, 0x00, 0) + * Package(){50, 520, 0, 0x18, 0) + * }) + */ + int i; + struct acpi_tstate *tstate = tstate_list; + + acpigen_write_name(ctx, "_TSS"); + acpigen_write_package(ctx, entries); + + for (i = 0; i < entries; i++) { + acpigen_write_package(ctx, 5); + acpigen_write_dword(ctx, tstate->percent); + acpigen_write_dword(ctx, tstate->power); + acpigen_write_dword(ctx, tstate->latency); + acpigen_write_dword(ctx, tstate->control); + acpigen_write_dword(ctx, tstate->status); + acpigen_pop_len(ctx); + tstate++; + } + + acpigen_pop_len(ctx); +} + +void acpigen_write_tsd_package(struct acpi_ctx *ctx, u32 domain, u32 numprocs, + enum psd_coord coordtype) +{ + acpigen_write_name(ctx, "_TSD"); + acpigen_write_package(ctx, 1); + acpigen_write_package(ctx, 5); + acpigen_write_byte(ctx, 5); // 5 values + acpigen_write_byte(ctx, 0); // revision 0 + acpigen_write_dword(ctx, domain); + acpigen_write_dword(ctx, coordtype); + acpigen_write_dword(ctx, numprocs); + acpigen_pop_len(ctx); + acpigen_pop_len(ctx); +} + +void acpigen_write_mem32fixed(struct acpi_ctx *ctx, int readwrite, u32 base, + u32 size) +{ + /* + * ACPI 4.0 section 6.4.3.4: 32-Bit Fixed Memory Range Descriptor + * Byte 0: + * Bit7 : 1 => big item + * Bit6-0: 0000110 (0x6) => 32-bit fixed memory + */ + acpigen_emit_byte(ctx, 0x86); + /* Byte 1+2: length (0x0009) */ + acpigen_emit_byte(ctx, 0x09); + acpigen_emit_byte(ctx, 0x00); + /* bit1-7 are ignored */ + acpigen_emit_byte(ctx, readwrite ? 0x01 : 0x00); + acpigen_emit_dword(ctx, base); + acpigen_emit_dword(ctx, size); +} + +static void acpigen_write_register(struct acpi_ctx *ctx, + const struct acpi_gen_regaddr *addr) +{ + acpigen_emit_byte(ctx, 0x82); /* Register Descriptor */ + acpigen_emit_byte(ctx, 0x0c); /* Register Length 7:0 */ + acpigen_emit_byte(ctx, 0x00); /* Register Length 15:8 */ + acpigen_emit_byte(ctx, addr->space_id); + acpigen_emit_byte(ctx, addr->bit_width); + acpigen_emit_byte(ctx, addr->bit_offset); + acpigen_emit_byte(ctx, addr->access_size); + acpigen_emit_dword(ctx, addr->addrl); + acpigen_emit_dword(ctx, addr->addrh); +} + +void acpigen_write_register_resource(struct acpi_ctx *ctx, + const struct acpi_gen_regaddr *addr) +{ + acpigen_write_resourcetemplate_header(ctx); + acpigen_write_register(ctx, addr); + acpigen_write_resourcetemplate_footer(ctx); +} + +void acpigen_write_irq(struct acpi_ctx *ctx, u16 mask) +{ + /* + * ACPI 3.0b section 6.4.2.1: IRQ Descriptor + * Byte 0: + * Bit7 : 0 => small item + * Bit6-3: 0100 (0x4) => IRQ port descriptor + * Bit2-0: 010 (0x2) => 2 Bytes long + */ + acpigen_emit_byte(ctx, 0x22); + acpigen_emit_byte(ctx, mask & 0xff); + acpigen_emit_byte(ctx, (mask >> 8) & 0xff); +} + +void acpigen_write_resourcetemplate_header(struct acpi_ctx *ctx) +{ + /* + * A ResourceTemplate() is a Buffer() with a + * (Byte|Word|DWord) containing the length, followed by one or more + * resource items, terminated by the end tag. + * (small item 0xf, len 1) + */ + acpigen_emit_byte(ctx, BUFFER_OP); + acpigen_write_len_f(ctx); + acpigen_emit_byte(ctx, WORD_PREFIX); + ctx->len_stack[ctx->ltop++] = ctx->current; + /* + * Add two dummy bytes for the ACPI word (keep aligned with the + * calclulation in acpigen_write_resourcetemplate() below) + */ + acpigen_emit_byte(ctx, 0x00); + acpigen_emit_byte(ctx, 0x00); +} + +void acpigen_write_resourcetemplate_footer(struct acpi_ctx *ctx) +{ + char *p = ctx->len_stack[--ctx->ltop]; + int len; + /* + * end tag (acpi 4.0 Section 6.4.2.8) + * 0x79 + * 0x00 is treated as a good checksum according to the spec + * and is what iasl generates. + */ + acpigen_emit_byte(ctx, 0x79); + acpigen_emit_byte(ctx, 0x00); + + /* + * Start counting past the 2-bytes length added in + * acpigen_write_resourcetemplate() above + */ + len = (char *)ctx->current - (p + 2); + + /* patch len word */ + p[0] = len & 0xff; + p[1] = (len >> 8) & 0xff; + /* patch len field */ + acpigen_pop_len(ctx); +} + +/* + * ToUUID(uuid) + * + * ACPI 6.1 Section 19.6.136 table 19-385 defines a special output + * order for the bytes that make up a UUID Buffer object. + * UUID byte order for input: + * aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * UUID byte order for output: + * ddccbbaa-ffee-hhgg-iijj-kkllmmnnoopp + */ +#define UUID_LEN 16 +int acpigen_write_uuid(struct acpi_ctx *ctx, const char *uuid) +{ + u8 buf[UUID_LEN]; + size_t i, order[UUID_LEN] = { 3, 2, 1, 0, 5, 4, 7, 6, + 8, 9, 10, 11, 12, 13, 14, 15 }; + int ret; + + /* Parse UUID string into bytes */ + ret = uuid_str_to_bin(uuid, buf, UUID_STR_FORMAT_STD); + if (ret) + return log_msg_ret("bad hex", -EINVAL); + + /* BufferOp */ + acpigen_emit_byte(ctx, BUFFER_OP); + acpigen_write_len_f(ctx); + + /* Buffer length in bytes */ + acpigen_write_word(ctx, UUID_LEN); + + /* Output UUID in expected order */ + for (i = 0; i < UUID_LEN; i++) + acpigen_emit_byte(ctx, buf[order[i]]); + + acpigen_pop_len(ctx); + + return 0; +} + +/* + * Name (_PRx, Package(One) { name }) + * ... + * PowerResource (name, level, order) + */ +void acpigen_write_power_res(struct acpi_ctx *ctx, const char *name, u8 level, + u16 order, const char *const dev_states[], + size_t dev_states_count) +{ + size_t i; + + for (i = 0; i < dev_states_count; i++) { + acpigen_write_name(ctx, dev_states[i]); + acpigen_write_package(ctx, 1); + acpigen_emit_simple_namestring(ctx, name); + acpigen_pop_len(ctx); /* Package */ + } + + acpigen_emit_ext_op(ctx, POWER_RES_OP); + + acpigen_write_len_f(ctx); + + acpigen_emit_simple_namestring(ctx, name); + acpigen_emit_byte(ctx, level); + acpigen_emit_word(ctx, order); +} + +/* Sleep (ms) */ +void acpigen_write_sleep(struct acpi_ctx *ctx, u64 sleep_ms) +{ + acpigen_emit_ext_op(ctx, SLEEP_OP); + acpigen_write_integer(ctx, sleep_ms); +} + +void acpigen_write_store(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, STORE_OP); +} + +/* Store (src, dst) */ +void acpigen_write_store_ops(struct acpi_ctx *ctx, u8 src, u8 dst) +{ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, src); + acpigen_emit_byte(ctx, dst); +} + +/* Or (arg1, arg2, res) */ +void acpigen_write_or(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res) +{ + acpigen_emit_byte(ctx, OR_OP); + acpigen_emit_byte(ctx, arg1); + acpigen_emit_byte(ctx, arg2); + acpigen_emit_byte(ctx, res); +} + +/* And (arg1, arg2, res) */ +void acpigen_write_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2, u8 res) +{ + acpigen_emit_byte(ctx, AND_OP); + acpigen_emit_byte(ctx, arg1); + acpigen_emit_byte(ctx, arg2); + acpigen_emit_byte(ctx, res); +} + +/* Not (arg, res) */ +void acpigen_write_not(struct acpi_ctx *ctx, u8 arg, u8 res) +{ + acpigen_emit_byte(ctx, NOT_OP); + acpigen_emit_byte(ctx, arg); + acpigen_emit_byte(ctx, res); +} + +/* Store (str, DEBUG) */ +void acpigen_write_debug_string(struct acpi_ctx *ctx, const char *str) +{ + acpigen_write_store(ctx); + acpigen_write_string(ctx, str); + acpigen_emit_ext_op(ctx, DEBUG_OP); +} + +/* Store (val, DEBUG) */ +void acpigen_write_debug_integer(struct acpi_ctx *ctx, u64 val) +{ + acpigen_write_store(ctx); + acpigen_write_integer(ctx, val); + acpigen_emit_ext_op(ctx, DEBUG_OP); +} + +/* Store (op, DEBUG) */ +void acpigen_write_debug_op(struct acpi_ctx *ctx, u8 op) +{ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, op); + acpigen_emit_ext_op(ctx, DEBUG_OP); +} + +void acpigen_write_if(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, IF_OP); + acpigen_write_len_f(ctx); +} + +/* If (And (arg1, arg2)) */ +void acpigen_write_if_and(struct acpi_ctx *ctx, u8 arg1, u8 arg2) +{ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, AND_OP); + acpigen_emit_byte(ctx, arg1); + acpigen_emit_byte(ctx, arg2); +} + +/* + * Generates ACPI code for checking if operand1 and operand2 are equal, where, + * operand1 is ACPI op and operand2 is an integer. + * + * If (Lequal (op, val)) + */ +void acpigen_write_if_lequal_op_int(struct acpi_ctx *ctx, u8 op, u64 val) +{ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LEQUAL_OP); + acpigen_emit_byte(ctx, op); + acpigen_write_integer(ctx, val); +} + +void acpigen_write_else(struct acpi_ctx *ctx) +{ + acpigen_emit_byte(ctx, ELSE_OP); + acpigen_write_len_f(ctx); +} + +void acpigen_write_to_buffer(struct acpi_ctx *ctx, u8 src, u8 dst) +{ + acpigen_emit_byte(ctx, TO_BUFFER_OP); + acpigen_emit_byte(ctx, src); + acpigen_emit_byte(ctx, dst); +} + +void acpigen_write_to_integer(struct acpi_ctx *ctx, u8 src, u8 dst) +{ + acpigen_emit_byte(ctx, TO_INTEGER_OP); + acpigen_emit_byte(ctx, src); + acpigen_emit_byte(ctx, dst); +} + +void acpigen_write_byte_buffer(struct acpi_ctx *ctx, u8 *arr, size_t size) +{ + size_t i; + + acpigen_emit_byte(ctx, BUFFER_OP); + acpigen_write_len_f(ctx); + acpigen_write_integer(ctx, size); + + for (i = 0; i < size; i++) + acpigen_emit_byte(ctx, arr[i]); + + acpigen_pop_len(ctx); +} + +void acpigen_write_return_byte_buffer(struct acpi_ctx *ctx, u8 *arr, + size_t size) +{ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_write_byte_buffer(ctx, arr, size); +} + +void acpigen_write_return_singleton_buffer(struct acpi_ctx *ctx, u8 arg) +{ + acpigen_write_return_byte_buffer(ctx, &arg, 1); +} + +void acpigen_write_return_byte(struct acpi_ctx *ctx, u8 arg) +{ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_write_byte(ctx, arg); +} + +void acpigen_write_return_integer(struct acpi_ctx *ctx, u64 arg) +{ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_write_integer(ctx, arg); +} + +void acpigen_write_return_string(struct acpi_ctx *ctx, const char *arg) +{ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_write_string(ctx, arg); +} + +void acpigen_write_upc(struct acpi_ctx *ctx, enum acpi_upc_type type) +{ + acpigen_write_name(ctx, "_UPC"); + acpigen_write_package(ctx, 4); + /* Connectable */ + acpigen_write_byte(ctx, type == UPC_TYPE_UNUSED ? 0 : 0xff); + /* Type */ + acpigen_write_byte(ctx, type); + /* Reserved0 */ + acpigen_write_zero(ctx); + /* Reserved1 */ + acpigen_write_zero(ctx); + acpigen_pop_len(ctx); +} + +int acpigen_write_dsm(struct acpi_ctx *ctx, const char *uuid, + hid_callback_func callbacks[], size_t count, void *arg) +{ + struct dsm_uuid id = DSM_UUID(uuid, callbacks, count, arg); + int ret; + + ret = acpigen_write_dsm_uuid_arr(ctx, &id, 1); + if (ret) + return log_msg_ret("uuid_arr", ret); + + return 0; +} + +static int acpigen_write_dsm_uuid(struct acpi_ctx *ctx, struct dsm_uuid *id) +{ + size_t i; + int ret; + + /* If (LEqual (Local0, ToUUID(uuid))) */ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LEQUAL_OP); + acpigen_emit_byte(ctx, LOCAL0_OP); + ret = acpigen_write_uuid(ctx, id->uuid); + if (ret) + return log_msg_ret("uuid", ret); + + /* ToInteger (Arg2, Local1) */ + acpigen_write_to_integer(ctx, ARG2_OP, LOCAL1_OP); + + for (i = 0; i < id->count; i++) { + /* If (LEqual (Local1, i)) */ + acpigen_write_if_lequal_op_int(ctx, LOCAL1_OP, i); + + /* Callback to write if handler. */ + if (id->callbacks[i]) + id->callbacks[i](ctx, id->arg); + + acpigen_pop_len(ctx); /* If */ + } + + /* Default case: Return (Buffer (One) { 0x0 }) */ + acpigen_write_return_singleton_buffer(ctx, 0x0); + + acpigen_pop_len(ctx); /* If (LEqual (Local0, ToUUID(uuid))) */ + + return 0; +} + +/* + * Generate ACPI AML code for _DSM method. + * This function takes as input array of uuid for the device, set of callbacks + * and argument to pass into the callbacks. Callbacks should ensure that Local0 + * and Local1 are left untouched. Use of Local2-Local7 is permitted in + * callbacks. + * + * Arguments passed into _DSM method: + * Arg0 = UUID + * Arg1 = Revision + * Arg2 = Function index + * Arg3 = Function specific arguments + * + * AML code generated would look like: + * Method (_DSM, 4, Serialized) { + * ToBuffer (Arg0, Local0) + * If (LEqual (Local0, ToUUID(uuid))) { + * ToInteger (Arg2, Local1) + * If (LEqual (Local1, 0)) { + * + * } + * ... + * If (LEqual (Local1, n)) { + * + * } + * Return (Buffer (One) { 0x0 }) + * } + * ... + * If (LEqual (Local0, ToUUID(uuidn))) { + * ... + * } + * Return (Buffer (One) { 0x0 }) + * } + */ +int acpigen_write_dsm_uuid_arr(struct acpi_ctx *ctx, struct dsm_uuid *ids, + size_t count) +{ + size_t i; + int ret; + + /* Method (_DSM, 4, Serialized) */ + acpigen_write_method_serialized(ctx, "_DSM", 0x4); + + /* ToBuffer (Arg0, Local0) */ + acpigen_write_to_buffer(ctx, ARG0_OP, LOCAL0_OP); + + for (i = 0; i < count; i++) { + ret = acpigen_write_dsm_uuid(ctx, &ids[i]); + if (ret) + return ret; + } + + /* Return (Buffer (One) { 0x0 }) */ + acpigen_write_return_singleton_buffer(ctx, 0x0); + + acpigen_pop_len(ctx); /* Method _DSM */ + + return 0; +} + +#define CPPC_PACKAGE_NAME "\\GCPC" + +int acpigen_write_cppc_package(struct acpi_ctx *ctx, + const struct cppc_config *config) +{ + u32 i; + u32 max; + + switch (config->version) { + case 1: + max = CPPC_MAX_FIELDS_VER_1; + break; + case 2: + max = CPPC_MAX_FIELDS_VER_2; + break; + case 3: + max = CPPC_MAX_FIELDS_VER_3; + break; + default: + log_err("CPPC version %u is not implemented\n", + config->version); + return -EDOM; + } + acpigen_write_name(ctx, CPPC_PACKAGE_NAME); + + /* Adding 2 to account for length and version fields */ + acpigen_write_package(ctx, max + 2); + acpigen_write_dword(ctx, max + 2); + + acpigen_write_byte(ctx, config->version); + + for (i = 0; i < max; ++i) { + const struct acpi_gen_regaddr *reg = &config->regs[i]; + + if (reg->space_id == ACPI_ADDRESS_SPACE_MEMORY && + reg->bit_width == 32 && reg->access_size == 0) { + acpigen_write_dword(ctx, reg->addrl); + } else { + acpigen_write_register_resource(ctx, reg); + } + } + acpigen_pop_len(ctx); + + return 0; +} + +void acpigen_write_cppc_method(struct acpi_ctx *ctx) +{ + acpigen_write_method(ctx, "_CPC", 0); + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_emit_namestring(ctx, CPPC_PACKAGE_NAME); + acpigen_pop_len(ctx); +} + +/* + * Generate ACPI AML code for _ROM method. + * This function takes as input ROM data and ROM length. + * + * The ACPI spec isn't clear about what should happen at the end of the + * ROM. Tests showed that it shouldn't truncate, but fill the remaining + * bytes in the returned buffer with zeros. + * + * Arguments passed into _DSM method: + * Arg0 = Offset in Bytes + * Arg1 = Bytes to return + * + * Example: + * acpigen_write_rom(0xdeadbeef, 0x10000) + * + * AML code generated would look like: + * Method (_ROM, 2, NotSerialized) { + * + * OperationRegion("ROMS", SYSTEMMEMORY, 0xdeadbeef, 0x10000) + * Field (ROMS, AnyAcc, NoLock, Preserve) + * { + * Offset (0), + * RBF0, 0x80000 + * } + * + * Store (Arg0, Local0) + * Store (Arg1, Local1) + * + * If (LGreater (Local1, 0x1000)) + * { + * Store (0x1000, Local1) + * } + * + * Store (Local1, Local3) + * + * If (LGreater (Local0, 0x10000)) + * { + * Return(Buffer(Local1){0}) + * } + * + * If (LGreater (Local0, 0x0f000)) + * { + * Subtract (0x10000, Local0, Local2) + * If (LGreater (Local1, Local2)) + * { + * Store (Local2, Local1) + * } + * } + * + * Name (ROM1, Buffer (Local3) {0}) + * + * Multiply (Local0, 0x08, Local0) + * Multiply (Local1, 0x08, Local1) + * + * CreateField (RBF0, Local0, Local1, TMPB) + * Store (TMPB, ROM1) + * Return (ROM1) + * } + */ +int acpigen_write_rom(struct acpi_ctx *ctx, void *bios, const size_t length) +{ + int ret; + + assert(bios); + assert(length); + + /* Method (_ROM, 2, Serialized) */ + acpigen_write_method_serialized(ctx, "_ROM", 2); + + /* OperationRegion("ROMS", SYSTEMMEMORY, current, length) */ + struct opregion opreg = OPREGION("ROMS", SYSTEMMEMORY, + (uintptr_t)bios, length); + acpigen_write_opregion(ctx, &opreg); + + struct fieldlist l[] = { + FIELDLIST_OFFSET(0), + FIELDLIST_NAMESTR("RBF0", 8 * length), + }; + + /* + * Field (ROMS, AnyAcc, NoLock, Preserve) + * { + * Offset (0), + * RBF0, 0x80000 + * } + */ + ret = acpigen_write_field(ctx, opreg.name, l, 2, FIELD_ANYACC | + FIELD_NOLOCK | FIELD_PRESERVE); + if (ret) + return log_msg_ret("field", ret); + + /* Store (Arg0, Local0) */ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, ARG0_OP); + acpigen_emit_byte(ctx, LOCAL0_OP); + + /* Store (Arg1, Local1) */ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, ARG1_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + + /* ACPI SPEC requires to return at maximum 4KiB */ + /* If (LGreater (Local1, 0x1000)) */ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LGREATER_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_write_integer(ctx, 0x1000); + + /* Store (0x1000, Local1) */ + acpigen_write_store(ctx); + acpigen_write_integer(ctx, 0x1000); + acpigen_emit_byte(ctx, LOCAL1_OP); + + /* Pop if */ + acpigen_pop_len(ctx); + + /* Store (Local1, Local3) */ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_emit_byte(ctx, LOCAL3_OP); + + /* If (LGreater (Local0, length)) */ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LGREATER_OP); + acpigen_emit_byte(ctx, LOCAL0_OP); + acpigen_write_integer(ctx, length); + + /* Return(Buffer(Local1){0}) */ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_emit_byte(ctx, BUFFER_OP); + acpigen_write_len_f(ctx); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_emit_byte(ctx, 0); + acpigen_pop_len(ctx); + + /* Pop if */ + acpigen_pop_len(ctx); + + /* If (LGreater (Local0, length - 4096)) */ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LGREATER_OP); + acpigen_emit_byte(ctx, LOCAL0_OP); + acpigen_write_integer(ctx, length - 4096); + + /* Subtract (length, Local0, Local2) */ + acpigen_emit_byte(ctx, SUBTRACT_OP); + acpigen_write_integer(ctx, length); + acpigen_emit_byte(ctx, LOCAL0_OP); + acpigen_emit_byte(ctx, LOCAL2_OP); + + /* If (LGreater (Local1, Local2)) */ + acpigen_write_if(ctx); + acpigen_emit_byte(ctx, LGREATER_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_emit_byte(ctx, LOCAL2_OP); + + /* Store (Local2, Local1) */ + acpigen_write_store(ctx); + acpigen_emit_byte(ctx, LOCAL2_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + + /* Pop if */ + acpigen_pop_len(ctx); + + /* Pop if */ + acpigen_pop_len(ctx); + + /* Name (ROM1, Buffer (Local3) {0}) */ + acpigen_write_name(ctx, "ROM1"); + acpigen_emit_byte(ctx, BUFFER_OP); + acpigen_write_len_f(ctx); + acpigen_emit_byte(ctx, LOCAL3_OP); + acpigen_emit_byte(ctx, 0); + acpigen_pop_len(ctx); + + /* Multiply (Local1, 0x08, Local1) */ + acpigen_emit_byte(ctx, MULTIPLY_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_write_integer(ctx, 0x08); + acpigen_emit_byte(ctx, LOCAL1_OP); + + /* Multiply (Local0, 0x08, Local0) */ + acpigen_emit_byte(ctx, MULTIPLY_OP); + acpigen_emit_byte(ctx, LOCAL0_OP); + acpigen_write_integer(ctx, 0x08); + acpigen_emit_byte(ctx, LOCAL0_OP); + + /* CreateField (RBF0, Local0, Local1, TMPB) */ + acpigen_emit_ext_op(ctx, CREATEFIELD_OP); + acpigen_emit_namestring(ctx, "RBF0"); + acpigen_emit_byte(ctx, LOCAL0_OP); + acpigen_emit_byte(ctx, LOCAL1_OP); + acpigen_emit_namestring(ctx, "TMPB"); + + /* Store (TMPB, ROM1) */ + acpigen_write_store(ctx); + acpigen_emit_namestring(ctx, "TMPB"); + acpigen_emit_namestring(ctx, "ROM1"); + + /* Return (ROM1) */ + acpigen_emit_byte(ctx, RETURN_OP); + acpigen_emit_namestring(ctx, "ROM1"); + + /* Pop method */ + acpigen_pop_len(ctx); + + return 0; +} + +/* Soc-implemented functions -- weak definitions. */ +int __weak acpigen_soc_read_rx_gpio(struct acpi_ctx *ctx, unsigned int gpio_num) +{ + log_err("not implemented\n"); + acpigen_write_debug_string(ctx, "read_rx_gpio not available"); + + return -ENOTSUPP; +} + +int __weak acpigen_soc_get_tx_gpio(struct acpi_ctx *ctx, unsigned int gpio_num) +{ + log_err("not implemented\n"); + acpigen_write_debug_string(ctx, "get_tx_gpio not available"); + + return -ENOTSUPP; +} + +int __weak acpigen_soc_set_tx_gpio(struct acpi_ctx *ctx, unsigned int gpio_num) +{ + log_err("not implemented\n"); + acpigen_write_debug_string(ctx, "set_tx_gpio not available"); + + return -ENOTSUPP; +} + +int __weak acpigen_soc_clear_tx_gpio(struct acpi_ctx *ctx, + unsigned int gpio_num) +{ + log_err("not implemented\n"); + acpigen_write_debug_string(ctx, "clear_tx_gpio not available"); + + return -ENOTSUPP; +} + +/* + * Helper functions for enabling/disabling Tx GPIOs based on the GPIO + * polarity. These functions end up calling acpigen_soc_{set,clear}_tx_gpio to + * make callbacks into SoC acpigen code. + * + * Returns 0 on success and -1 on error. + */ +int acpigen_enable_tx_gpio(struct acpi_ctx *ctx, struct acpi_gpio *gpio) +{ + int ret; + + if (gpio->polarity == ACPI_GPIO_ACTIVE_HIGH) + ret = acpigen_soc_set_tx_gpio(ctx, gpio->pins[0]); + else + ret = acpigen_soc_clear_tx_gpio(ctx, gpio->pins[0]); + if (ret) + return log_msg_ret("call", ret); + + return 0; +} + +int acpigen_disable_tx_gpio(struct acpi_ctx *ctx, struct acpi_gpio *gpio) +{ + int ret; + + if (gpio->polarity == ACPI_GPIO_ACTIVE_LOW) + return acpigen_soc_set_tx_gpio(ctx, gpio->pins[0]); + else + return acpigen_soc_clear_tx_gpio(ctx, gpio->pins[0]); + if (ret) + return log_msg_ret("call", ret); + + return 0; +} From patchwork Mon Jan 27 05:05:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229538 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=Be9prjE3; 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 485dHx0pV2z9sR1 for ; Mon, 27 Jan 2020 16:15:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5704B8185B; Mon, 27 Jan 2020 06:11:33 +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="Be9prjE3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8992F817F8; Mon, 27 Jan 2020 06:09:13 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 61F748172D for ; Mon, 27 Jan 2020 06:08:50 +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-xd42.google.com with SMTP id s24so7028936iog.5 for ; Sun, 26 Jan 2020 21:08:50 -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=5qA/6vIxB1D4wH6hOCfi+uXnIGiBC+mn1K7p2OqZ2/U=; b=Be9prjE3W4KwB0c1cpTd1zh4k1Cm3FYyXgIL3fYmUDUZZfhaqY30IobqfY/RVkfoBp 2NwwxIKF8RW6WsoRtiDcttrJ5QdSENcLUm8Hu8RkRP5k31OBb1QIXCesw63cT6HR3FaM dTim/dPH2e4oaqhoOcdgZNj+L0qLJf4IoVHmU= 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=5qA/6vIxB1D4wH6hOCfi+uXnIGiBC+mn1K7p2OqZ2/U=; b=JASsZVsDRMyexV2SirqWxHVQmumV484YeSj1dp8h8Opx1unTBldu5/7hU9Li7bZjbj 0UHzVAvRfXKeKS5jTMUaaZ0DGXw3Dbi3SG9Av3GzRBDIaaTVhoCdv/YxdDy4SS22ElhI 7eM4NRxxlhwP8ns60UOdCVSTGxL7M8WulvK6xgp6e/yoE/Z+udfJwCSGANOC8FCgJKLF E1vDfM424WzJdUyn/LCnHXBDrWOAoWbeFG5jVJElqnUahx5pmT36IFCoH3lNBex+nlFR luIORqGONMok92scODuxmkp2TqRu4kn1BzTo40N9l2B+gMMGwGCEmkyXkP9SPM5+xynJ B85w== X-Gm-Message-State: APjAAAVcIF/wf7jf6++ICove70xR00kx1UQ4YGZnkJ9Zff1zirJDIClm wZ2FGcs3P5JtWAtFjTHRoYH00wGrWjCUew== X-Google-Smtp-Source: APXvYqw6BmCXIB+X/aPgTpO6TGaby+WW/sqFloMC8T28C8V2em35Gu7qotEA8PCTKH9cmU61u8Amag== X-Received: by 2002:a02:a718:: with SMTP id k24mr11364584jam.89.1580101729071; Sun, 26 Jan 2020 21:08:49 -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.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 031/108] gpio: Add a method to convert a GPIO to ACPI Date: Sun, 26 Jan 2020 22:05:38 -0700 Message-Id: <20200126220508.31.I29adaf758a9ea81f51ffbecf89b53983968a0d2a@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 When generating ACPI tables we need to convert GPIOs in U-Boot to the ACPI structures required by ACPI. This is a SoC-specific conversion and cannot be handled by generic code, so add a new GPIO method to do the conversion. Signed-off-by: Simon Glass --- drivers/gpio/gpio-uclass.c | 21 +++++++++++++++++++++ include/acpi_device.h | 12 ++++++++++++ include/asm-generic/gpio.h | 27 +++++++++++++++++++++++++++ lib/acpi/acpi_device.c | 16 ++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index c3c60a73eb..b49f64d90d 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -697,6 +698,26 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize) return 0; } +#if CONFIG_IS_ENABLED(ACPIGEN) +int gpio_get_acpi(const struct gpio_desc *desc, struct acpi_gpio *gpio) +{ + struct dm_gpio_ops *ops; + + if (!dm_gpio_is_valid(desc)) { + /* Indicate that the GPIO is not valid */ + gpio->pin_count = 0; + gpio->pins[0] = 0; + return -EINVAL; + } + + ops = gpio_get_ops(desc->dev); + if (!ops->get_acpi) + return -ENOSYS; + + return ops->get_acpi(desc, gpio); +} +#endif + int gpio_claim_vector(const int *gpio_num_array, const char *fmt) { int i, ret; diff --git a/include/acpi_device.h b/include/acpi_device.h index 919e6bcdaa..fd047f3944 100644 --- a/include/acpi_device.h +++ b/include/acpi_device.h @@ -533,6 +533,18 @@ size_t acpi_dp_add_property_list(struct acpi_dp *dp, */ int acpi_dp_write(struct acpi_ctx *ctx, struct acpi_dp *table); +/** + * acpi_device_write_gpio_desc() - Write a GPIO to ACPI + * + * This creates a GPIO descriptor for a GPIO, including information ACPI needs + * to use it. The type is always ACPI_GPIO_TYPE_IO. + * + * @desc: GPIO to write + * @return 0 if OK, -ve on error + */ +int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, + const struct gpio_desc *desc); + /** * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including * information ACPI needs to use it. diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d6cf18744f..42e112ee66 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -9,6 +9,7 @@ #include +struct acpi_gpio; struct ofnode_phandle_args; /* @@ -290,6 +291,20 @@ struct dm_gpio_ops { */ int (*xlate)(struct udevice *dev, struct gpio_desc *desc, struct ofnode_phandle_args *args); + +#if CONFIG_IS_ENABLED(ACPIGEN) + /** + * get_acpi() - Get the ACPI info for a GPIO + * + * This converts a GPIO to an ACPI structure for adding to the ACPI + * tables. + * + * @desc: GPIO description to convert + * @gpio: Output ACPI GPIO information + * @return ACPI pin number or -ve on error + */ + int (*get_acpi)(const struct gpio_desc *desc, struct acpi_gpio *gpio); +#endif }; /** @@ -657,4 +672,16 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags); */ int gpio_get_number(const struct gpio_desc *desc); +/** + * gpio_get_acpi() - Get the ACPI pin for a GPIO + * + * This converts a GPIO to an ACPI pin number for adding to the ACPI + * tables. If the GPIO is invalid, the pin_count and pins[0] are set to 0 + * + * @desc: GPIO description to convert + * @gpio: Output ACPI GPIO information + * @return ACPI pin number or -ve on error + */ +int gpio_get_acpi(const struct gpio_desc *desc, struct acpi_gpio *gpio); + #endif /* _ASM_GENERIC_GPIO_H_ */ diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index 2d03639714..d94a403aa1 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -287,6 +287,22 @@ int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio) return 0; } +int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, + const struct gpio_desc *desc) +{ + struct acpi_gpio gpio; + int ret; + + ret = gpio_get_acpi(desc, &gpio); + if (ret) + return log_msg_ret("desc", ret); + ret = acpi_device_write_gpio(ctx, &gpio); + if (ret) + return log_msg_ret("gpio", ret); + + return 0; +} + /* ACPI 6.1 section 6.4.3.8.2.1 - I2cSerialBus() */ static void acpi_device_write_i2c(struct acpi_ctx *ctx, const struct acpi_i2c *i2c) From patchwork Mon Jan 27 05:05:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229540 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=AJJl2iAU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dJH2WN5z9sR1 for ; Mon, 27 Jan 2020 16:16:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6314181861; Mon, 27 Jan 2020 06:11:39 +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="AJJl2iAU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1AC378181F; Mon, 27 Jan 2020 06:09:15 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 46693817C4 for ; Mon, 27 Jan 2020 06:08:51 +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-x144.google.com with SMTP id v13so1571717iln.4 for ; Sun, 26 Jan 2020 21:08:51 -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=D6XBC/UFBHrBcdAxz6QvKHmGx5Lta53z4A6eDU7azpE=; b=AJJl2iAUbrKzSPRC15Ijpr1jJa/ULfMxnKTTzn3kg2/Dy0SII/DRt6skSurI0/UwA7 ZVPt5kOYnVWzy+UHId4XdG7C4PBNS5RiFHry/kLV3q19H+Ka9GrkuauQNk7EuMrosv07 m0tzvgZ8Q8KfwSfDEPScOOp6rDHmFavOu//EQ= 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=D6XBC/UFBHrBcdAxz6QvKHmGx5Lta53z4A6eDU7azpE=; b=gqiXyc1XOCmWtopji9dDhqEErfPXVpAwSXhy41+2/m5Jqs663oqj8D2xzvwSWSVeNf phi6GoDye20nLgxj3ebQqib8kFD8MRJ9a1o8N5RuJZvqV2H9V9jCDj6ACOjhSzl52Qfz 9UvjtC1tv7wTTmr6wjX6YYpsFwCvvCZmeeuwec01e8RsMNiLbr5HDiu31XRCBPsVv52G kSIudKUa/+h+Gpi+Wwijz93DB1MxFR9NBFy5TU1bD7TY2OwdzQw4RXlwYiVBAGXlgM+l +rVtRuttzlsv1WelyUs9AbdkNcKV3rOpaY/FITMKWbSl4qo9L3KQJKzjVmktStFtjC8Q pXyQ== X-Gm-Message-State: APjAAAWX3yHef6Ad2gb7kLcpOOTIO637vrFXK6N9MRYhawoUppz+KGLR 0zSYth5jM/eFInDQ+DsXdfdISAiA2CoX3A== X-Google-Smtp-Source: APXvYqxWIJFUtydIfwKUZeKdp4Z0ab9VmZxho6CXO4hOyVEXn9ldEZTvbQuRuBtZwFSNiBr0eEYBHg== X-Received: by 2002:a92:88dc:: with SMTP id m89mr3618845ilh.265.1580101729790; Sun, 26 Jan 2020 21:08:49 -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.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 032/108] irq: Add a method to convert an interrupt to ACPI Date: Sun, 26 Jan 2020 22:05:39 -0700 Message-Id: <20200126220508.32.I29adaf758a9ea81f51ffbecf89b53983968a0d2a@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 When generating ACPI tables we need to convert IRQs in U-Boot to the ACPI structures required by ACPI. This is a SoC-specific conversion and cannot be handled by generic code, so add a new IRQ method to do the conversion. Signed-off-by: Simon Glass --- drivers/misc/irq-uclass.c | 18 +++++++- include/acpi_device.h | 27 +++++++++++ include/irq.h | 41 +++++++++++++++++ lib/acpi/acpi_device.c | 94 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 2 deletions(-) diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c index 7d65192858..720aff9bda 100644 --- a/drivers/misc/irq-uclass.c +++ b/drivers/misc/irq-uclass.c @@ -153,8 +153,6 @@ int irq_request(struct udevice *dev, struct irq *irq) const struct irq_ops *ops; log_debug("(dev=%p, irq=%p)\n", dev, irq); - if (!irq) - return 0; ops = irq_get_ops(dev); irq->dev = dev; @@ -185,6 +183,22 @@ int irq_first_device_type(enum irq_dev_t type, struct udevice **devp) return -ENODEV; } +#if CONFIG_IS_ENABLED(ACPIGEN) +int irq_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq) +{ + struct irq_ops *ops; + + if (!irq_is_valid(irq)) + return -EINVAL; + + ops = irq_get_ops(irq->dev); + if (!ops->get_acpi) + return -ENOSYS; + + return ops->get_acpi(irq, acpi_irq); +} +#endif + UCLASS_DRIVER(irq) = { .id = UCLASS_IRQ, .name = "irq", diff --git a/include/acpi_device.h b/include/acpi_device.h index fd047f3944..0657d2636c 100644 --- a/include/acpi_device.h +++ b/include/acpi_device.h @@ -545,6 +545,33 @@ int acpi_dp_write(struct acpi_ctx *ctx, struct acpi_dp *table); int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, const struct gpio_desc *desc); +/** + * acpi_device_write_interrupt_irq() - Write an interrupt to ACPI + * + * This creates an interrupt descriptor for an interrupt, including information + * ACPI needs to use it. + * + * @req_irq: Interrupt to write + * @return 0 if OK, -ve on error + */ +int acpi_device_write_interrupt_irq(struct acpi_ctx *ctx, + const struct irq *req_irq); + +/** + * acpi_device_write_interrupt_or_gpio() - Write interrupt or GPIO to ACPI + * + * This reads the an interrupt from the device tree, if available. If not it + * reads the first GPIO with the name @prop. + * + * If an interrupt is found, that is written to ACPI. If not, but an GPIO is + * found, that is written. + * + * @return 0 if OK, -ve if neither an interrupt nor a GPIO could be found, or + * some other error occurred + */ +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx, + struct udevice *dev, const char *prop); + /** * acpi_device_write_i2c_dev() - Write an I2C device to ACPI, including * information ACPI needs to use it. diff --git a/include/irq.h b/include/irq.h index eeeef5b56c..f862800aef 100644 --- a/include/irq.h +++ b/include/irq.h @@ -8,6 +8,7 @@ #ifndef __irq_H #define __irq_H +struct acpi_irq; struct ofnode_phandle_args; /* @@ -26,10 +27,12 @@ enum irq_dev_t { * * @dev: IRQ device that handles this irq * @id: ID to identify this irq with the device + * @flags: Flags associated with this interrupt (IRQ_TYPE_...) */ struct irq { struct udevice *dev; ulong id; + ulong flags; }; /** @@ -121,10 +124,36 @@ struct irq_ops { * @return 0 if OK, or a negative error code. */ int (*free)(struct irq *irq); + +#if CONFIG_IS_ENABLED(ACPIGEN) + /** + * get_acpi() - Get the ACPI info for an irq + * + * This converts a irq to an ACPI structure for adding to the ACPI + * tables. + * + * @irq: irq to convert + * @acpi_irq: Output ACPI interrupt information + * @return ACPI pin number or -ve on error + */ + int (*get_acpi)(const struct irq *irq, struct acpi_irq *acpi_irq); +#endif }; #define irq_get_ops(dev) ((struct irq_ops *)(dev)->driver->ops) +/** + * irq_is_valid() - Check if an IRQ is valid + * + * @irq: IRQ description containing device and ID, e.g. previously + * returned by irq_get_by_index() + * @return true if valid, false if not + */ +static inline bool irq_is_valid(const struct irq *irq) +{ + return irq->dev != NULL; +} + /** * irq_route_pmc_gpio_gpe() - Get the GPIO for an event * @@ -225,4 +254,16 @@ int irq_free(struct irq *irq); */ int irq_first_device_type(enum irq_dev_t type, struct udevice **devp); +/** + * irq_get_acpi() - Get the ACPI info for an irq + * + * This converts a irq to an ACPI structure for adding to the ACPI + * tables. + * + * @irq: irq to convert + * @acpi_irq: Output ACPI interrupt information + * @return ACPI pin number or -ve on error + */ +int irq_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq); + #endif diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c index d94a403aa1..23f75b4ce8 100644 --- a/lib/acpi/acpi_device.c +++ b/lib/acpi/acpi_device.c @@ -153,6 +153,58 @@ int acpi_device_status(const struct udevice *dev) return ACPI_STATUS_DEVICE_ALL_ON; } +/* ACPI 6.1 section 6.4.3.6: Extended Interrupt Descriptor */ +static int acpi_device_write_interrupt(struct acpi_ctx *ctx, + const struct acpi_irq *irq) +{ + void *desc_length; + u8 flags; + + if (!irq || !irq->pin) + return -ENOENT; + + /* This is supported by GpioInt() but not Interrupt() */ + if (irq->polarity == ACPI_IRQ_ACTIVE_BOTH) + return -EINVAL; + + /* Byte 0: Descriptor Type */ + acpigen_emit_byte(ctx, ACPI_DESCRIPTOR_INTERRUPT); + + /* Byte 1-2: Length (filled in later) */ + desc_length = acpi_device_write_zero_len(ctx); + + /* + * Byte 3: Flags + * [7:5]: Reserved + * [4]: Wake (0=NO_WAKE 1=WAKE) + * [3]: Sharing (0=EXCLUSIVE 1=SHARED) + * [2]: Polarity (0=HIGH 1=LOW) + * [1]: Mode (0=LEVEL 1=EDGE) + * [0]: Resource (0=PRODUCER 1=CONSUMER) + */ + flags = 1 << 0; /* ResourceConsumer */ + if (irq->mode == ACPI_IRQ_EDGE_TRIGGERED) + flags |= 1 << 1; + if (irq->polarity == ACPI_IRQ_ACTIVE_LOW) + flags |= 1 << 2; + if (irq->shared == ACPI_IRQ_SHARED) + flags |= 1 << 3; + if (irq->wake == ACPI_IRQ_WAKE) + flags |= 1 << 4; + acpigen_emit_byte(ctx, flags); + + /* Byte 4: Interrupt Table Entry Count */ + acpigen_emit_byte(ctx, 1); + + /* Byte 5-8: Interrupt Number */ + acpigen_emit_dword(ctx, irq->pin); + + /* Fill in Descriptor Length (account for len word) */ + acpi_device_fill_len(ctx, desc_length); + + return 0; +} + /* ACPI 6.1 section 6.4.3.8.1 - GPIO Interrupt or I/O */ int acpi_device_write_gpio(struct acpi_ctx *ctx, const struct acpi_gpio *gpio) { @@ -303,6 +355,48 @@ int acpi_device_write_gpio_desc(struct acpi_ctx *ctx, return 0; } +int acpi_device_write_interrupt_irq(struct acpi_ctx *ctx, + const struct irq *req_irq) +{ + struct acpi_irq irq; + int ret; + + ret = irq_get_acpi(req_irq, &irq); + if (ret) + return log_msg_ret("get", ret); + ret = acpi_device_write_interrupt(ctx, &irq); + if (ret) + return log_msg_ret("write", ret); + + return 0; +} + +int acpi_device_write_interrupt_or_gpio(struct acpi_ctx *ctx, + struct udevice *dev, const char *prop) +{ + struct irq req_irq; + int ret; + + ret = irq_get_by_index(dev, 0, &req_irq); + if (!ret) { + ret = acpi_device_write_interrupt_irq(ctx, &req_irq); + if (ret) + return log_msg_ret("irq", ret); + } else { + struct gpio_desc req_gpio; + + ret = gpio_request_by_name(dev, prop, 0, &req_gpio, + GPIOD_IS_IN); + if (ret) + return log_msg_ret("no gpio", ret); + ret = acpi_device_write_gpio_desc(ctx, &req_gpio); + if (ret) + return log_msg_ret("gpio", ret); + } + + return 0; +} + /* ACPI 6.1 section 6.4.3.8.2.1 - I2cSerialBus() */ static void acpi_device_write_i2c(struct acpi_ctx *ctx, const struct acpi_i2c *i2c) From patchwork Mon Jan 27 05:05:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229529 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=fkLOKb6K; 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 485dG81gktz9sR1 for ; Mon, 27 Jan 2020 16:14:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BCB5C8182D; Mon, 27 Jan 2020 06:11:09 +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="fkLOKb6K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 63F0481822; Mon, 27 Jan 2020 06:09:16 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 E8F5D81780 for ; Mon, 27 Jan 2020 06:08:51 +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-xd42.google.com with SMTP id z8so8587728ioh.0 for ; Sun, 26 Jan 2020 21:08:51 -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=vPx5E7Y6OKrBq6y+/Zf9D2DKViAWH+snKnz2eD0pNHc=; b=fkLOKb6KYxp34UDi7dydFbOly5e8Szln7dxWRjsEi4DDSEdBPm40d339CBwxk+VE3K LmRApS8sU2TiNY9J8o5sQ93m8qclyOJK5q5+Mx6fFmCDLuQd9HthmgvrqETKDdod5zcB ChRy3ehzXeSM3SI/ClQmFMA9zWASnvpcn+gM8= 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=vPx5E7Y6OKrBq6y+/Zf9D2DKViAWH+snKnz2eD0pNHc=; b=ArEvyxLw7lKTL6fBtwad9rnob8ZpFuS7XmDyqaNYCO3HqDZ+L1F1hoCTknbpnWI5dL bjTFvTCx++7J69sXwpz+xGMUEVF568UWQ4bmogcAWcAh3N0uux7NwfXxmMKOCBGIsFxl b6MU351bQHq+PuAT6/f0hrf7tb+ibEqp9yjgn0x+Nrjom6N0QOLEXMtuRiEsMoGkTV2K tgVRGd+TLyRID8RWi4Xf1yol2OFHm5ovyLHtP1e0lgN/KMvrUnMTd0TbKerucNNXCfgZ IKGZ51Rb5FWeidHO2nOgDWPutBL+/WDxyMuuhtTSjQEVif44w0ul/txaLhA0pIWW+v+C jMLA== X-Gm-Message-State: APjAAAUO6rqtjdoeZFKdAaw8txqLWcWg9dg6HFequKmJTbzKFCq0vzbk WxjsA5Ba6wQd0LODh+14GZM+hgJR9yIs7A== X-Google-Smtp-Source: APXvYqwf6AiEddBayEtwU7JOjBlGf/bhsd7SvCjD6T+3CXuijPOMmwSTTKRsziLPiH+mtBY7W3p6+w== X-Received: by 2002:a05:6602:2113:: with SMTP id x19mr6694877iox.227.1580101730603; Sun, 26 Jan 2020 21:08:50 -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.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:50 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 033/108] acpi: Add support for SSDT generation Date: Sun, 26 Jan 2020 22:05:40 -0700 Message-Id: <20200126220508.33.I5ed669af183c547e044a628e7c670f1ef73bfa3d@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 Some devices need to generate code for the Secondary System Descriptor Table (SSDT). Add a method to handle this. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 2 ++ drivers/core/acpi.c | 38 ++++++++++++++++++++++++++++++++++++ include/dm/acpi.h | 23 ++++++++++++++++++++++ test/dm/acpi.c | 41 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 82208de5a8..3351f92165 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -208,10 +208,12 @@ acpi-test { compatible = "denx,u-boot-acpi-test"; + acpi-ssdt-test-data = "ab"; }; acpi-test2 { compatible = "denx,u-boot-acpi-test"; + acpi-ssdt-test-data = "cd"; }; clocks { diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index f748aa3f33..18567682f2 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include int acpi_return_name(char *out_name, const char *name) @@ -31,6 +32,43 @@ int acpi_get_name(const struct udevice *dev, char *out_name) return -ENOSYS; } +int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) +{ + struct acpi_ops *aops; + struct udevice *dev; + int ret; + + aops = device_get_acpi_ops(parent); + if (aops && aops->fill_ssdt) { + log_debug("\n- %s %p\n", parent->name, + aops->fill_ssdt); + ret = device_ofdata_to_platdata(parent); + if (ret) + return log_msg_ret("ofdata", ret); + ret = aops->fill_ssdt(parent, ctx); + if (ret) + return log_msg_ret("ssdt", ret); + } + device_foreach_child(dev, parent) { + ret = _acpi_fill_ssdt(ctx, dev); + if (ret) + return log_msg_ret("recurse", ret); + } + + return 0; +} + +int acpi_fill_ssdt(struct acpi_ctx *ctx) +{ + int ret; + + log_debug("Writing SSDT tables\n"); + ret = _acpi_fill_ssdt(ctx, dm_root()); + log_debug("Writing SSDT finished, err=%d\n", ret); + + return ret; +} + int _acpi_write_dev_tables(struct acpi_ctx *ctx, const struct udevice *parent) { struct acpi_ops *aops; diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 0f78a506da..c340c21685 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -72,6 +72,19 @@ struct acpi_ops { * @return 0 if OK, -ve on error */ int (*write_tables)(const struct udevice *dev, struct acpi_ctx *ctx); + + /** + * fill_ssdt() - Generate SSDT code for a device + * + * This is called to create the SSDT code. THe method should write out + * whatever ACPI code is needed by this device. It will end up in the + * SSDT table. + * + * @dev: Device to write + * @ctx: ACPI context to use + * @return 0 if OK, -ve on error + */ + int (*fill_ssdt)(const struct udevice *dev, struct acpi_ctx *ctx); }; #define device_get_acpi_ops(dev) ((dev)->driver->acpi_ops) @@ -116,6 +129,16 @@ int acpi_return_name(char *out_name, const char *name); */ int acpi_write_dev_tables(struct acpi_ctx *ctx); +/** + * acpi_fill_ssdt() - Generate ACPI tables for SSDT + * + * This is called to create the SSDT code for all devices. + * + * @ctx: ACPI context to use + * @return 0 if OK, -ve on error + */ +int acpi_fill_ssdt(struct acpi_ctx *ctx); + #endif /* __ACPI__ */ #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index feb380b26c..50d6ec91f7 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -14,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -43,9 +43,21 @@ static int testacpi_get_name(const struct udevice *dev, char *out_name) return acpi_return_name(out_name, ACPI_TEST_DEV_NAME); } +static int testacpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + const char *data; + + data = dev_read_string(dev, "acpi-ssdt-test-data"); + while (*data) + acpigen_emit_byte(ctx, *data++); + + return 0; +} + struct acpi_ops testacpi_ops = { .get_name = testacpi_get_name, .write_tables = testacpi_write_tables, + .fill_ssdt = testacpi_fill_ssdt, }; static const struct udevice_id testacpi_ids[] = { @@ -313,3 +325,30 @@ static int dm_test_acpi_cmd_dump(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_cmd_dump, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_fill_ssdt() */ +static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + u8 *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + buf[4] = 'z'; /* sentinal */ + ut_assertok(acpi_fill_ssdt(&ctx)); + + /* These values come from acpi-test's acpi-ssdt-test-data property */ + ut_asserteq('a', buf[0]); + ut_asserteq('b', buf[1]); + + /* These values come from acpi-test2's acpi-ssdt-test-data property */ + ut_asserteq('c', buf[2]); + ut_asserteq('d', buf[3]); + + ut_asserteq('z', buf[4]); + + return 0; +} +`DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229539 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=VFF509A1; 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 485dJ76VhYz9sR1 for ; Mon, 27 Jan 2020 16:16:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8E52F81868; Mon, 27 Jan 2020 06:11:36 +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="VFF509A1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90A6581819; Mon, 27 Jan 2020 06:09:15 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 85526817A7 for ; Mon, 27 Jan 2020 06:08:52 +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-xd42.google.com with SMTP id n21so8545907ioo.10 for ; Sun, 26 Jan 2020 21:08:52 -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=cNVtf/LHH6eSL6TNsG6JaVpB2yD5kEvARhMTiMkBCVU=; b=VFF509A1sVBDvSKIR1C3cRujjuEQE9JQczTOIHi6UqU8NaEnn26qedemwbFoT8ygyk mhbQN6/5OTdMRdGYC8Ip0iCMkkrcCg+FZlszFDUH4w3i0pPrPh/P+BkyNpRFw00MIVvD Gy7SP3pKEDyeU9jHspbbAI+YSqzNX8z7Cf4Jo= 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=cNVtf/LHH6eSL6TNsG6JaVpB2yD5kEvARhMTiMkBCVU=; b=aYPZFQHiZW1Y4k57vPjQQCdmpSGX8XDrn3cA7VZwl+gt5JMapCULbdjSBFzssj4vcT W1KAzLL1ozjo0azB08wHO79LJq+TSVeZf3oD3oPTZDNO56YFGWx3qIXNForFJDHOwICa MxDKcUx8f3sdAzUpQo1qdl7+honxhRw/5eLMVOvip2q0fj+AnVABx338LGshwcJ5yK3B WDZNtCnjRcRT+NDX6Bc5u2DPMvn+RFlw641TdjcR4nO4NDtrnQex3ZcF1D1LnCBWYM/O KZHYIvTUrRWY5bTIrTuBCPsJYYQ/xLhF7q4svQLk18EajTL5DpAeyvjfbRdZttz8qpVX d3bA== X-Gm-Message-State: APjAAAXOrsB+jFFkSUiG0Iu/i+cGqOEywrdq3AP4UeaHbQ/7nOxMGSn2 Wsxuf6Lq1yt9O7YBsWBT/8URA/6E7UsdQg== X-Google-Smtp-Source: APXvYqzlMMbZ8gPo9h/dSUeBvHnU68hJzz4zVbAj/Q9Qxk8EfUqJeYxx3Mt1IkDopk90NOSlGlSRtg== X-Received: by 2002:a05:6638:5b1:: with SMTP id b17mr11801696jar.66.1580101731286; Sun, 26 Jan 2020 21:08:51 -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.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 034/108] x86: acpi: Move MADT up a bit Date: Sun, 26 Jan 2020 22:05:41 -0700 Message-Id: <20200126220508.34.Ib6a3a2f7b429bfd6a43f7bea0543862a1a2eced0@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 Put this table before MCFG so that it matches the order that coreboot uses when passing tables to Linux. This is a cosmetic change since the order of the tables does not otherwise matter. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 83b92e2a4c..694e92c158 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -408,18 +408,18 @@ ulong write_acpi_tables(ulong start_addr) acpi_create_fadt(fadt, facs, dsdt); acpi_add_table(ctx, fadt); - debug("ACPI: * MADT\n"); - madt = ctx->current; - acpi_create_madt(madt); - acpi_inc_align(ctx, madt->header.length); - acpi_add_table(ctx, madt); - debug("ACPI: * MCFG\n"); mcfg = ctx->current; acpi_create_mcfg(mcfg); acpi_inc_align(ctx, mcfg->header.length); acpi_add_table(ctx, mcfg); + debug("ACPI: * MADT\n"); + madt = ctx->current; + acpi_create_madt(madt); + acpi_inc_align(ctx, madt->header.length); + acpi_add_table(ctx, madt); + debug("ACPI: * CSRT\n"); csrt = ctx->current; acpi_create_csrt(csrt); From patchwork Mon Jan 27 05:05:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229530 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=np4PKdSi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dGM64JRz9sR1 for ; Mon, 27 Jan 2020 16:14:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BB7278183C; Mon, 27 Jan 2020 06:11:12 +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="np4PKdSi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1736E81780; Mon, 27 Jan 2020 06:09:17 +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 77567817D0 for ; Mon, 27 Jan 2020 06:08:53 +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 f5so6451352ilq.5 for ; Sun, 26 Jan 2020 21:08:53 -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=Hv7CvsEnR3rBdZh92vEcizdz6NdGtgJfFvGx995gSh8=; b=np4PKdSiUBxNlTvZUw4AyF+iCA68UoXJ6eB/AAldMP75L6omlVr6feGBHjPRDcgZWN O8/mCvEsaiEhM9rtMpy1lR9XxNDnyORh7YK+RZRO6ujDscO+wo3gwp3AceW3aWEVPelG nUXG3ot028oKZJK4vqCYn9U6wimxnZor0oDa8= 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=Hv7CvsEnR3rBdZh92vEcizdz6NdGtgJfFvGx995gSh8=; b=nPiM0Cl/2q6efPLWajk/TFDExkNq22iY58+IAO0ihBMhya1FuPBRONYMP24PronoWe JtCek+KYaQ31brFIs9izxyVdPbef1Rst+AYfIzVbTlUEaZsDeSN27PdDRTG/2XLS/JkC OgOeMU4fVXBRr32Nq8SAAFGcUf1h0w4WCrC6J23z/bLTY5MgLrFePtNfhOL+QaihAgOg QOuHTaUul9C+Me57UHS3hthPg+0AN/tZ5cbi+E721kn7BfZbDK+O9b9yifwMoEDsfFVD mwxQQxhdUMyEW+OoccBvIP/rpXfX75VAimzNsvk+DBcJbGOpOMwuqHmGyUzQOjPwynWw 4Jtg== X-Gm-Message-State: APjAAAU25mMByq7hveg5QqAJPwgvrhwDkifUj+l98T1D9JP9f7ghlWVn BwEZ/g8mue9NrLf8POy7uv4jyr35ZNBIAg== X-Google-Smtp-Source: APXvYqwIABGVKGhNJNd2ho7yyBsIivlcUfeTKu9PP1Eus/VZaJ1tTBLY3zEHhkmw2KvwcgnYninswA== X-Received: by 2002:a92:cd02:: with SMTP id z2mr14250481iln.286.1580101732013; Sun, 26 Jan 2020 21:08:52 -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.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:51 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 035/108] acpi: Record the items added to SSDT Date: Sun, 26 Jan 2020 22:05:42 -0700 Message-Id: <20200126220508.35.I1f119e7a847da3e0b2b1791e6f48acaeaf25a223@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 It is useful to be able to control the order of data written to the SSDT so that we can compare the output against known-good kernel dumps. Add code to record each item that is added along with the device that added it. That allows us to reorder things later if needed. Signed-off-by: Simon Glass --- drivers/core/acpi.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 18567682f2..d7ab906757 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -14,6 +14,32 @@ #include #include +#define MAX_ITEMS 100 + +/* Type of table that we collected */ +enum gen_type_t { + TYPE_SSDT, +}; + +/** + * struct acpi_item - Holds info about ACPI data generated by a driver method + * + * @dev: Device that generated this data + * @type: Table type it refers to + * @buf: Buffer containing the data + * @size: Size of the data in bytes + */ +struct acpi_item { + struct udevice *dev; + enum gen_type_t type; + char *buf; + int size; +}; + +/* List of ACPI items collected */ +static struct acpi_item acpi_item[MAX_ITEMS]; +static int item_count; + int acpi_return_name(char *out_name, const char *name) { strcpy(out_name, name); @@ -32,6 +58,43 @@ int acpi_get_name(const struct udevice *dev, char *out_name) return -ENOSYS; } +/** + * acpi_add_item() - Add a new item to the list of data collected + * + * @ctx: ACPI context + * @dev: Device that generated the data + * @type: Table type it refers to + * @start: The start of the data (the end is obtained from ctx->current) + * @return 0 if OK, -ENOSPC if too many items, -ENOMEM if out of memory + */ +static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev, + enum gen_type_t type, void *start) +{ + struct acpi_item *item; + void *end = ctx->current; + + if (item_count == MAX_ITEMS) { + log_err("Too many items\n"); + return log_msg_ret("mem", -ENOSPC); + } + + item = &acpi_item[item_count]; + item->dev = dev; + item->type = type; + item->size = end - start; + if (!item->size) + return 0; + item->buf = malloc(item->size); + if (!item->buf) + return log_msg_ret("mem", -ENOMEM); + memcpy(item->buf, start, item->size); + item_count++; + log_debug("* %s: Added type %d, %p, size %x\n", dev->name, type, start, + item->size); + + return 0; +} + int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) { struct acpi_ops *aops; @@ -40,6 +103,8 @@ int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) aops = device_get_acpi_ops(parent); if (aops && aops->fill_ssdt) { + void *start = ctx->current; + log_debug("\n- %s %p\n", parent->name, aops->fill_ssdt); ret = device_ofdata_to_platdata(parent); @@ -48,6 +113,11 @@ int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) ret = aops->fill_ssdt(parent, ctx); if (ret) return log_msg_ret("ssdt", ret); + + /* Add the item to the internal list */ + ret = acpi_add_item(ctx, parent, TYPE_SSDT, start); + if (ret) + return log_msg_ret("add", ret); } device_foreach_child(dev, parent) { ret = _acpi_fill_ssdt(ctx, dev); From patchwork Mon Jan 27 05:05:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229532 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=QFpZS84H; 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 485dGn5shnz9sR1 for ; Mon, 27 Jan 2020 16:14:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 18E4681841; Mon, 27 Jan 2020 06:11:17 +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="QFpZS84H"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5ED108182B; Mon, 27 Jan 2020 06:09: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-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 1F776817D4 for ; Mon, 27 Jan 2020 06:08:54 +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-xd43.google.com with SMTP id k24so8558926ioc.4 for ; Sun, 26 Jan 2020 21:08:54 -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=QEcJSlddCdYZQM574lfpCV67vS3+SjFOU8whZXh7GcA=; b=QFpZS84HUI01yohYCcceeh5VxH3cOLWRve9OKr1sBa/+K6XgahulQK3/GjHFexkrFv IFhxufEF7O1DwvsLxR0Qw5jDddJPD6klr0SvG2XjzeNi2MedeKlr2WAYu6IB91gfcTso Y72/cAcMwRCUkOr7uZUCMoPYxE9Xo84Yl8Ork= 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=QEcJSlddCdYZQM574lfpCV67vS3+SjFOU8whZXh7GcA=; b=BzNjokrr763QrP0DUIjuDCm8RAWu3LfSxPJln+ypr/ME3YluwgQciXgRAZRQzARGgZ CyQmpA54yzxm0cue7NFPZsHbK7Ihg/mBlO3bh5FnMIV9G1MOxyhlwVA5wEUa0vboCf27 2+PaY5Q5w/7BompH4wkJEYauU7zlYNw4psCD2OQJFkD9QPWVbUlDFqywGyBxudCLcZJt cpVO4gHK6TJNVyBLUWDSB1d80hOdO17zOXnIyPJf9nEl5UTCfCk3/j4uEBADJ5ekg+dZ 3mtd6XNxrl3u5th3DA9JXz9TYGl5oOn/ZC3cv4b64nQy9n/VjzQ5Fr7UlCZ8YnJuEzzK 9Kgg== X-Gm-Message-State: APjAAAXFi+pu5GNSHvFUn2hUQESTS4pCz/YzTH+rrHzCFTZkqm6+6vku B/jxb1T0kVVHNqWhZ78eWpGMqnpFHhqU1w== X-Google-Smtp-Source: APXvYqwd6KxGacI/aq5zNqVfaQvETZQydzjE0lm5Y0XdMTVvXNYiR/Leyebjvh0h2d7QU+wYqpVdBQ== X-Received: by 2002:a6b:8e47:: with SMTP id q68mr10821780iod.274.1580101732838; Sun, 26 Jan 2020 21:08:52 -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.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 036/108] acpi: Support ordering SSDT data by device Date: Sun, 26 Jan 2020 22:05:43 -0700 Message-Id: <20200126220508.36.I91d8e58921d27a54f6ecb58ecd5b72d141238f63@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 Add a /chosen property to control the order in which the data appears in the SSDT. This allows matching up U-Boot's output from a dump of the known-good data obtained from within Linux. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 5 ++- doc/device-tree-bindings/chosen.txt | 9 +++++ drivers/core/acpi.c | 61 +++++++++++++++++++++++++++++ test/dm/acpi.c | 17 ++++---- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 3351f92165..100953452a 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -206,12 +206,12 @@ compatible = "denx,u-boot-devres-test"; }; - acpi-test { + acpi_test1: acpi-test { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "ab"; }; - acpi-test2 { + acpi_test2: acpi-test2 { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "cd"; }; @@ -822,6 +822,7 @@ chosen { #address-cells = <1>; #size-cells = <1>; + u-boot,acpi-ssdt-order = <&acpi_test2 &acpi_test1>; chosen-test { compatible = "denx,u-boot-fdt-test"; reg = <9 1>; diff --git a/doc/device-tree-bindings/chosen.txt b/doc/device-tree-bindings/chosen.txt index 395c9501e3..d4dfc05847 100644 --- a/doc/device-tree-bindings/chosen.txt +++ b/doc/device-tree-bindings/chosen.txt @@ -134,3 +134,12 @@ Example phandlepart = <&mmc 1>; }; }; + +u-boot,acpi-ssdt-order +---------------------- + +This provides the ordering to use when writing device data to the ACPI SSDT +(Secondary System Descriptor Table). Each cell is a phandle pointer to a device +node to add. The ACPI information is written in this order. + +If the ordering does not include all nodes, an error is generated. diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index d7ab906757..b8e192dce5 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -95,6 +95,63 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev, return 0; } +struct acpi_item *find_item(const char *devname) +{ + int i; + + for (i = 0; i < item_count; i++) { + struct acpi_item *item = &acpi_item[i]; + + if (!strcmp(devname, item->dev->name)) + return item; + } + + return NULL; +} + +static int build_type(struct acpi_ctx *ctx, void *start, enum gen_type_t type) +{ + const u32 *order; + int size; + int count; + void *ptr; + void *end = ctx->current; + + ptr = start; + order = ofnode_get_chosen_prop("u-boot,acpi-ssdt-order", &size); + if (!order) { + log_warning("Failed to find ordering, leaving as is\n"); + return 0; + } + + count = size / sizeof(u32); + while (count--) { + struct acpi_item *item; + const char *name; + ofnode node; + + node = ofnode_get_by_phandle(fdt32_to_cpu(*order++)); + name = ofnode_get_name(node); + item = find_item(name); + if (!item) { + log_err("Failed to find item '%s'\n", name); + return log_msg_ret("find", -ENOENT); + } + if (item->type == type) { + log_debug(" - add %s\n", item->dev->name); + memcpy(ptr, item->buf, item->size); + ptr += item->size; + } + } + + if (ptr != end) { + log_warning("*** Missing bytes: ptr=%p, end=%p\n", ptr, end); + return -ENXIO; + } + + return 0; +} + int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) { struct acpi_ops *aops; @@ -130,11 +187,15 @@ int _acpi_fill_ssdt(struct acpi_ctx *ctx, struct udevice *parent) int acpi_fill_ssdt(struct acpi_ctx *ctx) { + void *start = ctx->current; int ret; log_debug("Writing SSDT tables\n"); ret = _acpi_fill_ssdt(ctx, dm_root()); log_debug("Writing SSDT finished, err=%d\n", ret); + ret = build_type(ctx, start, TYPE_SSDT); + if (ret) + return log_msg_ret("build", ret); return ret; } diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 50d6ec91f7..3221563ca6 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -336,16 +336,19 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts) ut_assertnonnull(buf); ctx.current = buf; - buf[4] = 'z'; /* sentinal */ + buf[4] = 'z'; /* sentinel */ ut_assertok(acpi_fill_ssdt(&ctx)); - /* These values come from acpi-test's acpi-ssdt-test-data property */ - ut_asserteq('a', buf[0]); - ut_asserteq('b', buf[1]); + /* + * These values come from acpi-test2's acpi-ssdt-test-data property. + * This device comes first because of u-boot,acpi-ssdt-order + */ + ut_asserteq('c', buf[0]); + ut_asserteq('d', buf[1]); - /* These values come from acpi-test2's acpi-ssdt-test-data property */ - ut_asserteq('c', buf[2]); - ut_asserteq('d', buf[3]); + /* These values come from acpi-test's acpi-ssdt-test-data property */ + ut_asserteq('a', buf[2]); + ut_asserteq('b', buf[3]); ut_asserteq('z', buf[4]); From patchwork Mon Jan 27 05:05:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229531 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GxcQ5BlU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dGb51pBz9sR1 for ; Mon, 27 Jan 2020 16:14:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B6FFB81829; Mon, 27 Jan 2020 06:11:14 +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="GxcQ5BlU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B455817D2; Mon, 27 Jan 2020 06:09:20 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 CAB5A817B6 for ; Mon, 27 Jan 2020 06:08:54 +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-xd43.google.com with SMTP id x1so8555152iop.7 for ; Sun, 26 Jan 2020 21:08:54 -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=b1VVRDnc1Rw4wW1Lluh7eOZoOnzm9T7Wzx4J1PnD5Sc=; b=GxcQ5BlUHWhG6MmTLfMQZjrEp5G6lxS/w5zY6enyiwTEGoD4NzI7ttaN7noIYHXWQc 754wjXCvOlHm0FegCIBLK5HUAPklgxXUYKR3vBg5XpwrKVJdx9NeTh6QwpmIdtfrjAwd ZcXHo3GIvNJTHNWEbDcASTMZAmc5iWpZ8ZRew= 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=b1VVRDnc1Rw4wW1Lluh7eOZoOnzm9T7Wzx4J1PnD5Sc=; b=A0WFu095G/nRfhM6tNm7cXRVnGVULlPSJYBE02Pyd6wIrgrNr6qBeitczspkB19qnG uN995Rqv0lZRcdfFRWogisLE5HxxBDdPEm8M9xDCd+1lFUhMa/z8orYd3zvwyiBbm+P5 kLHp9ZCOpmD68qsnN2sbpCbV5W+/rBiqW7m+RDrMY7ecuPiT864KfqH8aBDJMl0w9MaK /5/rEQTRGu4vaWFC/dR2HkSDBTtZ+pwtzoWK+7guXsETfGA9hw/4ipU1mOC4rsJIbuVk OUUp3/3nFPkR72hTT9HiUejlQBdBehBZt3qanN4yXp03Q4q2zPHEIYNb/HZQeP3J5+ol 9oqA== X-Gm-Message-State: APjAAAUy34fAcK87w5XjRw+eLU8o/b5Foz/9gUS9K8hrrYp7umZ6cN4U BihVu+Km4Td69nsMhxkbIdywu+roiHwTRg== X-Google-Smtp-Source: APXvYqyyW7YvTZvMUoUJcIkVCTeJ/MKwTc4VJnQ1nQwP4eUZRTy0/NmeZbNtlOsGugg1wM0PMUFXHw== X-Received: by 2002:a02:2402:: with SMTP id f2mr11501437jaa.135.1580101733523; Sun, 26 Jan 2020 21:08:53 -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.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 037/108] x86: Allow devices to write an SSDT Date: Sun, 26 Jan 2020 22:05:44 -0700 Message-Id: <20200126220508.37.Id6fc7367886ec2e2d9f2ddf423ad32720e14e5e5@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 Call the new core function to write the SSDT. This is made up of fragments generated by devices that have the fill_ssdt() method. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 694e92c158..3b97fe162c 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -344,6 +345,46 @@ static void acpi_create_spcr(struct acpi_spcr *spcr) header->checksum = table_compute_checksum((void *)spcr, header->length); } +static void acpi_ssdt_write_cbtable(struct acpi_ctx *ctx) +{ + uintptr_t base; + u32 size; + + base = 0; + size = 0; + + acpigen_write_device(ctx, "CTBL"); + acpigen_write_coreboot_hid(ctx, COREBOOT_ACPI_ID_CBTABLE); + acpigen_write_name_integer(ctx, "_UID", 0); + acpigen_write_sta(ctx, ACPI_STATUS_DEVICE_HIDDEN_ON); + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + acpigen_write_mem32fixed(ctx, 0, base, size); + acpigen_write_resourcetemplate_footer(ctx); + acpigen_pop_len(ctx); +} + +void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, + const char *oem_table_id) +{ + memset((void *)ssdt, '\0', sizeof(struct acpi_table_header)); + + acpi_fill_header(ssdt, "SSDT"); + ssdt->revision = acpi_get_table_revision(ACPITAB_SSDT); + ssdt->aslc_revision = 1; + ssdt->length = sizeof(struct acpi_table_header); + + acpi_inc(ctx, sizeof(struct acpi_table_header)); + + /* Write object to declare coreboot tables */ + acpi_ssdt_write_cbtable(ctx); + acpi_fill_ssdt(ctx); + + /* (Re)calculate length and checksum. */ + ssdt->length = ctx->current - (void *)ssdt; + ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length); +} + /* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ @@ -353,6 +394,7 @@ ulong write_acpi_tables(ulong start_addr) struct acpi_facs *facs; struct acpi_table_header *dsdt; struct acpi_fadt *fadt; + struct acpi_table_header *ssdt; struct acpi_mcfg *mcfg; struct acpi_madt *madt; struct acpi_csrt *csrt; @@ -408,6 +450,14 @@ ulong write_acpi_tables(ulong start_addr) acpi_create_fadt(fadt, facs, dsdt); acpi_add_table(ctx, fadt); + debug("ACPI: * SSDT\n"); + ssdt = (struct acpi_table_header *)ctx->current; + acpi_create_ssdt(ctx, ssdt, ACPI_TABLE_CREATOR); + if (ssdt->length > sizeof(struct acpi_table_header)) { + acpi_inc_align(ctx, ssdt->length); + acpi_add_table(ctx, ssdt); + } + debug("ACPI: * MCFG\n"); mcfg = ctx->current; acpi_create_mcfg(mcfg); From patchwork Mon Jan 27 05:05:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229536 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=fsO1XqQA; 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 485dHZ1XLGz9sR1 for ; Mon, 27 Jan 2020 16:15:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A62B8184F; Mon, 27 Jan 2020 06:11:27 +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="fsO1XqQA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3ED4F817B4; Mon, 27 Jan 2020 06:09:28 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 6C959817DF for ; Mon, 27 Jan 2020 06:08:55 +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-xd44.google.com with SMTP id i11so8535272ioi.12 for ; Sun, 26 Jan 2020 21:08:55 -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=mQ4Ww0NcgPB7tLCSX4/mg+Dxi4rfy2yDjMSduTIji1k=; b=fsO1XqQA0VYdocwJ2tl7SUfoSXnUbOW6G1RyL3EFfZZRUzoXZB9pvFShF69V55mjEg cmZ66h9E5ia+WNHh3XqCf0BCJ3Peycgk+DOeckgVE+IwSv2bCqVMYSDQ6e8KjdG4b8CG plpRHbGMoPdqE8hYay9yxKBmuKVWFyk14OLF0= 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=mQ4Ww0NcgPB7tLCSX4/mg+Dxi4rfy2yDjMSduTIji1k=; b=m8rBegw7rxpX4xC9LhgX8+vSLVREZjuUPhG7/8ZHSOApCSNwRzQdjlNORtM1iNk8dH FLaRHg+buTBkG20mgZFsb14/SiyUMStyGfepSQBHeUOzBZZ7VVmB3jJDKo/QjYLsTxVv cdBOXbgGLCkRp3E5/gS5uQmmp/G4G1EjvCgI24z2ZCUeMuI/I0Uh4k1je89JjW41aNLg 09mhgn9TKGDuQsF6dYDUB534cILhLPtpOhmYMNycTwDUyKEERhokLTg6BWwLKO+PB/Hy thKvd3stW+mC3JcsTvHZRwVCWPLRsc79DIsEYQ2MvtpDr4OsFi1e31WwFiPmxFen2gTf QjSg== X-Gm-Message-State: APjAAAWTAYz5tff/6+6gbaZMC9Op+KRG9gEyVrIWhu3u8+nqBkxwLX0a BCSsCq/DQqlMbYvUGY+lyecHsZUk07S2ag== X-Google-Smtp-Source: APXvYqylsRS/oxDHj/mnLDc1V2mPBOizadOjo5gVhTQ8ZUeQb/oArHI0NIX3jNUcm2URYOM0brr5aA== X-Received: by 2002:a02:864b:: with SMTP id e69mr11679297jai.83.1580101734194; Sun, 26 Jan 2020 21:08:54 -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.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 038/108] acpi: Add support for DSDT generation Date: Sun, 26 Jan 2020 22:05:45 -0700 Message-Id: <20200126220508.38.I2e68300c24666745bcb7ecb874b13329538265e0@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 Some devices need to inject extra code into the Differentiated System Descriptor Table (DSDT). Add a method to handle this. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 2 ++ drivers/core/acpi.c | 50 ++++++++++++++++++++++++++++++++++++++- include/dm/acpi.h | 23 ++++++++++++++++++ test/dm/acpi.c | 44 +++++++++++++++++++++++++++++++++- 4 files changed, 117 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 100953452a..f60f0adc05 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -209,11 +209,13 @@ acpi_test1: acpi-test { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "ab"; + acpi-dsdt-test-data = "hi"; }; acpi_test2: acpi-test2 { compatible = "denx,u-boot-acpi-test"; acpi-ssdt-test-data = "cd"; + acpi-dsdt-test-data = "jk"; }; clocks { diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index b8e192dce5..657753ebb3 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -18,6 +18,7 @@ /* Type of table that we collected */ enum gen_type_t { + TYPE_DSDT, TYPE_SSDT, }; @@ -118,7 +119,9 @@ static int build_type(struct acpi_ctx *ctx, void *start, enum gen_type_t type) void *end = ctx->current; ptr = start; - order = ofnode_get_chosen_prop("u-boot,acpi-ssdt-order", &size); + order = ofnode_get_chosen_prop(type == TYPE_DSDT ? + "u-boot,acpi-dsdt-order" : + "u-boot,acpi-ssdt-order", &size); if (!order) { log_warning("Failed to find ordering, leaving as is\n"); return 0; @@ -200,6 +203,51 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx) return ret; } +int _acpi_inject_dsdt(struct acpi_ctx *ctx, struct udevice *parent) +{ + struct acpi_ops *aops; + struct udevice *dev; + int ret; + + aops = device_get_acpi_ops(parent); + if (aops && aops->inject_dsdt) { + void *start = ctx->current; + + log_debug("- %s %p\n", parent->name, aops->inject_dsdt); + ret = device_ofdata_to_platdata(parent); + if (ret) + return log_msg_ret("ofdata", ret); + ret = aops->inject_dsdt(parent, ctx); + if (ret) + return ret; + ret = acpi_add_item(ctx, parent, TYPE_DSDT, start); + if (ret) + return ret; + } + device_foreach_child(dev, parent) { + ret = _acpi_inject_dsdt(ctx, dev); + if (ret) + return ret; + } + + return 0; +} + +int acpi_inject_dsdt(struct acpi_ctx *ctx) +{ + void *start = ctx->current; + int ret; + + log_debug("Writing DSDT tables\n"); + ret = _acpi_inject_dsdt(ctx, dm_root()); + log_debug("Writing DSDT finished, err=%d\n", ret); + ret = build_type(ctx, start, TYPE_DSDT); + if (ret) + return log_msg_ret("build", ret); + + return ret; +} + int _acpi_write_dev_tables(struct acpi_ctx *ctx, const struct udevice *parent) { struct acpi_ops *aops; diff --git a/include/dm/acpi.h b/include/dm/acpi.h index c340c21685..8de9296e71 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -85,6 +85,19 @@ struct acpi_ops { * @return 0 if OK, -ve on error */ int (*fill_ssdt)(const struct udevice *dev, struct acpi_ctx *ctx); + + /** + * inject_dsdt() - Generate DSDT code for a device + * + * This is called to create the DSDT code. THe method should write out + * whatever ACPI code is needed by this device. It will end up in the + * DSDT table. + * + * @dev: Device to write + * @ctx: ACPI context to use + * @return 0 if OK, -ve on error + */ + int (*inject_dsdt)(const struct udevice *dev, struct acpi_ctx *ctx); }; #define device_get_acpi_ops(dev) ((dev)->driver->acpi_ops) @@ -139,6 +152,16 @@ int acpi_write_dev_tables(struct acpi_ctx *ctx); */ int acpi_fill_ssdt(struct acpi_ctx *ctx); +/** + * acpi_inject_dsdt() - Generate ACPI tables for DSDT + * + * This is called to create the DSDT code for all devices. + * + * @ctx: ACPI context to use + * @return 0 if OK, -ve on error + */ +int acpi_inject_dsdt(struct acpi_ctx *ctx); + #endif /* __ACPI__ */ #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 3221563ca6..16dc0955be 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -54,10 +54,22 @@ static int testacpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) return 0; } +static int testacpi_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + const char *data; + + data = dev_read_string(dev, "acpi-dsdt-test-data"); + while (*data) + acpigen_emit_byte(ctx, *data++); + + return 0; +} + struct acpi_ops testacpi_ops = { .get_name = testacpi_get_name, .write_tables = testacpi_write_tables, .fill_ssdt = testacpi_fill_ssdt, + .inject_dsdt = testacpi_inject_dsdt, }; static const struct udevice_id testacpi_ids[] = { @@ -354,4 +366,34 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts) return 0; } -`DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test acpi_inject_dsdt() */ +static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + u8 *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + buf[4] = 'z'; /* sentinel */ + ut_assertok(acpi_inject_dsdt(&ctx)); + + /* + * These values come from acpi-test's acpi-dsdt-test-data property. + * There is no u-boot,acpi-dsdt-order so device-tree order is used. + */ + ut_asserteq('h', buf[0]); + ut_asserteq('i', buf[1]); + + /* These values come from acpi-test's acpi-dsdt-test-data property */ + ut_asserteq('j', buf[2]); + ut_asserteq('k', buf[3]); + + ut_asserteq('z', buf[4]); + + return 0; +} +DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229534 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=kbztIgwV; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dHC0Yxvz9sR1 for ; Mon, 27 Jan 2020 16:15:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 308EE81851; Mon, 27 Jan 2020 06:11:23 +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="kbztIgwV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A4088182E; Mon, 27 Jan 2020 06:09:27 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 1AD878148F for ; Mon, 27 Jan 2020 06:08:56 +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-xd42.google.com with SMTP id x1so8555200iop.7 for ; Sun, 26 Jan 2020 21:08:56 -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=o68eT7GFbe8NDk8yAeR6lPqA3qR+t9U9jn6qUbVvY8s=; b=kbztIgwVZz8APfWmc/zoQdAaEoSGN6U4YhKHYMzRTrJj9pjm1mYEV0iWBbMlo58Y/B YeooOtpe9bYnAG/05VyqcDQrVjVcPoDZokMOgLfgpE4TxTnTH6hWTW7IIQnWtereLnfV FPjDkzlt5dWLsELbfA1sp6cS8CKHHLSXwSaRg= 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=o68eT7GFbe8NDk8yAeR6lPqA3qR+t9U9jn6qUbVvY8s=; b=glSZI9cFGwlpT89O1zV3saZ/R5HyNfzuUeVi+L1Hqr/2mODpTt22KbXVaHHmzy4+u0 O6jToARSYj5emNoFYl3xbsXh/ECMgFTgVNuYP40H68Xm6Q0keZDgS0khl5De6/GLBzbL YWduDkZYXeIrmzoWxggXV7aLrglYlgJQDsQ1C0R859r28D1LcB7XYlWK0RIFHD0yhMoo Pjp+iKthr1WJNGZD9h6vm+8vYv5CmEwfh8hseIfZpj9/CJHn3moD8P1Pe1taejX3veGg /fjwKohY/rDkmaV75BzHltS4vk0FCvTorGs17pzv1OqP0LdzaWIEnDuOut2jhNN7pwIe tlQQ== X-Gm-Message-State: APjAAAXRuVydGhxyd1tueCt3pv/+q7SkQ57r5rKd24ja+cfNCFRFiyf9 BmP/T7fRqndvGCrPiEnFoGIsFemCgRDTsA== X-Google-Smtp-Source: APXvYqxOT1Z86CJ1KGytCzvfduqNxK/Te4R3YOjjt6KkirGjIckacOvnIng39I7W/Z/9BYrPFGIN+w== X-Received: by 2002:a5e:aa18:: with SMTP id s24mr3091292ioe.221.1580101734889; Sun, 26 Jan 2020 21:08:54 -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.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 039/108] x86: Allow devices to write to DSDT Date: Sun, 26 Jan 2020 22:05:46 -0700 Message-Id: <20200126220508.39.I8b14735c2286701cc6be7d36b85bbad8ca58babd@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 Call the new core function to inject ASL programmatically into the DSDT. This is made up of fragments generated by devices that have the inject_dsdt() method. The normal, compiled ASL file is added after this. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 3b97fe162c..5e14149923 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -422,7 +422,20 @@ ulong write_acpi_tables(ulong start_addr) memcpy(ctx->current, (char *)&AmlCode + sizeof(struct acpi_table_header), dsdt->length - sizeof(struct acpi_table_header)); - acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header)); + + if (dsdt->length >= sizeof(struct acpi_table_header)) { + acpi_inject_dsdt(ctx); + memcpy(ctx->current, + (char *)AmlCode + sizeof(struct acpi_table_header), + dsdt->length - sizeof(struct acpi_table_header)); + acpi_inc(ctx, dsdt->length - sizeof(struct acpi_table_header)); + + /* (Re)calculate length and checksum. */ + dsdt->length = ctx->current - (void *)dsdt; + dsdt->checksum = 0; + dsdt->checksum = table_compute_checksum(dsdt, dsdt->length); + } + acpi_align(ctx); /* Pack GNVS into the ACPI table area */ for (i = 0; i < dsdt->length; i++) { From patchwork Mon Jan 27 05:05:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229535 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=miyOiSzf; 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 485dHN1Sktz9sR1 for ; Mon, 27 Jan 2020 16:15:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9DE1281854; Mon, 27 Jan 2020 06:11:25 +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="miyOiSzf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B489281835; Mon, 27 Jan 2020 06:09:27 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 36D91817C1 for ; Mon, 27 Jan 2020 06:08:57 +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-xd42.google.com with SMTP id h8so8565567iob.2 for ; Sun, 26 Jan 2020 21:08:57 -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=RVzQV7LwwdR+vniJnRWJ7GSRnbWJrtn9J2ypgxI4xM4=; b=miyOiSzfI6Vmt+scXMfwFGgNFGozpAvcVO4Luano9OGB6bJGqRl15ThSLxN8v+ksRL mWhJgmqlJMFAjlnw6JHRZ3A6jcBTbjrKUCC8WxQiKYCFw8QVqFWmhDspuUeJdk6BifRX wLpobJ+OD+MngYTC5thp7TYZ1siBOGSfgV08o= 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=RVzQV7LwwdR+vniJnRWJ7GSRnbWJrtn9J2ypgxI4xM4=; b=IuuwnUmMASmifkVNUIFJ4ETm3cKJfq1a8FGkew532KB+Gna0aLAi7QM2JenC61gLoQ i2ImhaXUu0nQSabU3U3KNFaJI/wvYAmI+xTf/T0gflzUeI62FPHyxCa+fD5R42kuhkQm UEOqYHNY/sBxXflHsBotxtWBX8PXB/9fbA65O3xFzfcLyFQQGkQSm6txRoq+QJaNFEXn +6a8EFhueTLafMcyETSbXqOc2TsBse7nynjEiHCQQUVvqQxqvLiTCOdLccNw4Qp8CzCz 9K65DifuRgHMUzWqlcE2UO9iWL+mxljjo4BudDMbjAotNU2V0SUygiTbrGxoyYZ+dQ9m pbAQ== X-Gm-Message-State: APjAAAV7bODsZMF86a/6kFTMQ08Zj1lHC2XANh+ZA4YrCLsUf8/7VPoq 20raXSxIssP8MlndKr+Ez+V3hfJ/iBz6Ig== X-Google-Smtp-Source: APXvYqz96fF9pvxPMTKKtXIA9BX8OlEXHQCyDcWiCfE8yCj78gVIwADpTd1wfcHy/FlbXIYNUY6nZQ== X-Received: by 2002:a02:a694:: with SMTP id j20mr12216948jam.69.1580101735955; Sun, 26 Jan 2020 21:08:55 -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.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 040/108] dm: core: Add an ACPI name for the root node Date: Sun, 26 Jan 2020 22:05:47 -0700 Message-Id: <20200126220508.40.I3fc26919ac73d55741c6ee8098cc0d6df70bb23c@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: , Cc: Pavel Herrmann 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 always has a fixed ACPI name so add it as a driver function. Signed-off-by: Simon Glass --- drivers/core/root.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/core/root.c b/drivers/core/root.c index e85643819e..431c8c7246 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -390,10 +391,22 @@ int dm_init_and_scan(bool pre_reloc_only) return 0; } +#ifdef CONFIG_ACPIGEN +static int root_acpi_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_return_name(out_name, "\\_SB"); +} + +struct acpi_ops root_acpi_ops = { + .get_name = root_acpi_get_name, +}; +#endif + /* This is the root driver - all drivers are children of this */ U_BOOT_DRIVER(root_driver) = { .name = "root_driver", .id = UCLASS_ROOT, + acpi_ops_ptr(&root_acpi_ops) }; /* This is the root uclass */ From patchwork Mon Jan 27 05:05:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229537 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=lA5Qo9gX; 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 485dHm1227z9sR1 for ; Mon, 27 Jan 2020 16:15:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5620681856; Mon, 27 Jan 2020 06:11:30 +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="lA5Qo9gX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F58181835; Mon, 27 Jan 2020 06:09:29 +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 19251817DD for ; Mon, 27 Jan 2020 06:08:58 +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 x1so8555260iop.7 for ; Sun, 26 Jan 2020 21:08:58 -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=unaDXL5HftX46LGLuxkGq1KmQJ3whfdR3l8OJG7IIz8=; b=lA5Qo9gX0KBKOEdc4iskmUt76Fma5jHIWPeltLlMoid73QdA0ahDin/JkCMrt3Ejjn thlbeQA6vNizOiDRXGVNQ7lY0VdBJ4X/grjpxmwPgPcOeBk91xJ6yvFpjjGaaFZ6I+EL DluFylDeIzd+W1ZegSxHsk3hOOin2+uE1JhKg= 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=unaDXL5HftX46LGLuxkGq1KmQJ3whfdR3l8OJG7IIz8=; b=W8zJBN5NdiHDcn7BOo3/RH6Cn0Xx5n8YQ/89Qj/lvwupx1EDxgO6XuZmjqOdj3LH81 PaR3ttQvdDe6EynpLQSjMSqZJeXHscqpeyt++esT6idYggBQns6XDr6QFB+kM6gA1ZK3 +084I9i9w5BfZZQSn8uXp9V9+PAKWISGemLH71tbPVz/s9s7+HwtIfL7ow876OIQJbyv MVnH35O3LpUhV1+xj4oLA+gYWDvrVFi/HW6Bh6PlHSl068Ms4CG4/Mv2hNSl1Q51L1BN tvNidlTBlMCJ6NwRh/I6kJom0YqETAMz++SGLCcU9X/na/RYTORAlgofr7zpmZZ3T6oD Du3w== X-Gm-Message-State: APjAAAWvdlvczymIpTvyEzl/lSHDe3EVLpR/u6NJGdoRQ1AfRIydPAYI P1FQq6K6jv/qx6EnPI5qt4zBf9/vcTyKYg== X-Google-Smtp-Source: APXvYqwxrNneOaPdqaCXHBHKhwUFgHoHrnFgSjv89iXMYwytZPjln62K3QbANDQhripsOHdbfRX3rA== X-Received: by 2002:a5e:8e4c:: with SMTP id r12mr10889934ioo.119.1580101736702; Sun, 26 Jan 2020 21:08:56 -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.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 041/108] dm: acpi: Enhance acpi_get_name() Date: Sun, 26 Jan 2020 22:05:48 -0700 Message-Id: <20200126220508.41.I1a77e678d7c6973796cc651ac6d858e1122bb7ae@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: , Cc: Pavel Herrmann 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 For many device types it is possible to figure out the name just by looking at its uclass or parent. Add a function to handle this, since it allows us to cover the vast majority of cases automatically. However it is sometimes impossible to figure out an ACPI name for a device just by looking at its uclass. For example a touch device may have a vendor-specific name. Add a new "acpi,name" property to allow a custom name to be created. Signed-off-by: Simon Glass --- arch/sandbox/dts/test.dts | 1 + doc/device-tree-bindings/device.txt | 13 +++++++++ drivers/core/acpi.c | 11 +++++++- include/dm/device.h | 2 +- test/dm/acpi.c | 42 ++++++++++++++++++++++++++++- 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index f60f0adc05..410235fae3 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -94,6 +94,7 @@ int-value = <1234>; uint-value = <(-1234)>; interrupts-extended = <&irq 3 0>; + acpi,name = "GHIJ"; }; junk { diff --git a/doc/device-tree-bindings/device.txt b/doc/device-tree-bindings/device.txt index e625e67f43..61ebd7a942 100644 --- a/doc/device-tree-bindings/device.txt +++ b/doc/device-tree-bindings/device.txt @@ -18,6 +18,8 @@ U-Boot provides for some optional properties which are documented here. - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that Linux will not re-init the device + - acpi,name : Provides the ACPI name for a device, which is a string consisting + of four alphanumeric character (upper case) - acpi,uid : _UID value for device @@ -35,3 +37,14 @@ synaptics_touchpad: synaptics-touchpad@2c { acpi,probed; acpi,hid-desc-reg-offset = <0x20>; }; + +pcie-a0@14,0 { + reg = <0x0000a000 0 0 0 0>; + acpi,name = "RP01"; + wifi: wifi { + compatible = "intel,generic-wifi"; + acpi,desc = "Intel WiFi"; + acpi,name = "WF00"; + interrupts-extended = <&acpi_gpe 0x3c 0>; + }; +}; diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 657753ebb3..ba02b04636 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -9,6 +9,7 @@ #define LOG_CATEOGRY LOGC_ACPI #include +#include #include #include #include @@ -51,12 +52,20 @@ int acpi_return_name(char *out_name, const char *name) int acpi_get_name(const struct udevice *dev, char *out_name) { struct acpi_ops *aops; + const char *name; + int ret; aops = device_get_acpi_ops(dev); if (aops && aops->get_name) return aops->get_name(dev, out_name); + name = dev_read_string(dev, "acpi,name"); + if (name) + return acpi_return_name(out_name, name); + ret = acpi_device_get_name(dev, out_name); + if (ret) + return log_msg_ret("dev", ret); - return -ENOSYS; + return 0; } /** diff --git a/include/dm/device.h b/include/dm/device.h index c2e12cd151..03d7ef1bb3 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -713,7 +713,7 @@ int dev_enable_by_path(const char *path); */ static inline bool device_is_on_pci_bus(const struct udevice *dev) { - return device_get_uclass_id(dev->parent) == UCLASS_PCI; + return dev->parent && device_get_uclass_id(dev->parent) == UCLASS_PCI; } /** diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 16dc0955be..c87bd8569d 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -93,12 +93,52 @@ UCLASS_DRIVER(testacpi) = { static int dm_test_acpi_get_name(struct unit_test_state *uts) { char name[ACPI_NAME_MAX]; - struct udevice *dev; + struct udevice *dev, *dev2, *i2c, *spi, *serial, *timer, *sound; + struct udevice *pci, *root; + /* Test getting the name from the driver */ ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); ut_assertok(acpi_get_name(dev, name)); ut_asserteq_str(ACPI_TEST_DEV_NAME, name); + /* Test getting the name from the device tree */ + ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "a-test", + &dev2)); + ut_assertok(acpi_get_name(dev2, name)); + ut_asserteq_str("GHIJ", name); + + /* Test getting the name from acpi_device_get_name() */ + ut_assertok(uclass_first_device(UCLASS_I2C, &i2c)); + ut_assertok(acpi_get_name(i2c, name)); + ut_asserteq_str("I2C0", name); + + ut_assertok(uclass_first_device(UCLASS_SPI, &spi)); + ut_assertok(acpi_get_name(spi, name)); + ut_asserteq_str("SPI0", name); + + /* The uart has no sequence number, so this should fail */ + ut_assertok(uclass_first_device(UCLASS_SERIAL, &serial)); + ut_asserteq(-ENXIO, acpi_get_name(serial, name)); + + /* ACPI doesn't know about the timer */ + ut_assertok(uclass_first_device(UCLASS_TIMER, &timer)); + ut_asserteq(-ENOENT, acpi_get_name(timer, name)); + + /* May as well test the rest of the cases */ + ut_assertok(uclass_first_device(UCLASS_SOUND, &sound)); + ut_assertok(acpi_get_name(sound, name)); + ut_asserteq_str("HDAS", name); + + ut_assertok(uclass_first_device(UCLASS_PCI, &pci)); + ut_assertok(acpi_get_name(pci, name)); + ut_asserteq_str("PCI0", name); + + ut_assertok(uclass_first_device(UCLASS_ROOT, &root)); + ut_assertok(acpi_get_name(root, name)); + ut_asserteq_str("\\_SB", name); + + /* Note that we don't have tests for acpi_name_from_id() */ + return 0; } DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229579 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=PhRcODMm; 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 485dS60M9lz9sR1 for ; Mon, 27 Jan 2020 16:23:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 450EF81900; Mon, 27 Jan 2020 06:13:21 +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="PhRcODMm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A187481845; Mon, 27 Jan 2020 06:09:30 +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 D3945817A0 for ; Mon, 27 Jan 2020 06:08:58 +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 n11so8552767iom.9 for ; Sun, 26 Jan 2020 21:08:58 -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=1dOo4WTpYFE5PZilJywqdVfEOy+qi3h6yCksx7vuEQo=; b=PhRcODMmeL1cskYDmiAWi2VfmRG0W0x1rE5YKOAUzAPQaI9xWlGX/1U90IiEYhgH/4 babAa3VSY+fi+AxPTsAfpB1IMsevvPwPNqzEo81xNpkg2OJLrCRhxnmvZD9KNjdvNLcT CtDSFZSBCq45zlzVbIe5WT5LlcLOKZebiqTzM= 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=1dOo4WTpYFE5PZilJywqdVfEOy+qi3h6yCksx7vuEQo=; b=AqvIBTXh7V14b6gr+NESq8y2CbtBBhCX4Tq5oh8sGQvHdnEkx95pwGnTVdPKapXQE7 5jexvHKFG55o+CwxoOvl2Oj0qWb/eCJeXe1oeSQAjFIzfJxoKKo0YwYaYdul48GqQsHG 9gpmB7eCkbZU+i5g2HnHXnJ0Ybo+2+AMebmZtPUo9+AQwPXP4Sv9BYCKVsH0LWCy1mdn mxarv3tZazTLupjRBGVXPook7BjCWgZGPo2OMaarFbNtTCloz8PyIUUQb47u4C3dRaIQ aXSAHD/q1FAjn8b7W2L6X/TL2ZIxy21CPatfv+3NZ7dlgyyp2D52d5yTFjJayLiccZhE dQDw== X-Gm-Message-State: APjAAAWSedlOIfs13yYy2jOct5n3U4c4lw+ahbAQ5aXfm4C2RlkY+jEo vk1nbaoHogvHLyI04hNkqG2EX9f4v0qRhg== X-Google-Smtp-Source: APXvYqxoiHKh57CmRO0l0ww531hZyxqXQ5F8FgjeOcl/AOob4fHsT+Hfi26Gqrln/dvA6SmoBU8vAA== X-Received: by 2002:a02:94e9:: with SMTP id x96mr11236707jah.68.1580101737549; Sun, 26 Jan 2020 21:08:57 -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.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:57 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 042/108] acpi: Add an acpi split command Date: Sun, 26 Jan 2020 22:05:49 -0700 Message-Id: <20200126220508.42.I5894252b8fe4522e409528c497d882226f34ab9b@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 Add a command that shows the individual blocks of data generated by each device. This can be helpful for debugging. Signed-off-by: Simon Glass --- cmd/acpi.c | 15 +++++++++++++-- drivers/core/acpi.c | 18 ++++++++++++++++++ include/dm/acpi.h | 10 ++++++++++ test/dm/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/cmd/acpi.c b/cmd/acpi.c index b66c26265b..a472618628 100644 --- a/cmd/acpi.c +++ b/cmd/acpi.c @@ -146,6 +146,17 @@ static int do_acpi_list(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +static int do_acpi_items(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + bool dump; + + dump = argc >= 2 && !strcmp("-d", argv[1]); + acpi_dump_items(dump); + + return 0; +} + static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { @@ -153,8 +164,6 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, char sig[ACPI_NAME_LEN]; int ret; - if (argc < 2) - return CMD_RET_USAGE; name = argv[1]; if (strlen(name) != ACPI_NAME_LEN) { printf("Table name '%s' must be four characters\n", name); @@ -172,8 +181,10 @@ static int do_acpi_dump(cmd_tbl_t *cmdtp, int flag, int argc, static char acpi_help_text[] = "list - list ACPI tables\n" + "acpi items [-d] - List/dump each piece of ACPI data from devices\n" "acpi dump - Dump ACPI table"; U_BOOT_CMD_WITH_SUBCMDS(acpi, "ACPI tables", acpi_help_text, U_BOOT_SUBCMD_MKENT(list, 1, 1, do_acpi_list), + U_BOOT_SUBCMD_MKENT(items, 2, 1, do_acpi_items), U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_acpi_dump)); diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index ba02b04636..762cc40511 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -105,6 +105,22 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev, return 0; } +void acpi_dump_items(bool dump_contents) +{ + int i; + + for (i = 0; i < item_count; i++) { + struct acpi_item *item = &acpi_item[i]; + + printf("dev '%s', type %d, size %x\n", item->dev->name, + item->type, item->size); + if (dump_contents) { + print_buffer(0, item->buf, 1, item->size, 0); + printf("\n"); + } + } +} + struct acpi_item *find_item(const char *devname) { int i; @@ -203,6 +219,7 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx) int ret; log_debug("Writing SSDT tables\n"); + item_count = 0; ret = _acpi_fill_ssdt(ctx, dm_root()); log_debug("Writing SSDT finished, err=%d\n", ret); ret = build_type(ctx, start, TYPE_SSDT); @@ -248,6 +265,7 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx) int ret; log_debug("Writing DSDT tables\n"); + item_count = 0; ret = _acpi_inject_dsdt(ctx, dm_root()); log_debug("Writing DSDT finished, err=%d\n", ret); ret = build_type(ctx, start, TYPE_DSDT); diff --git a/include/dm/acpi.h b/include/dm/acpi.h index 8de9296e71..ea3a615f60 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -162,6 +162,16 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx); */ int acpi_inject_dsdt(struct acpi_ctx *ctx); +/** + * acpi_dump_items() - Dump out the collected ACPI items + * + * This lists the ACPI DSDT and SSDT items generated by the various U-Boot + * drivers. + * + * @dump_contents: true to dump the binary contents, false to just show the list + */ +void acpi_dump_items(bool dump_contents); + #endif /* __ACPI__ */ #endif diff --git a/test/dm/acpi.c b/test/dm/acpi.c index c87bd8569d..dbb4f26a71 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -437,3 +437,42 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test 'acpi items' command */ +static int dm_test_acpi_cmd_items(struct unit_test_state *uts) +{ + struct acpi_ctx ctx; + void *buf; + + buf = malloc(BUF_SIZE); + ut_assertnonnull(buf); + + ctx.current = buf; + ut_assertok(acpi_fill_ssdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 1, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 1, size 2"); + ut_assert_console_end(); + + ctx.current = buf; + ut_assertok(acpi_inject_dsdt(&ctx)); + console_record_reset(); + run_command("acpi items", 0); + ut_assert_nextline("dev 'acpi-test', type 0, size 2"); + ut_assert_nextline("dev 'acpi-test2', type 0, size 2"); + ut_assert_console_end(); + + console_record_reset(); + run_command("acpi items -d", 0); + ut_assert_nextline("dev 'acpi-test', type 0, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_nextline("dev 'acpi-test2', type 0, size 2"); + ut_assert_nextlines_are_dump(2); + ut_assert_nextline("%s", ""); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); From patchwork Mon Jan 27 05:05:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229541 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=aOvJE3hm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dJS6yGNz9sR1 for ; Mon, 27 Jan 2020 16:16:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1B1A817E1; Mon, 27 Jan 2020 06:11:41 +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="aOvJE3hm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2F86A8176E; Mon, 27 Jan 2020 06:09:32 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 81F708176E for ; Mon, 27 Jan 2020 06:08:59 +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-xd44.google.com with SMTP id c16so8566878ioh.6 for ; Sun, 26 Jan 2020 21:08:59 -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=tdLlXqN52/rM6Xd/sw/6rNCLvoOZ35peFS1P+8oC+40=; b=aOvJE3hmxLYnhMYc0z+7K1V2Hebxsx6X4ILqhvdmh324MDh16mDAlIy3dod19xNxT0 ekhA7+NHf83TDKG17JWguAH6P4ViKollMS8e4p8CX89BpzqbbDG9veV2Z8e0SBtn17X9 dLi7Oex35og07N67O4xiqjZM+Y7p9VZ0GMWZM= 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=tdLlXqN52/rM6Xd/sw/6rNCLvoOZ35peFS1P+8oC+40=; b=B+wTtzrRgpRwLurPsXafoWNRGl3xXKlKMOPPwxtQd2bX7mnn2Vd30qnENuvRv+svM1 DthzGgIsxWQ++WCveP0a/843TRj/KU3ZWoDthmU6N0xKXxttv2nsstYT/qYVSe9gLOG7 zLWStWG+960u6bHN1h8mMvhPRiYSoE4JjOT/WJBAZVF9guW+uDIEjRX4z8b+YxjuX9aW RiGfnow3R+KRAEwbH/mXVkDW/kmSlH3PxLo2JPwQYnAgaGja9kFXz9CfrRqogT8y1PXD BYElspJ1sCBIIxzQrQpSXExGqF9nunwgyrxqYUBT+JE1xyU4yGQd8eqEj2//KZ0as4PO uGKw== X-Gm-Message-State: APjAAAV22llqIwciYmlSUb9aDwNsXvMF3Lk8Sy//wLUbZSGHYx1z4lMf ewX6xCGzFkU2FLLfC/JyfLBtdVNyymtxBA== X-Google-Smtp-Source: APXvYqyz45Rtpuh6DER60SwJdo/ljiXSiqNMgi3z2rQokYAOyGWzz6alXdCNCzpKw8ELbrt5RGQQjQ== X-Received: by 2002:a02:cd9c:: with SMTP id l28mr11852666jap.46.1580101738263; Sun, 26 Jan 2020 21:08:58 -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.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:58 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 043/108] acpi: Allow creating the GNVS to fail Date: Sun, 26 Jan 2020 22:05:50 -0700 Message-Id: <20200126220508.43.Id6c2992321a188f3fa0eacc84bbd5568b6e750fe@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 In some cases an internal error may prevent this from working. Update the function return value and report the error. At present the API for writing tables does not easily support reporting errors, but once it is fully updated to use a context pointer, this will be easier. Signed-off-by: Simon Glass --- arch/x86/cpu/baytrail/acpi.c | 4 +++- arch/x86/cpu/quark/acpi.c | 4 +++- arch/x86/cpu/tangier/acpi.c | 4 +++- arch/x86/include/asm/acpi_table.h | 10 +++++++++- arch/x86/lib/acpi_table.c | 10 ++++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c index 856af95556..38cf832817 100644 --- a/arch/x86/cpu/baytrail/acpi.c +++ b/arch/x86/cpu/baytrail/acpi.c @@ -138,7 +138,7 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum = table_compute_checksum(fadt, header->length); } -void acpi_create_gnvs(struct acpi_global_nvs *gnvs) +int acpi_create_gnvs(struct acpi_global_nvs *gnvs) { struct udevice *dev; int ret; @@ -158,6 +158,8 @@ void acpi_create_gnvs(struct acpi_global_nvs *gnvs) gnvs->iuart_en = 1; else gnvs->iuart_en = 0; + + return 0; } #ifdef CONFIG_HAVE_ACPI_RESUME diff --git a/arch/x86/cpu/quark/acpi.c b/arch/x86/cpu/quark/acpi.c index dd562a6e2f..fcc93a7c59 100644 --- a/arch/x86/cpu/quark/acpi.c +++ b/arch/x86/cpu/quark/acpi.c @@ -133,8 +133,10 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, header->checksum = table_compute_checksum(fadt, header->length); } -void acpi_create_gnvs(struct acpi_global_nvs *gnvs) +int acpi_create_gnvs(struct acpi_global_nvs *gnvs) { /* quark is a uni-processor */ gnvs->pcnt = 1; + + return 0; } diff --git a/arch/x86/cpu/tangier/acpi.c b/arch/x86/cpu/tangier/acpi.c index 768c4dcbc8..760e3eda84 100644 --- a/arch/x86/cpu/tangier/acpi.c +++ b/arch/x86/cpu/tangier/acpi.c @@ -107,7 +107,7 @@ u32 acpi_fill_csrt(u32 current) return current; } -void acpi_create_gnvs(struct acpi_global_nvs *gnvs) +int acpi_create_gnvs(struct acpi_global_nvs *gnvs) { struct udevice *dev; int ret; @@ -122,4 +122,6 @@ void acpi_create_gnvs(struct acpi_global_nvs *gnvs) if (ret > 0) gnvs->pcnt = ret; } + + return 0; } diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 22d54057f1..7b5217893f 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -26,7 +26,15 @@ int acpi_create_mcfg_mmconfig(struct acpi_mcfg_mmconfig *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end); u32 acpi_fill_mcfg(u32 current); u32 acpi_fill_csrt(u32 current); -void acpi_create_gnvs(struct acpi_global_nvs *gnvs); + +/** + * acpi_create_gnvs() - Create a GNVS (Global Non Volatile Storage) table + * + * @gnvs: Table to fill in + * @return 0 if OK, -ve on error + */ +int acpi_create_gnvs(struct acpi_global_nvs *gnvs); + ulong write_acpi_tables(ulong start); /** diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 5e14149923..68e0779357 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -453,8 +453,14 @@ ulong write_acpi_tables(ulong start_addr) dsdt->checksum = 0; dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length); - /* Fill in platform-specific global NVS variables */ - acpi_create_gnvs(ctx->current); + /* + * Fill in platform-specific global NVS variables. If this fails we + * cannot return the error but this should only happen while debugging. + */ + addr = acpi_create_gnvs(ctx->current); + if (IS_ERR_VALUE(addr)) + printf("Error: Gailed to create GNVS\n"); + acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); debug("ACPI: * FADT\n"); From patchwork Mon Jan 27 05:05:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229543 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=N2FAy7eC; 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 485dJp51KTz9sR1 for ; Mon, 27 Jan 2020 16:16:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E079781874; Mon, 27 Jan 2020 06:11:45 +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="N2FAy7eC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2381481835; Mon, 27 Jan 2020 06:09:33 +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-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (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 7B805817EB for ; Mon, 27 Jan 2020 06:09:00 +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-xd2e.google.com with SMTP id e7so8539577iof.11 for ; Sun, 26 Jan 2020 21:09:00 -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=UAQ6tbl8+BOetB9sHhwJDm65MW23Hskc3eZKXtrVglo=; b=N2FAy7eCQzLlLJHT04aFwsVzmjr17Zzw1Mo4aKz4Fd2R30vVhCWjAmFDNKyxPvYmmr ednNqk2MPLleWEp+OlxBic7UE7xNgPHQpHvwcWT3ao8rgqNi5KrWMRQQJ+fJGLZ4HCpU kNqUyDka0rhhdnd+6dRF+ER1XbWuY+eyT/1iA= 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=UAQ6tbl8+BOetB9sHhwJDm65MW23Hskc3eZKXtrVglo=; b=Ec/6nQMvNCmMNAlHJYh0p5sDLM0mi+ivIkhFv69mUMNdrTYDpxw7spmXNK2oCH/kx7 Rr85OiSkfTm720Vah8qRJel9mxDuA0RY1EReFmFan6B9zEVWpHsgyu6q3Znc8wlm8Cl1 sJzAuLs4UURJHPkwGNsXo1CWB/FTk3X2/OS8cc5hDOzh3J7mVDVZHrJKvIjdNf5jgTAr IdEZg07+rLCjby20FvPSZ1kegadgs+cXgpofppKAahCqpGxv3jMTEvECe5Er8wzIjXLR t1S5+3WL2BsO+ImMX5pNTsxfnyjFCh5wpgfwDQnG8j9G+7sfLXb0WDyetcGtl045Ekz8 C1ug== X-Gm-Message-State: APjAAAUmz6Wg48LYTSzsIQgW01fErvllUSP1u8al4STOYlBvAOeekyIs TMvVwQZ3ZLdGJKmWVf9+6n/jKchgiXn/XA== X-Google-Smtp-Source: APXvYqwsCmkynZhdsfZEuzj8LxMAcdeUseuO3Th7VIoY1EhAA4UBqbmYqHuhIHppFBgu1XsP2OXfww== X-Received: by 2002:a6b:7215:: with SMTP id n21mr11531578ioc.131.1580101739019; Sun, 26 Jan 2020 21:08:59 -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.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:58 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 044/108] dtoc: Support ACPI paths in of-platdata Date: Sun, 26 Jan 2020 22:05:51 -0700 Message-Id: <20200126220508.44.I59ad0c1b7fc217bc1d2e798324e2dec7db02a3aa@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 The start of an ACPI path typically has backslashes in it. These are not preserved during the translation from device tree to C code, since dtc (correctly) uses the first backslash as an escape character, and dtoc therefore leaves it out of the C string. Fix this with special-case handling. Signed-off-by: Simon Glass --- tools/dtoc/dtb_platdata.py | 4 +++- tools/dtoc/dtoc_test_simple.dts | 1 + tools/dtoc/test_dtoc.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 037e82c8bb..7bd9a5474e 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -102,7 +102,9 @@ def get_value(ftype, value): elif ftype == fdt.TYPE_BYTE: return '%#x' % tools.ToByte(value[0]) elif ftype == fdt.TYPE_STRING: - return '"%s"' % value + # Handle evil ACPI backslashes by adding another backslash before them. + # So "\\_SB.GPO0" in the device tree effectively stays like that in C + return '"%s"' % value.replace('\\', '\\\\') elif ftype == fdt.TYPE_BOOL: return 'true' elif ftype == fdt.TYPE_INT64: diff --git a/tools/dtoc/dtoc_test_simple.dts b/tools/dtoc/dtoc_test_simple.dts index 165680bd4b..11bfc4c47a 100644 --- a/tools/dtoc/dtoc_test_simple.dts +++ b/tools/dtoc/dtoc_test_simple.dts @@ -34,6 +34,7 @@ longbytearray = [09 0a 0b 0c]; stringval = "message2"; stringarray = "another", "multi-word", "message"; + acpi-name = "\\_SB.GPO0"; }; spl-test3 { diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index d733b70655..6246ce45f5 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -70,6 +70,7 @@ class TestDtoc(unittest.TestCase): @classmethod def setUpClass(cls): tools.PrepareOutputDir(None) + cls.maxDiff = None @classmethod def tearDownClass(cls): @@ -181,6 +182,7 @@ struct dtd_sandbox_pmic_test { \tfdt64_t\t\treg[2]; }; struct dtd_sandbox_spl_test { +\tconst char * acpi_name; \tbool\t\tboolval; \tunsigned char\tbytearray[3]; \tunsigned char\tbyteval; @@ -218,6 +220,7 @@ U_BOOT_DEVICE(spl_test) = { }; static const struct dtd_sandbox_spl_test dtv_spl_test2 = { +\t.acpi_name\t\t= "\\\\_SB.GPO0", \t.bytearray\t\t= {0x1, 0x23, 0x34}, \t.byteval\t\t= 0x8, \t.intarray\t\t= {0x5, 0x0, 0x0, 0x0}, From patchwork Mon Jan 27 05:05:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229542 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=alUDnGw8; 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 485dJd5KXSz9sR1 for ; Mon, 27 Jan 2020 16:16:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 84CF681870; Mon, 27 Jan 2020 06:11: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="alUDnGw8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0729817BF; Mon, 27 Jan 2020 06:09:31 +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-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (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 305CD817F2 for ; Mon, 27 Jan 2020 06:09:01 +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-x12d.google.com with SMTP id p8so6411438iln.12 for ; Sun, 26 Jan 2020 21:09:01 -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=/PKXu1jLFaiN63kze2Kt9WV1QUHQR79KOxBbGOrix0M=; b=alUDnGw89+fECiiGyNZ6TJfcUPx9Q+gvh2i+9oXmRfdijUBpr0UN7+UDGJCD0uhxvC hhlseJ26ciPfKbCazMJuEQ00dFl/eIXIa7dCJYbvsmybyVEnWBqVsmRONO8WkSU4O4Cp bEbVsZH02Ye/nCMbxJ47tCUAA72+8CJl876/g= 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=/PKXu1jLFaiN63kze2Kt9WV1QUHQR79KOxBbGOrix0M=; b=n5C3oxv9g1+fqd+mMCrZW7BdvcMJxY7KzmUw+oF9gbbXJS6t2+NUZQ3OBMdLY45WAi cFUgbgoNH0Ka5OmPN0qEOsXaCoa8Hz78qLcW3pd74mp/3KmBIfYN+OP2m1j1ogl8vhR7 5ThpASsQAeV9B1I7FNbmO6ip6BhxDIwsrmCd9khNrGS1+eQ+Oywnxh4rwDEV8qqaC5Vw kHZ7VegweViD0Y/Bp1zXtnSTjM5vFttsV8b4V1i2c8UpvFyK3RYMZQlM6ZjpO+lWkmzy yBOHi1QeLVtZE9ssycS9YsyIosnDNOMmA3CN2wQ/Dtj6JCHQLr4OIcVTgrwHcB0FofdZ P2rQ== X-Gm-Message-State: APjAAAX59D+/XA3I3ETSi+ULvL+A2pe2XLze6mLmZ0obaiTHhs8FDn/d JPcmlLotZ9Kx+xKgU1ZeLL03Ualu7kdzvQ== X-Google-Smtp-Source: APXvYqzfpnMirMUG3RVdYJlzXzdGzNcR3Hy3KVbBhzpk/Gr4PnyHypaxpcY56UF0SkKf28KHeqJZiQ== X-Received: by 2002:a92:290a:: with SMTP id l10mr13555349ilg.151.1580101739858; Sun, 26 Jan 2020 21:08:59 -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.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:08:59 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 045/108] acpi: mmc: Generate ACPI info for the PCI SD Card Date: Sun, 26 Jan 2020 22:05:52 -0700 Message-Id: <20200126220508.45.I9313ecf187a225877256809220ada492a47f4340@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 Write required information into the SSDT to describe the SD card card-detect pin. Since the required GPIO properties are not present in the device-tree binding, set them manually for now. Signed-off-by: Simon Glass --- configs/sandbox_defconfig | 2 ++ drivers/mmc/pci_mmc.c | 76 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 858ad04b10..83a42cfddf 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -137,7 +137,9 @@ CONFIG_P2SB=y CONFIG_PWRSEQ=y CONFIG_SPL_PWRSEQ=y CONFIG_I2C_EEPROM=y +CONFIG_MMC_PCI=y CONFIG_MMC_SANDBOX=y +CONFIG_MMC_SDHCI=y CONFIG_MTD=y CONFIG_SPI_FLASH_SANDBOX=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index 404264a697..b4705e45a1 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -5,12 +5,15 @@ */ #include +#include +#include #include #include #include #include #include -#include +#include +#include struct pci_mmc_plat { struct mmc_config cfg; @@ -20,6 +23,7 @@ struct pci_mmc_plat { struct pci_mmc_priv { struct sdhci_host host; void *base; + struct gpio_desc cd_gpio; }; static int pci_mmc_probe(struct udevice *dev) @@ -44,6 +48,15 @@ static int pci_mmc_probe(struct udevice *dev) return sdhci_probe(dev); } +static int pci_mmc_ofdata_to_platdata(struct udevice *dev) +{ + struct pci_mmc_priv *priv = dev_get_priv(dev); + + gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN); + + return 0; +} + static int pci_mmc_bind(struct udevice *dev) { struct pci_mmc_plat *plat = dev_get_platdata(dev); @@ -51,14 +64,75 @@ static int pci_mmc_bind(struct udevice *dev) return sdhci_bind(dev, &plat->mmc, &plat->cfg); } +static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct pci_mmc_priv *priv = dev_get_priv(dev); + char path[ACPI_PATH_MAX]; + struct acpi_gpio gpio; + struct acpi_dp *dp; + int ret; + + if (!dev_of_valid(dev)) + return 0; + + ret = gpio_get_acpi(&priv->cd_gpio, &gpio); + if (ret) + return log_msg_ret("gpio", ret); + gpio.type = ACPI_GPIO_TYPE_INTERRUPT; + gpio.pull = ACPI_GPIO_PULL_NONE; + gpio.irq.mode = ACPI_IRQ_EDGE_TRIGGERED; + gpio.irq.polarity = ACPI_IRQ_ACTIVE_BOTH; + gpio.irq.shared = ACPI_IRQ_SHARED; + gpio.irq.wake = ACPI_IRQ_WAKE; + gpio.interrupt_debounce_timeout = 10000; /* 100ms */ + + /* Use device path as the Scope for the SSDT */ + ret = acpi_device_path(dev, path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + acpigen_write_scope(ctx, path); + acpigen_write_name(ctx, "_CRS"); + + /* Write GpioInt() as default (if set) or custom from devicetree */ + acpigen_write_resourcetemplate_header(ctx); + acpi_device_write_gpio(ctx, &gpio); + acpigen_write_resourcetemplate_footer(ctx); + + /* Bind the cd-gpio name to the GpioInt() resource */ + dp = acpi_dp_new_table("_DSD"); + if (!dp) + return -ENOMEM; + acpi_dp_add_gpio(dp, "cd-gpio", path, 0, 0, 1); + ret = acpi_dp_write(ctx, dp); + if (ret) + return log_msg_ret("cd", ret); + + acpigen_pop_len(ctx); + + return 0; +} + +struct acpi_ops pci_mmc_acpi_ops = { + .fill_ssdt = pci_mmc_acpi_fill_ssdt, +}; + +static const struct udevice_id pci_mmc_match[] = { + { .compatible = "intel,apl-sd" }, + { } +}; + U_BOOT_DRIVER(pci_mmc) = { .name = "pci_mmc", .id = UCLASS_MMC, + .of_match = pci_mmc_match, .bind = pci_mmc_bind, + .ofdata_to_platdata = pci_mmc_ofdata_to_platdata, .probe = pci_mmc_probe, .ops = &sdhci_ops, .priv_auto_alloc_size = sizeof(struct pci_mmc_priv), .platdata_auto_alloc_size = sizeof(struct pci_mmc_plat), + acpi_ops_ptr(&pci_mmc_acpi_ops) }; static struct pci_device_id mmc_supported[] = { From patchwork Mon Jan 27 05:05:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229544 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GumajfqG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dJz6zWwz9sR1 for ; Mon, 27 Jan 2020 16:16:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2D088187E; Mon, 27 Jan 2020 06:11:48 +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="GumajfqG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F2887817DD; Mon, 27 Jan 2020 06:09:33 +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-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (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 B1E4C817DC for ; Mon, 27 Jan 2020 06:09:07 +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-xd30.google.com with SMTP id e7so8539643iof.11 for ; Sun, 26 Jan 2020 21:09:07 -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=96fM+J5XK1fzOBzlbtL2k3u0/19k/p6jTMCaDK0DCcc=; b=GumajfqGzOpud8/SJFKGZD+ifd7qS1LUV2+Z1a/ljtxoCx5T4w7t+IZzJDGivKNrS8 kAkyTAZwxFWqsGiJ0v3pELNN2LKLVrhNlDmbEYYb8vVxaGBDLNGzxrENuy8VhrlWOXOC bbW3knY639JIPaLU4yuAWeb1LOfsBZK2W+0Qc= 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=96fM+J5XK1fzOBzlbtL2k3u0/19k/p6jTMCaDK0DCcc=; b=q47iH4dwid63qlaIHVwIROpu8B2BDd/fMaNjIBMb68lkF9YEaeQ2BN9Y2P3UUbw7TT BFnUaA2i9+RR7vPgH6/mlrWW8vousQzfdya7geMiEyWv/svy7olCdofWFc8TfW9Hyg8Q 64RMLVs8apCLrCABpBNQg8jqTGDfNHoeAGqCW4/UWKZYy2SsIVofr89VRAMYFue/wprZ OF76bX9hTU8+DqtQVX6oG0C2jc9iWes/v8vwsc68jIOgH8Z8fqLnTCsFzodmjomikoiM IrKp8Kw5xmZAeGR0GIQRzzoFgEj56vHyvCwDXYBBAIGx+GgkH0IRTWjKoh7BnknVFwVf xymw== X-Gm-Message-State: APjAAAUAf1ro4kxcuvOXy3+pQnR7IhKWr+zexETWewM34p58xtkW4ZE+ cXGQLBm5p8EuQhPRd9jIVjVE9OB0sEvFIg== X-Google-Smtp-Source: APXvYqw9dndYmYQHx9d6dK96kNCT5+tPaRjZJsNJpLqcv3/k/wi3C+xwY1pNLox0o95UuZ77wW4oDQ== X-Received: by 2002:a02:3508:: with SMTP id k8mr7349318jaa.114.1580101740662; Sun, 26 Jan 2020 21:09:00 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:00 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 046/108] sound: Add an ACPI driver for Dialog Semicondutor da7219 Date: Sun, 26 Jan 2020 22:05:53 -0700 Message-Id: <20200126220508.46.Ia2e108d28eecf6576fd92294b9871cd94143a01f@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 This chip is used on coral and we need to generate ACPI tables for sound to make it work. Add a driver that does just this (i.e. at present does not actually support playing sound). Signed-off-by: Simon Glass --- configs/sandbox_defconfig | 1 + doc/device-tree-bindings/sound/da7219.txt | 113 +++++++++++++++++++++ drivers/sound/Kconfig | 9 ++ drivers/sound/Makefile | 1 + drivers/sound/da7219.c | 115 ++++++++++++++++++++++ 5 files changed, 239 insertions(+) create mode 100644 doc/device-tree-bindings/sound/da7219.txt create mode 100644 drivers/sound/da7219.c diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 83a42cfddf..cf1037f9a3 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -196,6 +196,7 @@ CONFIG_SANDBOX_SERIAL=y CONFIG_SMEM=y CONFIG_SANDBOX_SMEM=y CONFIG_SOUND=y +CONFIG_SOUND_DA7219=y CONFIG_SOUND_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SPMI=y diff --git a/doc/device-tree-bindings/sound/da7219.txt b/doc/device-tree-bindings/sound/da7219.txt new file mode 100644 index 0000000000..5fd8a9f1e7 --- /dev/null +++ b/doc/device-tree-bindings/sound/da7219.txt @@ -0,0 +1,113 @@ +Dialog Semiconductor DA7219 Audio Codec bindings + +DA7219 is an audio codec with advanced accessory detect features. + +====== + +Required properties: +- compatible : Should be "dlg,da7219" +- reg: Specifies the I2C slave address + +- interrupts : IRQ line info for DA7219. + (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for + further information relating to interrupt properties) + +- VDD-supply: VDD power supply for the device +- VDDMIC-supply: VDDMIC power supply for the device +- VDDIO-supply: VDDIO power supply for the device + (See Documentation/devicetree/bindings/regulator/regulator.txt for further + information relating to regulators) + +Optional properties: +- interrupt-names : Name associated with interrupt line. Should be "wakeup" if + interrupt is to be used to wake system, otherwise "irq" should be used. +- wakeup-source: Flag to indicate this device can wake system (suspend/resume). + +- #clock-cells : Should be set to '<0>', only one clock source provided; +- clock-output-names : Name given for DAI clocks output; + +- clocks : phandle and clock specifier for codec MCLK. +- clock-names : Clock name string for 'clocks' attribute, should be "mclk". + +- dlg,micbias-lvl : Voltage (mV) for Mic Bias + [<1600>, <1800>, <2000>, <2200>, <2400>, <2600>] +- dlg,mic-amp-in-sel : Mic input source type + ["diff", "se_p", "se_n"] +- dlg,mclk-name : String name of MCLK for ACPI + +Deprecated properties: +- dlg,ldo-lvl : Required internal LDO voltage (mV) level for digital engine + (LDO unavailable in production HW so property no longer required). + +====== + +Child node - 'da7219_aad': + +Optional properties: +- dlg,micbias-pulse-lvl : Mic bias higher voltage pulse level (mV). + [<2800>, <2900>] +- dlg,micbias-pulse-time : Mic bias higher voltage pulse duration (ms) +- dlg,btn-cfg : Periodic button press measurements for 4-pole jack (ms) + [<2>, <5>, <10>, <50>, <100>, <200>, <500>] +- dlg,mic-det-thr : Impedance threshold for mic detection measurement (Ohms) + [<200>, <500>, <750>, <1000>] +- dlg,jack-ins-deb : Debounce time for jack insertion (ms) + [<5>, <10>, <20>, <50>, <100>, <200>, <500>, <1000>] +- dlg,jack-det-rate: Jack type detection latency (3/4 pole) + ["32ms_64ms", "64ms_128ms", "128ms_256ms", "256ms_512ms"] +- dlg,jack-rem-deb : Debounce time for jack removal (ms) + [<1>, <5>, <10>, <20>] +- dlg,a-d-btn-thr : Impedance threshold between buttons A and D + [0x0 - 0xFF] +- dlg,d-b-btn-thr : Impedance threshold between buttons D and B + [0x0 - 0xFF] +- dlg,b-c-btn-thr : Impedance threshold between buttons B and C + [0x0 - 0xFF] +- dlg,c-mic-btn-thr : Impedance threshold between button C and Mic + [0x0 - 0xFF] +- dlg,btn-avg : Number of 8-bit readings for averaged button measurement + [<1>, <2>, <4>, <8>] +- dlg,adc-1bit-rpt : Repeat count for 1-bit button measurement + [<1>, <2>, <4>, <8>] + +====== + +Example: + + codec: da7219@1a { + compatible = "dlg,da7219"; + reg = <0x1a>; + + interrupt-parent = <&gpio6>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + + VDD-supply = <®_audio>; + VDDMIC-supply = <®_audio>; + VDDIO-supply = <®_audio>; + + #clock-cells = <0>; + clock-output-names = "dai-clks"; + + clocks = <&clks 201>; + clock-names = "mclk"; + + dlg,ldo-lvl = <1200>; + dlg,micbias-lvl = <2600>; + dlg,mic-amp-in-sel = "diff"; + + da7219_aad { + dlg,btn-cfg = <50>; + dlg,mic-det-thr = <500>; + dlg,jack-ins-deb = <20>; + dlg,jack-det-rate = "32ms_64ms"; + dlg,jack-rem-deb = <1>; + + dlg,a-d-btn-thr = <0xa>; + dlg,d-b-btn-thr = <0x16>; + dlg,b-c-btn-thr = <0x21>; + dlg,c-mic-btn-thr = <0x3E>; + + dlg,btn-avg = <4>; + dlg,adc-1bit-rpt = <1>; + }; + }; diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig index 4ebc719be2..7f214b97be 100644 --- a/drivers/sound/Kconfig +++ b/drivers/sound/Kconfig @@ -40,6 +40,15 @@ config I2S_SAMSUNG option provides an implementation for sound_init() and sound_play(). +config SOUND_DA7219 + bool "Dialog Semiconductor audio codec" + depends on SOUND + help + The DA7219 is an ultra-low-power audio codec with Advanced Accessory + Detection (AAD). This driver only supports generation of ACPI tables. + It does not support sound output or any of the other codec + features. + config SOUND_I8254 bool "Intel i8254 timer / beeper" depends on SOUND diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 73ed7fe53c..8c3933ad15 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_SOUND) += codec-uclass.o obj-$(CONFIG_SOUND) += i2s-uclass.o obj-$(CONFIG_SOUND) += sound-uclass.o +obj-$(CONFIG_SOUND_DA7219) += da7219.o obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o obj-$(CONFIG_I2S_ROCKCHIP) += rockchip_i2s.o rockchip_sound.o diff --git a/drivers/sound/da7219.c b/drivers/sound/da7219.c new file mode 100644 index 0000000000..5dc822fc59 --- /dev/null +++ b/drivers/sound/da7219.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * ACPI driver for DA7219 codec + * + * Copyright 2019 Google LLC + * Parts taken from coreboot + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DA7219_ACPI_HID "DLGS7219" + +static int da7219_acpi_fill_ssdt(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + char scope[ACPI_PATH_MAX]; + char name[ACPI_NAME_MAX]; + struct acpi_dp *dsd, *aad; + ofnode node; + u32 val; + int ret; + + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + /* Device */ + acpigen_write_scope(ctx, scope); + acpigen_write_device(ctx, name); + acpigen_write_name_string(ctx, "_HID", DA7219_ACPI_HID); + acpigen_write_name_integer(ctx, "_UID", 1); + acpigen_write_name_string(ctx, "_DDN", + dev_read_string(dev, "acpi,desc")); + acpigen_write_name_integer(ctx, "_S0W", 4); + acpigen_write_sta(ctx, acpi_device_status(dev)); + + /* Resources */ + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + ret = acpi_device_write_i2c_dev(ctx, dev); + if (ret) + return log_msg_ret("i2c", ret); + + /* Use either Interrupt() or GpioInt() */ + ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev, + "req-gpios"); + if (ret) + return log_msg_ret("irq_gpio", ret); + acpigen_write_resourcetemplate_footer(ctx); + + /* AAD Child Device Properties */ + aad = acpi_dp_new_table("DAAD"); + if (!aad) + return log_msg_ret("aad", -ENOMEM); + + node = ofnode_find_subnode(dev_ofnode(dev), "da7219_aad"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,btn-cfg"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,mic-det-thr"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,jack-ins-deb"); + acpi_dp_ofnode_copy_str(node, aad, "dlg,jack-det-rate"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,jack-rem-deb"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,a-d-btn-thr"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,d-b-btn-thr"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,b-c-btn-thr"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,c-mic-btn-thr"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,btn-avg"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,adc-1bit-rpt"); + if (!ofnode_read_u32(node, "dlg,micbias-pulse-lvl", &val)) { + acpi_dp_ofnode_copy_int(node, aad, "dlg,micbias-pulse-lvl"); + acpi_dp_ofnode_copy_int(node, aad, "dlg,micbias-pulse-time"); + } + + /* DA7219 Properties */ + dsd = acpi_dp_new_table("_DSD"); + if (!dsd) + return log_msg_ret("dsd", -ENOMEM); + acpi_dp_dev_copy_int(dev, dsd, "dlg,micbias-lvl"); + acpi_dp_dev_copy_str(dev, dsd, "dlg,mic-amp-in-sel"); + acpi_dp_dev_copy_str(dev, dsd, "dlg,mclk-name"); + acpi_dp_add_child(dsd, "da7219_aad", aad); + + /* Write Device Property Hierarchy */ + acpi_dp_write(ctx, dsd); + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + +struct acpi_ops da7219_acpi_ops = { + .fill_ssdt = da7219_acpi_fill_ssdt, +}; + +static const struct udevice_id da7219_ids[] = { + { .compatible = "dlg,da7219" }, + { } +}; + +U_BOOT_DRIVER(da7219) = { + .name = "da7219", + .id = UCLASS_MISC, + .of_match = da7219_ids, + acpi_ops_ptr(&da7219_acpi_ops) +}; From patchwork Mon Jan 27 05:05:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229545 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=Ttoo0StP; 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 485dK85ZgDz9sR1 for ; Mon, 27 Jan 2020 16:17:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE07A81887; Mon, 27 Jan 2020 06:11:50 +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="Ttoo0StP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8AFE81835; Mon, 27 Jan 2020 06:09:34 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 31E73817EE for ; Mon, 27 Jan 2020 06:09:08 +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-xd42.google.com with SMTP id n11so8552915iom.9 for ; Sun, 26 Jan 2020 21:09:08 -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=A46TS1mBl6gJLxORlMzez7+slLsCjbWlu74yMnIcApE=; b=Ttoo0StPdIcJRXiFZrcIl8BoVq8XsqcJjPsc2TC5p7laS95NQIqR6iMdTlQXRmwJY9 IOShwnJSRn0ggq0ccgeoUBdadnSLvRuGDt4ZjByJxvZw8Pe37mGLHQxXzlue6uW0xmNj uS8sif7d9l1nic0zmwLJeNSOw5zeGDtAPLhtg= 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=A46TS1mBl6gJLxORlMzez7+slLsCjbWlu74yMnIcApE=; b=JagqzkzydSQ9ajPB44Tih/VIoPg5Z6uHKMEkQDD+MHtNzh2VhIUoR+kiUUvrReTZmo trrXECqaZgGmX5Nz1Bg5pWUsn0aOUZ0XTAHj9Fpc02paLywTgNDAO2BOBADrw3b5iGYc T+5eoxaqnNTjxnDfDWxEjujkpg7U4eHZh/4Udtj9BLHQSxU+OG1sHP7JoaPKknRkA3+b sgyA+2xTnUDjWthDK0zeABO1c6xA+TPqfq7WVziHBXpWIvNgMTSo2AphNTGJIJVv1GA8 N1drY8xvMVCnFdE4RAthL17UDsu+kMi5xenqR46jmGQv2YVTWUPf1FrLyAoEMr6rquNf wVHA== X-Gm-Message-State: APjAAAUt5B9NAq0dawmH6HbqMJ1bZbHX2ZPideWqeyWJGaWF2leC+zZE 1ZqZbbuYwmLf0MgAg7kZFAbY4QYTaE9GhQ== X-Google-Smtp-Source: APXvYqwXwXGOTBpOClT8Spw+1r0pgTl9QVjNVtAiu24HjI+ycwnJlOQeJHxAPT5K6O7uiRpvoEPsQA== X-Received: by 2002:a5e:d616:: with SMTP id w22mr10776765iom.57.1580101741415; Sun, 26 Jan 2020 21:09:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 047/108] sound: Add an ACPI driver for Maxim MAX98357ac Date: Sun, 26 Jan 2020 22:05:54 -0700 Message-Id: <20200126220508.47.Ia2e108d28eecf6576fd92294b9871cd94143a01f@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 This chip is used on coral and we need to generate ACPI tables for sound to make it work. Add a driver that does just this (i.e. at present does not actually support playing sound). Signed-off-by: Simon Glass --- configs/sandbox_defconfig | 1 + doc/device-tree-bindings/sound/max98357a.txt | 22 ++++ drivers/sound/Kconfig | 9 ++ drivers/sound/Makefile | 1 + drivers/sound/max98357a.c | 109 +++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 doc/device-tree-bindings/sound/max98357a.txt create mode 100644 drivers/sound/max98357a.c diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index cf1037f9a3..cbd9eea77a 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -197,6 +197,7 @@ CONFIG_SMEM=y CONFIG_SANDBOX_SMEM=y CONFIG_SOUND=y CONFIG_SOUND_DA7219=y +CONFIG_SOUND_MAX98357A=y CONFIG_SOUND_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SPMI=y diff --git a/doc/device-tree-bindings/sound/max98357a.txt b/doc/device-tree-bindings/sound/max98357a.txt new file mode 100644 index 0000000000..4bce14ce80 --- /dev/null +++ b/doc/device-tree-bindings/sound/max98357a.txt @@ -0,0 +1,22 @@ +Maxim MAX98357A audio DAC + +This node models the Maxim MAX98357A DAC. + +Required properties: +- compatible : "maxim,max98357a" + +Optional properties: +- sdmode-gpios : GPIO specifier for the chip's SD_MODE pin. + If this option is not specified then driver does not manage + the pin state (e.g. chip is always on). +- sdmode-delay : specify delay time for SD_MODE pin. + If this option is specified, which means it's required i2s clocks + ready before SD_MODE is unmuted in order to avoid the speaker pop noise. + It's observed that 5ms is sufficient. + +Example: + +max98357a { + compatible = "maxim,max98357a"; + sdmode-gpios = <&qcom_pinmux 25 0>; +}; diff --git a/drivers/sound/Kconfig b/drivers/sound/Kconfig index 7f214b97be..0948d8caab 100644 --- a/drivers/sound/Kconfig +++ b/drivers/sound/Kconfig @@ -113,6 +113,15 @@ config SOUND_MAX98095 audio data and I2C for codec control. At present it only works with the Samsung I2S driver. +config SOUND_MAX98357A + bool "Support Maxim max98357a audio codec" + depends on PCI + help + Enable the max98357a audio codec. This is connected on PCI for + audio data codec control. This is currently only capable of providing + ACPI information. A full driver (with sound in U-Boot) is currently + not available. + config SOUND_RT5677 bool "Support Realtek RT5677 audio codec" depends on SOUND diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile index 8c3933ad15..9b40c8012f 100644 --- a/drivers/sound/Makefile +++ b/drivers/sound/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_SOUND_WM8994) += wm8994.o obj-$(CONFIG_SOUND_MAX98088) += max98088.o maxim_codec.o obj-$(CONFIG_SOUND_MAX98090) += max98090.o maxim_codec.o obj-$(CONFIG_SOUND_MAX98095) += max98095.o maxim_codec.o +obj-$(CONFIG_SOUND_MAX98357A) += max98357a.o obj-$(CONFIG_SOUND_INTEL_HDA) += hda_codec.o obj-$(CONFIG_SOUND_I8254) += i8254_beep.o obj-$(CONFIG_SOUND_RT5677) += rt5677.o diff --git a/drivers/sound/max98357a.c b/drivers/sound/max98357a.c new file mode 100644 index 0000000000..63c336c27b --- /dev/null +++ b/drivers/sound/max98357a.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * max98357a.c -- MAX98357A Audio driver + * + * Copyright 2019 Google LLC + * Parts taken from coreboot + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct max97357a_priv { + struct gpio_desc sdmode_gpio; +}; + +static int max97357a_ofdata_to_platdata(struct udevice *dev) +{ + struct max97357a_priv *priv = dev_get_priv(dev); + + gpio_request_by_name(dev, "sdmode-gpios", 0, &priv->sdmode_gpio, + GPIOD_IS_IN); + + return 0; +} + +static int max97357a_acpi_fill_ssdt(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct max97357a_priv *priv = dev_get_priv(dev); + char scope[ACPI_PATH_MAX]; + char name[ACPI_NAME_MAX]; + char path[ACPI_PATH_MAX]; + struct acpi_dp *dp; + int ret; + + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + /* Device */ + acpigen_write_scope(ctx, scope); + acpigen_write_device(ctx, name); + acpigen_write_name_string(ctx, "_HID", + dev_read_string(dev, "acpi,hid")); + acpigen_write_name_integer(ctx, "_UID", 0); + acpigen_write_name_string(ctx, "_DDN", + dev_read_string(dev, "acpi,desc")); + acpigen_write_sta(ctx, acpi_device_status(dev)); + + ret = acpi_device_write_gpio_desc(ctx, &priv->sdmode_gpio); + if (ret) + return log_msg_ret("gpio", ret); + + /* Resources */ + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + ret = acpi_device_write_gpio_desc(ctx, &priv->sdmode_gpio); + if (ret) + return log_msg_ret("gpio", ret); + acpigen_write_resourcetemplate_footer(ctx); + + /* _DSD for devicetree properties */ + /* This points to the first pin in the first gpio entry in _CRS */ + ret = acpi_device_path(dev, path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + dp = acpi_dp_new_table("_DSD"); + acpi_dp_add_gpio(dp, "sdmode-gpio", path, 0, 0, + priv->sdmode_gpio.flags & GPIOD_ACTIVE_LOW ? + ACPI_GPIO_ACTIVE_LOW : ACPI_GPIO_ACTIVE_HIGH); + acpi_dp_add_integer(dp, "sdmode-delay", + dev_read_u32_default(dev, "sdmode-delay", 0)); + acpi_dp_write(ctx, dp); + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + +struct acpi_ops max97357a_acpi_ops = { + .fill_ssdt = max97357a_acpi_fill_ssdt, +}; + +static const struct audio_codec_ops max98357a_ops = { +}; + +static const struct udevice_id max98357a_ids[] = { + { .compatible = "maxim,max98357a" }, + { } +}; + +U_BOOT_DRIVER(max98357a) = { + .name = "max98357a", + .id = UCLASS_AUDIO_CODEC, + .of_match = max98357a_ids, + .ofdata_to_platdata = max97357a_ofdata_to_platdata, + .ops = &max98357a_ops, + acpi_ops_ptr(&max97357a_acpi_ops) +}; From patchwork Mon Jan 27 05:05:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229548 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=WoQlaYzN; 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 485dKk0X72z9sR1 for ; Mon, 27 Jan 2020 16:17:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F2BA1817C4; Mon, 27 Jan 2020 06:11:57 +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="WoQlaYzN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E535817E6; Mon, 27 Jan 2020 06:09:37 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 54167817FB for ; Mon, 27 Jan 2020 06:09:08 +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-x144.google.com with SMTP id t17so6410359ilm.13 for ; Sun, 26 Jan 2020 21:09:08 -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=NvWb9rKnpbe3DkTk1pSiJXpED8UHZxX8peAahyZUsno=; b=WoQlaYzNid7wX17cZnjFSx9ExYjfBnmN1KKQl7xZseAWflwHDjV39cj2TA6HdJrz18 PN6P/wixq3SYBigxhT88Jjr42YqXn0l/4/U6OgY2MtYLmmBkZtOZWTh6D8HL9v3yTXak cFgRbwXFFbisuHBcbRhw3ntSBBBzEoBRxq7Bo= 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=NvWb9rKnpbe3DkTk1pSiJXpED8UHZxX8peAahyZUsno=; b=d+zeH2nAXMRCf9BDF6qwl+wNASnuQalYY9o7xoMntbalbdqiDKEPalYhcqJzpu5Xrb e842RmFbNpaANjt+goQ8a973k6u2KnZu5N0RMBp8qEkmZhaeaZqcdy8Wuwv90ewyin4c qlTLTgQRqtKZylcE8FpaivbtsVpELa9q3ODBPJGjE6Fq8VDmSL41uk+sM7T5ub3uUqXt 6Wnum/8uxRaj3RoC42IKSlY0GVgNJwOO8op9opiGdNxsOlpqMB9+3bkoeF/KstqzvKLU 9FhWzTQo8lTbjqfAgosQwjwz38hq1t9pDtv4dma3i9MOLMQuT7FaxutHz53VyvggsAxU p3Vw== X-Gm-Message-State: APjAAAV7ZnNVmdjqqbeBy42EBPmN5d8Rk8hy+zWboW6bclpRZEJLsKL6 kELdpB4E/n7v/P/sIWdQyFMiGDwp0yVFrA== X-Google-Smtp-Source: APXvYqzPQ845P2UoLGR0w2cz1MzMxU72fHZk394NHrYcJ0rsN8T5cwOUqurSQFIbcWp7vig5KvFn8A== X-Received: by 2002:a92:5806:: with SMTP id m6mr13499127ilb.234.1580101742230; Sun, 26 Jan 2020 21:09:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:01 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 048/108] x86: pinctrl: Add a way to get the pinctrl reg address Date: Sun, 26 Jan 2020 22:05:55 -0700 Message-Id: <20200126220508.48.I6d4adee5cfa6760f332c0a463658ab3167308689@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 At present we can query the offset of a pinctrl register within the p2sb. For ACPI we need to get the actual address of the register. Add a function to handle this and rename the old one to more accurately reflect its purpose. Signed-off-by: Simon Glass --- arch/x86/include/asm/intel_pinctrl.h | 16 ++++++++++++++-- drivers/gpio/intel_gpio.c | 15 +++++++++++---- drivers/misc/p2sb-uclass.c | 16 ++++++++-------- drivers/pinctrl/intel/pinctrl.c | 11 +++++++++-- include/p2sb.h | 9 +++++++++ 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/intel_pinctrl.h b/arch/x86/include/asm/intel_pinctrl.h index 72fd9246cb..ebdaa39265 100644 --- a/arch/x86/include/asm/intel_pinctrl.h +++ b/arch/x86/include/asm/intel_pinctrl.h @@ -262,11 +262,23 @@ int pinctrl_read_pads(struct udevice *dev, ofnode node, const char *prop, int pinctrl_count_pads(struct udevice *dev, u32 *pads, int size); /** - * intel_pinctrl_get_config_reg_addr() - Get address of the pin config registers + * intel_pinctrl_get_config_reg_offset() - Get offset of pin config registers * + * This works out the register offset of a pin within the p2sb region. + * + * @dev: Pinctrl device + * @offset: GPIO offset within this device + * @return register offset of first register within the GPIO p2sb region + */ +u32 intel_pinctrl_get_config_reg_offset(struct udevice *dev, uint offset); + +/** + * intel_pinctrl_get_config_reg_offset() - Get address of pin config registers + * + * This works out the absolute address of the registers for a pin * @dev: Pinctrl device * @offset: GPIO offset within this device - * @return register offset within the GPIO p2sb region + * @return register offset of first register within the GPIO p2sb region */ u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset); diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c index 4bf1c9ddc4..c56b362c4e 100644 --- a/drivers/gpio/intel_gpio.c +++ b/drivers/gpio/intel_gpio.c @@ -23,7 +23,9 @@ static int intel_gpio_direction_input(struct udevice *dev, uint offset) { struct udevice *pinctrl = dev_get_parent(dev); - uint config_offset = intel_pinctrl_get_config_reg_addr(pinctrl, offset); + uint config_offset; + + config_offset = intel_pinctrl_get_config_reg_offset(pinctrl, offset); pcr_clrsetbits32(pinctrl, config_offset, PAD_CFG0_MODE_MASK | PAD_CFG0_TX_STATE | @@ -37,7 +39,9 @@ static int intel_gpio_direction_output(struct udevice *dev, uint offset, int value) { struct udevice *pinctrl = dev_get_parent(dev); - uint config_offset = intel_pinctrl_get_config_reg_addr(pinctrl, offset); + uint config_offset; + + config_offset = intel_pinctrl_get_config_reg_offset(pinctrl, offset); pcr_clrsetbits32(dev, config_offset, PAD_CFG0_MODE_MASK | PAD_CFG0_RX_STATE | @@ -67,10 +71,13 @@ static int intel_gpio_get_value(struct udevice *dev, uint offset) return 0; } -static int intel_gpio_set_value(struct udevice *dev, unsigned offset, int value) +static int intel_gpio_set_value(struct udevice *dev, unsigned int offset, + int value) { struct udevice *pinctrl = dev_get_parent(dev); - uint config_offset = intel_pinctrl_get_config_reg_addr(pinctrl, offset); + uint config_offset; + + config_offset = intel_pinctrl_get_config_reg_offset(pinctrl, offset); pcr_clrsetbits32(dev, config_offset, PAD_CFG0_TX_STATE, value ? PAD_CFG0_TX_STATE : 0); diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c index a198700b5f..1d00a73f2f 100644 --- a/drivers/misc/p2sb-uclass.c +++ b/drivers/misc/p2sb-uclass.c @@ -16,7 +16,7 @@ #define PCR_COMMON_IOSF_1_0 1 -static void *_pcr_reg_address(struct udevice *dev, uint offset) +void *pcr_reg_address(struct udevice *dev, uint offset) { struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); struct udevice *p2sb = dev_get_parent(dev); @@ -53,7 +53,7 @@ uint pcr_read32(struct udevice *dev, uint offset) /* Ensure the PCR offset is correctly aligned */ assert(IS_ALIGNED(offset, sizeof(uint32_t))); - ptr = _pcr_reg_address(dev, offset); + ptr = pcr_reg_address(dev, offset); val = readl(ptr); unmap_sysmem(ptr); @@ -65,7 +65,7 @@ uint pcr_read16(struct udevice *dev, uint offset) /* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align(offset, sizeof(uint16_t)); - return readw(_pcr_reg_address(dev, offset)); + return readw(pcr_reg_address(dev, offset)); } uint pcr_read8(struct udevice *dev, uint offset) @@ -73,7 +73,7 @@ uint pcr_read8(struct udevice *dev, uint offset) /* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align(offset, sizeof(uint8_t)); - return readb(_pcr_reg_address(dev, offset)); + return readb(pcr_reg_address(dev, offset)); } /* @@ -84,7 +84,7 @@ uint pcr_read8(struct udevice *dev, uint offset) */ static void write_completion(struct udevice *dev, uint offset) { - readl(_pcr_reg_address(dev, ALIGN_DOWN(offset, sizeof(uint32_t)))); + readl(pcr_reg_address(dev, ALIGN_DOWN(offset, sizeof(uint32_t)))); } void pcr_write32(struct udevice *dev, uint offset, uint indata) @@ -92,7 +92,7 @@ void pcr_write32(struct udevice *dev, uint offset, uint indata) /* Ensure the PCR offset is correctly aligned */ assert(IS_ALIGNED(offset, sizeof(indata))); - writel(indata, _pcr_reg_address(dev, offset)); + writel(indata, pcr_reg_address(dev, offset)); /* Ensure the writes complete */ write_completion(dev, offset); } @@ -102,7 +102,7 @@ void pcr_write16(struct udevice *dev, uint offset, uint indata) /* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align(offset, sizeof(uint16_t)); - writew(indata, _pcr_reg_address(dev, offset)); + writew(indata, pcr_reg_address(dev, offset)); /* Ensure the writes complete */ write_completion(dev, offset); } @@ -112,7 +112,7 @@ void pcr_write8(struct udevice *dev, uint offset, uint indata) /* Ensure the PCR offset is correctly aligned */ check_pcr_offset_align(offset, sizeof(uint8_t)); - writeb(indata, _pcr_reg_address(dev, offset)); + writeb(indata, pcr_reg_address(dev, offset)); /* Ensure the writes complete */ write_completion(dev, offset); } diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c index bd58b85dd8..68955f66ed 100644 --- a/drivers/pinctrl/intel/pinctrl.c +++ b/drivers/pinctrl/intel/pinctrl.c @@ -391,7 +391,7 @@ static int pinctrl_configure_pad(struct udevice *dev, return 0; } -u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset) +u32 intel_pinctrl_get_config_reg_offset(struct udevice *dev, uint offset) { struct intel_pinctrl_priv *priv = dev_get_priv(dev); const struct pad_community *comm = priv->comm; @@ -404,9 +404,16 @@ u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset) return config_offset; } +u32 intel_pinctrl_get_config_reg_addr(struct udevice *dev, uint offset) +{ + uint config_offset = intel_pinctrl_get_config_reg_offset(dev, offset); + + return (u32)(ulong)pcr_reg_address(dev, config_offset); +} + u32 intel_pinctrl_get_config_reg(struct udevice *dev, uint offset) { - uint config_offset = intel_pinctrl_get_config_reg_addr(dev, offset); + uint config_offset = intel_pinctrl_get_config_reg_offset(dev, offset); return pcr_read32(dev, config_offset); } diff --git a/include/p2sb.h b/include/p2sb.h index 60c7f70773..74eb08b7ff 100644 --- a/include/p2sb.h +++ b/include/p2sb.h @@ -132,4 +132,13 @@ int p2sb_set_port_id(struct udevice *dev, int portid); */ int p2sb_get_port_id(struct udevice *dev); +/** + * pcr_reg_address() Convert an offset in p2sb space to an absolute address + * + * @dev: Child device (whose parent is UCLASS_P2SB) + * @offset: Offset within that child's address space + * @return pointer to that offset within the child's address space + */ +void *pcr_reg_address(struct udevice *dev, uint offset); + #endif From patchwork Mon Jan 27 05:05:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229547 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=efQvhzFh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dKX47Cdz9sR1 for ; Mon, 27 Jan 2020 16:17:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD4798187C; Mon, 27 Jan 2020 06:11:55 +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="efQvhzFh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B7BD817DD; Mon, 27 Jan 2020 06:09:36 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 56AE4817FF for ; Mon, 27 Jan 2020 06:09:08 +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-xd42.google.com with SMTP id z193so8583150iof.1 for ; Sun, 26 Jan 2020 21:09:08 -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=mTITDJfPBTSvTH56PoSSqkgOXOLOt2qQgEuFEy1n42c=; b=efQvhzFh8q9uxRCSEt44MZ2Nq3PEuGQrfcF5MJmrLPfSqI3eVnOa7Xo0Kq7XmYaktA 1aJefrOdvGel/ZcuVFXo6PIotU7m/plfIiiSB3HKzFKoqrZhALdsp1cVxO66DN3/swWB aVgudg2oZ71BFJEZGWyPTYImlvsvwh/k6zPO4= 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=mTITDJfPBTSvTH56PoSSqkgOXOLOt2qQgEuFEy1n42c=; b=kL5lhrnyXEAekDde4lTzIfOgtVkZK251pdbgwbQO6/foiXF5Bd/MUxwcr16gNpcMGx anma6mE92mnybYcIYoD3qZ6ip4rQOQaGv4h+bkZLw1Cx3+sKMADc+7o8q64H6IYERl4b NFiXcUBisx0PBUGVykyCbRhEdbYq4F+lcViODL1yRPTKjKAB4DwHHfG0NSxOQsCWwOn3 uWcIYY6qGFp6nY27jczrKjYnvE6zgakcRaA7ay+hT92npEiUb9m2rSX6p9E68NjOJ4FS 4NOp9wgzcXbkAS1Y7ZZ7uX3fbEuuSIv2mB4Sj1qoaExrVrmLCXe10Lewv3miz4s3oYEB 66MA== X-Gm-Message-State: APjAAAXQYQgfQwK9FJN68ChENqPzkNLS5SoA2sEc82BNHlQoitMGACsQ lEZX7+aLvIBWGZDRzjdkDrwExQLpHLn3rw== X-Google-Smtp-Source: APXvYqxJKR2io4tHR1hBqyLij2m8fjXIr5TyzwjJh4kK9G3QUJ0ZAS3DfK1M65iCTZa1GAV1TqhP7A== X-Received: by 2002:a02:6a10:: with SMTP id l16mr11771672jac.77.1580101742997; Sun, 26 Jan 2020 21:09:02 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:02 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 049/108] x86: pinctrl: Update comment for intel_pinctrl_get_pad() Date: Sun, 26 Jan 2020 22:05:56 -0700 Message-Id: <20200126220508.49.Id23a87cbfe05f86560b788a8e180e9109c35b20d@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 Add information about what is returned on error. Signed-off-by: Simon Glass --- arch/x86/include/asm/intel_pinctrl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/intel_pinctrl.h b/arch/x86/include/asm/intel_pinctrl.h index ebdaa39265..26fbd4c377 100644 --- a/arch/x86/include/asm/intel_pinctrl.h +++ b/arch/x86/include/asm/intel_pinctrl.h @@ -299,6 +299,7 @@ u32 intel_pinctrl_get_config_reg(struct udevice *dev, uint offset); * @pad: Pad to check * @devp: Returns pinctrl device containing that pad * @offsetp: Returns offset of pad within that pinctrl device + * @return 0 if OK, -ENOTBLK if pad number is invalid */ int intel_pinctrl_get_pad(uint pad, struct udevice **devp, uint *offsetp); From patchwork Mon Jan 27 05:05:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229546 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=O85JtJwP; 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 485dKN74Zxz9sR1 for ; Mon, 27 Jan 2020 16:17:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F9A88182F; Mon, 27 Jan 2020 06:11:53 +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="O85JtJwP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9A91817EB; Mon, 27 Jan 2020 06:09:34 +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 6756B8180B for ; Mon, 27 Jan 2020 06:09:08 +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 i7so3257567ilr.7 for ; Sun, 26 Jan 2020 21:09:08 -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=3IG3k6oAqqfe2V8QiSiGCd7d6zftLTAoJ/Tq+FLdt+k=; b=O85JtJwPKytZDqNTugsF3XjkLWFqxBuj2DS2gCD0uj3ishc9A1xybCgoLSlEqYVtZT pqUTmo2Eo3/OXLx+DQ7IaGPGr4u5n4Cv6gMABA2/KHg85n6XKbzGAVuqZwhKFF0FbH/P V78NrCSzfH5Pmkajgbpu8hPkLOa+PG9yfuRGg= 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=3IG3k6oAqqfe2V8QiSiGCd7d6zftLTAoJ/Tq+FLdt+k=; b=X5Xq1YGBNQPdxu+OyXMxBHZdeJMqHIoMoMWrafqZztyvWWiwASbWlo6Mm+4TINnAA+ mSTdOmYc+VWnfG5nnVL3Ty+5CznLwlDhdoZ/ZA4re0Ur3TvDT531WWW+NG3qTw2qIsCP MyEJRo+aoukVeOqk+RYRojHComK+JyqN3gRJpJ7EWhHAq4wEYj4EpviE6SwBBhG8IB4s alV4QUNuF//SvCjHIZpVHT3N+U0It1QGmY/4SM3vx3k+T3GKJnSa56X1r3AvVlCO+4nW veLDbshdH27G+npTQgrWxWkJcL+N+XyEjMOD3GaXQZLXKT4XwTo1AvyoO1Etb7JU/wm0 i2Yw== X-Gm-Message-State: APjAAAVUEUBde57xlE91TwwmR8kngUN89HDkz+oQn7a+Nw0T8GycWkQC Tas4+/LTCYMUeHU2H5ZZ+zwUtU/p+Zu9MQ== X-Google-Smtp-Source: APXvYqwsM33hlgyieQ3DEjrdzjTAhi8QqkqIiPhCPTQKhFtOfSbI5PLOc1zCYP34WfL/iUsu1kJBQw== X-Received: by 2002:a92:d708:: with SMTP id m8mr12947765iln.244.1580101743692; Sun, 26 Jan 2020 21:09:03 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:03 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 050/108] x86: pinctrl: Add multi-ACPI control Date: Sun, 26 Jan 2020 22:05:57 -0700 Message-Id: <20200126220508.50.I4f722d76cfa910b97ecad2c968d4bef1f9ea12f8@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 Add a Kconfig to control whether pinctrl is represented as a single ACPI device or as multiple devices. In the latter case (the default) we should return the pin number relative to the pinctrl device. Signed-off-by: Simon Glass --- drivers/pinctrl/intel/Kconfig | 4 ++++ drivers/pinctrl/intel/pinctrl.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/pinctrl/intel/Kconfig b/drivers/pinctrl/intel/Kconfig index e62a2e0349..05a314af88 100644 --- a/drivers/pinctrl/intel/Kconfig +++ b/drivers/pinctrl/intel/Kconfig @@ -15,6 +15,10 @@ config INTEL_PINCTRL_IOSTANDBY bool default y +config INTEL_PINCTRL_MULTI_ACPI_DEVICES + bool + default y + config PINCTRL_INTEL_APL bool "Support Intel Apollo Lake (APL)" help diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c index 68955f66ed..8204add295 100644 --- a/drivers/pinctrl/intel/pinctrl.c +++ b/drivers/pinctrl/intel/pinctrl.c @@ -424,6 +424,8 @@ int intel_pinctrl_get_acpi_pin(struct udevice *dev, uint offset) const struct pad_community *comm = priv->comm; int group; + if (IS_ENABLED(CONFIG_INTEL_PINCTRL_MULTI_ACPI_DEVICES)) + return offset; group = pinctrl_group_index(comm, offset); /* If pad base is not set then use GPIO number as ACPI pin number */ From patchwork Mon Jan 27 05:05:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229549 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=QptU5BUs; 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 485dKw2Xmdz9sR1 for ; Mon, 27 Jan 2020 16:17:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 803098188B; Mon, 27 Jan 2020 06:12:00 +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="QptU5BUs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3A7A6817EE; Mon, 27 Jan 2020 06:09:37 +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-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 7FD61817E6 for ; Mon, 27 Jan 2020 06:09:08 +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-x141.google.com with SMTP id f10so6438579ils.8 for ; Sun, 26 Jan 2020 21:09:08 -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=QEoqGmEpYSHNgkWBBIwumRaE8i8Oq05D0EfXnqx8P5s=; b=QptU5BUsiCdz6gkGZdA/qu6chBqAH6NwO6pSmmQwjsI6iCz6ZuSNf38FUDeZhZ7Q4m KywHquHbHes8+tntbRD1UGN0h20XoQRv2xqEWuVv05kWoXf7f7suP76O9+yNfFtmHHrZ Ohew53yga2UrRHQ8CXmlscT8mpMoaReg2Xu1M= 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=QEoqGmEpYSHNgkWBBIwumRaE8i8Oq05D0EfXnqx8P5s=; b=J1Rs7oqjTJokGpqFKJ8BwSrql4aWp32Tl7jQSmtJTFjrsz2/j4gSpZHEGsPccGwVKp DoYhruCXcJxo8usphVNHEUk/1HLTMPNG0QJ+bCwriykqhCwPKfY8azVnqxstAo0lT5xZ 24SAS/8O7Gni2oPVIWLor2wvRna+0Fo/4tUzqsrsBXd5Z1CgBjLtXSa5BZPeslLUYj4h Y0nWu+9+DHqnFeTutpEjg/C9qEDx1dg8gsWxIUgq7Hy2R59ft+b3jj5GgzokoPs1TOFy jfZmiJ0WOy2LSUiQ9/abgw00ZG14mVTi/PiSjtwztbk/sz4l5fF98teDsZVi/5ijJp2c TeUQ== X-Gm-Message-State: APjAAAXScR6L8kFOwZnvhm7bxNUVYt1t685xo4sqw28DjAfUTd/IMwo+ 5vR8fWyHQzbIWHh0RomGeLrLwI66KbbAeA== X-Google-Smtp-Source: APXvYqxgsBHmMVheUCrZHhHz3lir1Je+DuQfzdw2NestYhq/xr7KrlPh+8FgGpS0jd+ocF50aukHgg== X-Received: by 2002:a92:1a0a:: with SMTP id a10mr13682877ila.295.1580101744369; Sun, 26 Jan 2020 21:09:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 051/108] x86: pinctrl: Set up itss in the probe() method Date: Sun, 26 Jan 2020 22:05:58 -0700 Message-Id: <20200126220508.51.Iabbdf4b844a81d8ba0382c512fa2becc47d6ed94@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 At present the itss is probed in the ofdata_to_platdata() method. This is incorrect since itss is a child of p2sb which itself needs to probe the pinctrl device. This means that p2sb is effectively not probed when the itss is probed, so we get the wrong register address from p2sb. Fix this by moving the itss probe to the correct place. Signed-off-by: Simon Glass --- drivers/pinctrl/intel/pinctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl.c b/drivers/pinctrl/intel/pinctrl.c index 8204add295..adc080c0b1 100644 --- a/drivers/pinctrl/intel/pinctrl.c +++ b/drivers/pinctrl/intel/pinctrl.c @@ -616,15 +616,11 @@ int intel_pinctrl_ofdata_to_platdata(struct udevice *dev, { struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); struct intel_pinctrl_priv *priv = dev_get_priv(dev); - int ret; if (!comm) { log_err("Cannot find community for pid %d\n", pplat->pid); return -EDOM; } - ret = irq_first_device_type(X86_IRQT_ITSS, &priv->itss); - if (ret) - return log_msg_ret("Cannot find ITSS", ret); priv->comm = comm; priv->num_cfgs = num_cfgs; @@ -634,8 +630,12 @@ int intel_pinctrl_ofdata_to_platdata(struct udevice *dev, int intel_pinctrl_probe(struct udevice *dev) { struct intel_pinctrl_priv *priv = dev_get_priv(dev); + int ret; priv->itss_pol_cfg = true; + ret = irq_first_device_type(X86_IRQT_ITSS, &priv->itss); + if (ret) + return log_msg_ret("Cannot find ITSS", ret); return 0; } From patchwork Mon Jan 27 05:05:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229550 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=L6fqKRKO; 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 485dL63W80z9sR1 for ; Mon, 27 Jan 2020 16:17:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D125C81895; Mon, 27 Jan 2020 06:12:05 +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="L6fqKRKO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F26B817E6; Mon, 27 Jan 2020 06:09:38 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 C93FC81802 for ; Mon, 27 Jan 2020 06:09:09 +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-x144.google.com with SMTP id p8so6411549iln.12 for ; Sun, 26 Jan 2020 21:09:09 -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=fxWuYObezOF89RklC1izeQaCkn0VcoQpBG97vvL6Ztg=; b=L6fqKRKOt0QsspFqcqvI/ioH5H7rnVPFtQGdhrB9RftGqvCW7nMvKMahnEU3fEzi7C N8Y3qwE9AVHRp6zC4bLgIyAvPDl1Z1tKBkLkEXXZQHB+ebYY2bYtaZqMUFt1oW6tGYen GNrgklgsuNqFS8BtIGaQXq4CIJBXj80NHsbmY= 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=fxWuYObezOF89RklC1izeQaCkn0VcoQpBG97vvL6Ztg=; b=ZNyJXyLegwuBgr20QB5Ko31ajEzG+s4T68sGcujp/sY+Q3Jp2gWqY+t2uFC4n1Di5p On+aT4Y3PVSa/R9UHZNojAyzLjr91wMYEXen4hhVVGWBsFTbJohlIdImFL7wloGHjbHX wIUA+MpxkKdp5Xe4+bu4jQVYHQQ4d7fWELm9AICU5nakoP5zbNzqn5kK7IoXF/2LWNc4 t7MOv/o40FHBeHufhMy0XDJOBXpkVgiz7mvt/dxp9v8Nz+ZHx646ydxAaZBFW3WVSdB2 MmWeKth/j5FGOBl7VCOX17rz1Gfb0i61ktF/59FPs/V5JgbeuE4JUsaFBGZ5o7pgp3gb pHpA== X-Gm-Message-State: APjAAAXTkTRSJxyF2WvhA0MGFs35+lxoDAcfgu16BYWPOLGoo9V40Bzb YN9OdDILIJ38C2lTgZFsSW3H++EsvM8nZg== X-Google-Smtp-Source: APXvYqzwIaUY1GkPCPhhvkiF/B9b/aUb+XsfwLxTGJ1srLfTR52mrxzQ/OFFKYia2K2YSDdljEIRtA== X-Received: by 2002:a92:8307:: with SMTP id f7mr12901010ild.183.1580101745041; Sun, 26 Jan 2020 21:09:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 052/108] x86: pinctrl: Drop the acpi_name member Date: Sun, 26 Jan 2020 22:05:59 -0700 Message-Id: <20200126220508.52.I3afd224b9bfd632a56dd7f5e621a46d75318f328@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 This is in the device tree now, so drop the unnecessary field here. Signed-off-by: Simon Glass --- arch/x86/include/asm/intel_pinctrl.h | 2 -- drivers/pinctrl/intel/pinctrl_apl.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/arch/x86/include/asm/intel_pinctrl.h b/arch/x86/include/asm/intel_pinctrl.h index 26fbd4c377..ed959a9cff 100644 --- a/arch/x86/include/asm/intel_pinctrl.h +++ b/arch/x86/include/asm/intel_pinctrl.h @@ -98,7 +98,6 @@ struct pad_group { * groups exist inside a community * * @name: Community name - * @acpi_path: ACPI path * @num_gpi_regs: number of gpi registers in community * @max_pads_per_group: number of pads in each group; number of pads bit-mapped * in each GPI status/en and Host Own Reg @@ -119,7 +118,6 @@ struct pad_group { */ struct pad_community { const char *name; - const char *acpi_path; size_t num_gpi_regs; size_t max_pads_per_group; uint first_pad; diff --git a/drivers/pinctrl/intel/pinctrl_apl.c b/drivers/pinctrl/intel/pinctrl_apl.c index bd80435ffa..5b65d7e5fe 100644 --- a/drivers/pinctrl/intel/pinctrl_apl.c +++ b/drivers/pinctrl/intel/pinctrl_apl.c @@ -74,7 +74,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_N", - .acpi_path = "\\_SB.GPO0", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_n_groups, @@ -93,7 +92,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_NW", - .acpi_path = "\\_SB.GPO1", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_nw_groups, @@ -112,7 +110,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_W", - .acpi_path = "\\_SB.GPO2", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_w_groups, @@ -131,7 +128,6 @@ static const struct pad_community apl_gpio_communities[] = { .gpi_smi_en_reg_0 = GPI_SMI_EN_0, .max_pads_per_group = GPIO_MAX_NUM_PER_GROUP, .name = "GPIO_GPE_SW", - .acpi_path = "\\_SB.GPO3", .reset_map = rst_map, .num_reset_vals = ARRAY_SIZE(rst_map), .groups = apl_community_sw_groups, From patchwork Mon Jan 27 05:06:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229551 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=FJQ+56vP; 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 485dLH4Qc9z9sR1 for ; Mon, 27 Jan 2020 16:17:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D0AF8188C; Mon, 27 Jan 2020 06:12:09 +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="FJQ+56vP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 644B9817BC; Mon, 27 Jan 2020 06:09:38 +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 C4FC2817F3 for ; Mon, 27 Jan 2020 06:09:09 +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 f16so6422240ilk.11 for ; Sun, 26 Jan 2020 21:09:09 -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=I/eyt7Bx4cg+jKjej8A2D52sMetWlx/QUgG6UxF56E4=; b=FJQ+56vPkc6wD08FCYA3EXddvv25HH4p42PL2BIqs9jnfFnZrdv/AD2DVK5HSfCBtm bCLeNO1McALmft5+UGL+9MpEFocjCk9JdKFYCfR3YajcQvnAXaE5nl703oHx/WhtRVR1 ASYuc6c/fzyphKhPP7uJAfJqW4D2RuTaKUycc= 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=I/eyt7Bx4cg+jKjej8A2D52sMetWlx/QUgG6UxF56E4=; b=Ths5lqp4RJTYnXpZ40Xz8yxrJoW0DEq/KwFooW+t2BKkZ+z1VveHPQtr/bNT2qYJBP I3oO6bQT1sHm7647QFsxRqFhj+ts6geJp7Ve6xwSGI3C5gqY5OxudqOaV397pB7ebgrr 2VKXDlVEoeppBEfQ5daEWoNo4KxeHZGHt58klLzJRmLYZR//oUxiZ5xpc4iGhcq6Jnnj 1AJO1YO/gYqOe+Xrey6LMaleRVxTxoyYUqWSjlA/9STp30xVVMDcNRqPS9lQB17WoJT/ lgfnvLGmjw6P9IwyRRJpD3HGn1to/KNUmoplkFyYtDF5Jq5DwIxn1JDxk5S9QGjR2qO1 VCrw== X-Gm-Message-State: APjAAAX1CRvJPElEUrvoEuWdp+3vR25bZ5zfkqUpcRT2pqFviUB6ymLs cvkiBdvZLHF/hb+HKKwSVWvMwrzHTu6iTQ== X-Google-Smtp-Source: APXvYqxR6GwKviga0Z0Pfsd/bJPjAyaEyecAFdINx2+kdbT4UudGe3wwNYo7GQv+bNG6KHtVprT7Vg== X-Received: by 2002:a92:860f:: with SMTP id g15mr13196532ild.297.1580101746216; Sun, 26 Jan 2020 21:09:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:05 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 053/108] dm: core: Add a way of overriding the ACPI device path Date: Sun, 26 Jan 2020 22:06:00 -0700 Message-Id: <20200126220508.53.I05c1764b12b8c4770c5a0aa9d149c551f9a8fe70@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: , Cc: Pavel Herrmann 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 Some devices such as GPIO need to override the normal path that would be generated by driver model. Add a device-tree property for this. Signed-off-by: Simon Glass --- doc/device-tree-bindings/device.txt | 23 +++++++++++++++++++++++ drivers/core/acpi.c | 19 +++++++++++++++++++ include/dm/acpi.h | 13 +++++++++++++ 3 files changed, 55 insertions(+) diff --git a/doc/device-tree-bindings/device.txt b/doc/device-tree-bindings/device.txt index 61ebd7a942..107b17589c 100644 --- a/doc/device-tree-bindings/device.txt +++ b/doc/device-tree-bindings/device.txt @@ -16,6 +16,8 @@ U-Boot provides for some optional properties which are documented here. - acpi,hid : Contains the string to use as the HID (Human Interface Device) identifier _HID - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + - acpi,path : Specifies the full ACPI path for a device. This overrides the + normal path built from the driver-model hierarchy - acpi,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that Linux will not re-init the device - acpi,name : Provides the ACPI name for a device, which is a string consisting @@ -48,3 +50,24 @@ pcie-a0@14,0 { interrupts-extended = <&acpi_gpe 0x3c 0>; }; }; + +p2sb: p2sb@d,0 { + u-boot,dm-pre-reloc; + reg = <0x02006810 0 0 0 0>; + compatible = "intel,apl-p2sb"; + early-regs = ; + pci,no-autoconfig; + + n { + compatible = "intel,apl-pinctrl"; + u-boot,dm-pre-reloc; + intel,p2sb-port-id = ; + acpi,path = "\\_SB.GPO0"; + gpio_n: gpio-n { + compatible = "intel,gpio"; + u-boot,dm-pre-reloc; + gpio-controller; + #gpio-cells = <2>; + linux-name = "INT3452:00"; + }; + }; diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 762cc40511..65c1fed132 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -68,6 +68,25 @@ int acpi_get_name(const struct udevice *dev, char *out_name) return 0; } +int acpi_get_path(const struct udevice *dev, char *out_path, int maxlen) +{ + const char *path; + int ret; + + path = dev_read_string(dev, "acpi,path"); + if (path) { + if (strlen(path) >= maxlen) + return -E2BIG; + strcpy(out_path, path); + return 0; + } + ret = acpi_device_path(dev, out_path, maxlen); + if (ret) + return log_msg_ret("dev", ret); + + return 0; +} + /** * acpi_add_item() - Add a new item to the list of data collected * diff --git a/include/dm/acpi.h b/include/dm/acpi.h index ea3a615f60..2b4e8d7e87 100644 --- a/include/dm/acpi.h +++ b/include/dm/acpi.h @@ -172,6 +172,19 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx); */ void acpi_dump_items(bool dump_contents); +/** + * acpi_get_path() - Get the full ACPI path for a device + * + * This checks for any override in the device tree and calls acpi_device_path() + * if not + * + * @dev: Device to check + * @out_path: Buffer to place the path in (should be ACPI_PATH_MAX long) + * @maxlen: Size of buffer (typically ACPI_PATH_MAX) + * @return 0 if OK, -ve on error + */ +int acpi_get_path(const struct udevice *dev, char *out_path, int maxlen); + #endif /* __ACPI__ */ #endif From patchwork Mon Jan 27 05:06:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229552 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=Y8SfCjIS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dLV2tzHz9sR1 for ; Mon, 27 Jan 2020 16:18:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BB8B981849; Mon, 27 Jan 2020 06:12:11 +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="Y8SfCjIS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9EB25817E6; Mon, 27 Jan 2020 06:09: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-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 ACB4581726 for ; Mon, 27 Jan 2020 06:09:10 +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-x143.google.com with SMTP id t17so6410457ilm.13 for ; Sun, 26 Jan 2020 21:09:10 -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=nMhcMjt8g/Yw+uo7FXusVJtTVYBdKJTNcpSBZIkKSXk=; b=Y8SfCjISZkfWfWvOuExvHxFd4mJeFQ/cWc+RyAALxnOCJ9Z0tiS36mCeaKwg/dxWmY Aa5vxt838CJc3HQQTN97l2dR/WY6wEuiTGtQ0XYRmvdkuJXHfp4kx8hJRjr9TgChqJF+ 9Hxyc0KpdjrwAqlgW34osSpCFW6UJezFPSLZM= 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=nMhcMjt8g/Yw+uo7FXusVJtTVYBdKJTNcpSBZIkKSXk=; b=FxLiGWHRg3TZi1BBME35BTDg8pVqWVvESZZedr3gAVDveJbHHLzgIgQUEIBkpYw949 rPfWE8UNpu2AGOI3knb2govuVtId4juWjj8A+sHiFgCuOXWwlREXjy7n+s8FjIBvv+AG mXu7Yos0dzDLXqlbvIBKZwKM6YtpYYkqx86rSIsSgUs1fkwMaDVBVY6jjNuZeX/AVmQC CeZyICAznNDS94R//0AyoJdg+ZVRX4nqcrimBuAzoSVYW4LyL/O9JlPXryeCUGaaS7tL tIXDAVt+mQNghw10qu/8YOgxpECW67Jcr+XFNJBlZtX6/hY/sCcg6ksVZrNSt1vkoq7t LQ3g== X-Gm-Message-State: APjAAAVoJsjDc0JPQZM+qkonJz+GRwXdKq6paSsWBjc93faQaEQLN393 o2C8772s21UQ2nLCdbr/5fAmCVIJAichxA== X-Google-Smtp-Source: APXvYqyQ2se7whfOqvyWWqwGP7aVXiQx5FCOB4MT3Dq2+GpBZayZKUESmpQ5I8yp+6OLX0WceYx7Xw== X-Received: by 2002:a05:6e02:692:: with SMTP id o18mr7135059ils.238.1580101746958; Sun, 26 Jan 2020 21:09:06 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:06 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 054/108] x86: gpio: Add support for obtaining ACPI info for a GPIO Date: Sun, 26 Jan 2020 22:06:01 -0700 Message-Id: <20200126220508.54.Ieac541912f8390ac07a3c9b693fb46858e3b813e@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 Implement the method that converts a GPIO into the form used by ACPI, so that GPIOs can be added to ACPI tables. Signed-off-by: Simon Glass --- drivers/gpio/intel_gpio.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/gpio/intel_gpio.c b/drivers/gpio/intel_gpio.c index c56b362c4e..51ea23df89 100644 --- a/drivers/gpio/intel_gpio.c +++ b/drivers/gpio/intel_gpio.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -127,6 +128,33 @@ static int intel_gpio_xlate(struct udevice *orig_dev, struct gpio_desc *desc, return 0; } +#if CONFIG_IS_ENABLED(ACPIGEN) +static int intel_gpio_get_acpi(const struct gpio_desc *desc, + struct acpi_gpio *gpio) +{ + struct udevice *pinctrl; + int ret; + + if (!dm_gpio_is_valid(desc)) + return -ENOENT; + pinctrl = dev_get_parent(desc->dev); + + memset(gpio, '\0', sizeof(*gpio)); + + gpio->type = ACPI_GPIO_TYPE_IO; + gpio->pull = ACPI_GPIO_PULL_DEFAULT; + gpio->io_restrict = ACPI_GPIO_IO_RESTRICT_OUTPUT; + gpio->polarity = ACPI_GPIO_ACTIVE_HIGH; + gpio->pin_count = 1; + gpio->pins[0] = intel_pinctrl_get_acpi_pin(pinctrl, desc->offset); + ret = acpi_device_path(pinctrl, gpio->resource, sizeof(gpio->resource)); + if (ret) + return log_msg_ret("resource", ret); + + return 0; +} +#endif + static int intel_gpio_probe(struct udevice *dev) { return 0; @@ -151,6 +179,9 @@ static const struct dm_gpio_ops gpio_intel_ops = { .set_value = intel_gpio_set_value, .get_function = intel_gpio_get_function, .xlate = intel_gpio_xlate, +#if CONFIG_IS_ENABLED(ACPIGEN) + .get_acpi = intel_gpio_get_acpi, +#endif }; static const struct udevice_id intel_intel_gpio_ids[] = { From patchwork Mon Jan 27 05:06:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229553 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=XsLS0ReG; 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 485dLh2RHGz9sR1 for ; Mon, 27 Jan 2020 16:18:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4D598189C; Mon, 27 Jan 2020 06:12:14 +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="XsLS0ReG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B016181848; Mon, 27 Jan 2020 06:09:40 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 B3D7081810 for ; Mon, 27 Jan 2020 06:09:10 +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-xd42.google.com with SMTP id n21so8546414ioo.10 for ; Sun, 26 Jan 2020 21:09:10 -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=Zogpa9LFuY8ILfRz3IYtgmR3t8Q5BiGoSxWUjHzjsXA=; b=XsLS0ReGJKaE1HjPdXwNtjaOWeqA/CbGFJnU+OTwgd5jE32rUudccSMWH6R0X9cd4A JM1NAIrtLNllvRKSQeKBFSAZj+Zm9ScGktgVvUCaEeirm2/VQFHpb0s59SMImzgKrfsQ oNOCeoCt2ZBZFcizXNRL0GjsT+8kxmJJrg7/k= 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=Zogpa9LFuY8ILfRz3IYtgmR3t8Q5BiGoSxWUjHzjsXA=; b=nx/LYmugq0ltHXA/SfkTn//2djlRVodUopQ0e7Zov9rscybv+ImjdAq53AlqOJy+uM a+rq/aazgnGOPAWCv1N+QKYmnqhwB3Gb8AIu5clMfJ5Jm+yJtQxMLjF+En+wqNxmmAED A2jTQyb6sK1RzWj+mY6j5pdt4+5Hf/cRTBk5Zm2Z81nNnZC8twtYIihLi84fkknUYK4v 4oAWaQndgjDLLoYvQHPug4Dk5YLCdsOizPep34OGTKUf04bpfpnmqL12QE8OS/nrkXsl EycYnASSARrMpNc10lRkHrsXcB5+fRcmtxiNI+ycnQY3bFlwVhwRXF9UN0L3X6yR0XAN rS/g== X-Gm-Message-State: APjAAAWn76+YB9+OZX7KLximfCH7omO+m6+UFp1rJGBDd9uOIyEkpDpZ t9WhkH12KrYCODXdh/M/gF309EDYUJRT0Q== X-Google-Smtp-Source: APXvYqy6g/1C28eOHAMuU/9dQfjZSKXNIn1z6MkmVSJ7EtD/nq585zmNEbmTIiahPXrEA6QiUwtzSg== X-Received: by 2002:a5e:da0d:: with SMTP id x13mr10241930ioj.123.1580101747721; Sun, 26 Jan 2020 21:09:07 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:07 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 055/108] i2c: designware_i2c: Support ACPI table generation Date: Sun, 26 Jan 2020 22:06:02 -0700 Message-Id: <20200126220508.55.I30e30b52dcbacb27014122754740fdabfd8218bf@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 Update the PCI driver to generate ACPI information so that Linux has the full information about each I2C bus. Signed-off-by: Simon Glass --- drivers/i2c/designware_i2c.c | 25 ++++++++ drivers/i2c/designware_i2c.h | 15 +++++ drivers/i2c/designware_i2c_pci.c | 104 ++++++++++++++++++++++++++++++- 3 files changed, 143 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index 9933391bdb..af9ad124d3 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -298,6 +298,31 @@ static int _dw_i2c_set_bus_speed(struct dw_i2c *priv, struct i2c_regs *i2c_base, /* Restore back i2c now speed set */ if (ena == IC_ENABLE_0B) dw_i2c_enable(i2c_base, true); + if (priv) + priv->config = config; + return 0; +} + +int dw_i2c_gen_speed_config(const struct udevice *dev, int speed_hz, + struct dw_i2c_speed_config *config) +{ + struct dw_i2c *priv = dev_get_priv(dev); + ulong rate; + int ret; + + if (CONFIG_IS_ENABLED(CLK)) { + rate = clk_get_rate(&priv->clk); + if (IS_ERR_VALUE(rate)) + return log_msg_ret("clk", -EINVAL); + } else { + rate = IC_CLK; + } + + ret = calc_bus_speed(priv, speed_hz, rate, config); + if (ret) + printf("%s: ret=%d\n", __func__, ret); + if (ret) + return log_msg_ret("calc_bus_speed", ret); return 0; } diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h index be17f00140..03657ea3ab 100644 --- a/drivers/i2c/designware_i2c.h +++ b/drivers/i2c/designware_i2c.h @@ -198,6 +198,7 @@ struct dw_i2c { #if CONFIG_IS_ENABLED(CLK) struct clk clk; #endif + struct dw_i2c_speed_config config; }; extern const struct dm_i2c_ops designware_i2c_ops; @@ -206,4 +207,18 @@ int designware_i2c_probe(struct udevice *bus); int designware_i2c_remove(struct udevice *dev); int designware_i2c_ofdata_to_platdata(struct udevice *bus); +/** + * dw_i2c_gen_speed_config() - Calculate config info from requested speed1 + * + * Calculate the speed config from the given @speed_hz and return it so that + * it can be incorporated in ACPI tables + * + * @dev: I2C bus to check + * @speed_hz: Requested speed in Hz + * @config: Returns config to use for that speed + * @return 0 if OK, -ve on error + */ +int dw_i2c_gen_speed_config(const struct udevice *dev, int speed_hz, + struct dw_i2c_speed_config *config); + #endif /* __DW_I2C_H_ */ diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c index 50f03e3d90..4fc918c955 100644 --- a/drivers/i2c/designware_i2c_pci.c +++ b/drivers/i2c/designware_i2c_pci.c @@ -6,9 +6,14 @@ */ #include +#include +#include #include #include #include +#include +#include +#include #include "designware_i2c.h" enum { @@ -86,6 +91,8 @@ static int designware_i2c_pci_bind(struct udevice *dev) { char name[20]; + if (dev_of_valid(dev)) + return 0; /* * Create a unique device name for PCI type devices * ToDo: @@ -99,13 +106,107 @@ static int designware_i2c_pci_bind(struct udevice *dev) * be possible. We cannot use static data in drivers since they may be * used in SPL or before relocation. */ - dev->req_seq = gd->arch.dw_i2c_num_cards++; + dev->req_seq = uclass_find_next_free_req_seq(UCLASS_I2C); sprintf(name, "i2c_designware#%u", dev->req_seq); device_set_name(dev, name); return 0; } +/* + * Write ACPI object to describe speed configuration. + * + * ACPI Object: Name ("xxxx", Package () { scl_lcnt, scl_hcnt, sda_hold } + * + * SSCN: I2C_SPEED_STANDARD + * FMCN: I2C_SPEED_FAST + * FPCN: I2C_SPEED_FAST_PLUS + * HSCN: I2C_SPEED_HIGH + */ +static void dw_i2c_acpi_write_speed_config(struct acpi_ctx *ctx, + struct dw_i2c_speed_config *config) +{ + switch (config->speed_mode) { + case IC_SPEED_MODE_HIGH: + acpigen_write_name(ctx, "HSCN"); + break; + case IC_SPEED_MODE_FAST_PLUS: + acpigen_write_name(ctx, "FPCN"); + break; + case IC_SPEED_MODE_FAST: + acpigen_write_name(ctx, "FMCN"); + break; + case IC_SPEED_MODE_STANDARD: + default: + acpigen_write_name(ctx, "SSCN"); + } + + /* Package () { scl_lcnt, scl_hcnt, sda_hold } */ + acpigen_write_package(ctx, 3); + acpigen_write_word(ctx, config->scl_hcnt); + acpigen_write_word(ctx, config->scl_lcnt); + acpigen_write_dword(ctx, config->sda_hold); + acpigen_pop_len(ctx); +} + +/* + * Generate I2C timing information into the SSDT for the OS driver to consume, + * optionally applying override values provided by the caller. + */ +static int dw_i2c_acpi_fill_ssdt(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct dw_i2c_speed_config config; + char path[ACPI_PATH_MAX]; + u32 speeds[4]; + int size, i; + int ret; + + /* If no device-tree node, ignore this since we assume it isn't used */ + if (!dev_of_valid(dev)) + return 0; + ret = acpi_device_path(dev, path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + + size = dev_read_size(dev, "i2c,speeds"); + if (size < 0) + return log_msg_ret("i2c,speeds", -EINVAL); + size /= sizeof(u32); + if (size > ARRAY_SIZE(speeds)) + return log_msg_ret("array", -E2BIG); + + ret = dev_read_u32_array(dev, "i2c,speeds", speeds, size); + if (ret) + return log_msg_ret("read", -E2BIG); + + if (0) { + acpigen_write_scope(ctx, path); + for (i = 0; i < size; i++) { + ret = dw_i2c_gen_speed_config(dev, speeds[i], &config); + if (ret) + return log_msg_ret("config", ret); + dw_i2c_acpi_write_speed_config(ctx, &config); + } + } else { + uint speed; + + speed = dev_read_u32_default(dev, "clock-frequency", 100000); + acpigen_write_scope(ctx, path); + ret = dw_i2c_gen_speed_config(dev, speed, &config); + if (ret) + return log_msg_ret("config", ret); + dw_i2c_acpi_write_speed_config(ctx, &config); + } + acpigen_pop_len(ctx); + + return 0; +} + +struct acpi_ops dw_i2c_acpi_ops = { + .fill_ssdt = dw_i2c_acpi_fill_ssdt, +}; + static const struct udevice_id designware_i2c_pci_ids[] = { { .compatible = "snps,designware-i2c-pci" }, { .compatible = "intel,apl-i2c", .data = INTEL_APL }, @@ -123,6 +224,7 @@ U_BOOT_DRIVER(i2c_designware_pci) = { .remove = designware_i2c_remove, .flags = DM_FLAG_OS_PREPARE, .ops = &designware_i2c_ops, + acpi_ops_ptr(&dw_i2c_acpi_ops) }; static struct pci_device_id designware_pci_supported[] = { From patchwork Mon Jan 27 05:06:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229555 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GhhV8ISL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dM41hgqz9sR1 for ; Mon, 27 Jan 2020 16:18:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BBE1818A9; Mon, 27 Jan 2020 06:12:18 +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="GhhV8ISL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6554581803; Mon, 27 Jan 2020 06:09:42 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 C155281803 for ; Mon, 27 Jan 2020 06:09:10 +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-xd42.google.com with SMTP id c16so8567189ioh.6 for ; Sun, 26 Jan 2020 21:09:10 -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=o3cgK1KFhvIKToIhg/43TcPr7BySC42KPdvcH0znkz8=; b=GhhV8ISLXUmD0qCMhKvrZ+GfOhh1I/C9aaQGdG5bnxBJyMAmEc1MwWxHsAYynjL+KI N8n2Y7LsJ1bxTrdGBSz8XFgABqDERO+QfqZ4mOY5GEOmQzBDdnmvFxyXg1nSCaU8cuAK 1QCfB1uiBWjseaRRtjJcGG9jTuQjoVADlIBOk= 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=o3cgK1KFhvIKToIhg/43TcPr7BySC42KPdvcH0znkz8=; b=Wz/TrHRpZzsD3P6wKtSH82BjUvWTXEcQv25CPSQvI0gF1NmvY81NCgEgIS+USDnsPG nRMa9RsLDLXme0t3nGitFlA+94x3G14Gvbfd0vhchpOOu/Ej6+b8KYD+WkYs8FDOSBdm d68HGLpoa4cm8aV2xlG6WUOtDE8aQ5ZIWr/qLI1s8p6NuupIxU0D884AjJccjgp+TTOh o2UOIGMvM1QjOuyBlNEI6EhfxF90epzkeZc43+7t7UzOs0C2fD2EiKOSbEWWdVjBIVoa 5mahonB+u2gdNRHkqKZUfHiVEC7RRqzAsN3FzDcaH89YvZvCOY341QPJBxuKg4Nypj9x 7JnA== X-Gm-Message-State: APjAAAXQV2AlsjYvJFlKEYmIL9psimnAZe8JZs9LmV3lNvCDQ7D3qQbR c3i/Q9B0p/eP6Ev4Le6hBjfhQ5vaq84t0Q== X-Google-Smtp-Source: APXvYqwg8udiqAFdEyWeGOBiAGhuW4hYgjNDRvyf1MMrMWl9wsn3LGP1ToLI1Uc13alxiOWkvPKrjQ== X-Received: by 2002:a5d:8f17:: with SMTP id f23mr11160910iof.265.1580101748522; Sun, 26 Jan 2020 21:09:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 056/108] i2c: Add a generic driver to generate ACPI info Date: Sun, 26 Jan 2020 22:06:03 -0700 Message-Id: <20200126220508.56.I12e1ee504597159411b44512d27bb8f81576605a@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 Many I2C devices produce roughly the same ACPI data with just things like the GPIO/interrupt information being different. This can be handled by a generic driver along with some information in the device tree. Add a generic i2c driver for this purpose. Signed-off-by: Simon Glass --- doc/device-tree-bindings/i2c/generic-acpi.txt | 42 ++++ drivers/i2c/Makefile | 3 + drivers/i2c/acpi_i2c.c | 228 ++++++++++++++++++ drivers/i2c/acpi_i2c.h | 15 ++ drivers/i2c/i2c-uclass.c | 14 ++ include/i2c.h | 17 ++ 6 files changed, 319 insertions(+) create mode 100644 doc/device-tree-bindings/i2c/generic-acpi.txt create mode 100644 drivers/i2c/acpi_i2c.c create mode 100644 drivers/i2c/acpi_i2c.h diff --git a/doc/device-tree-bindings/i2c/generic-acpi.txt b/doc/device-tree-bindings/i2c/generic-acpi.txt new file mode 100644 index 0000000000..b1a4e8d752 --- /dev/null +++ b/doc/device-tree-bindings/i2c/generic-acpi.txt @@ -0,0 +1,42 @@ +I2C generic device +================== + +This is used only to generate ACPI tables for an I2C device. + +Required properties : + + - compatible : "i2c-chip"; + - reg : I2C chip address + - acpi,hid : HID name for the device + +Optional properies in addition to device.txt: + + - reset-gpios : GPIO used to assert reset to the device + - irq-gpios : GPIO used for interrupt (if Interrupt is not used) + - stop-gpios : GPIO used to stop the device + - interrupts-extended : Interrupt to use for the device + - reset-delay-ms : Delay after de-asserting reset, in ms + - reset-off-delay-ms : Delay after asserting reset (during power off) + - enable-delay-ms : Delay after asserting enable + - enable-off-delay-m s: Delay after de-asserting enable (during power off) + - stop-delay-ms : Delay after de-aserting stop + - stop-off-delay-ms : Delay after asserting stop (during power off) + - acpi,hid-desc-reg-offset : HID register offset (for Human Interface Devices) + +Example +------- + + elan-touchscreen@10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,desc = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>; + reset-delay-ms = <20>; + enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>; + enable-delay-ms = <1>; + acpi,has-power-resource; + }; diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index f5a471f887..43e58b8cac 100644 --- a/drivers/i2c/Makefile +++ b/drivers/i2c/Makefile @@ -3,6 +3,9 @@ # (C) Copyright 2000-2007 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. obj-$(CONFIG_DM_I2C) += i2c-uclass.o +ifdef CONFIG_ACPIGEN +obj-$(CONFIG_DM_I2C) += acpi_i2c.o +endif obj-$(CONFIG_DM_I2C_GPIO) += i2c-gpio.o obj-$(CONFIG_$(SPL_)I2C_CROS_EC_TUNNEL) += cros_ec_tunnel.o obj-$(CONFIG_$(SPL_)I2C_CROS_EC_LDO) += cros_ec_ldo.o diff --git a/drivers/i2c/acpi_i2c.c b/drivers/i2c/acpi_i2c.c new file mode 100644 index 0000000000..53609b2137 --- /dev/null +++ b/drivers/i2c/acpi_i2c.c @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + */ + +#include +#include +#include +#include +#include +#include +#include + +static bool acpi_i2c_add_gpios_to_crs(struct acpi_i2c_priv *priv) +{ + /* + * Return false if: + * 1. Request to explicitly disable export of GPIOs in CRS, or + * 2. Both reset and enable GPIOs are not provided. + */ + if (priv->disable_gpio_export_in_crs || + (!dm_gpio_is_valid(&priv->reset_gpio) && + !dm_gpio_is_valid(&priv->enable_gpio))) + return false; + + return true; +} + +static int acpi_i2c_write_gpio(struct acpi_ctx *ctx, struct gpio_desc *gpio, + int *curindex) +{ + int ret; + + if (!dm_gpio_is_valid(gpio)) + return -ENOENT; + + acpi_device_write_gpio_desc(ctx, gpio); + ret = *curindex; + (*curindex)++; + + return ret; +} + +int acpi_i2c_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + int reset_gpio_index = -1, enable_gpio_index = -1, irq_gpio_index = -1; + struct acpi_i2c_priv *priv = dev_get_priv(dev); + char scope[ACPI_PATH_MAX]; + char name[ACPI_NAME_MAX]; + struct acpi_dp *dsd = NULL; + int curindex = 0; + int ret; + + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + + /* Device */ + acpigen_write_scope(ctx, scope); + acpigen_write_device(ctx, name); + acpigen_write_name_string(ctx, "_HID", priv->hid); + if (priv->cid) + acpigen_write_name_string(ctx, "_CID", priv->cid); + acpigen_write_name_integer(ctx, "_UID", priv->uid); + acpigen_write_name_string(ctx, "_DDN", priv->desc); + acpigen_write_sta(ctx, acpi_device_status(dev)); + + /* Resources */ + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + acpi_device_write_i2c_dev(ctx, dev); + + /* Use either Interrupt() or GpioInt() */ + if (dm_gpio_is_valid(&priv->irq_gpio)) { + irq_gpio_index = acpi_i2c_write_gpio(ctx, &priv->irq_gpio, + &curindex); + } else { + ret = acpi_device_write_interrupt_irq(ctx, &priv->irq); + if (ret) + return log_msg_ret("irq", ret); + } + + if (acpi_i2c_add_gpios_to_crs(priv)) { + reset_gpio_index = acpi_i2c_write_gpio(ctx, &priv->reset_gpio, + &curindex); + enable_gpio_index = acpi_i2c_write_gpio(ctx, &priv->enable_gpio, + &curindex); + } + acpigen_write_resourcetemplate_footer(ctx); + + /* Wake capabilities */ + if (priv->wake) { + acpigen_write_name_integer(ctx, "_S0W", 4); + acpigen_write_prw(ctx, priv->wake, 3); + } + + /* DSD */ + if (priv->probed || priv->property_count || priv->compat_string || + reset_gpio_index >= 0 || enable_gpio_index >= 0 || + irq_gpio_index >= 0) { + char path[ACPI_PATH_MAX]; + + ret = acpi_device_path(dev, path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + + dsd = acpi_dp_new_table("_DSD"); + if (priv->compat_string) + acpi_dp_add_string(dsd, "compatible", + priv->compat_string); + if (priv->probed) + acpi_dp_add_integer(dsd, "linux,probed", 1); + if (irq_gpio_index >= 0) + acpi_dp_add_gpio(dsd, "irq-gpios", path, + irq_gpio_index, 0, + priv->irq_gpio.flags & + GPIOD_ACTIVE_LOW ? + ACPI_GPIO_ACTIVE_LOW : 0); + if (reset_gpio_index >= 0) + acpi_dp_add_gpio(dsd, "reset-gpios", path, + reset_gpio_index, 0, + priv->reset_gpio.flags & + GPIOD_ACTIVE_LOW ? + ACPI_GPIO_ACTIVE_LOW : 0); + if (enable_gpio_index >= 0) + acpi_dp_add_gpio(dsd, "enable-gpios", path, + enable_gpio_index, 0, + priv->enable_gpio.flags & + GPIOD_ACTIVE_LOW ? + ACPI_GPIO_ACTIVE_LOW : 0); + /* Add generic property list (not supported) */ + assert(!priv->property_count); + acpi_dp_add_property_list(dsd, NULL, priv->property_count); + acpi_dp_write(ctx, dsd); + } + + /* Power Resource */ + if (priv->has_power_resource) { + struct acpi_gpio reset_gpio, enable_gpio, stop_gpio; + + gpio_get_acpi(&priv->reset_gpio, &reset_gpio); + gpio_get_acpi(&priv->enable_gpio, &enable_gpio); + gpio_get_acpi(&priv->stop_gpio, &stop_gpio); + const struct acpi_power_res_params power_res_params = { + &reset_gpio, + priv->reset_delay_ms, + priv->reset_off_delay_ms, + &enable_gpio, + priv->enable_delay_ms, + priv->enable_off_delay_ms, + &stop_gpio, + priv->stop_delay_ms, + priv->stop_off_delay_ms + }; + ret = acpi_device_add_power_res(ctx, &power_res_params); + if (ret) + return log_msg_ret("power", ret); + } + if (priv->hid_desc_reg_offset) { + struct dsm_i2c_hid_config dsm_config = { + .hid_desc_reg_offset = priv->hid_desc_reg_offset, + }; + + acpi_device_write_dsm_i2c_hid(ctx, &dsm_config); + } + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + +int acpi_i2c_ofdata_to_platdata(struct udevice *dev) +{ + struct acpi_i2c_priv *priv = dev_get_priv(dev); + + gpio_request_by_name(dev, "reset-gpios", 0, &priv->reset_gpio, + GPIOD_IS_OUT); + gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable_gpio, + GPIOD_IS_OUT); + gpio_request_by_name(dev, "irq-gpios", 0, &priv->irq_gpio, GPIOD_IS_IN); + gpio_request_by_name(dev, "stop-gpios", 0, &priv->stop_gpio, + GPIOD_IS_OUT); + irq_get_by_index(dev, 0, &priv->irq); + priv->hid = dev_read_string(dev, "acpi,hid"); + if (!priv->hid) + return log_msg_ret("hid", -EINVAL); + priv->cid = dev_read_string(dev, "acpi,cid"); + dev_read_u32(dev, "acpi,uid", &priv->uid); + priv->desc = dev_read_string(dev, "acpi,desc"); + dev_read_u32(dev, "acpi,wake", &priv->wake); + priv->probed = dev_read_bool(dev, "acpi,probed"); + priv->compat_string = dev_read_string(dev, "acpi,compatible"); + priv->has_power_resource = dev_read_bool(dev, + "acpi,has-power-resource"); + dev_read_u32(dev, "acpi,hid-desc-reg-offset", + &priv->hid_desc_reg_offset); + dev_read_u32(dev, "reset-delay-ms", &priv->reset_delay_ms); + dev_read_u32(dev, "reset-off-delay-ms", &priv->reset_off_delay_ms); + dev_read_u32(dev, "enable-delay-ms", &priv->enable_delay_ms); + dev_read_u32(dev, "enable-off-delay-ms", &priv->enable_off_delay_ms); + dev_read_u32(dev, "stop-delay-ms", &priv->stop_delay_ms); + dev_read_u32(dev, "stop-off-delay-ms", &priv->stop_off_delay_ms); + dev_read_u32(dev, "stop-off-delay-ms", &priv->hid_desc_reg_offset); + + return 0; +} + +/* Use name specified in priv or build one from I2C address */ +static int acpi_i2c_get_name(const struct udevice *dev, char *out_name) +{ + struct dm_i2c_chip *chip = dev_get_parent_platdata(dev); + struct acpi_i2c_priv *priv = dev_get_priv(dev); + + snprintf(out_name, ACPI_NAME_MAX, + priv->hid_desc_reg_offset ? "H%03X" : "D%03X", + chip->chip_addr); + + return 0; +} + +struct acpi_ops acpi_i2c_ops = { + .fill_ssdt = acpi_i2c_fill_ssdt, + .get_name = acpi_i2c_get_name, +}; diff --git a/drivers/i2c/acpi_i2c.h b/drivers/i2c/acpi_i2c.h new file mode 100644 index 0000000000..1f4be29601 --- /dev/null +++ b/drivers/i2c/acpi_i2c.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __ACPI_I2C_H +#define __ACPI_I2C_H + +#include + +extern struct acpi_ops acpi_i2c_ops; + +int acpi_i2c_ofdata_to_platdata(struct udevice *dev); + +#endif diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index a577988bfb..5a3bee57b9 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -4,16 +4,19 @@ */ #include +#include #include #include #include #include +#include #include #include #include #if CONFIG_IS_ENABLED(DM_GPIO) #include #endif +#include "acpi_i2c.h" #define I2C_MAX_OFFSET_LEN 4 @@ -728,7 +731,18 @@ UCLASS_DRIVER(i2c_generic) = { .name = "i2c_generic", }; +static const struct udevice_id generic_chip_i2c_ids[] = { + { .compatible = "i2c-chip" }, + { } +}; + U_BOOT_DRIVER(i2c_generic_chip_drv) = { .name = "i2c_generic_chip_drv", .id = UCLASS_I2C_GENERIC, + .of_match = generic_chip_i2c_ids, +#if CONFIG_IS_ENABLED(ACPIGEN) + .ofdata_to_platdata = acpi_i2c_ofdata_to_platdata, + .priv_auto_alloc_size = sizeof(struct acpi_i2c_priv), +#endif + acpi_ops_ptr(&acpi_i2c_ops) }; diff --git a/include/i2c.h b/include/i2c.h index 41ee5875e7..721b4305dd 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -538,6 +538,23 @@ int i2c_emul_find(struct udevice *dev, struct udevice **emulp); */ struct udevice *i2c_emul_get_device(struct udevice *emul); +/* ACPI operations for generic I2C devices */ +extern struct acpi_ops i2c_acpi_ops; + +/** + * acpi_i2c_ofdata_to_platdata() - Read properties intended for ACPI + * + * This reads the generic I2C properties from the device tree, so that these + * can be used to create ACPI information for the device. + * + * See the i2c/generic-acpi.txt binding file for information about the + * properties. + * + * @dev: I2C device to process + * @return 0 if OK, -EINVAL if acpi,hid is not present + */ +int acpi_i2c_ofdata_to_platdata(struct udevice *dev); + #ifndef CONFIG_DM_I2C /* From patchwork Mon Jan 27 05:06:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229554 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=IHzM+ENA; 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 485dLt3PHpz9sR1 for ; Mon, 27 Jan 2020 16:18:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 35FDB8189E; Mon, 27 Jan 2020 06:12:16 +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="IHzM+ENA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BF6F381810; Mon, 27 Jan 2020 06:09:41 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 0712081818 for ; Mon, 27 Jan 2020 06:09:10 +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-x143.google.com with SMTP id i7so3257675ilr.7 for ; Sun, 26 Jan 2020 21:09:10 -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=4SwV34K465AzBQFF5SamJNyrtizv4mVVEEKx/ZYWfp4=; b=IHzM+ENAzkxgge3XxYGN9fiz05lL5SY3uALjRa9jWP8ATD/g+g+vTdd7kF5XDknbJt 5Ra2rigs0CJcMCYSrn/CbR6fT3kNtBlQmWa2i2k+OM0bkT/8JGu4MOCfrgWS6JDo2xni dvTYjQ0q2tQC2Zp3zbFadkCFvE+WvZh7yyQOw= 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=4SwV34K465AzBQFF5SamJNyrtizv4mVVEEKx/ZYWfp4=; b=cA3iCHrQU1IWAv1EmERjNK5yySha5y1tUWaxmDiw0l+8HbrLYwfRuC1sMNORarnc9n MegqhKbSBbVVotRxlSEWeeTQCq2DM3F5zMHxh1dvS8Xj91vp8IiUHZ6cZyW1uJSARhMB /MeBKF4ukWUawUA0OHGOff8120czj4JTZTLVbHFhXRle1CLR/y0uVLc+MYiJKzLZ2UaT BLYsNr6YQ5agENsvX097dhLJIbo3Ca/wBzxLcK4lA92qKhstmzY9VgVDGN/bC1nlSLnH nmjftcztrJeazDFSu7pDpZabFiHdccheLGdYM3Q9UF4aCq0ON6Etif5lg3+tyPj5o4nE 5WDA== X-Gm-Message-State: APjAAAXPj+112ImULyTqZfaiX3snOXulGKsuUv5pD5pmLFJlQkQ9p7MP CMTa3tlLCea2tTqBzoTozolINXqPjtVEmg== X-Google-Smtp-Source: APXvYqy1hfC7qbTVbBgS71XfUbwBFvFLHwuiPdw4j1V3xNP5YvfzOq6ha2b5zTkZXdQPfTWqFlBx2g== X-Received: by 2002:a92:d090:: with SMTP id h16mr12008063ilh.78.1580101749308; Sun, 26 Jan 2020 21:09:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:08 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 057/108] p2sb: Add a method to hide the bus Date: Sun, 26 Jan 2020 22:06:04 -0700 Message-Id: <20200126220508.57.I1f931671a92c0c6eaed9247d847329360accaa80@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 The P2SB bus needs to be hidden in some cases so that it does not get auto-configured by Linux. Add a method for this. Signed-off-by: Simon Glass --- drivers/misc/p2sb-uclass.c | 10 ++++++++++ include/p2sb.h | 25 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/misc/p2sb-uclass.c b/drivers/misc/p2sb-uclass.c index 1d00a73f2f..aa6d7aeef7 100644 --- a/drivers/misc/p2sb-uclass.c +++ b/drivers/misc/p2sb-uclass.c @@ -16,6 +16,16 @@ #define PCR_COMMON_IOSF_1_0 1 +int p2sb_set_hide(struct udevice *dev, bool hide) +{ + struct p2sb_ops *ops = p2sb_get_ops(dev); + + if (!ops->set_hide) + return -ENOSYS; + + return ops->set_hide(dev, hide); +} + void *pcr_reg_address(struct udevice *dev, uint offset) { struct p2sb_child_platdata *pplat = dev_get_parent_platdata(dev); diff --git a/include/p2sb.h b/include/p2sb.h index 74eb08b7ff..93e1155dca 100644 --- a/include/p2sb.h +++ b/include/p2sb.h @@ -31,13 +31,36 @@ struct p2sb_uc_priv { }; /** - * struct p2sb_ops - Operations for the P2SB (none at present) + * struct p2sb_ops - Operations for the P2SB */ struct p2sb_ops { + /** + * set_hide() - Set/clear the 'hide' bit on the p2sb + * + * This device can be hidden from the PCI bus if needed. This method + * can be called before the p2sb is probed. + * + * @dev: P2SB device + * @hide: true to hide the device, false to show it + * @return 0 if OK, -ve on error + */ + int (*set_hide)(struct udevice *dev, bool hide); }; #define p2sb_get_ops(dev) ((struct p2sb_ops *)(dev)->driver->ops) +/** + * p2sb_set_hide() - Set/clear the 'hide' bit on the p2sb + * + * This device can be hidden from the PCI bus if needed. This method + * can be called before the p2sb is probed. + * + * @dev: P2SB device + * @hide: true to hide the device, false to show it + * @return 0 if OK, -ve on error + */ +int p2sb_set_hide(struct udevice *dev, bool hide); + /** * pcr_read32/16/8() - Read from a PCR device * From patchwork Mon Jan 27 05:06:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229559 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=HBxltveP; 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 485dMr3fQnz9sR1 for ; Mon, 27 Jan 2020 16:19:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7CFB5818B2; Mon, 27 Jan 2020 06:12:27 +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="HBxltveP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AAEC4817EB; Mon, 27 Jan 2020 06:09:45 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 7CE8A80929 for ; Mon, 27 Jan 2020 06:09:11 +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-x143.google.com with SMTP id f16so6422338ilk.11 for ; Sun, 26 Jan 2020 21:09:11 -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=vc400vTr/lnxwBgjVxzGZi0Vl3AM++HG3Rb2WeiPeYE=; b=HBxltvePEOMwCnaIevCCFVqDkGVsjzobrBI9KR5//ULROsWXJtANpXOEcxtt3rEKg9 DFsASuG5PYTJFycgh9kQHnjCNLI4Rm70hNEwQj9dqHo3U9SobmadU5XUlyKKYRKmzNoL 1NEG1tKap944f/h0UqQCU6Oz/QsGmc08xkoec= 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=vc400vTr/lnxwBgjVxzGZi0Vl3AM++HG3Rb2WeiPeYE=; b=O1JBS+McrFTiQLzSkCBeg3zFvNA7mpzsujO3U4x1KlcotKQrcCeMKzP5DxAhxy6jod FeEoy7wA8tn0fHQK40Eki8EyGVUHppyncxDBVGg8mXwHkKoxm/sgHPpcWBpx1P4yCljw VclBroO1rOiL+LoLqqK2uZ23l/13oLMHJ49Xkr1OcOTFEpRgP+MSVJnhPfCzxVcBFIQD hNWqm9KlbPHkH1geQG18E6JHc6qopUyLHmZ6O+cttbs1l65S57xxuUFtR+rMt8WPR48y XAoQ3QJEsJEo7Qy7H9b0K1+Mtuo2dY5E0dreGmeTHE6EISaXXl7uukkIUP/3sqSNPV9r PpsA== X-Gm-Message-State: APjAAAU+myhblSKQU/AIUPwszYW51x296OiW4rUURF3Xm0jogCGBj2iQ RC0cKUHX2oSi1cNVRIMExwKr1+eJLk7ydg== X-Google-Smtp-Source: APXvYqxQ64plL6piul5NTGrywhOCIz7TvfJ49Ct77BtdpI/ecMV42hFG5d5W4qj8KgNFYMKXE70Vag== X-Received: by 2002:a92:5d5d:: with SMTP id r90mr12206480ilb.284.1580101750020; Sun, 26 Jan 2020 21:09:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 058/108] x86: apl: Support set_hide() in p2sb driver Date: Sun, 26 Jan 2020 22:06:05 -0700 Message-Id: <20200126220508.58.Id91837de4ede32b7f67f8cd29c7e6903a5d97f5e@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 Add support for this new method in the driver and in the fsp-s setup. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/fsp_s.c | 27 ++++++++++----------------- arch/x86/cpu/apollolake/p2sb.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c index 3ee816f44b..e7e0c30873 100644 --- a/arch/x86/cpu/apollolake/fsp_s.c +++ b/arch/x86/cpu/apollolake/fsp_s.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -19,9 +20,7 @@ #include #include #include - -#define PCH_P2SB_E0 0xe0 -#define HIDE_BIT BIT(0) +#include #define INTEL_GSPI_MAX 3 #define MAX_USB2_PORTS 8 @@ -433,12 +432,6 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset, return 0; } -static void p2sb_set_hide_bit(pci_dev_t dev, int hide) -{ - pci_x86_clrset_config(dev, PCH_P2SB_E0 + 1, HIDE_BIT, - hide ? HIDE_BIT : 0, PCI_SIZE_8); -} - /* Configure package power limits */ static int set_power_limits(struct udevice *dev) { @@ -511,15 +504,15 @@ static int set_power_limits(struct udevice *dev) int p2sb_unhide(void) { - pci_dev_t dev = PCI_BDF(0, 0xd, 0); - ulong val; - - p2sb_set_hide_bit(dev, 0); - - pci_x86_read_config(dev, PCI_VENDOR_ID, &val, PCI_SIZE_16); + struct udevice *dev; + int ret; - if (val != PCI_VENDOR_ID_INTEL) - return log_msg_ret("p2sb unhide", -EIO); + ret = uclass_find_first_device(UCLASS_P2SB, &dev); + if (ret) + return log_msg_ret("p2sb", ret); + ret = p2sb_set_hide(dev, false); + if (ret) + return log_msg_ret("hide", ret); return 0; } diff --git a/arch/x86/cpu/apollolake/p2sb.c b/arch/x86/cpu/apollolake/p2sb.c index a3d8e094e7..92bf31333c 100644 --- a/arch/x86/cpu/apollolake/p2sb.c +++ b/arch/x86/cpu/apollolake/p2sb.c @@ -14,6 +14,9 @@ #include #include +#define PCH_P2SB_E0 0xe0 +#define HIDE_BIT BIT(0) + struct p2sb_platdata { #if CONFIG_IS_ENABLED(OF_PLATDATA) struct dtd_intel_apl_p2sb dtplat; @@ -125,6 +128,29 @@ static int apl_p2sb_probe(struct udevice *dev) return 0; } +static void p2sb_set_hide_bit(struct udevice *dev, bool hide) +{ + dm_pci_clrset_config8(dev, PCH_P2SB_E0 + 1, HIDE_BIT, + hide ? HIDE_BIT : 0); +} + +static int apl_p2sb_set_hide(struct udevice *dev, bool hide) +{ + u16 vendor; + + if (!CONFIG_IS_ENABLED(PCI)) + return -EPERM; + p2sb_set_hide_bit(dev, hide); + + dm_pci_read_config16(dev, PCI_VENDOR_ID, &vendor); + if (hide && vendor != 0xffff) + return log_msg_ret("hide", -EEXIST); + else if (!hide && vendor != PCI_VENDOR_ID_INTEL) + return log_msg_ret("unhide", -ENOMEDIUM); + + return 0; +} + static int p2sb_child_post_bind(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) @@ -141,6 +167,10 @@ static int p2sb_child_post_bind(struct udevice *dev) return 0; } +struct p2sb_ops apl_p2sb_ops = { + .set_hide = apl_p2sb_set_hide, +}; + static const struct udevice_id apl_p2sb_ids[] = { { .compatible = "intel,apl-p2sb" }, { } From patchwork Mon Jan 27 05:06:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229556 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=Pa/LW8D9; 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 485dMG1tj2z9sR1 for ; Mon, 27 Jan 2020 16:18:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 13F3D81898; Mon, 27 Jan 2020 06:12:21 +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="Pa/LW8D9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBCE1817EB; Mon, 27 Jan 2020 06:09:44 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 047168180F for ; Mon, 27 Jan 2020 06:09:11 +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-xd44.google.com with SMTP id i11so8535812ioi.12 for ; Sun, 26 Jan 2020 21:09:11 -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=DXrgc9RQCo0+TEnqAwY2mnp/GTIdiwKpZ98lt1jQ9dI=; b=Pa/LW8D9JPR1fahsh7b3gaEXwy9PnJM/RCARLxtHes152tKlC2cdVvKYziZonu7is0 MyWRZpndAEaRbfXvd0M2YxZw52NGQ7jVSIVQqQLRygH5GYRbgOx5yXPYOVbnQRQiNS76 kqWaiWxkuPkX0PmbDNquW9GsSmbzSX52+YMIY= 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=DXrgc9RQCo0+TEnqAwY2mnp/GTIdiwKpZ98lt1jQ9dI=; b=DulHyxWLK1z0f48sD14BiXznrAXNrzvq1D27RcCFuLNMk+DBLAIevpHrAFHXddupJR cKfpBfL8mNxd72tpWiKSZoRJqhXRkW1Uz14+hUrmVvhN3aGd1vtpjXvtzBx9+/eomkFp o5rbR06UlVRqJT3IZGDift1nWb881jX3ccUhG+npgb5Tl7CvrJMmdTQe/jh2uQ7YL/Ea fZlMtr20VsD/I7gb/lSdR34RUGB7fwpuGHU5hhJFQHyWK+fcxxs8mVTcOpBW+4imRvs5 ddN+gpVyMmLdWmn1g+RPb/PTMK9QNXaqvOw4BYQcCdvc6uuVQwycFh5OVJ5kw8bIkyo4 aGSw== X-Gm-Message-State: APjAAAXO/wTb8d2LeOMjSeRe8F4njUJSXT4PmE4Yfxu/V87CmpVR1Qrt kH4077uJuOzlUTSZk2GlfT+Fj9Cr7+IEQw== X-Google-Smtp-Source: APXvYqyjSKCXUxgrzi6qVjGF6iWFMP/whj0KSjVl3Jc9UV+yHVvGlJHaFbzjypB5mn/PJV822DMasw== X-Received: by 2002:a5e:840f:: with SMTP id h15mr11796127ioj.286.1580101750656; Sun, 26 Jan 2020 21:09:10 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:10 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 059/108] x86: apl: Hide the p2sb on exit from U-Boot Date: Sun, 26 Jan 2020 22:06:06 -0700 Message-Id: <20200126220508.59.I68d05c644cec1ef05b0845010253943c44385616@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 This confuses Linux's PCI probing so needs to be hidden when booting Linux. Add a remove() method to handle this. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/p2sb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/cpu/apollolake/p2sb.c b/arch/x86/cpu/apollolake/p2sb.c index 92bf31333c..9f4b1a0d92 100644 --- a/arch/x86/cpu/apollolake/p2sb.c +++ b/arch/x86/cpu/apollolake/p2sb.c @@ -151,6 +151,17 @@ static int apl_p2sb_set_hide(struct udevice *dev, bool hide) return 0; } +static int apl_p2sb_remove(struct udevice *dev) +{ + int ret; + + ret = apl_p2sb_set_hide(dev, true); + if (ret) + return log_msg_ret("hide", ret); + + return 0; +} + static int p2sb_child_post_bind(struct udevice *dev) { #if !CONFIG_IS_ENABLED(OF_PLATDATA) @@ -181,9 +192,12 @@ U_BOOT_DRIVER(apl_p2sb_drv) = { .id = UCLASS_P2SB, .of_match = apl_p2sb_ids, .probe = apl_p2sb_probe, + .remove = apl_p2sb_remove, + .ops = &apl_p2sb_ops, .ofdata_to_platdata = apl_p2sb_ofdata_to_platdata, .platdata_auto_alloc_size = sizeof(struct p2sb_platdata), .per_child_platdata_auto_alloc_size = sizeof(struct p2sb_child_platdata), .child_post_bind = p2sb_child_post_bind, + .flags = DM_FLAG_OS_PREPARE, }; From patchwork Mon Jan 27 05:06:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229557 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=a1lnkLyN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dMR3519z9sR1 for ; Mon, 27 Jan 2020 16:18:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 26DDF818A4; Mon, 27 Jan 2020 06:12:23 +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="a1lnkLyN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 08AD88180F; Mon, 27 Jan 2020 06:09:46 +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 A16958177D for ; Mon, 27 Jan 2020 06:09:12 +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 s18so6086092iln.0 for ; Sun, 26 Jan 2020 21:09:12 -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=mbydVlg6iS5lleWW29CjAAIIVlxDBjptBiBHZbkAoMA=; b=a1lnkLyN6bZAMxWebffFkcE3kFEgZ0tWFee+TE72OUAd7rNdzC0dLjGHHokQcCXIUd /cWpKXtSgN9xHl9LuhXy+95NdXTdfv5arZK8h8AR1LPGTXtXo0mbcPJsVIKfw9NToeuh FicGv22Wpz6FtNIfguk1hyPbldK/xOMT67gUQ= 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=mbydVlg6iS5lleWW29CjAAIIVlxDBjptBiBHZbkAoMA=; b=ox+vnbbYzj01WJmHBGRr4wN5x2B3UiHo/YBnGXXG5VJb4HSDRQWk9h/vtNnI9HSNSs ArO1yUnQ13+xVVU7Q8UoXXi4a60wNHyfbKFz7vRrcv/dB2CM2mK1nMCNyaOX182Zm8hV YxCDYJDD8CZecLskEE/n0byg8bJy60Ssowx/uMh64IhyY9FYsN7p9OqdQ+WJ8C5OiyAD oMIH7vn6VgFAkAFg+OpcQngq8pc0Kc3cGgHPRytwN4ERae41iS5ITXKcnMGJnZg42Uvm 2hPmb8+Eotkcramz8NQLoBp/dKx8tFmDGa3G98Bnkpvud0vA7WvfvcuWvtx49Qf0C41N PesQ== X-Gm-Message-State: APjAAAWeKQRZ1vn486+zuu/KeR7kTUv49Ir5LD3eDZ39kVd1nXncia9P IDH8V6FsyvTrokcHdINkratpd+2ZvXxFxQ== X-Google-Smtp-Source: APXvYqxhUmhvPyFhwKGvyKSiUsPsBVX2et1zCw00td8yxw7P07OId9cYgYMx4phjfiMcIGIeBBMQDA== X-Received: by 2002:a92:5cda:: with SMTP id d87mr14069725ilg.100.1580101751400; Sun, 26 Jan 2020 21:09:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:11 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 060/108] pmc: Move common registers to the header file Date: Sun, 26 Jan 2020 22:06:07 -0700 Message-Id: <20200126220508.60.Idff8b7c7b8504c20481771fe39c10976df3e4f5d@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 These registers need to be accesses from ACPI code, so move them to the header file. Signed-off-by: Simon Glass --- drivers/power/acpi_pmc/acpi-pmc-uclass.c | 9 --------- include/power/acpi_pmc.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/power/acpi_pmc/acpi-pmc-uclass.c b/drivers/power/acpi_pmc/acpi-pmc-uclass.c index d43de87126..dd2a62f35c 100644 --- a/drivers/power/acpi_pmc/acpi-pmc-uclass.c +++ b/drivers/power/acpi_pmc/acpi-pmc-uclass.c @@ -15,15 +15,6 @@ #include #include -enum { - PM1_STS = 0x00, - PM1_EN = 0x02, - PM1_CNT = 0x04, - - GPE0_STS = 0x20, - GPE0_EN = 0x30, -}; - struct tco_regs { u32 tco_rld; u32 tco_sts; diff --git a/include/power/acpi_pmc.h b/include/power/acpi_pmc.h index 1f50c23f5f..5fbf745136 100644 --- a/include/power/acpi_pmc.h +++ b/include/power/acpi_pmc.h @@ -6,10 +6,22 @@ #ifndef __ACPI_PMC_H #define __ACPI_PMC_H +#ifndef __ACPI__ + enum { GPE0_REG_MAX = 4, }; +enum { + PM1_STS = 0x00, + PM1_EN = 0x02, + PM1_CNT = 0x04, + PM1_TMR = 0x08, + + GPE0_STS = 0x20, + GPE0_EN = 0x30, +}; + /** * struct acpi_pmc_upriv - holds common data for the x86 PMC * @@ -182,4 +194,6 @@ void pmc_dump_info(struct udevice *dev); */ int pmc_gpe_init(struct udevice *dev); +#endif /* !__ACPI__ */ + #endif From patchwork Mon Jan 27 05:06:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229560 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=kFLzmmPk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dN35d09z9sR1 for ; Mon, 27 Jan 2020 16:19:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C7FC1818B7; Mon, 27 Jan 2020 06:12:29 +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="kFLzmmPk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 26BB3817BC; Mon, 27 Jan 2020 06:09:47 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 7372D8178D for ; Mon, 27 Jan 2020 06:09:13 +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-xd42.google.com with SMTP id c16so8567280ioh.6 for ; Sun, 26 Jan 2020 21:09:13 -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=qstM9JUkkzF7/yaL+cDNVKNSx6cTXrHb2LQO+HawbOw=; b=kFLzmmPknPZNb2XfPKGPNqBCB699FAmGKeXoF3dKM+aLOtZms2luVT9cKSbT3vdoxu yLEebm04GhJmoetHXaD8hhRzjW+NdaYqE2BICduZTwAGgrS8CNaMUOAcGm5JoMou5+/0 kuNUa8TBKCeZxnFRZxUUx5QJ8y6ncpm2speRg= 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=qstM9JUkkzF7/yaL+cDNVKNSx6cTXrHb2LQO+HawbOw=; b=Q8Nfn60s0y+Dp/t5ZJfS73cJZM2mOISEhSqgjScufJARkA5yHSoV4KLcmfER4/53sz 1H01epV1RhbO+KCSZ/Xtrp0dnxbH3OjaUiEO8BTJXqcWE7GhbfYolZS7EAiFBXm+vGgu bBEQi05kI8RzmQl1EFBc98dAdpvRnbgI0F1N4T9s8vTLh7tUc1qsyn3Tjrapu2RccNsc f8QmFU3wkXaV1SMk7LoMZqezvrU/EnVvIfuqUrTDjE1yAF1CUnVlDrvKID2I3NxDYrg0 mE8G+CAiI+sxy3mqsfum87esSpU3UDJktjIbxzPtXYiIGZPtUtVdUeD6frSp0LDQucke X+kg== X-Gm-Message-State: APjAAAXyCKMJ6VqDkZpkh7PCje/LYRmeuMS1jNxo/2HxfyOsReEqI+VY 3knYf0i16s2QKgxY/E3aQFHVdfhpkkUv2Q== X-Google-Smtp-Source: APXvYqxqHX3JTDHDqu2FDxYP+vfwaveP+buIip9W6Itc5i8zUscO/M5E+pPqVz4NylpCzojKcNBZEg== X-Received: by 2002:a05:6602:210a:: with SMTP id x10mr9666966iox.151.1580101752106; Sun, 26 Jan 2020 21:09:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:11 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 061/108] x86: irq: Support flags for acpi_gpe Date: Sun, 26 Jan 2020 22:06:08 -0700 Message-Id: <20200126220508.61.Ib4031b53044900874165fc11e273f5e2571306c4@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 This binding currently has a flags cell but it is not used. Make use of it to create ACPI tables for interrupts. Signed-off-by: Simon Glass --- arch/x86/cpu/acpi_gpe.c | 22 +++++++++++++++++++ .../interrupt-controller/x86-irq.h | 14 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 include/dt-bindings/interrupt-controller/x86-irq.h diff --git a/arch/x86/cpu/acpi_gpe.c b/arch/x86/cpu/acpi_gpe.c index ccc2622b23..239d8319e9 100644 --- a/arch/x86/cpu/acpi_gpe.c +++ b/arch/x86/cpu/acpi_gpe.c @@ -5,9 +5,12 @@ */ #include +#include #include #include #include +#include +#include struct acpi_gpe_priv { ulong acpi_base; @@ -56,6 +59,24 @@ static int acpi_gpe_ofdata_to_platdata(struct udevice *dev) static int acpi_gpe_of_xlate(struct irq *irq, struct ofnode_phandle_args *args) { irq->id = args->args[0]; + irq->flags = args->args[1]; + + return 0; +} + +static int acpi_gpe_get_acpi(const struct irq *irq, struct acpi_irq *acpi_irq) +{ + memset(acpi_irq, '\0', sizeof(*acpi_irq)); + acpi_irq->pin = irq->id; + acpi_irq->mode = irq->flags & IRQ_TYPE_EDGE_BOTH ? + ACPI_IRQ_EDGE_TRIGGERED : ACPI_IRQ_LEVEL_TRIGGERED; + acpi_irq->polarity = irq->flags & + (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW) ? + ACPI_IRQ_ACTIVE_LOW : ACPI_IRQ_ACTIVE_HIGH; + acpi_irq->shared = irq->flags & X86_IRQ_TYPE_SHARED ? + ACPI_IRQ_SHARED : ACPI_IRQ_EXCLUSIVE; + acpi_irq->wake = irq->flags & X86_IRQ_TYPE_WAKE ? ACPI_IRQ_WAKE : + ACPI_IRQ_NO_WAKE; return 0; } @@ -63,6 +84,7 @@ static int acpi_gpe_of_xlate(struct irq *irq, struct ofnode_phandle_args *args) static const struct irq_ops acpi_gpe_ops = { .read_and_clear = acpi_gpe_read_and_clear, .of_xlate = acpi_gpe_of_xlate, + .get_acpi = acpi_gpe_get_acpi, }; static const struct udevice_id acpi_gpe_ids[] = { diff --git a/include/dt-bindings/interrupt-controller/x86-irq.h b/include/dt-bindings/interrupt-controller/x86-irq.h new file mode 100644 index 0000000000..9e0b4612e1 --- /dev/null +++ b/include/dt-bindings/interrupt-controller/x86-irq.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + * + * This provides additional flags used by x86. + */ + +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_X86_IRQ_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_X86_IRQ_H + +#define X86_IRQ_TYPE_SHARED (1 << 4) +#define X86_IRQ_TYPE_WAKE (1 << 5) + +#endif From patchwork Mon Jan 27 05:06:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229558 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=Iluk2krS; 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 485dMf0tHZz9sR1 for ; Mon, 27 Jan 2020 16:19:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC06E817D3; Mon, 27 Jan 2020 06:12:24 +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="Iluk2krS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73653817BC; Mon, 27 Jan 2020 06:09:46 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 54D9581813 for ; Mon, 27 Jan 2020 06:09:14 +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-xd42.google.com with SMTP id h8so8566029iob.2 for ; Sun, 26 Jan 2020 21:09:14 -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=9nuhhkS9xsb29wkuZvNzcINY1kioi1mudAgVt2g+Jxg=; b=Iluk2krSD9Y1bppWJZ5ohJ5fgzKIIYAgCt03/qHX4pWYp6krl+chN8303jdjuowmR/ 9eBI+C4r3errsjoKTrLYZ5Igs5DCJ65uWmw4XzywiKUCzDvjs+Uw4CuQb+1vrJhrYb+g 3QMkQvJM+gzvaTwz7/uXPk+CmDF9t7WMdYHJo= 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=9nuhhkS9xsb29wkuZvNzcINY1kioi1mudAgVt2g+Jxg=; b=FJMfUZV2h00TN9ViSPuQaDNie79eCY7pAy9p9Fn1qwoHNNRBVq1XGY2JgZKTgvmcJA nTw4x6ExZ2dbwUo+vUTOVvmjYEDwv6nJIBbQ1uEymP0tX2UXOxkxpr4rfDtfJQ7Dl+5g OWxyz3q2AvLoduJ02X4/RmvX4zWKW3ERo55jADomBoJZmUCBY0413cmRza8tNIk9hxzR 5Td67fipswDzOGnlRpWfL+neik4ru37k8yzJnvOS7YK3fh/0r/iPWZkBcM6x4xMkVdUs SQq2/+QSWLYt9HQ/pIoRGPOLsMbo+//1OLz01YuVsmHk2rtfXsTcS1VHpcYFRlzfeJLa GwKg== X-Gm-Message-State: APjAAAU4wg5BjKO1ORQl6XabIKXJcoSSxc9ZKpF5s2e9jkKUxY7t1EdY bDz4Vvuc+CXHvsR9bUnNxXNBZyNcOWQnug== X-Google-Smtp-Source: APXvYqx3mO1XQICFykBXX3PZjONFaU13T7/oWeAYypXmdDMlUSz9XybwTSmHAxJX8U+9E2ECBaQXbQ== X-Received: by 2002:a5d:824c:: with SMTP id n12mr11122518ioo.234.1580101753006; Sun, 26 Jan 2020 21:09:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:12 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 062/108] x86: Add debugging to table writing Date: Sun, 26 Jan 2020 22:06:09 -0700 Message-Id: <20200126220508.62.I7759eca88ecdfe2cab1769ab2c28828f5b026012@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 Writing tables is currently pretty opaque. Add a bit of debugging to the process so we can see what tables are written and where they start/end in memory. Signed-off-by: Simon Glass --- arch/x86/lib/tables.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index e359828c8e..80abe1584a 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -19,21 +19,32 @@ */ typedef ulong (*table_write)(ulong addr); -static table_write table_write_funcs[] = { +/** + * struct table_info - Information about each table to write + * + * @name: Name of table (for debugging) + * @write: Function to call to write this table + */ +struct table_info { + const char *name; + table_write write; +}; + +static struct table_info table_list[] = { #ifdef CONFIG_GENERATE_PIRQ_TABLE - write_pirq_routing_table, + { "pirq", write_pirq_routing_table }, #endif #ifdef CONFIG_GENERATE_SFI_TABLE - write_sfi_table, + { "sfi", write_sfi_table, }, #endif #ifdef CONFIG_GENERATE_MP_TABLE - write_mp_table, + { "mp", write_mp_table, }, #endif #ifdef CONFIG_GENERATE_ACPI_TABLE - write_acpi_tables, + { "acpi", write_acpi_tables, }, #endif #ifdef CONFIG_GENERATE_SMBIOS_TABLE - write_smbios_table, + { "smbios", write_smbios_table, }, #endif }; @@ -61,15 +72,18 @@ void write_tables(void) #endif int i; - for (i = 0; i < ARRAY_SIZE(table_write_funcs); i++) { - rom_table_end = table_write_funcs[i](rom_table_start); + debug("Writing tables to %x:\n", rom_table_start); + for (i = 0; i < ARRAY_SIZE(table_list); i++) { + const struct table_info *table = &table_list[i]; + + rom_table_end = table->write(rom_table_start); rom_table_end = ALIGN(rom_table_end, ROM_TABLE_ALIGN); #ifdef CONFIG_SEABIOS table_size = rom_table_end - rom_table_start; high_table = (u32)high_table_malloc(table_size); if (high_table) { - table_write_funcs[i](high_table); + table->write(high_table); cfg_tables[i].start = high_table; cfg_tables[i].size = table_size; @@ -78,6 +92,8 @@ void write_tables(void) } #endif + debug("- wrote '%s' to %x, end %x\n", table->name, + rom_table_start, rom_table_end); rom_table_start = rom_table_end; } @@ -86,4 +102,5 @@ void write_tables(void) cfg_tables[i].size = 0; write_coreboot_table(CB_TABLE_ADDR, cfg_tables); #endif + debug("- done writing tables\n"); } From patchwork Mon Jan 27 05:06:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229561 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=C0JDjri2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dNG4zjmz9sRR for ; Mon, 27 Jan 2020 16:19:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6F9181883; Mon, 27 Jan 2020 06:12:33 +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="C0JDjri2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 891DB81803; Mon, 27 Jan 2020 06:09:48 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 147D9817FC for ; Mon, 27 Jan 2020 06:09:15 +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-xd42.google.com with SMTP id s24so7029547iog.5 for ; Sun, 26 Jan 2020 21:09:15 -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=3qKhF8ItqNJ7VpDuEtgzqF9M2BJokiA9hNwqDU8d6tA=; b=C0JDjri2v27tnBOLRPr29b4LlleudDJg9GNN5zl8uW4awtZVS2x+5ktuEOjqr3S80L 11kUIiSxd8Lw3ZXh9YvvOjPHDx2qqb7OC2w3GyZMqrd1NS2cEYumOQZSfL6ZDrd3dx7k KHFblgGw8IE2ELLdbdbpoD9b0GhWImazIBERM= 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=3qKhF8ItqNJ7VpDuEtgzqF9M2BJokiA9hNwqDU8d6tA=; b=Tu5tcoxti3uyNncDNNWoYtMHC90fIlesNud/8r7SguGOHObP+K4t0u1x27+kxXUgyo fo98naXnZYLLDhLmxtC9JYNhNU1uXlYWhy0qCIWdpnVP9UuS10K56HSFe1XpMkXhitau LakihLpSHSElX4rvGAR+CpRSEI1YioVR6h80GMBeG7x8B1EOPW06CNc8/MwyG2FWxIk9 8W1N+gH5oSxDBtTQDnRrgRgat8VhiHBftDoA4WglbXA0prrt4cRGB67Vt/w5t+y+99jj P9Vr9Uy5Vyc2DYkgnXDsNJQYYiipuXNyo2ThgsQcFo06UFGUCtOmPC8i3I+3e5Vaoo/U r4iQ== X-Gm-Message-State: APjAAAXYZ48Kn6jjChUroOGX14Ck516+lhLUGwBUxxunQjyuZ5SimtMJ NkaiQR008JsY3v15MPervKLYdaMVdUTp0w== X-Google-Smtp-Source: APXvYqxcYTyjsQv1nSSPKnuoje0XkPDiFwcl+6H2Zmedp/ePOS+uHdKsGXocNyp/YBGuuByr7vZVdw== X-Received: by 2002:a6b:ee07:: with SMTP id i7mr10686275ioh.244.1580101753843; Sun, 26 Jan 2020 21:09:13 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:13 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 063/108] x86: Rename board_final_cleanup() to board_final_init() Date: Sun, 26 Jan 2020 22:06:10 -0700 Message-Id: <20200126220508.63.I2762a08266cb540453f944c69ce0031ad0fe7c05@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 This function sounds like something that is called when U-Boot is about to jump to Linux. In fact it is an init function. Rename it to reduce confusion. Signed-off-by: Simon Glass --- arch/x86/cpu/coreboot/coreboot.c | 4 ++-- arch/x86/cpu/cpu.c | 8 ++++---- arch/x86/cpu/efi/app.c | 2 +- arch/x86/cpu/quark/quark.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index 0c4c6348d1..874fdfc17e 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -40,7 +40,7 @@ int print_cpuinfo(void) return default_print_cpuinfo(); } -static void board_final_cleanup(void) +static void board_final_init(void) { /* * Un-cache the ROM so the kernel has one @@ -78,7 +78,7 @@ int last_stage_init(void) if (CONFIG_IS_ENABLED(USB_KEYBOARD)) usb_init(); - board_final_cleanup(); + board_final_init(); return 0; } diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 3891de088f..a2df92cec9 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -175,10 +175,10 @@ void show_boot_progress(int val) #if !defined(CONFIG_SYS_COREBOOT) && !defined(CONFIG_EFI_STUB) /* - * Implement a weak default function for boards that optionally - * need to clean up the system before jumping to the kernel. + * Implement a weak default function for boards that need to do some final init + * before the system is ready. */ -__weak void board_final_cleanup(void) +__weak void board_final_init(void) { } @@ -186,7 +186,7 @@ int last_stage_init(void) { struct acpi_fadt __maybe_unused *fadt; - board_final_cleanup(); + board_final_init(); #ifdef CONFIG_HAVE_ACPI_RESUME fadt = acpi_find_fadt(); diff --git a/arch/x86/cpu/efi/app.c b/arch/x86/cpu/efi/app.c index 13077411dc..d92153d922 100644 --- a/arch/x86/cpu/efi/app.c +++ b/arch/x86/cpu/efi/app.c @@ -23,7 +23,7 @@ int print_cpuinfo(void) return default_print_cpuinfo(); } -void board_final_cleanup(void) +void board_final_init(void) { } diff --git a/arch/x86/cpu/quark/quark.c b/arch/x86/cpu/quark/quark.c index d6611eea5d..912eca9299 100644 --- a/arch/x86/cpu/quark/quark.c +++ b/arch/x86/cpu/quark/quark.c @@ -360,7 +360,7 @@ int arch_misc_init(void) return 0; } -void board_final_cleanup(void) +void board_final_init(void) { struct quark_rcba *rcba; u32 base, val; diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c index 5eff0f99aa..8a6108fb32 100644 --- a/arch/x86/lib/fsp/fsp_common.c +++ b/arch/x86/lib/fsp/fsp_common.c @@ -45,7 +45,7 @@ int fsp_init_phase_pci(void) return status ? -EPERM : 0; } -void board_final_cleanup(void) +void board_final_init(void) { u32 status; From patchwork Mon Jan 27 05:06:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229562 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=WzvlmAX+; 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 485dNT388Yz9sR1 for ; Mon, 27 Jan 2020 16:19:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C236F81802; Mon, 27 Jan 2020 06:12:35 +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="WzvlmAX+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 65E2C8180F; Mon, 27 Jan 2020 06:09:49 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 E680C817A7 for ; Mon, 27 Jan 2020 06:09:15 +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-xd44.google.com with SMTP id i11so8535924ioi.12 for ; Sun, 26 Jan 2020 21:09:15 -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=FKuEWOVIRxDBhgf/02KxwfjVat1ebEEGSVkp/MzgTwk=; b=WzvlmAX+0WPX2fsHi6sAN/hf/CbYIPPO5pEJ9ZW6YgsaKlk30SYAFDNGbjUVojn230 pSqpBiELie1yGTv3VV2xZAqfpRdCQ8zPYJo1aKkUcB82GH7pz32/Bg20/+H0R7x1JKg8 grTr6JzusXuXsDteqmi+TjL9gyZ/icDDIB3yU= 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=FKuEWOVIRxDBhgf/02KxwfjVat1ebEEGSVkp/MzgTwk=; b=QLGKneX4xDSbNAndr/lq6uSDOiO1/kYyvBdGllFB0ZczvPkrbEz3gClIVlthFY/d7y GWpzh6efo3MCMJi+S45L/dE7vFFQNuhDiLhAsYXEUefGX4wYdJiDKZOsDLq3e0AwepZg ACM3awDFGJ/M39oYScFM1o6299oVUPxcuXk9HdHlkRFLUJf/HquCW/+lOv+f2AP4XQdL DJfQyhH/sRToimUJobJNqE0DzKO35I+YMSbytL0wZEsXeRpFA+KFxVnzAwBE0nVrpgC+ Ng5uRsB0gFF1fm0y66CeaOfwg6PYvMkjGZaPvGf1pndEKoGE4g1JUgR42fc+UYhxfWt7 cnkg== X-Gm-Message-State: APjAAAW2riBM1/ICwMiMleKTgW0M9M5KwE9gZ5nIVB6LEWrhUdxJ9KHi 6UMfIQjjXjlL6foaz73ORmt0NNfd0MaA4w== X-Google-Smtp-Source: APXvYqz67WPVOpO9EftgWWehp4xDx+jnfdtxqPTn3/92RiwBt3xjmUfV2mtvSGs8bSmZopKbGIJSSA== X-Received: by 2002:a05:6638:6af:: with SMTP id d15mr11154314jad.74.1580101754663; Sun, 26 Jan 2020 21:09:14 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:14 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 064/108] acpi: Enable ACPI table generation by default on x86 Date: Sun, 26 Jan 2020 22:06:11 -0700 Message-Id: <20200126220508.64.I4c0c2ab2332368225244b54e2762d8acd78b4982@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 This should ideally be used by all x86 boards in U-Boot. Enable it by default. If some boards don't use it, the cost is small. Signed-off-by: Simon Glass --- arch/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/Kconfig b/arch/Kconfig index ae9c93ed7b..4454fb0f9a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -187,6 +187,7 @@ config X86 imply PCH imply RTC_MC146818 imply IRQ + imply ACPIGEN # Thing to enable for when SPL/TPL are enabled: SPL imply SPL_DM From patchwork Mon Jan 27 05:06:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229564 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=YBmK4PRl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dNw4VM0z9sR1 for ; Mon, 27 Jan 2020 16:20:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2B37A818C2; Mon, 27 Jan 2020 06:12:41 +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="YBmK4PRl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 523CB8180F; Mon, 27 Jan 2020 06:09:53 +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-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 6D964816E1 for ; Mon, 27 Jan 2020 06:09:17 +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-xd36.google.com with SMTP id e7so8540115iof.11 for ; Sun, 26 Jan 2020 21:09:17 -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=Mx171XIvZyc3D0MMTHRgqgqg/gmSjIg3pZKySdKhje8=; b=YBmK4PRluLMfZ1JuklZSGadYxoaNm/deuwv+1kht+wU9RvKGeosOGYBiOMexvF30eR l/BUR6BEGYpil4FgzC4EYwOpAzdq/M7qrzkOCIGzfGMHFb8kgBz0a8My2Q31xJpxsz+r 0OOVwLjxNaBEM53ngJHRY8EXcJSo9IPwcNk2g= 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=Mx171XIvZyc3D0MMTHRgqgqg/gmSjIg3pZKySdKhje8=; b=mSR42Bb2w9g32Jc7LECnWP7zCTbvUFhBcvh8WeSafYIAAA40g+eLvBQ63o+nEsDVuo ESUuKJBl2KvYEMv+fcE2lopvw4XiR12kH1i1v4w/vy+i9FeiLBiqaHp/887JpkZo2gM7 dyXwGwHLWEKUrLBZxgzOrHqoMVw7l6R2pdTVh6ZgTFK+RlXf4hCW1Fo7xlEuQkFq8zG2 4KBrAFuA6EtXc6bK3pkeG01yC+itOY/2OYrMNba0FVOVMJEoFjxtR/bgHg8a/TIZKTjq EAaVneYgZZ89uAkbmdcuO2lhOOHPMVoIxS9Oq6ckwCRMESNeL++u7wfRsBWgAo353Xe1 G2lA== X-Gm-Message-State: APjAAAXezWBquRU1klBwVie1GYTJBFI/f0JJNGsePEQNoapT1+/zZDg9 om0aaxz3HTAHNRj1Qywooc9ZB8lmjkSpGg== X-Google-Smtp-Source: APXvYqzMNy7PmIJXMmItCyAG+ndcPnoHoV8Dvy0J6OFDN3peaPf9Ud1nJDQDoDE4ZL0s0verQDT6Nw== X-Received: by 2002:a5e:c60a:: with SMTP id f10mr11316818iok.295.1580101755472; Sun, 26 Jan 2020 21:09:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 065/108] acpi: Add cros_ec tables Date: Sun, 26 Jan 2020 22:06:12 -0700 Message-Id: <20200126220508.65.I8cf0259a2e9b2c2d3cfa2e31ffef1210e42ffd78@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 Add ASL files for the Chrome OS EC, taken from coreboot. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi/cros_ec/ac.asl | 22 + arch/x86/include/asm/acpi/cros_ec/als.asl | 56 ++ arch/x86/include/asm/acpi/cros_ec/battery.asl | 411 +++++++++++++ arch/x86/include/asm/acpi/cros_ec/cros_ec.asl | 57 ++ arch/x86/include/asm/acpi/cros_ec/ec.asl | 557 ++++++++++++++++++ arch/x86/include/asm/acpi/cros_ec/emem.asl | 53 ++ .../asm/acpi/cros_ec/keyboard_backlight.asl | 52 ++ arch/x86/include/asm/acpi/cros_ec/pd.asl | 15 + arch/x86/include/asm/acpi/cros_ec/superio.asl | 159 +++++ arch/x86/include/asm/acpi/cros_ec/tbmc.asl | 23 + 10 files changed, 1405 insertions(+) create mode 100644 arch/x86/include/asm/acpi/cros_ec/ac.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/als.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/battery.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/cros_ec.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/ec.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/emem.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/pd.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/superio.asl create mode 100644 arch/x86/include/asm/acpi/cros_ec/tbmc.asl diff --git a/arch/x86/include/asm/acpi/cros_ec/ac.asl b/arch/x86/include/asm/acpi/cros_ec/ac.asl new file mode 100644 index 0000000000..80e0ebd3ad --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/ac.asl @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2012 The Chromium OS Authors. All rights reserved. + */ + +// Scope (EC0) + +Device (AC) +{ + Name (_HID, "ACPI0003") + Name (_PCL, Package () { \_SB }) + + Method (_PSR) + { + Return (ACEX) + } + + Method (_STA) + { + Return (0x0F) + } +} diff --git a/arch/x86/include/asm/acpi/cros_ec/als.asl b/arch/x86/include/asm/acpi/cros_ec/als.asl new file mode 100644 index 0000000000..f3d40f889c --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/als.asl @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + */ + +Device (ALS) +{ + Name (_HID, "ACPI0008") + Name (_UID, 1) + + Method (_STA, 0, NotSerialized) + { + Return (0xF) + } + + /* + * Returns the current ambient light illuminance reading in lux + * + * 0: Reading is below the range of sensitivity of the sensor + * -1: Reading is above the range or sensitivity of the sensor + */ + Method (_ALI, 0, NotSerialized) + { + Return (^^ALS0) + } + + /* + * Returns a recommended polling frequency in tenths of seconds + * + * 0: No need to poll, async notifications will indicate changes + */ + Name (_ALP, 10) + + /* + * Returns a package of packages where each tuple consists of a pair + * of integers mapping ambient light illuminance to display brightness. + * + * {, } + * + * Ambient light illuminance values are specified in lux. + * + * Display luminance adjustment values are relative percentages where + * 100 is no (0%) display brightness adjustment. Values <100 indicate + * negative adjustment (dimming) and values >100 indicate positive + * adjustment (brightening). + * + * This is currently unused by the Linux kernel ACPI ALS driver but + * is required by the ACPI specification so just define a basic two + * point response curve. + */ + Name (_ALR, Package () + { + Package () { 70, 30 }, // Min { -30% adjust at 30 lux } + Package () { 150, 1000 } // Max { +50% adjust at 1000 lux } + }) +} diff --git a/arch/x86/include/asm/acpi/cros_ec/battery.asl b/arch/x86/include/asm/acpi/cros_ec/battery.asl new file mode 100644 index 0000000000..f106088231 --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/battery.asl @@ -0,0 +1,411 @@ +/*/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2011 The Chromium OS Authors. All rights reserved. + */ + +// Scope (EC0) + +/* Mutex for EC battery index interface */ +Mutex (BATM, 0) + +// Wait for desired battery index to be presented in shared memory +// Arg0 = battery index +// Returns Zero on success, One on error. +Method (BTSW, 1) +{ +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + If (LEqual (BTIX, Arg0)) { + Return (Zero) + } + If (LGreaterEqual (Arg0, BTCN)) { + Return (One) + } + Store (Arg0, \_SB.PCI0.LPCB.EC0.BTID) + Store (5, Local0) // Timeout 5 msec + While (LNotEqual (BTIX, Arg0)) + { + Sleep (1) + Decrement (Local0) + If (LEqual (Local0, Zero)) + { + Return (One) + } + } +#else + If (LNotEqual (0, Arg0)) { + Return (One) + } +#endif + Return (Zero) +} + +// _STA implementation. +// Arg0 = battery index +Method (BSTA, 1, Serialized) +{ + If (Acquire (^BATM, 1000)) { + Return (Zero) + } + + If (And(Not(BTSW (Arg0)), BTEX)) { + Store (0x1F, Local0) + } Else { + Store (0x0F, Local0) + } + + Release (^BATM) + Return (Local0) +} + +// _BIF implementation. +// Arg0 = battery index +// Arg1 = PBIF +Method (BBIF, 2, Serialized) +{ + If (Acquire (^BATM, 1000)) { + Return (Arg1) + } + + If (BTSW (Arg0)) { + Release (^BATM) + Return (Arg1) + } + // Last Full Charge Capacity + Store (BTDF, Index (Arg1, 2)) + + // Design Voltage + Store (BTDV, Index (Arg1, 4)) + + // Design Capacity + Store (BTDA, Local0) + Store (Local0, Index (Arg1, 1)) + + // Design Capacity of Warning + Divide (Multiply (Local0, DWRN), 100, , Local2) + Store (Local2, Index (Arg1, 5)) + + // Design Capacity of Low + Divide (Multiply (Local0, DLOW), 100, , Local2) + Store (Local2, Index (Arg1, 6)) + + // Get battery info from mainboard + Store (ToString(Concatenate(BMOD, 0x00)), Index (Arg1, 9)) + Store (ToString(Concatenate(BSER, 0x00)), Index (Arg1, 10)) + Store (ToString(Concatenate(BMFG, 0x00)), Index (Arg1, 12)) + + Release (^BATM) + Return (Arg1) +} + +// _BIX implementation. +// Arg0 = battery index +// Arg1 = PBIX +Method (BBIX, 2, Serialized) +{ + If (Acquire (^BATM, 1000)) { + Return (Arg1) + } + + If (BTSW (Arg0)) { + Release (^BATM) + Return (Arg1) + } + // Last Full Charge Capacity + Store (BTDF, Index (Arg1, 3)) + + // Design Voltage + Store (BTDV, Index (Arg1, 5)) + + // Design Capacity + Store (BTDA, Local0) + Store (Local0, Index (Arg1, 2)) + + // Design Capacity of Warning + Divide (Multiply (Local0, DWRN), 100, , Local2) + Store (Local2, Index (Arg1, 6)) + + // Design Capacity of Low + Divide (Multiply (Local0, DLOW), 100, , Local2) + Store (Local2, Index (Arg1, 7)) + + // Cycle Count + Store (BTCC, Index (Arg1, 8)) + + // Get battery info from mainboard + Store (ToString(Concatenate(BMOD, 0x00)), Index (Arg1, 16)) + Store (ToString(Concatenate(BSER, 0x00)), Index (Arg1, 17)) + Store (ToString(Concatenate(BMFG, 0x00)), Index (Arg1, 19)) + + Release (^BATM) + Return (Arg1) +} + +// _BST implementation. +// Arg0 = battery index +// Arg1 = PBST +// Arg2 = BSTP +// Arg3 = BFWK +Method (BBST, 4, Serialized) +{ + If (Acquire (^BATM, 1000)) { + Return (Arg1) + } + + If (BTSW (Arg0)) { + Release (^BATM) + Return (Arg1) + } + // + // 0: BATTERY STATE + // + // bit 0 = discharging + // bit 1 = charging + // bit 2 = critical level + // + Store (Zero, Local1) + + // Check if AC is present + If (ACEX) { + If (BFCG) { + Store (0x02, Local1) + } ElseIf (BFDC) { + Store (0x01, Local1) + } + } Else { + // Always discharging when on battery power + Store (0x01, Local1) + } + + // Check for critical battery level + If (BFCR) { + Or (Local1, 0x04, Local1) + } + Store (Local1, Index (Arg1, 0)) + + // Notify if battery state has changed since last time + If (LNotEqual (Local1, DeRefOf (Arg2))) { + Store (Local1, Arg2) + If (LEqual(Arg0, 0)) { + Notify (BAT0, 0x80) + } +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + Else { + Notify (BAT1, 0x80) + } +#endif + } + + // + // 1: BATTERY PRESENT RATE + // + Store (BTPR, Index (Arg1, 1)) + + // + // 2: BATTERY REMAINING CAPACITY + // + Store (BTRA, Local1) + If (LAnd (Arg3, LAnd (ACEX, LNot (LAnd (BFDC, BFCG))))) { + // On AC power and battery is neither charging + // nor discharging. Linux expects a full battery + // to report same capacity as last full charge. + // https://bugzilla.kernel.org/show_bug.cgi?id=12632 + Store (BTDF, Local2) + + // See if within ~6% of full + ShiftRight (Local2, 4, Local3) + If (LAnd (LGreater (Local1, Subtract (Local2, Local3)), + LLess (Local1, Add (Local2, Local3)))) + { + Store (Local2, Local1) + } + } + Store (Local1, Index (Arg1, 2)) + + // + // 3: BATTERY PRESENT VOLTAGE + // + Store (BTVO, Index (Arg1, 3)) + + Release (^BATM) + Return (Arg1) +} + +Device (BAT0) +{ + Name (_HID, EISAID ("PNP0C0A")) + Name (_UID, 1) + Name (_PCL, Package () { \_SB }) + + Name (PBIF, Package () { + 0x00000001, // 0x00: Power Unit: mAh + 0xFFFFFFFF, // 0x01: Design Capacity + 0xFFFFFFFF, // 0x02: Last Full Charge Capacity + 0x00000001, // 0x03: Battery Technology: Rechargeable + 0xFFFFFFFF, // 0x04: Design Voltage + 0x00000003, // 0x05: Design Capacity of Warning + 0xFFFFFFFF, // 0x06: Design Capacity of Low + 0x00000001, // 0x07: Capacity Granularity 1 + 0x00000001, // 0x08: Capacity Granularity 2 + "", // 0x09: Model Number + "", // 0x0a: Serial Number + "LION", // 0x0b: Battery Type + "" // 0x0c: OEM Information + }) + + Name (PBIX, Package () { + 0x00000000, // 0x00: Revision + 0x00000001, // 0x01: Power Unit: mAh + 0xFFFFFFFF, // 0x02: Design Capacity + 0xFFFFFFFF, // 0x03: Last Full Charge Capacity + 0x00000001, // 0x04: Battery Technology: Rechargeable + 0xFFFFFFFF, // 0x05: Design Voltage + 0x00000003, // 0x06: Design Capacity of Warning + 0xFFFFFFFF, // 0x07: Design Capacity of Low + 0x00000000, // 0x08: Cycle Count + 0x00018000, // 0x09: Measurement Accuracy (98.3%?) + 0x000001F4, // 0x0a: Max Sampling Time (500ms) + 0x0000000a, // 0x0b: Min Sampling Time (10ms) + 0xFFFFFFFF, // 0x0c: Max Averaging Interval + 0xFFFFFFFF, // 0x0d: Min Averaging Interval + 0x00000001, // 0x0e: Capacity Granularity 1 + 0x00000001, // 0x0f: Capacity Granularity 2 + "", // 0x10 Model Number + "", // 0x11: Serial Number + "LION", // 0x12: Battery Type + "" // 0x13: OEM Information + }) + + Name (PBST, Package () { + 0x00000000, // 0x00: Battery State + 0xFFFFFFFF, // 0x01: Battery Present Rate + 0xFFFFFFFF, // 0x02: Battery Remaining Capacity + 0xFFFFFFFF, // 0x03: Battery Present Voltage + }) + Name (BSTP, Zero) + + // Workaround for full battery status, disabled by default + Name (BFWK, Zero) + + // Method to enable full battery workaround + Method (BFWE) + { + Store (One, BFWK) + } + + // Method to disable full battery workaround + Method (BFWD) + { + Store (Zero, BFWK) + } + + Method (_STA, 0, Serialized) + { + Return (BSTA (0)) + } + + Method (_BIF, 0, Serialized) + { + Return (BBIF (0, PBIF)) + } + + Method (_BIX, 0, Serialized) + { + Return (BBIX (0, PBIX)) + } + + Method (_BST, 0, Serialized) + { + Return (BBST (0, PBST, RefOf (BSTP), BFWK)) + } +} + +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE +Device (BAT1) +{ + Name (_HID, EISAID ("PNP0C0A")) + Name (_UID, 1) + Name (_PCL, Package () { \_SB }) + + Name (PBIF, Package () { + 0x00000001, // 0x00: Power Unit: mAh + 0xFFFFFFFF, // 0x01: Design Capacity + 0xFFFFFFFF, // 0x02: Last Full Charge Capacity + 0x00000001, // 0x03: Battery Technology: Rechargeable + 0xFFFFFFFF, // 0x04: Design Voltage + 0x00000003, // 0x05: Design Capacity of Warning + 0xFFFFFFFF, // 0x06: Design Capacity of Low + 0x00000001, // 0x07: Capacity Granularity 1 + 0x00000001, // 0x08: Capacity Granularity 2 + "", // 0x09: Model Number + "", // 0x0a: Serial Number + "LION", // 0x0b: Battery Type + "" // 0x0c: OEM Information + }) + + Name (PBIX, Package () { + 0x00000000, // 0x00: Revision + 0x00000001, // 0x01: Power Unit: mAh + 0xFFFFFFFF, // 0x02: Design Capacity + 0xFFFFFFFF, // 0x03: Last Full Charge Capacity + 0x00000001, // 0x04: Battery Technology: Rechargeable + 0xFFFFFFFF, // 0x05: Design Voltage + 0x00000003, // 0x06: Design Capacity of Warning + 0xFFFFFFFF, // 0x07: Design Capacity of Low + 0x00000000, // 0x08: Cycle Count + 0x00018000, // 0x09: Measurement Accuracy (98.3%?) + 0x000001F4, // 0x0a: Max Sampling Time (500ms) + 0x0000000a, // 0x0b: Min Sampling Time (10ms) + 0xFFFFFFFF, // 0x0c: Max Averaging Interval + 0xFFFFFFFF, // 0x0d: Min Averaging Interval + 0x00000001, // 0x0e: Capacity Granularity 1 + 0x00000001, // 0x0f: Capacity Granularity 2 + "", // 0x10 Model Number + "", // 0x11: Serial Number + "LION", // 0x12: Battery Type + "" // 0x13: OEM Information + }) + + Name (PBST, Package () { + 0x00000000, // 0x00: Battery State + 0xFFFFFFFF, // 0x01: Battery Present Rate + 0xFFFFFFFF, // 0x02: Battery Remaining Capacity + 0xFFFFFFFF, // 0x03: Battery Present Voltage + }) + Name (BSTP, Zero) + + // Workaround for full battery status, disabled by default + Name (BFWK, Zero) + + // Method to enable full battery workaround + Method (BFWE) + { + Store (One, BFWK) + } + + // Method to disable full battery workaround + Method (BFWD) + { + Store (Zero, BFWK) + } + + Method (_STA, 0, Serialized) + { + Return (BSTA (1)) + } + + Method (_BIF, 0, Serialized) + { + Return (BBIF (1, PBIF)) + } + + Method (_BIX, 0, Serialized) + { + Return (BBIX (1, PBIX)) + } + + Method (_BST, 0, Serialized) + { + Return (BBST (1, PBST, RefOf (BSTP), BFWK)) + } +} +#endif diff --git a/arch/x86/include/asm/acpi/cros_ec/cros_ec.asl b/arch/x86/include/asm/acpi/cros_ec/cros_ec.asl new file mode 100644 index 0000000000..9f50185b70 --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/cros_ec.asl @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2016 Google Inc. + */ + +Device (CREC) +{ + Name (_HID, "GOOG0004") + Name (_UID, 1) + Name (_DDN, "EC Command Device") +#ifdef EC_ENABLE_WAKE_PIN + Name (_PRW, Package () { EC_ENABLE_WAKE_PIN, 0x5 }) +#endif + +#ifdef EC_ENABLE_SYNC_IRQ + Name (_CRS, ResourceTemplate () + { + Interrupt (ResourceConsumer, Level, ActiveLow, Exclusive) + { + EC_SYNC_IRQ + } + }) +#endif + +#ifdef EC_ENABLE_SYNC_IRQ_GPIO + Name (_CRS, ResourceTemplate () + { + GpioInt (Level, ActiveLow, Exclusive, PullDefault, 0x0000, + "\\_SB.GPIO", 0x00, ResourceConsumer, ,) + { + EC_SYNC_IRQ + } + }) +#endif + +#ifdef EC_ENABLE_MKBP_DEVICE + Device (CKSC) + { + Name (_HID, "GOOG0007") + Name (_UID, 1) + Name (_DDN, "EC MKBP Device") + } +#endif + +#ifdef EC_ENABLE_CBAS_DEVICE + Device (CBAS) + { + Name (_HID, "GOOG000B") + Name (_UID, 1) + Name (_DDN, "EC Base Switch Device") + } +#endif + Method(_STA, 0) + { + Return (0xB) + } +} diff --git a/arch/x86/include/asm/acpi/cros_ec/ec.asl b/arch/x86/include/asm/acpi/cros_ec/ec.asl new file mode 100644 index 0000000000..03f57f25a2 --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/ec.asl @@ -0,0 +1,557 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2012 The Chromium OS Authors. All rights reserved. + */ + +/* + * The mainboard must define a PNOT method to handle power + * state notifications and Notify CPU device objects to + * re-evaluate their _PPC and _CST tables. + */ + +// Mainboard specific throttle handler +#ifdef DPTF_ENABLE_CHARGER +External (\_SB.DPTF.TCHG, DeviceObj) +#endif + + +Device (EC0) +{ + Name (_HID, EISAID ("PNP0C09")) + Name (_UID, 1) + Name (_GPE, EC_SCI_GPI) + Name (TOFS, EC_TEMP_SENSOR_OFFSET) + Name (TNCA, EC_TEMP_SENSOR_NOT_CALIBRATED) + Name (TNOP, EC_TEMP_SENSOR_NOT_POWERED) + Name (TBAD, EC_TEMP_SENSOR_ERROR) + Name (TNPR, EC_TEMP_SENSOR_NOT_PRESENT) + Name (DWRN, 15) // Battery capacity warning at 15% + Name (DLOW, 10) // Battery capacity low at 10% + + OperationRegion (ERAM, EmbeddedControl, 0x00, EC_ACPI_MEM_MAPPED_BEGIN) + Field (ERAM, ByteAcc, Lock, Preserve) + { + Offset (0x00), + RAMV, 8, // EC RAM Version + TSTB, 8, // Test Byte + TSTC, 8, // Complement of Test Byte + KBLV, 8, // Keyboard Backlight value + FAND, 8, // Set Fan Duty Cycle + PATI, 8, // Programmable Auxiliary Trip Sensor ID + PATT, 8, // Programmable Auxiliary Trip Threshold + PATC, 8, // Programmable Auxiliary Trip Commit + CHGL, 8, // Charger Current Limit + TBMD, 1, // Tablet mode + DDPN, 3, // Device DPTF Profile Number + // DFUD must be 0 for the other 31 values to be valid + Offset (0x0a), + DFUD, 1, // Device Features Undefined + FLSH, 1, // Flash commands present + PFAN, 1, // PWM Fan control present + KBLE, 1, // Keyboard Backlight present + LTBR, 1, // Lightbar present + LEDC, 1, // LED control + MTNS, 1, // Motion sensors present + KEYB, 1, // EC is keyboard controller + PSTR, 1, // Persistent storage + P80P, 1, // EC serves I/O Port 80h + THRM, 1, // EC supports thermal management + SBKL, 1, // Screen backlight switch present + WIFI, 1, // WIFI switch present + HOST, 1, // EC monitors host events (eg SCI, SMI) + GPIO, 1, // EC provides GPIO commands + I2CB, 1, // EC provides I2C controller access + CHRG, 1, // EC provides commands for charger control + BATT, 1, // Simply Battery support + SBAT, 1, // Smart Battery support + HANG, 1, // EC can detect host hang + PMUI, 1, // Power Information + DSEC, 1, // another EC exists downstream + UPDC, 1, // supports USB Power Delivery + UMUX, 1, // supports USB Mux + MSFF, 1, // Motion Sense has FIFO + TVST, 1, // supports temporary secure vstore + TCMV, 1, // USB Type C Muxing is virtual (host assisted) + RTCD, 1, // EC provides an RTC device + FPRD, 1, // EC provides a fingerprint reader device + TPAD, 1, // EC provides a touchpad device + RWSG, 1, // EC has RWSIG task enabled + DEVE, 1, // EC supports device events + // make sure we're within our space envelope + Offset (0x0e), + Offset (0x12), + BTID, 8, // Battery index that host wants to read + USPP, 8, // USB Port Power +} + +#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_ACPI_MEMMAP) + OperationRegion (EMEM, EmbeddedControl, + EC_ACPI_MEM_MAPPED_BEGIN, EC_ACPI_MEM_MAPPED_SIZE) + Field (EMEM, ByteAcc, Lock, Preserve) +#else + OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE) + Field (EMEM, ByteAcc, NoLock, Preserve) +#endif + { + #include "emem.asl" + } + +#ifdef EC_ENABLE_LID_SWITCH + /* LID Switch */ + Device (LID0) + { + Name (_HID, EisaId ("PNP0C0D")) + Method (_LID, 0) + { + Return (^^LIDS) + } + +#ifdef EC_ENABLE_WAKE_PIN + Name (_PRW, Package () { EC_ENABLE_WAKE_PIN, 0x5 }) +#endif + } +#endif + + Method (TINS, 1, Serialized) + { + Switch (ToInteger (Arg0)) + { + Case (0) { Return (TIN0) } + Case (1) { Return (TIN1) } + Case (2) { Return (TIN2) } + Case (3) { Return (TIN3) } + Case (4) { Return (TIN4) } + Case (5) { Return (TIN5) } + Case (6) { Return (TIN6) } + Case (7) { Return (TIN7) } + Case (8) { Return (TIN8) } + Case (9) { Return (TIN9) } + Default { Return (TIN0) } + } + } + + Method (_CRS, 0, Serialized) + { + Name (ECMD, ResourceTemplate() + { + IO (Decode16, + EC_LPC_ADDR_ACPI_DATA, + EC_LPC_ADDR_ACPI_DATA, + 0, 1) + IO (Decode16, + EC_LPC_ADDR_ACPI_CMD, + EC_LPC_ADDR_ACPI_CMD, + 0, 1) + }) + Return (ECMD) + } + + Method (_REG, 2, NotSerialized) + { + // Initialize AC power state + Store (ACEX, \PWRS) + + // Initialize LID switch state + Store (LIDS, \LIDS) + } + + /* Read requested temperature and check against EC error values */ + Method (TSRD, 1, Serialized) + { + Store (\_SB.PCI0.LPCB.EC0.TINS (Arg0), Local0) + + /* Check for sensor not calibrated */ + If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNCA)) { + Return (Zero) + } + + /* Check for sensor not present */ + If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNPR)) { + Return (Zero) + } + + /* Check for sensor not powered */ + If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNOP)) { + Return (Zero) + } + + /* Check for sensor bad reading */ + If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TBAD)) { + Return (Zero) + } + + /* Adjust by offset to get Kelvin */ + Add (\_SB.PCI0.LPCB.EC0.TOFS, Local0, Local0) + + /* Convert to 1/10 Kelvin */ + Multiply (Local0, 10, Local0) + + Return (Local0) + } + + // Lid Closed Event + Method (_Q01, 0, NotSerialized) + { + Store ("EC: LID CLOSE", Debug) + Store (LIDS, \LIDS) +#ifdef EC_ENABLE_LID_SWITCH + Notify (LID0, 0x80) +#endif + } + + // Lid Open Event + Method (_Q02, 0, NotSerialized) + { + Store ("EC: LID OPEN", Debug) + Store (LIDS, \LIDS) + Notify (CREC, 0x2) +#ifdef EC_ENABLE_LID_SWITCH + Notify (LID0, 0x80) +#endif + } + + // Power Button + Method (_Q03, 0, NotSerialized) + { + Store ("EC: POWER BUTTON", Debug) + } + + // AC Connected + Method (_Q04, 0, NotSerialized) + { + Store ("EC: AC CONNECTED", Debug) + Store (ACEX, \PWRS) + Notify (AC, 0x80) +#ifdef DPTF_ENABLE_CHARGER + If (CondRefOf (\_SB.DPTF.TCHG)) { + Notify (\_SB.DPTF.TCHG, 0x80) + } +#endif + \PNOT () + } + + // AC Disconnected + Method (_Q05, 0, NotSerialized) + { + Store ("EC: AC DISCONNECTED", Debug) + Store (ACEX, \PWRS) + Notify (AC, 0x80) +#ifdef DPTF_ENABLE_CHARGER + If (CondRefOf (\_SB.DPTF.TCHG)) { + Notify (\_SB.DPTF.TCHG, 0x80) + } +#endif + \PNOT () + } + + // Battery Low Event + Method (_Q06, 0, NotSerialized) + { + Store ("EC: BATTERY LOW", Debug) + Notify (BAT0, 0x80) + } + + // Battery Critical Event + Method (_Q07, 0, NotSerialized) + { + Store ("EC: BATTERY CRITICAL", Debug) + Notify (BAT0, 0x80) + } + + // Battery Info Event + Method (_Q08, 0, NotSerialized) + { + Store ("EC: BATTERY INFO", Debug) + Notify (BAT0, 0x81) +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + If (CondRefOf (BAT1)) { + Notify (BAT1, 0x81) + } +#endif + } + + // Thermal Overload Event + Method (_Q0A, 0, NotSerialized) + { + Store ("EC: THERMAL OVERLOAD", Debug) + Notify (\_TZ, 0x80) + } + + // Thermal Event + Method (_Q0B, 0, NotSerialized) + { + Store ("EC: THERMAL", Debug) + Notify (\_TZ, 0x80) + } + + // USB Charger + Method (_Q0C, 0, NotSerialized) + { + Store ("EC: USB CHARGER", Debug) + } + + // Key Pressed + Method (_Q0D, 0, NotSerialized) + { + Store ("EC: KEY PRESSED", Debug) + Notify (CREC, 0x2) + } + + // Thermal Shutdown Imminent + Method (_Q10, 0, NotSerialized) + { + Store ("EC: THERMAL SHUTDOWN", Debug) + Notify (\_TZ, 0x80) + } + + // Battery Shutdown Imminent + Method (_Q11, 0, NotSerialized) + { + Store ("EC: BATTERY SHUTDOWN", Debug) + Notify (BAT0, 0x80) + } + + // Throttle Start + Method (_Q12, 0, NotSerialized) + { +#ifdef EC_ENABLE_THROTTLING_HANDLER + Store ("EC: THROTTLE START", Debug) + \_TZ.THRT (1) +#endif + } + + // Throttle Stop + Method (_Q13, 0, NotSerialized) + { +#ifdef EC_ENABLE_THROTTLING_HANDLER + Store ("EC: THROTTLE STOP", Debug) + \_TZ.THRT (0) +#endif + } + +#ifdef EC_ENABLE_PD_MCU_DEVICE + // PD event + Method (_Q16, 0, NotSerialized) + { + Store ("EC: GOT PD EVENT", Debug) + Notify (ECPD, 0x80) + } +#endif + + // Battery Status + Method (_Q17, 0, NotSerialized) + { + Store ("EC: BATTERY STATUS", Debug) + Notify (BAT0, 0x80) +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + If (CondRefOf (BAT1)) { + Notify (BAT1, 0x80) + } +#endif + } + + // MKBP interrupt. + Method (_Q1B, 0, NotSerialized) + { + Store ("EC: MKBP", Debug) + Notify (CREC, 0x80) + } + + // TABLET mode switch Event + Method (_Q1D, 0, NotSerialized) + { + Store ("EC: TABLET mode switch Event", Debug) + Notify (CREC, 0x2) +#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES + \_SB.DPTF.TPET() +#endif +#ifdef EC_ENABLE_TBMC_DEVICE + Notify (TBMC, 0x80) +#endif + } + + /* + * Dynamic Platform Thermal Framework support + */ + + /* Mutex for EC PAT interface */ + Mutex (PATM, 1) + + /* + * Set Aux Trip Point 0 + * Arg0 = Temp Sensor ID + * Arg1 = Value to set + */ + Method (PAT0, 2, Serialized) + { + If (Acquire (^PATM, 1000)) { + Return (0) + } + + /* Set sensor ID */ + Store (ToInteger (Arg0), ^PATI) + + /* Temperature is passed in 1/10 Kelvin */ + Divide (ToInteger (Arg1), 10, , Local1) + + /* Adjust by EC temperature offset */ + Subtract (Local1, ^TOFS, ^PATT) + + /* Set commit value with SELECT=0 and ENABLE=1 */ + Store (0x02, ^PATC) + + Release (^PATM) + Return (1) + } + + /* + * Set Aux Trip Point 1 + * Arg0 = Temp Sensor ID + * Arg1 = Value to set + */ + Method (PAT1, 2, Serialized) + { + If (Acquire (^PATM, 1000)) { + Return (0) + } + + /* Set sensor ID */ + Store (ToInteger (Arg0), ^PATI) + + /* Temperature is passed in 1/10 Kelvin */ + Divide (ToInteger (Arg1), 10, , Local1) + + /* Adjust by EC temperature offset */ + Subtract (Local1, ^TOFS, ^PATT) + + /* Set commit value with SELECT=1 and ENABLE=1 */ + Store (0x03, ^PATC) + + Release (^PATM) + Return (1) + } + + /* Disable Aux Trip Points + * Arg0 = Temp Sensor ID + */ + Method (PATD, 1, Serialized) + { + If (Acquire (^PATM, 1000)) { + Return (0) + } + + Store (ToInteger (Arg0), ^PATI) + Store (0x00, ^PATT) + + /* Disable PAT0 */ + Store (0x00, ^PATC) + + /* Disable PAT1 */ + Store (0x01, ^PATC) + + Release (^PATM) + Return (1) + } + + /* + * Thermal Threshold Event + */ + Method (_Q09, 0, NotSerialized) + { + If (LNot(Acquire (^PATM, 1000))) { + /* Read sensor ID for event */ + Store (^PATI, Local0) + + /* When sensor ID returns 0xFF then no more events */ + While (LNotEqual (Local0, EC_TEMP_SENSOR_NOT_PRESENT)) + { +#ifdef HAVE_THERM_EVENT_HANDLER + \_SB.DPTF.TEVT (Local0) +#endif + + /* Keep reaading sensor ID for event */ + Store (^PATI, Local0) + } + + Release (^PATM) + } + } + + /* + * Set Charger Current Limit + * Arg0 = Current Limit in 64mA steps + */ + Method (CHGS, 1, Serialized) + { + Store (ToInteger (Arg0), ^CHGL) + } + + /* + * Disable Charger Current Limit + */ + Method (CHGD, 0, Serialized) + { + Store (0xFF, ^CHGL) + } + + /* Read current Tablet mode */ + Method (RCTM, 0, NotSerialized) + { + Return (^TBMD) + } + + /* Read current Device DPTF Profile Number */ + Method (RCDP, 0, NotSerialized) + { + /* + * DDPN = 0 is reserved for backwards compatibility. + * If DDPN == 0 use TBMD to load appropriate DPTF table. + */ + If (LEqual (^DDPN, 0)) { + Return (^TBMD) + } Else { + Subtract (^DDPN, 1, Local0) + Return (Local0) + } + } + +#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER) + /* + * Enable USB Port Power + * Arg0 = USB port ID + */ + Method (UPPS, 1, Serialized) + { + Or (USPP, ShiftLeft (1, Arg0), USPP) + } + + /* + * Disable USB Port Power + * Arg0 = USB port ID + */ + Method (UPPC, 1, Serialized) + { + And (USPP, Not (ShiftLeft (1, Arg0)), USPP) + } +#endif + + #include "ac.asl" + #include "battery.asl" + #include "cros_ec.asl" + +#ifdef EC_ENABLE_ALS_DEVICE + #include "als.asl" +#endif + +#ifdef EC_ENABLE_KEYBOARD_BACKLIGHT + #include "keyboard_backlight.asl" +#endif + +#ifdef EC_ENABLE_PD_MCU_DEVICE + #include "pd.asl" +#endif + +#ifdef EC_ENABLE_TBMC_DEVICE + #include "tbmc.asl" +#endif +} diff --git a/arch/x86/include/asm/acpi/cros_ec/emem.asl b/arch/x86/include/asm/acpi/cros_ec/emem.asl new file mode 100644 index 0000000000..681ca1c9de --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/emem.asl @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2015 The Chromium OS Authors. All rights reserved. + */ + +/* + * EMEM data may be accessed through port 62/66 or through LPC at 900h. + */ + +Offset (0x00), +TIN0, 8, // Temperature 0 +TIN1, 8, // Temperature 1 +TIN2, 8, // Temperature 2 +TIN3, 8, // Temperature 3 +TIN4, 8, // Temperature 4 +TIN5, 8, // Temperature 5 +TIN6, 8, // Temperature 6 +TIN7, 8, // Temperature 7 +TIN8, 8, // Temperature 8 +TIN9, 8, // Temperature 9 +Offset (0x10), +FAN0, 16, // Fan Speed 0 +Offset (0x24), +BTVR, 8, // Battery structure version +Offset (0x30), +LIDS, 1, // Lid Switch State +PBTN, 1, // Power Button Pressed +WPDI, 1, // Write Protect Disabled +RECK, 1, // Keyboard Initiated Recovery +RECD, 1, // Dedicated Recovery Mode +Offset (0x40), +BTVO, 32, // Battery Present Voltage +BTPR, 32, // Battery Present Rate +BTRA, 32, // Battery Remaining Capacity +ACEX, 1, // AC Present +BTEX, 1, // Battery Present +BFDC, 1, // Battery Discharging +BFCG, 1, // Battery Charging +BFCR, 1, // Battery Level Critical +Offset (0x4d), +BTCN, 8, // Battery Count +BTIX, 8, // Battery index +Offset (0x50), +BTDA, 32, // Battery Design Capacity +BTDV, 32, // Battery Design Voltage +BTDF, 32, // Battery Last Full Charge Capacity +BTCC, 32, // Battery Cycle Count +BMFG, 64, // Battery Manufacturer String +BMOD, 64, // Battery Model String +BSER, 64, // Battery Serial String +BTYP, 64, // Battery Type String +Offset (0x80), +ALS0, 16, // ALS reading 0 in lux diff --git a/arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl b/arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl new file mode 100644 index 0000000000..e6edd9680c --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/keyboard_backlight.asl @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2015 Google Inc. + */ + +Scope (\_SB) +{ + /* + * Chrome EC Keyboard Backlight interface + */ + Device (KBLT) + { + Name (_HID, "GOOG0002") + Name (_UID, 1) + + /* Ask EC if we even have a backlight + * Return 0xf (present, enabled, show in UI, functioning) or 0 + * + * With older EC codebases that don't support the Device + * Features bitfield, this reports the keyboard backlight as + * enabled since reads to undefined addresses in EC address + * space return 0xff and so KBLE will be 1. + */ + Method (_STA, 0, NotSerialized) + { + /* If query is unsupported, but this code is compiled + * in, assume the backlight exists physically. + */ + If (LEqual (1, \_SB.PCI0.LPCB.EC0.DFUD)) { + Return (0xf) + } + /* If EC reports that backlight exists, trust it */ + If (LEqual (1, \_SB.PCI0.LPCB.EC0.KBLE)) { + Return (0xf) + } + /* Otherwise: no device -> disable */ + Return (0) + } + + /* Read current backlight value */ + Method (KBQC, 0, NotSerialized) + { + Return (\_SB.PCI0.LPCB.EC0.KBLV) + } + + /* Write new backlight value */ + Method (KBCM, 1, NotSerialized) + { + Store (Arg0, \_SB.PCI0.LPCB.EC0.KBLV) + } + } +} diff --git a/arch/x86/include/asm/acpi/cros_ec/pd.asl b/arch/x86/include/asm/acpi/cros_ec/pd.asl new file mode 100644 index 0000000000..e55fde347c --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/pd.asl @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + */ + +Device (ECPD) +{ + Name (_HID, "GOOG0003") + Name (_UID, 1) + Name (_DDN, "EC PD Device") + Method(_STA, 0) + { + Return (0xB) + } +} diff --git a/arch/x86/include/asm/acpi/cros_ec/superio.asl b/arch/x86/include/asm/acpi/cros_ec/superio.asl new file mode 100644 index 0000000000..7ddab1e3cf --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/superio.asl @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved. + */ + +/* + * Chrome OS Embedded Controller interface + * + * Constants that should be defined: + * + * SIO_EC_MEMMAP_ENABLE : Enable EC LPC memory map resources + * EC_LPC_ADDR_MEMMAP : Base address of memory map range + * EC_MEMMAP_SIZE : Size of memory map range + * + * SIO_EC_HOST_ENABLE : Enable EC host command interface resources + * EC_LPC_ADDR_HOST_DATA : EC host command interface data port + * EC_LPC_ADDR_HOST_CMD : EC host command interface command port + * EC_HOST_CMD_REGION0 : EC host command buffer + * EC_HOST_CMD_REGION1 : EC host command buffer + * EC_HOST_CMD_REGION_SIZE : EC host command buffer size + */ + +// Scope is \_SB.PCI0.LPCB + +Device (SIO) { + Name (_UID, 0) + Name (_ADR, 0) + +#ifdef SIO_EC_MEMMAP_ENABLE + Device (ECMM) { + Name (_HID, EISAID ("PNP0C02")) + Name (_UID, 4) + + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + + Name (_CRS, ResourceTemplate () + { + IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP, + 0x08, EC_MEMMAP_SIZE) + }) + + Name (_PRS, ResourceTemplate () + { + IO (Decode16, EC_LPC_ADDR_MEMMAP, EC_LPC_ADDR_MEMMAP, + 0x08, EC_MEMMAP_SIZE) + }) + } +#endif + +#ifdef SIO_EC_HOST_ENABLE + Device (ECUI) { + Name (_HID, EISAID ("PNP0C02")) + Name (_UID, 3) + + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + + Name (_CRS, ResourceTemplate () + { + IO (Decode16, + EC_LPC_ADDR_HOST_DATA, EC_LPC_ADDR_HOST_DATA, + 0x01, 0x01) + IO (Decode16, + EC_LPC_ADDR_HOST_CMD, EC_LPC_ADDR_HOST_CMD, + 0x01, 0x01) + IO (Decode16, + EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION0, 0x08, + EC_HOST_CMD_REGION_SIZE) + IO (Decode16, + EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1, 0x08, + EC_HOST_CMD_REGION_SIZE) + }) + + Name (_PRS, ResourceTemplate () + { + StartDependentFn (0, 0) { + IO (Decode16, EC_LPC_ADDR_HOST_DATA, + EC_LPC_ADDR_HOST_DATA, 0x01, 0x01) + IO (Decode16, EC_LPC_ADDR_HOST_CMD, + EC_LPC_ADDR_HOST_CMD, 0x01, 0x01) + IO (Decode16, + EC_HOST_CMD_REGION0, EC_HOST_CMD_REGION0, + 0x08, EC_HOST_CMD_REGION_SIZE) + IO (Decode16, + EC_HOST_CMD_REGION1, EC_HOST_CMD_REGION1, + 0x08, EC_HOST_CMD_REGION_SIZE) + } + EndDependentFn () + }) + } +#endif + +#ifdef SIO_EC_ENABLE_COM1 + Device (COM1) { + Name (_HID, EISAID ("PNP0501")) + Name (_UID, 1) + + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08) + IRQNoFlags () {4} + }) + + Name (_PRS, ResourceTemplate () + { + StartDependentFn (0, 0) { + IO (Decode16, 0x03F8, 0x3F8, 0x08, 0x08) + IRQNoFlags () {4} + } + EndDependentFn () + }) + } +#endif +} + +#ifdef SIO_EC_ENABLE_PS2K +Device (PS2K) // Keyboard +{ + Name (_UID, 0) + Name (_HID, "GOOG000A") + Name (_CID, Package() { EISAID("PNP0303"), EISAID("PNP030B") } ) + + Method (_STA, 0, NotSerialized) { + Return (0x0F) + } + + Name (_CRS, ResourceTemplate() + { + IO (Decode16, 0x60, 0x60, 0x01, 0x01) + IO (Decode16, 0x64, 0x64, 0x01, 0x01) +#ifdef SIO_EC_PS2K_IRQ + SIO_EC_PS2K_IRQ +#else + IRQ (Edge, ActiveHigh, Exclusive) {1} +#endif + }) + + Name (_PRS, ResourceTemplate() + { + StartDependentFn (0, 0) { + IO (Decode16, 0x60, 0x60, 0x01, 0x01) + IO (Decode16, 0x64, 0x64, 0x01, 0x01) +#ifdef SIO_EC_PS2K_IRQ + SIO_EC_PS2K_IRQ +#else + IRQ (Edge, ActiveHigh, Exclusive) {1} +#endif + } + EndDependentFn () + }) +} +#endif diff --git a/arch/x86/include/asm/acpi/cros_ec/tbmc.asl b/arch/x86/include/asm/acpi/cros_ec/tbmc.asl new file mode 100644 index 0000000000..bfe38d668e --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_ec/tbmc.asl @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2017 Google Inc. + */ + +Device (TBMC) +{ + Name (_HID, "GOOG0006") + Name (_UID, 1) + Name (_DDN, "Tablet Motion Control") + Method (TBMC) + { + If (LEqual (^^RCTM, One)) { + Return (0x1) + } Else { + Return (0x0) + } + } + Method(_STA, 0) + { + Return (0xB) + } +} From patchwork Mon Jan 27 05:06:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229563 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=TSU54Lfi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dNh6tG7z9sRV for ; Mon, 27 Jan 2020 16:20:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30FC0818B1; Mon, 27 Jan 2020 06:12:38 +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="TSU54Lfi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C0A68180F; Mon, 27 Jan 2020 06:09:51 +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,T_FILL_THIS_FORM_SHORT, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 D754581819 for ; Mon, 27 Jan 2020 06:09:17 +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-xd43.google.com with SMTP id m25so8556723ioo.8 for ; Sun, 26 Jan 2020 21:09:17 -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=L7aAj3V389yvCh9vuWW2ICaWhjvy9mLgShSsDRN+AiM=; b=TSU54LfigPVYWPxWJzNMO1qsacSn06B9zqoWeevZZMFkNUvc9LIzuwV+ppBzSppCKL Nkkfn5jewNw++TMK1xBiHLDzcLmSwM9yI1FwMsqTaNIzbPszYtH70dDOOBmdgjkW1Ylh 8XiwcOxLEOTnjUH1Oohss6wrmPW+L5lPdVjoY= 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=L7aAj3V389yvCh9vuWW2ICaWhjvy9mLgShSsDRN+AiM=; b=LKNnJJynaw/Bnac35q5LISk59CTfeXYb6N8Mg5l5CVVeUqxefrbCa90ophSoN4BkFt /QTXeZd2/rUtifdWOkEISMmukV5RJjRa1c9g3KaXFTHkQle1Wj7T49M0QwF0xvWBLTtx sg8Y5Ma0hAsJFiORUqna1sr2b76Xeui9ZuQG+qZKymyQUQQ3ZleUtRPHRKj9GtheB+/8 eYXR9tTnIyyGbvGgCOTpb60aQ1mRIg2tilFwIGPJHVhwBLehDNSS0fCEoCAuAgZvMdgx YLkXpvqz1N40GZ/DRVWp2+kKT+VLsy1oiSZsmkdAyIbgUQXJCYMmKPlK6RSzA8oxyAdm tp3g== X-Gm-Message-State: APjAAAUmqgjJnDH7T2+GUFytYQ6rG9UDaISCCQcNDYduZrW+35DIL3Ek xt5a6s8uzDciB5ObIEESCCH3hocQUoDG+Q== X-Google-Smtp-Source: APXvYqzgo7L5209Jt09vbEHZVAJWHOaj9mbqKogVB0xMfUQniqQdsJZLjBHjtc8dIQMa57jzwxRPIw== X-Received: by 2002:a6b:fc02:: with SMTP id r2mr10619836ioh.183.1580101756194; Sun, 26 Jan 2020 21:09:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:15 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 066/108] x86: acpi: Add base asl files for common x86 devices Date: Sun, 26 Jan 2020 22:06:13 -0700 Message-Id: <20200126220508.66.I25148ea0707da6ca2a9c2a86cdaca2439052abac@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 Add common x86 ASL files, taken from coreboot. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi/chromeos.asl | 110 +++++++++++++++++ arch/x86/include/asm/acpi/cpu.asl | 25 ++++ arch/x86/include/asm/acpi/cros_gnvs.asl | 29 +++++ arch/x86/include/asm/acpi/lpc.asl | 141 ++++++++++++++++++++++ arch/x86/include/asm/acpi/pci_osc.asl | 21 ++++ arch/x86/include/asm/acpi/pcr.asl | 80 ++++++++++++ arch/x86/include/asm/acpi/ramoops.asl | 32 +++++ arch/x86/include/asm/acpi/sleepstates.asl | 12 +- 8 files changed, 445 insertions(+), 5 deletions(-) create mode 100644 arch/x86/include/asm/acpi/chromeos.asl create mode 100644 arch/x86/include/asm/acpi/cpu.asl create mode 100644 arch/x86/include/asm/acpi/cros_gnvs.asl create mode 100644 arch/x86/include/asm/acpi/lpc.asl create mode 100644 arch/x86/include/asm/acpi/pci_osc.asl create mode 100644 arch/x86/include/asm/acpi/pcr.asl create mode 100644 arch/x86/include/asm/acpi/ramoops.asl diff --git a/arch/x86/include/asm/acpi/chromeos.asl b/arch/x86/include/asm/acpi/chromeos.asl new file mode 100644 index 0000000000..a0dcfe616b --- /dev/null +++ b/arch/x86/include/asm/acpi/chromeos.asl @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. + */ + +/* +#ifdef CONFIG_CHROMEOS +*/ +#define CONFIG_VBOOT_VBNV_OFFSET 0x26 + +#include + +/* GPIO package generated at run time. */ +External (OIPG) + +Device (CRHW) +{ + Name(_HID, EISAID("GGL0001")) + + Method(_STA, 0, Serialized) + { + Return (0xb) + } + + Method(CHSW, 0, Serialized) + { + Name (WSHC, Package() { VBT3 }) + Return (WSHC) + } + + Method(FWID, 0, Serialized) + { + Name (DIW1, "") + ToString(VBT5, 63, DIW1) + Name (DIWF, Package() { DIW1 }) + Return(DIWF) + } + + Method(FRID, 0, Serialized) + { + Name (DIR1, "") + ToString(VBT6, 63, DIR1) + Name (DIRF, Package() { DIR1 }) + Return (DIRF) + } + + Method(HWID, 0, Serialized) + { + Name (DIW0, "") + ToString(VBT4, 255, DIW0) + Name (DIWH, Package() { DIW0 }) + Return (DIWH) + } + + Method(BINF, 0, Serialized) + { + Name (FNIB, Package() { VBT0, VBT1, VBT2, VBT7, VBT8 }) + Return (FNIB) + } + + Method(GPIO, 0, Serialized) + { + Return (OIPG) + + } + + Method(VBNV, 0, Serialized) + { + Name(VNBV, Package() { + // See src/vendorcode/google/chromeos/Kconfig + // for the definition of these: + CONFIG_VBOOT_VBNV_OFFSET, + VBOOT_VBNV_BLOCK_SIZE + }) + Return(VNBV) + } + + Method(VDAT, 0, Serialized) + { + Name(TAD0,"") + ToBuffer(CHVD, TAD0) + Name (TADV, Package() { TAD0 }) + Return (TADV) + } + + Method(FMAP, 0, Serialized) + { + Name(PAMF, Package() { VBT9 }) + Return(PAMF) + } + + Method(MECK, 0, Serialized) + { + Name(HASH, Package() { MEHH }) + Return(HASH) + } + + Method(MLST, 0, Serialized) + { + Name(TSLM, Package() { "CHSW", "FWID", "HWID", "FRID", "BINF", + "GPIO", "VBNV", "VDAT", "FMAP", "MECK" + }) + Return (TSLM) + } +} + +#include "ramoops.asl" +/* +#endif +*/ diff --git a/arch/x86/include/asm/acpi/cpu.asl b/arch/x86/include/asm/acpi/cpu.asl new file mode 100644 index 0000000000..b20b3572f2 --- /dev/null +++ b/arch/x86/include/asm/acpi/cpu.asl @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +/* These come from the dynamically created CPU SSDT */ +External (\_PR.CNOT, MethodObj) + +/* Notify OS to re-read CPU tables */ +Method (PNOT) +{ + \_PR.CNOT (0x81) +} + +/* Notify OS to re-read CPU _PPC limit */ +Method (PPCN) +{ + \_PR.CNOT (0x80) +} + +/* Notify OS to re-read Throttle Limit tables */ +Method (TNOT) +{ + \_PR.CNOT (0x82) +} diff --git a/arch/x86/include/asm/acpi/cros_gnvs.asl b/arch/x86/include/asm/acpi/cros_gnvs.asl new file mode 100644 index 0000000000..c20b64565e --- /dev/null +++ b/arch/x86/include/asm/acpi/cros_gnvs.asl @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +/* This is the ChromeOS specific ACPI information needed by + * the mainboard's chromeos.asl + */ + +VBT0, 32, // 0x000 - Boot Reason +VBT1, 32, // 0x004 - Active Main Firmware +VBT2, 32, // 0x008 - Active EC Firmware +VBT3, 16, // 0x00c - CHSW +VBT4, 2048, // 0x00e - HWID +VBT5, 512, // 0x10e - FWID +VBT6, 512, // 0x14e - FRID +VBT7, 32, // 0x18e - active main firmware type +VBT8, 32, // 0x192 - Recovery Reason +VBT9, 32, // 0x196 - FMAP base address +CHVD, 24576, // 0x19a - VDAT space filled by verified boot +VBTA, 32, // 0xd9a - pointer to smbios FWID +MEHH, 256, // 0xd9e - Management Engine Hash +RMOB, 32, // 0xdbe - RAM oops base address +RMOL, 32, // 0xdc2 - RAM oops length +ROVP, 32, // 0xdc6 - pointer to RO_VPD +ROVL, 32, // 0xdca - size of RO_VPD +RWVP, 32, // 0xdce - pointer to RW_VPD +RWVL, 32, // 0xdd2 - size of RW_VPD + // 0xdd6 diff --git a/arch/x86/include/asm/acpi/lpc.asl b/arch/x86/include/asm/acpi/lpc.asl new file mode 100644 index 0000000000..18cc78b3e1 --- /dev/null +++ b/arch/x86/include/asm/acpi/lpc.asl @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2007-2009 coresystems GmbH + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2015 Intel Corporation. + */ + +/* Intel LPC/eSPI Bus Device - 0:1f.0 */ +#include + +Device (LPCB) +{ + Name (_ADR, 0x001f0000) + Name (_DDN, "LPC Bus Device") + + /* DMA Controller */ + Device (DMAC) + { + Name (_HID, EISAID("PNP0200")) + Name (_CRS, ResourceTemplate() + { + IO (Decode16, 0x00, 0x00, 0x01, 0x20) + IO (Decode16, 0x81, 0x81, 0x01, 0x11) + IO (Decode16, 0x93, 0x93, 0x01, 0x0d) + IO (Decode16, 0xc0, 0xc0, 0x01, 0x20) + DMA (Compatibility, NotBusMaster, Transfer8_16) { 4 } + }) + } + + /* Firmware Hub */ + Device (FWH) + { + Name (_HID, EISAID ("INT0800")) + Name (_DDN, "Firmware Hub") + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadOnly, 0xff000000, 0x01000000) + }) + } + + /* High Precision Event Timer */ + Device (HPET) + { + Name (_HID, EISAID ("PNP0103")) + Name (_CID, 0x010CD041) + Name (_DDN, "High Precision Event Timer") + Name (_CRS, ResourceTemplate () + { + Memory32Fixed (ReadWrite, HPET_BASE_ADDRESS, 0x400) + }) + Method (_STA, 0) + { + Return (0xF) + } + } + + /* FPU */ + Device(MATH) + { + Name (_HID, EISAID("PNP0C04")) + Name (_CRS, ResourceTemplate() + { + IO (Decode16, 0xf0, 0xf0, 0x01, 0x01) + IRQNoFlags() { 13 } + }) + } + + /* AT Interrupt Controller */ + Device (PIC) + { + Name (_HID, EISAID ("PNP0000")) + Name (_DDN, "8259 Interrupt Controller") + Name (_CRS, ResourceTemplate() + { + IO (Decode16, 0x20, 0x20, 0x01, 0x02) + IO (Decode16, 0x24, 0x24, 0x01, 0x02) + IO (Decode16, 0x28, 0x28, 0x01, 0x02) + IO (Decode16, 0x2c, 0x2c, 0x01, 0x02) + IO (Decode16, 0x30, 0x30, 0x01, 0x02) + IO (Decode16, 0x34, 0x34, 0x01, 0x02) + IO (Decode16, 0x38, 0x38, 0x01, 0x02) + IO (Decode16, 0x3c, 0x3c, 0x01, 0x02) + IO (Decode16, 0xa0, 0xa0, 0x01, 0x02) + IO (Decode16, 0xa4, 0xa4, 0x01, 0x02) + IO (Decode16, 0xa8, 0xa8, 0x01, 0x02) + IO (Decode16, 0xac, 0xac, 0x01, 0x02) + IO (Decode16, 0xb0, 0xb0, 0x01, 0x02) + IO (Decode16, 0xb4, 0xb4, 0x01, 0x02) + IO (Decode16, 0xb8, 0xb8, 0x01, 0x02) + IO (Decode16, 0xbc, 0xbc, 0x01, 0x02) + IO (Decode16, 0x4d0, 0x4d0, 0x01, 0x02) + IRQNoFlags () { 2 } + }) + } + + /* LPC device: Resource consumption */ + Device (LDRC) + { + Name (_HID, EISAID ("PNP0C02")) + Name (_UID, 2) + Name (_DDN, "Legacy Device Resources") + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x2e, 0x2e, 0x1, 0x02) // First SuperIO + IO (Decode16, 0x4e, 0x4e, 0x1, 0x02) // Second SuperIO + IO (Decode16, 0x61, 0x61, 0x1, 0x01) // NMI Status + IO (Decode16, 0x63, 0x63, 0x1, 0x01) // CPU Reserved + IO (Decode16, 0x65, 0x65, 0x1, 0x01) // CPU Reserved + IO (Decode16, 0x67, 0x67, 0x1, 0x01) // CPU Reserved + IO (Decode16, 0x80, 0x80, 0x1, 0x01) // Port 80 Post + IO (Decode16, 0x92, 0x92, 0x1, 0x01) // CPU Reserved + IO (Decode16, 0xb2, 0xb2, 0x1, 0x02) // SWSMI + IO (Decode16, ACPI_BASE_ADDRESS, ACPI_BASE_ADDRESS, + 0x1, 0xff) + }) + } + + /* Real Time Clock Device */ + Device (RTC) + { + Name (_HID, EISAID ("PNP0B00")) + Name (_DDN, "Real Time Clock") + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x70, 0x70, 1, 8) + }) + } + + /* Timer */ + Device (TIMR) + { + Name (_HID, EISAID ("PNP0100")) + Name (_DDN, "8254 Timer") + Name (_CRS, ResourceTemplate () + { + IO (Decode16, 0x40, 0x40, 0x01, 0x04) + IO (Decode16, 0x50, 0x50, 0x10, 0x04) + IRQNoFlags () {0} + }) + } +} diff --git a/arch/x86/include/asm/acpi/pci_osc.asl b/arch/x86/include/asm/acpi/pci_osc.asl new file mode 100644 index 0000000000..864556fa83 --- /dev/null +++ b/arch/x86/include/asm/acpi/pci_osc.asl @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corp. + */ + +#define PCI_OSC_UUID "33DB4D5B-1FF7-401C-9657-7441C03DD766" + +Scope (\_SB.PCI0) { + Method (_OSC, 4) { + /* Check for proper GUID */ + If (LEqual (Arg0, ToUUID (PCI_OSC_UUID))) { + /* Let OS control everything */ + Return (Arg3) + } Else { + /* Unrecognized UUID */ + CreateDWordField (Arg3, 0, CDW1) + Or (CDW1, 4, CDW1) + Return (Arg3) + } + } +} diff --git a/arch/x86/include/asm/acpi/pcr.asl b/arch/x86/include/asm/acpi/pcr.asl new file mode 100644 index 0000000000..f66737b89c --- /dev/null +++ b/arch/x86/include/asm/acpi/pcr.asl @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2015 Google Inc. + * Copyright (C) 2018 Intel Corporation. + */ + +#include + +/* + * Calculate PCR register base at specified PID + * Arg0 - PCR Port ID + */ +Method (PCRB, 1, NotSerialized) +{ + Return (Add (IOMAP_P2SB_BAR, + ShiftLeft (Arg0, PCR_PORTID_SHIFT))) +} + +/* + * Read a PCR register at specified PID and offset + * Arg0 - PCR Port ID + * Arg1 - Register Offset + */ +Method (PCRR, 2, Serialized) +{ + OperationRegion (PCRD, SystemMemory, Add (PCRB (Arg0), Arg1), 4) + Field (PCRD, DWordAcc, NoLock, Preserve) + { + DATA, 32 + } + Return (DATA) +} + +/* + * AND a value with PCR register at specified PID and offset + * Arg0 - PCR Port ID + * Arg1 - Register Offset + * Arg2 - Value to AND + */ +Method (PCRA, 3, Serialized) +{ + OperationRegion (PCRD, SystemMemory, Add (PCRB (Arg0), Arg1), 4) + Field (PCRD, DWordAcc, NoLock, Preserve) + { + DATA, 32 + } + And (DATA, Arg2, DATA) + + /* + * After every write one needs to read an innocuous register + * to ensure the writes are completed for certain ports. This is done + * for all ports so that the callers don't need the per-port knowledge + * for each transaction. + */ + PCRR (Arg0, Arg1) +} + +/* + * OR a value with PCR register at specified PID and offset + * Arg0 - PCR Port ID + * Arg1 - Register Offset + * Arg2 - Value to OR + */ +Method (PCRO, 3, Serialized) +{ + OperationRegion (PCRD, SystemMemory, Add (PCRB (Arg0), Arg1), 4) + Field (PCRD, DWordAcc, NoLock, Preserve) + { + DATA, 32 + } + Or (DATA, Arg2, DATA) + + /* + * After every write one needs to read an innocuous register + * to ensure the writes are completed for certain ports. This is done + * for all ports so that the callers don't need the per-port knowledge + * for each transaction. + */ + PCRR (Arg0, Arg1) +} diff --git a/arch/x86/include/asm/acpi/ramoops.asl b/arch/x86/include/asm/acpi/ramoops.asl new file mode 100644 index 0000000000..55939e1aa3 --- /dev/null +++ b/arch/x86/include/asm/acpi/ramoops.asl @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + */ + +Scope (\_SB) +{ + Device(RMOP) + { + Name (_HID, "GOOG9999") + Name (_CID, "GOOG9999") + Name (_UID, 1) + + Name (RBUF, ResourceTemplate() + { + Memory32Fixed (ReadWrite, 0, 0, MRES) + }) + + Method (_CRS) + { + CreateDwordField (^RBUF, ^MRES._BAS, RBAS) + CreateDwordField (^RBUF, ^MRES._LEN, RLEN) + Store (\RMOB, RBAS) + Store (\RMOL, RLEN) + Return (^RBUF) + } + Method(_STA, 0) + { + Return (0xB) + } + } +} diff --git a/arch/x86/include/asm/acpi/sleepstates.asl b/arch/x86/include/asm/acpi/sleepstates.asl index 32e16a2c2f..31aa69a570 100644 --- a/arch/x86/include/asm/acpi/sleepstates.asl +++ b/arch/x86/include/asm/acpi/sleepstates.asl @@ -6,9 +6,11 @@ * Modified from coreboot src/soc/intel/baytrail/acpi/sleepstates.asl */ -Name(\_S0, Package() {0x0, 0x0, 0x0, 0x0}) -#ifdef CONFIG_HAVE_ACPI_RESUME -Name(\_S3, Package() {0x5, 0x0, 0x0, 0x0}) +Name(\_S0, Package(){0x0,0x0,0x0,0x0}) +#if !IS_ENABLED(CONFIG_HAVE_ACPI_RESUME) +Name(\_S1, Package(){0x1,0x0,0x0,0x0}) +#else +Name(\_S3, Package(){0x5,0x0,0x0,0x0}) #endif -Name(\_S4, Package() {0x6, 0x0, 0x0, 0x0}) -Name(\_S5, Package() {0x7, 0x0, 0x0, 0x0}) +Name(\_S4, Package(){0x6,0x0,0x0,0x0}) +Name(\_S5, Package(){0x7,0x0,0x0,0x0}) From patchwork Mon Jan 27 05:06:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229567 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=ACXPogpT; 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 485dPV5vT4z9sR1 for ; Mon, 27 Jan 2020 16:20:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A27BA818D0; Mon, 27 Jan 2020 06:12:47 +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="ACXPogpT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32292816E1; Mon, 27 Jan 2020 06:09:57 +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,T_FILL_THIS_FORM_SHORT, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 A91A381828 for ; Mon, 27 Jan 2020 06:09:19 +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-xd2d.google.com with SMTP id z193so8583575iof.1 for ; Sun, 26 Jan 2020 21:09:19 -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=0R6KGc64wI3rLwvEY0z0c5W6tJ6ze5aoCrseqBNp2fc=; b=ACXPogpTzyoltN9BE+9sn6Q0qgWImQA35kpztUNPevLSYqmhmkBL/1anlQjn3GS/YL wZeXEsEz9fJA2LJrOGvjQKk5SFboJikUWSIHm/W9l7HkmV4FHBaaMeYfmdrx/WSrjpdV x4C2FzefpbSQ+IEGTONICqrQMPTjTmv80s2UQ= 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=0R6KGc64wI3rLwvEY0z0c5W6tJ6ze5aoCrseqBNp2fc=; b=JfiKg/T4bcxQR+3TK1KckcA3CpnCzxARvjsa8g89p3y5LmW3803xPeIRhOpNNrOcMI ae32dl+aTjHjcpy3/aEK/2wC7o1mimWtc7yd57f2JvoI6pINhKVgZZjgvkQXVtGuqwyi fR0uOXPrHplPdt2cePwj/lGAh5TPCqQqamLn15Yko3jIUQ3KtWlP9buPO3ziar/1DD6s LM2eqf8J6lDkM2nbbyF1UQZcg2rp5UYMSAkwDfDkzCTB6Z5Rd2zQJ1D9YXMEebh5OlRE xb/eVQGLSMhR6i85NgErW2HZD7gPtT8NAQRKDj8XasC8TNKj4cyIpyUNaaw4Gf5B/Ld/ v60Q== X-Gm-Message-State: APjAAAWBH2hyUdtH7MsYfU1DglMFhTa4593Q0psss2DpdL8cmWmiTQ6T KNStPlOBGeZ5mHQlqFLyk8QCmgBPoXR51g== X-Google-Smtp-Source: APXvYqxDdUQffGEKCwwY15RjoBdad/8eRlJKJ5iLEJPDQx4BLHCLfhavzPWUUuhYx0/em+D/uG4Ugg== X-Received: by 2002:a02:5489:: with SMTP id t131mr11815780jaa.40.1580101757430; Sun, 26 Jan 2020 21:09:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:16 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 067/108] x86: acpi: apl: Add asl files for Apollo Lake Date: Sun, 26 Jan 2020 22:06:14 -0700 Message-Id: <20200126220508.67.I25148ea0707da6ca2a9c2a86cdaca2439052abac@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 Add Apollo Lake ASL files, taken from coreboot. Signed-off-by: Simon Glass --- .../include/asm/arch-apollolake/acpi/dptf.asl | 35 ++++ .../asm/arch-apollolake/acpi/globalnvs.asl | 41 ++++ .../include/asm/arch-apollolake/acpi/gpio.asl | 191 ++++++++++++++++++ .../asm/arch-apollolake/acpi/gpiolib.asl | 109 ++++++++++ .../include/asm/arch-apollolake/acpi/lpss.asl | 105 ++++++++++ .../asm/arch-apollolake/acpi/northbridge.asl | 120 +++++++++++ .../asm/arch-apollolake/acpi/pch_hda.asl | 77 +++++++ .../asm/arch-apollolake/acpi/pci_irqs.asl | 52 +++++ .../include/asm/arch-apollolake/acpi/pcie.asl | 22 ++ .../asm/arch-apollolake/acpi/pcie_port.asl | 113 +++++++++++ .../asm/arch-apollolake/acpi/platform.asl | 10 + .../asm/arch-apollolake/acpi/pmc_ipc.asl | 49 +++++ .../include/asm/arch-apollolake/acpi/scs.asl | 173 ++++++++++++++++ .../asm/arch-apollolake/acpi/soc_int.asl | 50 +++++ .../asm/arch-apollolake/acpi/southbridge.asl | 34 ++++ .../include/asm/arch-apollolake/acpi/xhci.asl | 33 +++ .../arch-apollolake/acpi/xhci_apl_ports.asl | 23 +++ .../arch-apollolake/acpi/xhci_glk_ports.asl | 24 +++ 18 files changed, 1261 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/dptf.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpio.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/lpss.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/platform.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/scs.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl create mode 100644 arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl diff --git a/arch/x86/include/asm/arch-apollolake/acpi/dptf.asl b/arch/x86/include/asm/arch-apollolake/acpi/dptf.asl new file mode 100644 index 0000000000..4c50bb45c0 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/dptf.asl @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + */ + +#define DPTF_CPU_DEVICE TCPU +#define DPTF_CPU_ADDR 0x00000001 + +#ifndef DPTF_CPU_PASSIVE +#define DPTF_CPU_PASSIVE 80 +#endif + +#ifndef DPTF_CPU_CRITICAL +#define DPTF_CPU_CRITICAL 90 +#endif + +#ifndef DPTF_CPU_ACTIVE_AC0 +#define DPTF_CPU_ACTIVE_AC0 90 +#endif + +#ifndef DPTF_CPU_ACTIVE_AC1 +#define DPTF_CPU_ACTIVE_AC1 80 +#endif + +#ifndef DPTF_CPU_ACTIVE_AC2 +#define DPTF_CPU_ACTIVE_AC2 70 +#endif + +#ifndef DPTF_CPU_ACTIVE_AC3 +#define DPTF_CPU_ACTIVE_AC3 60 +#endif + +#ifndef DPTF_CPU_ACTIVE_AC4 +#define DPTF_CPU_ACTIVE_AC4 50 +#endif diff --git a/arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl b/arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl new file mode 100644 index 0000000000..7854f7e1c5 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/globalnvs.asl @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Alexandru Gagniuc for Intel Corp.) + */ + +/* + * NOTE: The layout of the GNVS structure below must match the layout in + * soc/intel/apollolake/include/soc/nvs.h !!! + * + */ + +External (NVSA) + +OperationRegion (GNVS, SystemMemory, NVSA, ACPI_GNVS_SIZE) +Field (GNVS, ByteAcc, NoLock, Preserve) +{ + /* Miscellaneous */ + Offset (0x00), + PCNT, 8, // 0x00 - Processor Count + PPCM, 8, // 0x01 - Max PPC State + LIDS, 8, // 0x02 - LID State + PWRS, 8, // 0x03 - AC Power State + DPTE, 8, // 0x04 - Enable DPTF + CBMC, 32, // 0x05 - 0x08 - coreboot Memory Console + PM1I, 64, // 0x09 - 0x10 - System Wake Source - PM1 Index + GPEI, 64, // 0x11 - 0x18 - GPE Wake Source + NHLA, 64, // 0x19 - 0x20 - NHLT Address + NHLL, 32, // 0x21 - 0x24 - NHLT Length + PRT0, 32, // 0x25 - 0x28 - PERST_0 Address + SCDP, 8, // 0x29 - SD_CD GPIO portid + SCDO, 8, // 0x2A - GPIO pad offset relative to the community + UIOR, 8, // 0x2B - UART debug controller init on S3 resume + EPCS, 8, // 0x2C - SGX Enabled status + EMNA, 64, // 0x2D - 0x34 EPC base address + ELNG, 64, // 0x35 - 0x3C EPC Length + + /* ChromeOS stuff (0x100 -> 0xfff, size 0xeff) */ + Offset (0x100), + #include +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/gpio.asl b/arch/x86/include/asm/arch-apollolake/acpi/gpio.asl new file mode 100644 index 0000000000..b0f892166b --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/gpio.asl @@ -0,0 +1,191 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ +#include +#include +// #include +// #include +#include +#include +#include "gpiolib.asl" + +scope (\_SB) { + + Device (GPO0) + { + Name (_HID, GPIO_COMM_NAME) + Name (_CID, GPIO_COMM_NAME) + Name (_DDN, GPIO_COMM_0_DESC) + Name (_UID, 1) + + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0, 0x4000, RMEM) + Interrupt (ResourceConsumer, Level, ActiveLow, Shared, , , ) + { + GPIO_BANK_INT + } + }) + + Method (_CRS, 0x0, NotSerialized) + { + CreateDwordField (^RBUF, ^RMEM._BAS, RBAS) + ShiftLeft (GPIO_COMM0_PID, PCR_PORTID_SHIFT, Local0) + Or (IOMAP_P2SB_BAR, Local0, RBAS) + Return (^RBUF) + } + + Method (_STA, 0x0, NotSerialized) + { + Return(0xf) + } + } + + Device (GPO1) + { + Name (_HID, GPIO_COMM_NAME) + Name (_CID, GPIO_COMM_NAME) + Name (_DDN, GPIO_COMM_1_DESC) + Name (_UID, 2) + + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0, 0x4000, RMEM) + Interrupt (ResourceConsumer, Level, ActiveLow, Shared, , , ) + { + GPIO_BANK_INT + } + }) + + Method (_CRS, 0x0, NotSerialized) + { + CreateDwordField (^RBUF, ^RMEM._BAS, RBAS) + ShiftLeft (GPIO_COMM1_PID, PCR_PORTID_SHIFT, Local0) + Or (IOMAP_P2SB_BAR, Local0, RBAS) + Return (^RBUF) + } + + Method (_STA, 0x0, NotSerialized) + { + Return(0xf) + } + } + + Device (GPO2) + { + Name (_HID, GPIO_COMM_NAME) + Name (_CID, GPIO_COMM_NAME) + Name (_DDN, GPIO_COMM_2_DESC) + Name (_UID, 3) + + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0, 0x4000, RMEM) + Interrupt (ResourceConsumer, Level, ActiveLow, Shared, , , ) + { + GPIO_BANK_INT + } + }) + + Method (_CRS, 0x0, NotSerialized) + { + CreateDwordField (^RBUF, ^RMEM._BAS, RBAS) + ShiftLeft (GPIO_COMM2_PID, PCR_PORTID_SHIFT, Local0) + Or (IOMAP_P2SB_BAR, Local0, RBAS) + Return (^RBUF) + } + + Method (_STA, 0x0, NotSerialized) + { + Return(0xf) + } + } + + Device (GPO3) + { + Name (_HID, GPIO_COMM_NAME) + Name (_CID, GPIO_COMM_NAME) + Name (_DDN, GPIO_COMM_3_DESC) + Name (_UID, 4) + + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0, 0x4000, RMEM) + Interrupt (ResourceConsumer, Level, ActiveLow, Shared, , , ) + { + GPIO_BANK_INT + } + }) + + Method (_CRS, 0x0, NotSerialized) + { + CreateDwordField (^RBUF, ^RMEM._BAS, RBAS) + ShiftLeft (GPIO_COMM3_PID, PCR_PORTID_SHIFT, Local0) + Or (IOMAP_P2SB_BAR, Local0, RBAS) + Return (^RBUF) + } + + Method (_STA, 0x0, NotSerialized) + { + Return(0xf) + } + } + + Scope(\_SB.PCI0) { + /* PERST Assertion + * Note: PERST is Active High + */ + Method (PRAS, 0x1, Serialized) + { + /* + * Assert PERST + * local1 - to toggle Tx pin of Dw0 + * local2 - Address of PERST + */ + Store (Arg0, Local2) + Store (\_SB.GPC0 (Local2), Local1) + Or (Local1, PAD_CFG0_TX_STATE, Local1) + \_SB.SPC0 (Local2, Local1) + } + + /* PERST DE-Assertion */ + Method (PRDA, 0x1, Serialized) + { + /* + * De-assert PERST + * local1 - to toggle Tx pin of Dw0 + * local2 - Address of PERST + */ + Store (Arg0, Local2) + Store (\_SB.GPC0 (Local2), Local1) + And (Local1, Not (PAD_CFG0_TX_STATE), Local1) + \_SB.SPC0 (Local2, Local1) + } + } + + /* + * Sleep button device ASL code. We are using this device to + * add the _PRW method for a dummy wake event to kernel so that + * before going to sleep kernel does not clear bit 15 in ACPI + * gpe0a enable register which is actually the GPIO_TIER1_SCI_EN bit. + */ + Device (SLP) + { + Name (_HID, EisaId ("PNP0C0E")) + + Name (_PRW, Package() { GPE0A_GPIO_TIER1_SCI_STS, 0x3 }) + } +} + +Scope(\_GPE) +{ + /* + * Dummy method for the Tier 1 GPIO SCI enable bit. When kernel reads + * _L0F in scope GPE it sets bit for gpio_tier1_sci_en in ACPI enable + * register at 0x430. For APL ACPI enable register DW0 i.e., ACPI + * GPE0a_EN at 0x430 is reserved. + */ + Method(_L0F, 0) {} +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl b/arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl new file mode 100644 index 0000000000..0eb808dc19 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/gpiolib.asl @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + */ + +Scope (\_SB) +{ + /* Get Pad Configuration DW0 register value */ + Method (GPC0, 0x1, Serialized) + { + /* Arg0 - GPIO DW0 address */ + Store (Arg0, Local0) + OperationRegion (PDW0, SystemMemory, Local0, 4) + Field (PDW0, AnyAcc, NoLock, Preserve) { + TEMP, 32 + } + Return (TEMP) + } + + /* Set Pad Configuration DW0 register value */ + Method (SPC0, 0x2, Serialized) + { + /* Arg0 - GPIO DW0 address */ + /* Arg1 - Value for DW0 register */ + Store (Arg0, Local0) + OperationRegion (PDW0, SystemMemory, Local0, 4) + Field (PDW0, AnyAcc, NoLock, Preserve) { + TEMP,32 + } + Store (Arg1, TEMP) + } + + /* Get Pad Configuration DW1 register value */ + Method (GPC1, 0x1, Serialized) + { + /* Arg0 - GPIO DW0 address */ + Store (Add (Arg0, 0x4), Local0) + OperationRegion (PDW1, SystemMemory, Local0, 4) + Field (PDW1, AnyAcc, NoLock, Preserve) { + TEMP, 32 + } + Return (TEMP) + } + + /* Set Pad Configuration DW1 register value */ + Method (SPC1, 0x2, Serialized) + { + /* Arg0 - GPIO DW0 address */ + /* Arg1 - Value for DW1 register */ + Store (Add (Arg0, 0x4), Local0) + OperationRegion (PDW1, SystemMemory, Local0, 4) + Field(PDW1, AnyAcc, NoLock, Preserve) { + TEMP,32 + } + Store (Arg1, TEMP) + } + + /* Get DW0 address of a given pad */ + Method (GDW0, 0x2, Serialized) + { + /* Arg0 - GPIO portid */ + /* Arg1 - GPIO pad offset relative to the community */ + Store (0, Local1) + Or( Or (ShiftLeft (Arg0, 16), IOMAP_P2SB_BAR), + Local1, Local1) + Or( Add (PAD_CFG_BASE, Multiply (Arg1, Multiply ( + GPIO_NUM_PAD_CFG_REGS, 4))), Local1, Local1) + Return (Local1) + } + + /* Calculate HOSTSW_REG address */ + Method (CHSA, 0x1, Serialized) + { + /* Arg0 - GPIO pad offset relative to the community */ + Add (HOSTSW_OWN_REG_0, Multiply (Divide (Arg0, 32), 4), Local1) + Return (Local1) + } + + /* Get Host ownership register of GPIO Community */ + Method (GHO, 0x2, Serialized) + { + /* Arg0 - GPIO portid */ + /* Arg1 - GPIO pad offset relative to the community */ + Store (CHSA (Arg1), Local1) + + OperationRegion (SHO0, SystemMemory, Or ( Or + (IOMAP_P2SB_BAR, ShiftLeft (Arg0, 16)), Local1), 4) + Field (SHO0, AnyAcc, NoLock, Preserve) { + TEMP, 32 + } + Return (TEMP) + } + + /* Set Host ownership register of GPIO Community */ + Method (SHO, 0x3, Serialized) + { + /* Arg0 - GPIO portid */ + /* Arg1 - GPIO pad offset relative to the community */ + /* Arg2 - Value for Host own register */ + Store (CHSA (Arg1), Local1) + + OperationRegion (SHO0, SystemMemory, Or ( Or + (IOMAP_P2SB_BAR, ShiftLeft (Arg0, 16)), Local1), 4) + Field (SHO0, AnyAcc, NoLock, Preserve) { + TEMP, 32 + } + Store (Arg2, TEMP) + } +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/lpss.asl b/arch/x86/include/asm/arch-apollolake/acpi/lpss.asl new file mode 100644 index 0000000000..bc3eabba60 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/lpss.asl @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ + +scope (\_SB.PCI0) { + + /* LPIO1 PWM */ + Device(PWM) { + Name (_ADR, 0x001A0000) + Name (_DDN, "Intel(R) PWM Controller") + } + + /* LPIO1 HS-UART #1 */ + Device(URT1) { + Name (_ADR, 0x00180000) + Name (_DDN, "Intel(R) HS-UART Controller #1") + } + + /* LPIO1 HS-UART #2 */ + Device(URT2) { + Name (_ADR, 0x00180001) + Name (_DDN, "Intel(R) HS-UART Controller #2") + } + + /* LPIO1 HS-UART #3 */ + Device(URT3) { + Name (_ADR, 0x00180002) + Name (_DDN, "Intel(R) HS-UART Controller #3") + } + + /* LPIO1 HS-UART #4 */ + Device(URT4) { + Name (_ADR, 0x00180003) + Name (_DDN, "Intel(R) HS-UART Controller #4") + } + + /* LPIO1 SPI */ + Device(SPI1) { + Name (_ADR, 0x00190000) + Name (_DDN, "Intel(R) SPI Controller #1") + } + + /* LPIO1 SPI #2 */ + Device(SPI2) { + Name (_ADR, 0x00190001) + Name (_DDN, "Intel(R) SPI Controller #2") + } + + /* LPIO1 SPI #3 */ + Device(SPI3) { + Name (_ADR, 0x00190002) + Name (_DDN, "Intel(R) SPI Controller #3") + } + + + /* LPIO2 I2C #0 */ + Device(I2C0) { + Name (_ADR, 0x00160000) + Name (_DDN, "Intel(R) I2C Controller #0") + } + + /* LPIO2 I2C #1 */ + Device(I2C1) { + Name (_ADR, 0x00160001) + Name (_DDN, "Intel(R) I2C Controller #1") + } + + /* LPIO2 I2C #2 */ + Device(I2C2) { + Name (_ADR, 0x00160002) + Name (_DDN, "Intel(R) I2C Controller #2") + } + + /* LPIO2 I2C #3 */ + Device(I2C3) { + Name (_ADR, 0x00160003) + Name (_DDN, "Intel(R) I2C Controller #3") + } + + /* LPIO2 I2C #4 */ + Device(I2C4) { + Name (_ADR, 0x00170000) + Name (_DDN, "Intel(R) I2C Controller #4") + } + + /* LPIO2 I2C #5 */ + Device(I2C5) { + Name (_ADR, 0x00170001) + Name (_DDN, "Intel(R) I2C Controller #5") + } + + /* LPIO2 I2C #6 */ + Device(I2C6) { + Name (_ADR, 0x00170002) + Name (_DDN, "Intel(R) I2C Controller #6") + } + + /* LPIO2 I2C #7 */ + Device(I2C7) { + Name (_ADR, 0x00170003) + Name (_DDN, "Intel(R) I2C Controller #7") + } +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl b/arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl new file mode 100644 index 0000000000..ff5657abd0 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/northbridge.asl @@ -0,0 +1,120 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ + + Name(_HID, EISAID("PNP0A08")) /* PCIe */ + Name(_CID, EISAID("PNP0A03")) /* PCI */ + Name(_BBN, 0) + +Device (MCHC) +{ + Name (_ADR, 0x00000000) /*Dev0 Func0 */ + + OperationRegion (MCHP, PCI_Config, 0x00, 0x100) + Field (MCHP, DWordAcc, NoLock, Preserve) + { + Offset(0x60), + MCNF, 32, /* PCI MMCONF base */ + Offset (0xA8), + TUUD, 64, /* Top of Upper Used Memory */ + Offset(0xB4), + BGSM, 32, /* Base of Graphics Stolen Memory */ + Offset(0xBC), + TLUD, 32, /* Top of Low Useable DRAM */ + } +} +Name (MCRS, ResourceTemplate() +{ + /* Bus Numbers */ + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, + 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,,) + + /* IO Region 0 */ + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,,) + + /* PCI Config Space */ + Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008) + + /* IO Region 1 */ + DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, + 0x0000, 0x01000, 0xffff, 0x0000, 0xf000,,,) + + /* VGA memory (0xa0000-0xbffff) */ + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, + Cacheable, ReadWrite, + 0x00000000, 0x000a0000, 0x000bffff, 0x00000000, + 0x00020000,,,) + + /* Data and GFX stolen memory */ + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, + Cacheable, ReadWrite, + 0x00000000, 0x3be00000, 0x3fffffff, 0x00000000, + 0x04200000,,, STOM) + + /* + * PCI MMIO Region (TOLUD - PCI extended base MMCONF) + * This assumes that MMCONF is placed after PCI config space, + * and that no resources are allocated after the MMCONF region. + * This works, sicne MMCONF is hardcoded to 0xe00000000. + */ + DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, + NonCacheable, ReadWrite, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000,,, PM01) + + /* PCI Memory Region (TOUUD - (TOUUD + ABOVE_4G_MMIO_SIZE)) */ + QWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, + NonCacheable, ReadWrite, + 0x00000000, 0x10000, 0x1ffff, 0x00000000, + 0x10000,,, PM02) +}) + +/* Current Resource Settings */ +Method (_CRS, 0, Serialized) +{ + + /* Find PCI resource area in MCRS */ + CreateDwordField (MCRS, ^PM01._MIN, PMIN) + CreateDwordField (MCRS, ^PM01._MAX, PMAX) + CreateDwordField (MCRS, ^PM01._LEN, PLEN) + + /* Read C-Unit PCI CFG Reg. 0xBC for TOLUD (shadow from B-Unit) */ + And(^MCHC.TLUD, 0xFFF00000, PMIN) + /* Read MMCONF base */ + And(^MCHC.MCNF, 0xF0000000, PMAX) + + /* Calculate PCI MMIO Length */ + Add(Subtract(PMAX, PMIN), 1, PLEN) + + /* Find GFX resource area in GCRS */ + CreateDwordField(MCRS, ^STOM._MIN, GMIN) + CreateDwordField(MCRS, ^STOM._MAX, GMAX) + CreateDwordField(MCRS, ^STOM._LEN, GLEN) + + /* Read BGSM */ + And(^MCHC.BGSM, 0xFFF00000, GMIN) + + /* Read TOLUD */ + And(^MCHC.TLUD, 0xFFF00000, GMAX) + Decrement(GMAX) + Add(Subtract(GMAX, GMIN), 1, GLEN) + + /* Patch PM02 range based on Memory Size */ + CreateQwordField (MCRS, ^PM02._MIN, MMIN) + CreateQwordField (MCRS, ^PM02._MAX, MMAX) + CreateQwordField (MCRS, ^PM02._LEN, MLEN) + + Store (^MCHC.TUUD, Local0) + + If (LLessEqual (Local0, 0x1000000000)) + { + Store (0, MMIN) + Store (0, MLEN) + } + Subtract (Add (MMIN, MLEN), 1, MMAX) + + Return (MCRS) +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl b/arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl new file mode 100644 index 0000000000..cc3b7a769d --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/pch_hda.asl @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + * Copyright (C) 2016 Google Inc. + * + */ + +/* Audio Controller - Device 14, Function 0 */ + +Device (HDAS) +{ + Name (_ADR, 0x000E0000) + Name (_DDN, "Audio Controller") + Name (UUID, ToUUID("A69F886E-6CEB-4594-A41F-7B5DCE24C553")) + + /* Device is D3 wake capable */ + Name (_S0W, 3) + + /* NHLT Table Address populated from GNVS values */ + Name (NBUF, ResourceTemplate() { + QWordMemory (ResourceConsumer, PosDecode, MinFixed, + MaxFixed, Cacheable, ReadOnly, + 0, 0, 0, 0, 1,,, NHLT, AddressRangeACPI) + } + ) + + /* can wake up from S3 state */ + Name (_PRW, Package() { GPE0A_AVS_PME_STS, 3 }) + + /* + * Device Specific Method + * Arg0 - UUID + * Arg1 - Revision + * Arg2 - Function Index + */ + Method (_DSM, 4) { + If (LEqual (Arg0, ^UUID)) { + /* + * Function 0: Function Support Query + * Returns a bitmask of functions supported. + */ + If (LEqual (Arg2, Zero)) { + /* + * NHLT Query only supported for revision 1 and + * if NHLT address and length are set in NVS. + */ + If (LAnd (LEqual (Arg1, One), + LAnd (LNotEqual (NHLA, Zero), + LNotEqual (NHLL, Zero)))) { + Return (Buffer (One) { 0x03 }) + } + Else { + Return (Buffer (One) { 0x01 }) + } + } + + /* + * Function 1: Query NHLT memory address used by + * Intel Offload Engine Driver to discover any non-HDA + * devices that are supported by the DSP. + * + * Returns a pointer to NHLT table in memory. + */ + If (LEqual (Arg2, One)) { + CreateQWordField (NBUF, ^NHLT._MIN, NBAS) + CreateQWordField (NBUF, ^NHLT._MAX, NMAS) + CreateQWordField (NBUF, ^NHLT._LEN, NLEN) + Store (NHLA, NBAS) + Store (NHLA, NMAS) + Store (NHLL, NLEN) + Return (NBUF) + } + } + + Return (Buffer (One) { 0x00 }) + } +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl b/arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl new file mode 100644 index 0000000000..21a1ca9ff9 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/pci_irqs.asl @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ + +#include "soc_int.asl" + +Method(_PRT) +{ + Return(Package() { + + Package(){0x0000FFFF, 0, 0, NPK_INT}, + Package(){0x0000FFFF, 1, 0, PUNIT_INT}, + Package(){0x0002FFFF, 0, 0, GEN_INT}, + Package(){0x0003FFFF, 0, 0, IUNIT_INT}, + Package(){0x000DFFFF, 1, 0, PMC_INT}, + Package(){0x000EFFFF, 0, 0, AUDIO_INT}, + Package(){0x000FFFFF, 0, 0, CSE_INT}, + Package(){0x0011FFFF, 0, 0, ISH_INT}, + Package(){0x0012FFFF, 0, 0, SATA_INT}, + Package(){0x0013FFFF, 0, 0, PIRQA_INT}, + Package(){0x0013FFFF, 1, 0, PIRQB_INT}, + Package(){0x0013FFFF, 2, 0, PIRQC_INT}, + Package(){0x0013FFFF, 3, 0, PIRQD_INT}, + Package(){0x0014FFFF, 0, 0, PIRQB_INT}, + Package(){0x0014FFFF, 1, 0, PIRQC_INT}, + Package(){0x0014FFFF, 2, 0, PIRQD_INT}, + Package(){0x0014FFFF, 3, 0, PIRQA_INT}, + Package(){0x0015FFFF, 0, 0, XHCI_INT}, + Package(){0x0015FFFF, 1, 0, XDCI_INT}, + Package(){0x0016FFFF, 0, 0, I2C0_INT}, + Package(){0x0016FFFF, 1, 0, I2C1_INT}, + Package(){0x0016FFFF, 2, 0, I2C2_INT}, + Package(){0x0016FFFF, 3, 0, I2C3_INT}, + Package(){0x0017FFFF, 0, 0, I2C4_INT}, + Package(){0x0017FFFF, 1, 0, I2C5_INT}, + Package(){0x0017FFFF, 2, 0, I2C6_INT}, + Package(){0x0017FFFF, 3, 0, I2C7_INT}, + Package(){0x0018FFFF, 0, 0, UART0_INT}, + Package(){0x0018FFFF, 1, 0, UART1_INT}, + Package(){0x0018FFFF, 2, 0, UART2_INT}, + Package(){0x0018FFFF, 3, 0, UART3_INT}, + Package(){0x0019FFFF, 0, 0, SPI0_INT}, + Package(){0x0019FFFF, 1, 0, SPI1_INT}, + Package(){0x0019FFFF, 2, 0, SPI2_INT}, + Package(){0x001BFFFF, 0, 0, SDCARD_INT}, + Package(){0x001CFFFF, 0, 0, EMMC_INT}, + Package(){0x001EFFFF, 0, 0, SDIO_INT}, + Package(){0x001FFFFF, 1, 0, SMBUS_INT}, + }) +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/pcie.asl b/arch/x86/include/asm/arch-apollolake/acpi/pcie.asl new file mode 100644 index 0000000000..ecff59ab1c --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/pcie.asl @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation + */ + +/* PCIe Ports */ + +Device (RP01) +{ + Name (_ADR, 0x00140000) + Name (_DDN, "PCIe-B 0") + + #include "pcie_port.asl" +} + +Device (RP03) +{ + Name (_ADR, 0x00130000) + Name (_DDN, "PCIe-A 0") + + #include "pcie_port.asl" +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl b/arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl new file mode 100644 index 0000000000..12a08b4aa8 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/pcie_port.asl @@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation + */ + +/* Include in each PCIe Root Port device */ + +/* lowest D-state supported by + * PCIe root port during S0 state + */ +Name (_S0W, 4) + +Name (PDST, 0) /* present Detect status */ + +/* Dynamic Opregion needed to access registers + * when the controller is in D3 cold + */ +OperationRegion (PX01, PCI_Config, 0x00, 0xFF) +Field (PX01, AnyAcc, NoLock, Preserve) +{ + Offset(0x5A), + , 6, + PDS, 1, /* 6, Presence detect Change */ + Offset(0xE2), /* RPPGEN - Root Port Power Gating Enable */ + , 2, + L23E, 1, /* 2, L23_Rdy Entry Request (L23ER) */ + L23R, 1, /* 3, L23_Rdy to Detect Transition (L23R2DT) */ + Offset(0xF4), /* BLKPLLEN */ + , 10, + BPLL, 1, +} + +OperationRegion (PX02, PCI_Config, 0x338, 0x4) +Field (PX02, AnyAcc, NoLock, Preserve) +{ + , 26, + BDQA, 1 /* BLKDQDA */ +} + +PowerResource (PXP, 0, 0) +{ + /* Define the PowerResource for PCIe slot */ + Method (_STA, 0, Serialized) + { + Store (PDS, PDST) + If (LEqual (PDS, 1)) { + Return (0xf) + } Else { + Return (0) + } + } + + Method (_ON, 0, Serialized) + { + If (LAnd (LEqual (PDST, 1), LNotEqual (\PRT0, 0))) { + /* Enter this condition if device + * is connected + */ + + /* De-assert PERST */ + \_SB.PCI0.PRDA (\PRT0) + + Store (0, BDQA) /* Set BLKDQDA to 0 */ + Store (0, BPLL) /* Set BLKPLLEN to 0 */ + + /* Set L23_Rdy to Detect Transition + * (L23R2DT) + */ + Store (1, L23R) + Sleep (16) + Store (0, Local0) + + /* Delay for transition Detect + * and link to train + */ + While (L23R) { + If (Lgreater (Local0, 4)) { + Break + } + Sleep (16) + Increment (Local0) + } + } /* End PDS condition check */ + } + + Method (_OFF, 0, Serialized) + { + /* Set L23_Rdy Entry Request (L23ER) */ + If (LAnd (LEqual (PDST, 1), LNotEqual (\PRT0, 0))) { + /* enter this condition if device + * is connected + */ + Store (1, L23E) + Sleep (16) + Store (0, Local0) + While (L23E) { + If (Lgreater (Local0, 4)) { + Break + } + Sleep (16) + Increment (Local0) + } + Store (1, BDQA) /* Set BLKDQDA to 1 */ + Store (1, BPLL) /* Set BLKPLLEN to 1 */ + + /* Assert PERST */ + \_SB.PCI0.PRAS (\PRT0) + } /* End PDS condition check */ + } /* End of Method_OFF */ +} /* End PXP */ + +Name(_PR0, Package() { PXP }) +Name(_PR3, Package() { PXP }) diff --git a/arch/x86/include/asm/arch-apollolake/acpi/platform.asl b/arch/x86/include/asm/arch-apollolake/acpi/platform.asl new file mode 100644 index 0000000000..b631a9fb38 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/platform.asl @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2007-2009 coresystems GmbH + * Copyright (C) 2012 Google Inc. + * Copyright (C) 2016 Intel Corp + */ + +/* Enable ACPI _SWS methods */ +#include +#include diff --git a/arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl b/arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl new file mode 100644 index 0000000000..4a592833cc --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/pmc_ipc.asl @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corp. + */ + +#include + +#define MAILBOX_DATA 0x7080 +#define MAILBOX_INTF 0x7084 +#define PMIO_LENGTH 0x80 +#define PMIO_LIMIT 0x480 + +scope (\_SB) { + Device (IPC1) + { + Name (_HID, "INT34D2") + Name (_CID, "INT34D2") + Name (_DDN, "Intel(R) IPC1 Controller") + Name (RBUF, ResourceTemplate () + { + Memory32Fixed (ReadWrite, 0x0, 0x2000, IBAR) + Memory32Fixed (ReadWrite, 0x0, 0x4, MDAT) + Memory32Fixed (ReadWrite, 0x0, 0x4, MINF) + IO (Decode16, IOMAP_ACPI_BASE, PMIO_LIMIT, + 0x04, PMIO_LENGTH) + Memory32Fixed (ReadWrite, 0x0, 0x2000, SBAR) + Interrupt (ResourceConsumer, Level, ActiveLow, Exclusive, , , ) + { + PMC_INT + } + }) + + Method (_CRS, 0x0, NotSerialized) + { + CreateDwordField (^RBUF, ^IBAR._BAS, IBAS) + Store (PMC_BAR0, IBAS) + + CreateDwordField (^RBUF, ^MDAT._BAS, MDBA) + Store (MCH_BASE_ADDRESS + MAILBOX_DATA, MDBA) + CreateDwordField (^RBUF, ^MINF._BAS, MIBA) + Store (MCH_BASE_ADDRESS + MAILBOX_INTF, MIBA) + + CreateDwordField (^RBUF, ^SBAR._BAS, SBAS) + Store (SRAM_BASE_0, SBAS) + + Return (^RBUF) + } + } +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/scs.asl b/arch/x86/include/asm/arch-apollolake/acpi/scs.asl new file mode 100644 index 0000000000..7d61861ea1 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/scs.asl @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + */ + +Scope (\_SB.PCI0) { + /* 0xD6- is the port address */ + /* 0x600- is the dynamic clock gating control register offset (GENR) */ + OperationRegion (SBMM, SystemMemory, + Or ( Or (IOMAP_P2SB_BAR, + ShiftLeft(0xD6, PCR_PORTID_SHIFT)), 0x0600), 0x18) + Field (SBMM, DWordAcc, NoLock, Preserve) + { + GENR, 32, + Offset (0x08), + , 5, /* bit[5] represents Force Card Detect SD Card */ + GRR3, 1, /* GPPRVRW3 for SD Card detect Bypass. It's active high */ + } + + /* SCC power gate control method, this method must be serialized as + * multiple device will control the GENR register + * + * Arguments: (2) + * Arg0: 0-AND 1-OR + * Arg1: Value + */ + Method (SCPG, 2, Serialized) + { + if (LEqual(Arg0, 0x1)) { + Or (^GENR, Arg1, ^GENR) + } ElseIf (LEqual(Arg0, 0x0)){ + And (^GENR, Arg1, ^GENR) + } + } + + /* eMMC */ + Device (SDHA) { + Name (_ADR, 0x001C0000) + Name (_DDN, "Intel(R) eMMC Controller - 80865ACC") + Name (UUID, ToUUID ("E5C937D0-3553-4D7A-9117-EA4D19C3434D")) + + /* + * Device Specific Method + * Arg0 - UUID + * Arg1 - Revision + * Arg2 - Function Index + */ + Method (_DSM, 4) + { + If (LEqual (Arg0, ^UUID)) { + /* + * Function 9: Device Readiness Durations + * Returns a package of five integers covering + * various device related delays in PCIe Base Spec. + */ + If (LEqual (Arg2, 9)) { + /* + * Function 9 support for revision 3. + * ECN link for function definitions + * [https://pcisig.com/sites/default/files/ + * specification_documents/ + * ECN_fw_latency_optimization_final.pdf] + */ + If (LEqual (Arg1, 3)) { + /* + * Integer 0: FW reset time. + * Integer 1: FW data link up time. + * Integer 2: FW functional level reset + * time. + * Integer 3: FW D3 hot to D0 time. + * Integer 4: FW VF enable time. + * set ACPI constant Ones for elements + * where overriding the default value + * is not desired. + */ + Return (Package (5) {0, Ones, Ones, + Ones, Ones}) + } + } + } + Return (Buffer() { 0x00 }) + } + + Method (_PS0, 0, NotSerialized) + { + /* Clear clock gate + * Clear bit 6 and 0 + */ + ^^SCPG(0,0xFFFFFFBE) + /* Sleep 2 ms */ + Sleep (2) + } + + Method (_PS3, 0, NotSerialized) + { + /* Enable power gate + * Restore clock gate + * Restore bit 6 and 0 + */ + ^^SCPG(1,0x00000041) + } + + Device (CARD) + { + Name (_ADR, 0x00000008) + Method (_RMV, 0, NotSerialized) + { + Return (0) + } + } + } /* Device (SDHA) */ + + /* SD CARD */ + Device (SDCD) + { + Name (_ADR, 0x001B0000) + Name (_S0W, 4) /* _S0W: S0 Device Wake State */ + Name (SCD0, 0) /* Store SD_CD DW0 address */ + + /* Set the host ownership of sdcard cd during kernel boot */ + Method (_INI, 0) + { + /* Check SDCard CD port is valid */ + If (LAnd (LNotEqual (\SCDP, 0), LNotEqual (\SCDO, 0) )) + { + /* Store DW0 address of SD_CD */ + Store (GDW0 (\SCDP, \SCDO), SCD0) + /* Get the current SD_CD ownership */ + Store (\_SB.GHO (\SCDP, \SCDO), Local0) + /* Set host ownership as GPIO in HOSTSW_OWN reg */ + Or (Local0, ShiftLeft (1, Mod (\SCDO, 32)), Local0) + \_SB.SHO (\SCDP, \SCDO, Local0) + } + } + + Method (_PS0, 0, NotSerialized) + { + /* Check SDCard CD port is valid */ + If (LAnd (LNotEqual (\SCDP, 0), LNotEqual (\SCDO, 0) )) + { + /* Store DW0 into local0 to get rxstate of GPIO */ + Store (\_SB.GPC0 (SCD0), Local0) + /* Extract rxstate [bit 1] of sdcard card detect pin */ + And (Local0, PAD_CFG0_RX_STATE, Local0) + /* If the sdcard is present, rxstate is low. + * If sdcard is not present, rxstate is High. + * Write the inverted value of rxstate to GRR3. + */ + If (LEqual (Local0, 0)) { + Store (1, ^^GRR3) + } Else { + Store (0, ^^GRR3) + } + Sleep (2) + } + } + + Method (_PS3, 0, NotSerialized) + { + /* Clear GRR3 to Power Gate SD Controller */ + Store (0, ^^GRR3) + } + + Device (CARD) + { + Name (_ADR, 0x00000008) + Method (_RMV, 0, NotSerialized) + { + Return (1) + } + } + } /* Device (SDCD) */ +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl b/arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl new file mode 100644 index 0000000000..df2fafb7f6 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/soc_int.asl @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ + +#ifndef _SOC_INT_DEFINE_ASL_ +#define _SOC_INT_DEFINE_ASL_ + +#define SDCARD_INT 3 /* Need to be shared by PMC and SCC only*/ +#define UART0_INT 4 /* Need to be shared by PMC and SCC only*/ +#define UART1_INT 5 /* Need to be shared by PMC and SCC only*/ +#define UART2_INT 6 /* Need to be shared by PMC and SCC only*/ +#define UART3_INT 7 /* Need to be shared by PMC and SCC only*/ +#define XDCI_INT 13 /* Need to be shared by PMC and SCC only*/ +#define GPIO_BANK_INT 14 +#define NPK_INT 16 +#define PIRQA_INT 16 +#define PIRQB_INT 17 +#define PIRQC_INT 18 +#define SATA_INT 19 +#define GEN_INT 19 +#define PIRQD_INT 19 +#define XHCI_INT 17 /* Need to be shared by PMC and SCC only*/ +#define SMBUS_INT 20 /* PIRQE */ +#define CSE_INT 20 /* PIRQE */ +#define IUNIT_INT 21 /* PIRQF */ +#define PIRQF_INT 21 +#define PIRQG_INT 22 +#define PUNIT_INT 24 +#define AUDIO_INT 25 +#define ISH_INT 26 +#define I2C0_INT 27 +#define I2C1_INT 28 +#define I2C2_INT 29 +#define I2C3_INT 30 +#define I2C4_INT 31 +#define I2C5_INT 32 +#define I2C6_INT 33 +#define I2C7_INT 34 +#define SPI0_INT 35 +#define SPI1_INT 36 +#define SPI2_INT 37 +#define UFS_INT 38 +#define EMMC_INT 39 +#define PMC_INT 40 +#define SDIO_INT 42 +#define CNVI_INT 44 + +#endif /* _SOC_INT_DEFINE_ASL_ */ diff --git a/arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl b/arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl new file mode 100644 index 0000000000..08290194f6 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/southbridge.asl @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2016 Intel Corp. + * (Written by Lance Zhao for Intel Corp.) + */ + +#include +#include + +/* PCIE device */ +#include "pcie.asl" + +/* LPSS device */ +#include "lpss.asl" + +/* PCI IRQ assignment */ +#include "pci_irqs.asl" + +/* GPIO controller */ +#include "gpio.asl" + +#include "xhci.asl" + +/* LPC */ +#include + +/* eMMC */ +#include "scs.asl" + +/* PMC IPC controller */ +#include "pmc_ipc.asl" + +/* PCI _OSC */ +#include diff --git a/arch/x86/include/asm/arch-apollolake/acpi/xhci.asl b/arch/x86/include/asm/arch-apollolake/acpi/xhci.asl new file mode 100644 index 0000000000..6333126c3f --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/xhci.asl @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + */ + +/* XHCI Controller 0:15.0 */ +Device (XHCI) { + Name (_ADR, 0x00150000) /* Device 21, Function 0 */ + + Name (_S3D, 3) /* D3 supported in S3 */ + Name (_S0W, 3) /* D3 can wake device in S0 */ + Name (_S3W, 3) /* D3 can wake system from S3 */ + + /* Declare XHCI GPE status and enable bits are bit 13 */ + Name (_PRW, Package() { GPE0A_XHCI_PME_STS, 3 }) + + Method (_STA, 0) + { + Return (0xF) + } + + Device (RHUB) + { + /* Root Hub */ + Name (_ADR, Zero) + +#if IS_ENABLED(CONFIG_SOC_INTEL_GLK) +#include "xhci_glk_ports.asl" +#else +#include "xhci_apl_ports.asl" +#endif + } +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl b/arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl new file mode 100644 index 0000000000..3ab7d18fc8 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/xhci_apl_ports.asl @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC. + * Copyright 2019 Intel Corp. + */ + +/* USB2 */ +Device (HS01) { Name (_ADR, 1) } +Device (HS02) { Name (_ADR, 2) } +Device (HS03) { Name (_ADR, 3) } +Device (HS04) { Name (_ADR, 4) } +Device (HS05) { Name (_ADR, 5) } +Device (HS06) { Name (_ADR, 6) } +Device (HS07) { Name (_ADR, 7) } +Device (HS08) { Name (_ADR, 8) } + +/* USB3 */ +Device (SS01) { Name (_ADR, 9) } +Device (SS02) { Name (_ADR, 10) } +Device (SS03) { Name (_ADR, 11) } +Device (SS04) { Name (_ADR, 12) } +Device (SS05) { Name (_ADR, 13) } +Device (SS06) { Name (_ADR, 14) } diff --git a/arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl b/arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl new file mode 100644 index 0000000000..192267221f --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi/xhci_glk_ports.asl @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 Google LLC. + * Copyright 2019 Intel Corp. + */ + +/* USB2 */ +Device (HS01) { Name (_ADR, 1) } +Device (HS02) { Name (_ADR, 2) } +Device (HS03) { Name (_ADR, 3) } +Device (HS04) { Name (_ADR, 4) } +Device (HS05) { Name (_ADR, 5) } +Device (HS06) { Name (_ADR, 6) } +Device (HS07) { Name (_ADR, 7) } +Device (HS08) { Name (_ADR, 8) } +Device (HS09) { Name (_ADR, 9) } + +/* USB3 */ +Device (SS01) { Name (_ADR, 10) } +Device (SS02) { Name (_ADR, 11) } +Device (SS03) { Name (_ADR, 12) } +Device (SS04) { Name (_ADR, 13) } +Device (SS05) { Name (_ADR, 14) } +Device (SS06) { Name (_ADR, 15) } From patchwork Mon Jan 27 05:06:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229565 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=Pp40G1/e; 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 485dP7194wz9sR1 for ; Mon, 27 Jan 2020 16:20:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 757F6818B9; Mon, 27 Jan 2020 06:12: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="Pp40G1/e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 630FC816E1; Mon, 27 Jan 2020 06:09:55 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 E814D817D3 for ; Mon, 27 Jan 2020 06:09:19 +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-xd42.google.com with SMTP id k24so8559722ioc.4 for ; Sun, 26 Jan 2020 21:09:19 -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=CYjqvnsihCVhRADhkOrK2joq8CZIPkvWMfvraSubPqU=; b=Pp40G1/e2fExNNai65oHoDXGCcdm3pBemx8olBEco50CnHhVLhmHgXOmpKvCcbBh06 P9rK0DvUARBBQ4M6vYL42WOmxBS43fOS97wMJAfQrLP+an+lgGpdN7iWpzegmUAjK/Rp AY6LKzg9p/MIWf5Ls1sLcr8WQnPITH13Ta1I0= 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=CYjqvnsihCVhRADhkOrK2joq8CZIPkvWMfvraSubPqU=; b=pydnGlw7VWUPKhhx/qFONmnzYHlb8wyRcLudU9qufVfbh0TCVhHU4aRqQWjyq3TnyE 0boNmdvi4B+s4CFc6EmgGLAYwTVA7axPbzzzezO8MIvg0CqMaBwfJiGUKXKW+4J6dD8u 5HRM392C/E9Xbrr612OtyxS5WSUOaKkvY1PYQWSgGFfPwtd3X/G005v5IW7u3h0WD+MR 16WBQqLZyfjFcAw5Y6h7qhco5Hg92lTOVtjmcmoER9A4Zb9+TI+WDNhv0EGH+PDVrMq2 54M454/DOruBR0rxZUQJcRLg082xhFIBWMTRq4nYkrkfZP9Qu66ximrqWllyGVxoyW27 EeXg== X-Gm-Message-State: APjAAAXWuv+eQ3HcNSEikIEXWQ8NLrVEOpZrtn1w+LINGbsI0xHxarSn va348+gylXJ7yP2zYPNjIDAZIC6rCn8/hQ== X-Google-Smtp-Source: APXvYqzsLpYQuTiHpq6SB2hc3vKYQnA4fR2ey53XfZJxU22g1e6o9awWYKAISS/rc6+1oOIgxHr6cg== X-Received: by 2002:a6b:f716:: with SMTP id k22mr10946392iog.297.1580101758286; Sun, 26 Jan 2020 21:09:18 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:17 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 068/108] x86: acpi: Add DPTF asl files Date: Sun, 26 Jan 2020 22:06:15 -0700 Message-Id: <20200126220508.68.I25148ea0707da6ca2a9c2a86cdaca2439052abac@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 Add common DPTF (Intel Dynamic Performance and Thermal Framework) files, taken from coreboot. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi/dptf/charger.asl | 65 +++ arch/x86/include/asm/acpi/dptf/cpu.asl | 186 ++++++++ arch/x86/include/asm/acpi/dptf/dptf.asl | 121 +++++ arch/x86/include/asm/acpi/dptf/fan.asl | 57 +++ arch/x86/include/asm/acpi/dptf/thermal.asl | 521 +++++++++++++++++++++ 5 files changed, 950 insertions(+) create mode 100644 arch/x86/include/asm/acpi/dptf/charger.asl create mode 100644 arch/x86/include/asm/acpi/dptf/cpu.asl create mode 100644 arch/x86/include/asm/acpi/dptf/dptf.asl create mode 100644 arch/x86/include/asm/acpi/dptf/fan.asl create mode 100644 arch/x86/include/asm/acpi/dptf/thermal.asl diff --git a/arch/x86/include/asm/acpi/dptf/charger.asl b/arch/x86/include/asm/acpi/dptf/charger.asl new file mode 100644 index 0000000000..7f4a7ecd36 --- /dev/null +++ b/arch/x86/include/asm/acpi/dptf/charger.asl @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2016 Intel Corporation. + */ + +Device (TCHG) +{ + Name (_HID, "INT3403") + Name (_UID, 0) + Name (PTYP, 0x0B) + Name (_STR, Unicode("Battery Charger")) + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + /* Return charger performance states defined by mainboard */ + Method (PPSS) + { + Return (\_SB.CHPS) + } + + /* Return maximum charger current limit */ + Method (PPPC) + { + /* Convert size of PPSS table to index */ + Store (SizeOf (\_SB.CHPS), Local0) + Decrement (Local0) + + /* Check if charging is disabled (AC removed) */ + If (LEqual (\_SB.PCI0.LPCB.EC0.ACEX, Zero)) { + /* Return last power state */ + Return (Local0) + } Else { + /* Return highest power state */ + Return (0) + } + + Return (0) + } + + /* Set charger current limit */ + Method (SPPC, 1) + { + /* Retrieve Control (index 4) for specified PPSS level */ + Store (DeRefOf (Index (DeRefOf (Index + (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0) + + /* Pass Control value to EC to limit charging */ + \_SB.PCI0.LPCB.EC0.CHGS (Local0) + } + + /* Initialize charger participant */ + Method (INIT) + { + /* Disable charge limit */ + \_SB.PCI0.LPCB.EC0.CHGD () + } +} diff --git a/arch/x86/include/asm/acpi/dptf/cpu.asl b/arch/x86/include/asm/acpi/dptf/cpu.asl new file mode 100644 index 0000000000..f77d353838 --- /dev/null +++ b/arch/x86/include/asm/acpi/dptf/cpu.asl @@ -0,0 +1,186 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2016 Intel Corporation. + */ + +External (\_PR.CP00._PSS, PkgObj) +External (\_PR.CP00._TSS, PkgObj) +External (\_PR.CP00._TPC, MethodObj) +External (\_PR.CP00._PTC, PkgObj) +External (\_PR.CP00._TSD, PkgObj) +External (\_SB.MPDL, IntObj) + +Device (DPTF_CPU_DEVICE) +{ + Name(_ADR, DPTF_CPU_ADDR) + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + /* + * Processor Throttling Controls + */ + + Method (_TSS) + { + If (CondRefOf (\_PR.CP00._TSS)) { + Return (\_PR.CP00._TSS) + } Else { + Return (Package () + { + Package () { 0, 0, 0, 0, 0 } + }) + } + } + + Method (_TPC) + { + If (CondRefOf (\_PR.CP00._TPC)) { + Return (\_PR.CP00._TPC) + } Else { + Return (0) + } + } + + Method (_PTC) + { + If (CondRefOf (\_PR.CP00._PTC)) { + Return (\_PR.CP00._PTC) + } Else { + Return (Package () + { + Buffer () { 0 }, + Buffer () { 0 } + }) + } + } + + Method (_TSD) + { + If (CondRefOf (\_PR.CP00._TSD)) { + Return (\_PR.CP00._TSD) + } Else { + Return (Package () + { + Package () { 5, 0, 0, 0, 0 } + }) + } + } + + Method (_TDL) + { + If (CondRefOf (\_PR.CP00._TSS)) { + Store (SizeOf (\_PR.CP00._TSS), Local0) + Decrement (Local0) + Return (Local0) + } Else { + Return (0) + } + } + + /* + * Processor Performance Control + */ + + Method (_PPC) + { + Return (0) + } + + Method (SPPC, 1) + { + Store (Arg0, \PPCM) + + /* Notify OS to re-read _PPC limit on each CPU */ + \PPCN () + } + + Method (_PSS) + { + If (CondRefOf (\_PR.CP00._PSS)) { + Return (\_PR.CP00._PSS) + } Else { + Return (Package () + { + Package () { 0, 0, 0, 0, 0, 0 } + }) + } + } + + + Method (_PDL) + { + /* Check for mainboard specific _PDL override */ + If (CondRefOf (\_SB.MPDL)) { + Return (\_SB.MPDL) + } ElseIf (CondRefOf (\_PR.CP00._PSS)) { + Store (SizeOf (\_PR.CP00._PSS), Local0) + Decrement (Local0) + Return (Local0) + } Else { + Return (0) + } + } + + /* Return PPCC table defined by mainboard */ + Method (PPCC) + { + Return (\_SB.MPPC) + } + +#ifdef DPTF_CPU_CRITICAL + Method (_CRT) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_CRITICAL)) + } +#endif + +#ifdef DPTF_CPU_PASSIVE + Method (_PSV) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_PASSIVE)) + } +#endif + +#ifdef DPTF_CPU_ACTIVE_AC0 + Method (_AC0) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_ACTIVE_AC0)) + } +#endif + +#ifdef DPTF_CPU_ACTIVE_AC1 + Method (_AC1) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_ACTIVE_AC1)) + } +#endif + +#ifdef DPTF_CPU_ACTIVE_AC2 + Method (_AC2) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_ACTIVE_AC2)) + } +#endif + +#ifdef DPTF_CPU_ACTIVE_AC3 + Method (_AC3) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_ACTIVE_AC3)) + } +#endif + +#ifdef DPTF_CPU_ACTIVE_AC4 + Method (_AC4) + { + Return (\_SB.DPTF.CTOK (DPTF_CPU_ACTIVE_AC4)) + } +#endif +} diff --git a/arch/x86/include/asm/acpi/dptf/dptf.asl b/arch/x86/include/asm/acpi/dptf/dptf.asl new file mode 100644 index 0000000000..5f958d200b --- /dev/null +++ b/arch/x86/include/asm/acpi/dptf/dptf.asl @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2016 Intel Corporation. + */ + +Device (DPTF) +{ + Name (_HID, EISAID ("INT3400")) + Name (_UID, 0) + + Name (IDSP, Package() + { + /* DPPM Passive Policy 1.0 */ + ToUUID ("42A441D6-AE6A-462B-A84B-4A8CE79027D3"), + + /* DPPM Critical Policy */ + ToUUID ("97C68AE7-15FA-499c-B8C9-5DA81D606E0A"), + + /* DPPM Cooling Policy */ + ToUUID ("16CAF1B7-DD38-40ED-B1C1-1B8A1913D531"), + +#ifdef DPTF_ENABLE_FAN_CONTROL + /* DPPM Active Policy */ + ToUUID ("3A95C389-E4B8-4629-A526-C52C88626BAE"), +#endif + }) + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + /* + * Arg0: Buffer containing UUID + * Arg1: Integer containing Revision ID of buffer format + * Arg2: Integer containing count of entries in Arg3 + * Arg3: Buffer containing list of DWORD capabilities + * Return: Buffer containing list of DWORD capabilities + */ + Method (_OSC, 4, Serialized) + { + /* Check for Passive Policy UUID */ + If (LEqual (DeRefOf (Index (IDSP, 0)), Arg0)) { + /* Initialize Thermal Devices */ + ^TINI () + +#ifdef DPTF_ENABLE_CHARGER + /* Initialize Charger Device */ + ^TCHG.INIT () +#endif + } + + Return (Arg3) + } + + /* Priority based _TRT */ + Name (TRTR, 1) + + Method (_TRT) + { + Return (\_SB.DTRT) + } + +#ifdef DPTF_ENABLE_FAN_CONTROL + /* _ART : Active Cooling Relationship Table */ + Method (_ART) + { + Return (\_SB.DART) + } +#endif + + /* Convert from Degrees C to 1/10 Kelvin for ACPI */ + Method (CTOK, 1) { + /* 10th of Degrees C */ + Multiply (Arg0, 10, Local0) + + /* Convert to Kelvin */ + Add (Local0, 2732, Local0) + + Return (Local0) + } + + /* Convert from 1/10 Kelvin to Degrees C for ACPI */ + Method (KTOC, 1) { + If (LLessEqual (Arg0, 2732)) { + Return (0) + } + + /* Convert to Celsius */ + Subtract (Arg0, 2732, Local0) + + /* Convert from 10th of degrees */ + Divide (Local0, 10,, Local0) + + Return (Local0) + } + + /* Include Thermal Participants */ + #include "thermal.asl" + +#ifdef DPTF_ENABLE_CHARGER + /* Include Charger Participant */ + #include "charger.asl" +#endif + +#ifdef DPTF_ENABLE_FAN_CONTROL + /* Include Fan Participant */ + #include "fan.asl" +#endif + +} + +Scope (\_SB.PCI0) +{ + #include "cpu.asl" +} diff --git a/arch/x86/include/asm/acpi/dptf/fan.asl b/arch/x86/include/asm/acpi/dptf/fan.asl new file mode 100644 index 0000000000..aa4aa12911 --- /dev/null +++ b/arch/x86/include/asm/acpi/dptf/fan.asl @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2016 Intel Corporation. + */ + +Device (TFN1) +{ + Name (_HID, "INT3404") + Name (_UID, 0) + Name (_STR, Unicode("Fan Control")) + + /* _FIF: Fan Information */ + Name (_FIF, Package () + { + 0, // Revision + 1, // Fine Grained Control + 2, // Step Size + 0 // No Low Speed Notification + }) + + /* Return Fan Performance States defined by mainboard */ + Method (_FPS) + { + Return (\_SB.DFPS) + } + + Name (TFST, Package () + { + 0, // Revision + 0x00, // Control + 0x00 // Speed + }) + + /* _FST: Fan current Status */ + Method (_FST, 0, Serialized,,PkgObj) + { + /* Fill in TFST with current control. */ + Store (\_SB.PCI0.LPCB.EC0.FAND, Index (TFST, 1)) + Return (TFST) + } + + /* _FSL: Fan Speed Level */ + Method (_FSL, 1, Serialized) + { + Store (Arg0, \_SB.PCI0.LPCB.EC0.FAND) + } + + Method (_STA) + { + If (LEqual (\DPTE, One)) + { + Return (0xF) + } Else { + Return (0x0) + } + } +} diff --git a/arch/x86/include/asm/acpi/dptf/thermal.asl b/arch/x86/include/asm/acpi/dptf/thermal.asl new file mode 100644 index 0000000000..4c3c8db8f2 --- /dev/null +++ b/arch/x86/include/asm/acpi/dptf/thermal.asl @@ -0,0 +1,521 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2016 Intel Corporation. + */ + +/* Thermal Threshold Event Handler */ +#define HAVE_THERM_EVENT_HANDLER +Method (TEVT, 1, NotSerialized) +{ + Store (ToInteger (Arg0), Local0) + +#ifdef DPTF_TSR0_SENSOR_ID + If (LEqual (Local0, DPTF_TSR0_SENSOR_ID)) { + Notify (^TSR0, 0x90) + } +#endif +#ifdef DPTF_TSR1_SENSOR_ID + If (LEqual (Local0, DPTF_TSR1_SENSOR_ID)) { + Notify (^TSR1, 0x90) + } +#endif +#ifdef DPTF_TSR2_SENSOR_ID + If (LEqual (Local0, DPTF_TSR2_SENSOR_ID)) { + Notify (^TSR2, 0x90) + } +#endif +#ifdef DPTF_TSR3_SENSOR_ID + If (LEqual (Local0, DPTF_TSR3_SENSOR_ID)) { + Notify (^TSR3, 0x90) + } +#endif +} + +/* Thermal device initialization - Disable Aux Trip Points */ +Method (TINI) +{ +#ifdef DPTF_TSR0_SENSOR_ID + ^TSR0.PATD () +#endif +#ifdef DPTF_TSR1_SENSOR_ID + ^TSR1.PATD () +#endif +#ifdef DPTF_TSR2_SENSOR_ID + ^TSR2.PATD () +#endif +#ifdef DPTF_TSR3_SENSOR_ID + ^TSR3.PATD () +#endif +} + +/* Thermal Trip Points Change Event Handler */ +Method (TPET) +{ +#ifdef DPTF_TSR0_SENSOR_ID + Notify (^TSR0, 0x81) +#endif +#ifdef DPTF_TSR1_SENSOR_ID + Notify (^TSR1, 0x81) +#endif +#ifdef DPTF_TSR2_SENSOR_ID + Notify (^TSR2, 0x81) +#endif +#ifdef DPTF_TSR3_SENSOR_ID + Notify (^TSR3, 0x81) +#endif +} + +/* + * Method to return trip temperature value depending upon the device mode. + * Arg0 --> Value to return when device is in tablet mode + * Arg1 --> Value to return when device is not in tablet mode. + */ +Method (DTRP, 2, Serialized) +{ +#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES + If (LEqual (\_SB.PCI0.LPCB.EC0.RCDP, One)) { + Return (CTOK (Arg0)) + } Else { +#endif + Return (CTOK (Arg1)) +#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES + } +#endif +} + +#ifdef DPTF_TSR0_SENSOR_ID + +#ifndef DPTF_TSR0_TABLET_PASSIVE +#define DPTF_TSR0_TABLET_PASSIVE DPTF_TSR0_PASSIVE +#endif +#ifndef DPTF_TSR0_TABLET_CRITICAL +#define DPTF_TSR0_TABLET_CRITICAL DPTF_TSR0_CRITICAL +#endif + +Device (TSR0) +{ + Name (_HID, EISAID ("INT3403")) + Name (_UID, 1) + Name (PTYP, 0x03) + Name (TMPI, DPTF_TSR0_SENSOR_ID) + Name (_STR, Unicode (DPTF_TSR0_SENSOR_NAME)) + Name (GTSH, 20) /* 2 degree hysteresis */ + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + Method (_TMP, 0, Serialized) + { + Return (\_SB.PCI0.LPCB.EC0.TSRD (TMPI)) + } + + Method (_PSV) + { + Return (DTRP (DPTF_TSR0_TABLET_PASSIVE, DPTF_TSR0_PASSIVE)) + } + + Method (_CRT) + { + Return (DTRP (DPTF_TSR0_TABLET_CRITICAL, DPTF_TSR0_CRITICAL)) + } + + Name (PATC, 2) + + /* Set Aux Trip Point */ + Method (PAT0, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT0 (TMPI, Arg0) + } + + /* Set Aux Trip Point */ + Method (PAT1, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT1 (TMPI, Arg0) + } + + /* Disable Aux Trip Point */ + Method (PATD, 0, Serialized) + { + \_SB.PCI0.LPCB.EC0.PATD (TMPI) + } + +#ifdef DPTF_ENABLE_FAN_CONTROL +#ifdef DPTF_TSR0_ACTIVE_AC0 + Method (_AC0) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC0)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC1 + Method (_AC1) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC1)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC2 + Method (_AC2) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC2)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC3 + Method (_AC3) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC3)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC4 + Method (_AC4) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC4)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC5 + Method (_AC5) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC5)) + } +#endif +#ifdef DPTF_TSR0_ACTIVE_AC6 + Method (_AC6) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR0_ACTIVE_AC6)) + } +#endif +#endif +} +#endif + +#ifdef DPTF_TSR1_SENSOR_ID + +#ifndef DPTF_TSR1_TABLET_PASSIVE +#define DPTF_TSR1_TABLET_PASSIVE DPTF_TSR1_PASSIVE +#endif +#ifndef DPTF_TSR1_TABLET_CRITICAL +#define DPTF_TSR1_TABLET_CRITICAL DPTF_TSR1_CRITICAL +#endif + +Device (TSR1) +{ + Name (_HID, EISAID ("INT3403")) + Name (_UID, 2) + Name (PTYP, 0x03) + Name (TMPI, DPTF_TSR1_SENSOR_ID) + Name (_STR, Unicode (DPTF_TSR1_SENSOR_NAME)) + Name (GTSH, 20) /* 2 degree hysteresis */ + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + Method (_TMP, 0, Serialized) + { + Return (\_SB.PCI0.LPCB.EC0.TSRD (TMPI)) + } + + Method (_PSV) + { + Return (DTRP (DPTF_TSR1_TABLET_PASSIVE, DPTF_TSR1_PASSIVE)) + } + + Method (_CRT) + { + Return (DTRP (DPTF_TSR1_TABLET_CRITICAL, DPTF_TSR1_CRITICAL)) + } + + Name (PATC, 2) + + /* Set Aux Trip Point */ + Method (PAT0, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT0 (TMPI, Arg0) + } + + /* Set Aux Trip Point */ + Method (PAT1, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT1 (TMPI, Arg0) + } + + /* Disable Aux Trip Point */ + Method (PATD, 0, Serialized) + { + \_SB.PCI0.LPCB.EC0.PATD (TMPI) + } + +#ifdef DPTF_ENABLE_FAN_CONTROL +#ifdef DPTF_TSR1_ACTIVE_AC0 + Method (_AC0) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC0)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC1 + Method (_AC1) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC1)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC2 + Method (_AC2) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC2)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC3 + Method (_AC3) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC3)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC4 + Method (_AC4) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC4)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC5 + Method (_AC5) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC5)) + } +#endif +#ifdef DPTF_TSR1_ACTIVE_AC6 + Method (_AC6) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR1_ACTIVE_AC6)) + } +#endif +#endif +} +#endif + +#ifdef DPTF_TSR2_SENSOR_ID + +#ifndef DPTF_TSR2_TABLET_PASSIVE +#define DPTF_TSR2_TABLET_PASSIVE DPTF_TSR2_PASSIVE +#endif +#ifndef DPTF_TSR2_TABLET_CRITICAL +#define DPTF_TSR2_TABLET_CRITICAL DPTF_TSR2_CRITICAL +#endif + +Device (TSR2) +{ + Name (_HID, EISAID ("INT3403")) + Name (_UID, 3) + Name (PTYP, 0x03) + Name (TMPI, DPTF_TSR2_SENSOR_ID) + Name (_STR, Unicode (DPTF_TSR2_SENSOR_NAME)) + Name (GTSH, 20) /* 2 degree hysteresis */ + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + Method (_TMP, 0, Serialized) + { + Return (\_SB.PCI0.LPCB.EC0.TSRD (TMPI)) + } + + Method (_PSV) + { + Return (DTRP (DPTF_TSR2_TABLET_PASSIVE, DPTF_TSR2_PASSIVE)) + } + + Method (_CRT) + { + Return (DTRP (DPTF_TSR2_TABLET_CRITICAL, DPTF_TSR2_CRITICAL)) + } + + Name (PATC, 2) + + /* Set Aux Trip Point */ + Method (PAT0, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT0 (TMPI, Arg0) + } + + /* Set Aux Trip Point */ + Method (PAT1, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT1 (TMPI, Arg0) + } + + /* Disable Aux Trip Point */ + Method (PATD, 0, Serialized) + { + \_SB.PCI0.LPCB.EC0.PATD (TMPI) + } + +#ifdef DPTF_ENABLE_FAN_CONTROL +#ifdef DPTF_TSR2_ACTIVE_AC0 + Method (_AC0) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC0)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC1 + Method (_AC1) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC1)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC2 + Method (_AC2) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC2)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC3 + Method (_AC3) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC3)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC4 + Method (_AC4) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC4)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC5 + Method (_AC5) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC5)) + } +#endif +#ifdef DPTF_TSR2_ACTIVE_AC6 + Method (_AC6) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR2_ACTIVE_AC6)) + } +#endif +#endif +} +#endif + +#ifdef DPTF_TSR3_SENSOR_ID + +#ifndef DPTF_TSR3_TABLET_PASSIVE +#define DPTF_TSR3_TABLET_PASSIVE DPTF_TSR3_PASSIVE +#endif +#ifndef DPTF_TSR3_TABLET_CRITICAL +#define DPTF_TSR3_TABLET_CRITICAL DPTF_TSR3_CRITICAL +#endif + +Device (TSR3) +{ + Name (_HID, EISAID ("INT3403")) + Name (_UID, 4) + Name (PTYP, 0x03) + Name (TMPI, DPTF_TSR3_SENSOR_ID) + Name (_STR, Unicode (DPTF_TSR3_SENSOR_NAME)) + Name (GTSH, 20) /* 2 degree hysteresis */ + + Method (_STA) + { + If (LEqual (\DPTE, One)) { + Return (0xF) + } Else { + Return (0x0) + } + } + + Method (_TMP, 0, Serialized) + { + Return (\_SB.PCI0.LPCB.EC0.TSRD (TMPI)) + } + + Method (_PSV) + { + Return (DTRP (DPTF_TSR3_TABLET_PASSIVE, DPTF_TSR3_PASSIVE)) + } + + Method (_CRT) + { + Return (DTRP (DPTF_TSR3_TABLET_CRITICAL, DPTF_TSR3_CRITICAL)) + } + + Name (PATC, 2) + + /* Set Aux Trip Point */ + Method (PAT0, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT0 (TMPI, Arg0) + } + + /* Set Aux Trip Point */ + Method (PAT1, 1, Serialized) + { + \_SB.PCI0.LPCB.EC0.PAT1 (TMPI, Arg0) + } + + /* Disable Aux Trip Point */ + Method (PATD, 0, Serialized) + { + \_SB.PCI0.LPCB.EC0.PATD (TMPI) + } + +#ifdef DPTF_ENABLE_FAN_CONTROL +#ifdef DPTF_TSR3_ACTIVE_AC0 + Method (_AC0) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC0)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC1 + Method (_AC1) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC1)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC2 + Method (_AC2) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC2)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC3 + Method (_AC3) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC3)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC4 + Method (_AC4) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC4)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC5 + Method (_AC5) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC5)) + } +#endif +#ifdef DPTF_TSR3_ACTIVE_AC6 + Method (_AC6) + { + Return (\_SB.DPTF.CTOK (DPTF_TSR3_ACTIVE_AC6)) + } +#endif +#endif +} +#endif From patchwork Mon Jan 27 05:06:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229566 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=l70mw28D; 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 485dPK4xTSz9sR1 for ; Mon, 27 Jan 2020 16:20:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48D07818C5; Mon, 27 Jan 2020 06:12:45 +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="l70mw28D"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D376817C4; Mon, 27 Jan 2020 06:09:56 +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-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 9C956817B6 for ; Mon, 27 Jan 2020 06:09:20 +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-x12e.google.com with SMTP id b15so6447865iln.3 for ; Sun, 26 Jan 2020 21:09:20 -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=IVUoyVMTcYbKr3GFygcu5eAm0b5upyvgTDaGEIOSNwI=; b=l70mw28D9En0g90kJ5ODIz+3m3Jz8jiVcwERg4SgqibPhr07gGisxjhRWwY6EiDln1 yu80szSkxmz6+FpW1H2IkfOXmotn3n0WOoOk1SjkvmR1wCIwtY9/Fdgam+sC9ijXH0dj AV5K3+cz6j8hrg7mmzhOGmnKqIb2749rW/VWg= 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=IVUoyVMTcYbKr3GFygcu5eAm0b5upyvgTDaGEIOSNwI=; b=IkHGSnBkqPB05zDqW9mI/qaTr77qinhol05AWdNToVkVSyf0h4pP0w0G8of0CrPwdn HPwAhIzcpxoR7Wi2S0jHjPBqzINNRrjq5U3S9I5WhNhakpOi3+V3qAOtrQqvyf3zS6Ux MUKmraz5iStCFY0b3zrmRG7Vy3rF/ihkWIAVWLZeOLrNEaKAjrYX9aGWolvhsw15ZVyH 3kzO5fobcGbR5ZGTPNij8OvNEoQoYF4gnncZyhWDgiu/7LvmtCraGH4aAn2AaAQWbUs6 d73NbJN+jEjdxeUcmxQp67YbnKwf+Ti25BdGJ9javuygVdlsyIqBl3Pi1O9acoe05oGN kBuQ== X-Gm-Message-State: APjAAAWeeZG6hCLD83QXX1rqkmnU5lo/fKvjxiVMrg+M3UmXfqAun7jU +UHr1CSfFFYhGW5ToldFkbOAQD8KFauLRQ== X-Google-Smtp-Source: APXvYqwZ6mNvXfPlaQiYImsApzzaqX66uyuLv8tDFo5fiqCtggUDXnpW6oKwTHzCq8pf/8Yn7jP4wQ== X-Received: by 2002:a92:15c1:: with SMTP id 62mr13171485ilv.216.1580101759277; Sun, 26 Jan 2020 21:09:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:18 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 069/108] x86: apl: Correct PCIE_ECAM_BASE Date: Sun, 26 Jan 2020 22:06:16 -0700 Message-Id: <20200126220508.69.I6f15c116cfec682dce106c6c30c2325846f6c232@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 This value is incorrect and causes problems booting Linux. Fix it. Signed-off-by: Simon Glass --- board/google/chromebook_coral/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/google/chromebook_coral/Kconfig b/board/google/chromebook_coral/Kconfig index 940bee89b0..f744b4c00c 100644 --- a/board/google/chromebook_coral/Kconfig +++ b/board/google/chromebook_coral/Kconfig @@ -22,7 +22,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select BOARD_ROMSIZE_KB_16384 config PCIE_ECAM_BASE - default 0xf0000000 + default 0xe0000000 config EARLY_POST_CROS_EC bool "Enable early post to Chrome OS EC" From patchwork Mon Jan 27 05:06:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229568 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=JZbe79vC; 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 485dPk2WfCz9sR1 for ; Mon, 27 Jan 2020 16:20:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0127F818D4; Mon, 27 Jan 2020 06:12:50 +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="JZbe79vC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 620CE816E1; Mon, 27 Jan 2020 06:09:59 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 B2B6C81822 for ; Mon, 27 Jan 2020 06:09:21 +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-x144.google.com with SMTP id g12so6460548ild.2 for ; Sun, 26 Jan 2020 21:09:21 -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=n74mtDbQ4efJGTK4LmgeTUF5FA6AIDUFdvFe34WDGLQ=; b=JZbe79vCN9hllbEY+c2Ad39Cz2J64Dioq+hglQ2jI/7RZr7xxDMS/EuMBQ203G37iR zEkjBb4UE+DTlQNelCc2qWYnk7+ibcnkOJHGSXwMSG7rpQpPD8X1fYV0CrQdor17MtDW L8A9s5Y0U0OLta57osESndSnvE9j9zgqMIjs0= 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=n74mtDbQ4efJGTK4LmgeTUF5FA6AIDUFdvFe34WDGLQ=; b=Vy3cdmp8kKTyfWqBjXMrLlWHHYfTc0/W0tZAfrl+WO70uCAcOTYtS9nfsRHqdAgrk3 xQsckW32zysmQH5ux5gAUPgklYB+8lnJBp/SmT0mdYEPTldfJdsWvckaU6xuU5VThSJF ENAis2XCIas2mqDv9MkPe4XaddGCrF064vth20ilcJd/P5EmLOjDe4nlR1ffBw3WJoj5 mGfg90/JbE/JvGCB9xAGvM1nhhN5vQQ1S2sNdYzDvF0fj0nBbvJLfBqs30N7k8Kt2DL7 wlEBvVqsiFbqAOdITq+LsViOtD9Hle3OreZoFeCOQGj01BiS9MQjhEpprqhvJyvzYfFF YKrg== X-Gm-Message-State: APjAAAU0pj2QrP2C3uVQ94I3IUYOHBipMgMZYsW5VxB4zVWP2LnD321X NDX+YGK5aK82+6i1HbnVpG0DG+SsdSWVcA== X-Google-Smtp-Source: APXvYqzo0G4sPwxvKzY1ZFdw+xkrmImmvVpErHI+FQNYOOEA+0qQ9RPz1HWWpcKDMXE6/kHpBqahpQ== X-Received: by 2002:a92:9cc6:: with SMTP id x67mr13684759ill.31.1580101760086; Sun, 26 Jan 2020 21:09:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:19 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 070/108] x86: coral: Add ACPI tables for coral Date: Sun, 26 Jan 2020 22:06:17 -0700 Message-Id: <20200126220508.70.I6eb820608db0f0854d20d5edbb63cfa5f1921c00@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 This device has a large set of ACPI tables. Bring these in from coreboot so that full functionality is available (apart from SMI). Signed-off-by: Simon Glass --- board/google/chromebook_coral/Makefile | 1 + .../chromebook_coral/baseboard_dptf.asl | 71 ++++++++++++ board/google/chromebook_coral/coral.c | 104 ++++++++++++++++++ board/google/chromebook_coral/dsdt.asl | 60 ++++++++++ .../google/chromebook_coral/variant_dptf.asl | 6 + board/google/chromebook_coral/variant_ec.h | 75 +++++++++++++ board/google/chromebook_coral/variant_gpio.h | 63 +++++++++++ 7 files changed, 380 insertions(+) create mode 100644 board/google/chromebook_coral/baseboard_dptf.asl create mode 100644 board/google/chromebook_coral/dsdt.asl create mode 100644 board/google/chromebook_coral/variant_dptf.asl create mode 100644 board/google/chromebook_coral/variant_ec.h create mode 100644 board/google/chromebook_coral/variant_gpio.h diff --git a/board/google/chromebook_coral/Makefile b/board/google/chromebook_coral/Makefile index 6a27ce3da1..f7a0ca6cc0 100644 --- a/board/google/chromebook_coral/Makefile +++ b/board/google/chromebook_coral/Makefile @@ -3,3 +3,4 @@ # Copyright 2019 Google LLC obj-y += coral.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += dsdt.o diff --git a/board/google/chromebook_coral/baseboard_dptf.asl b/board/google/chromebook_coral/baseboard_dptf.asl new file mode 100644 index 0000000000..5da963a670 --- /dev/null +++ b/board/google/chromebook_coral/baseboard_dptf.asl @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2014 Google Inc. + * Copyright (C) 2015 Intel Corporation. + */ + +#define DPTF_CPU_PASSIVE 95 +#define DPTF_CPU_CRITICAL 105 + +#define DPTF_TSR0_SENSOR_ID 0 +#define DPTF_TSR0_SENSOR_NAME "Battery" +#define DPTF_TSR0_PASSIVE 120 +#define DPTF_TSR0_CRITICAL 125 + +#define DPTF_TSR1_SENSOR_ID 1 +#define DPTF_TSR1_SENSOR_NAME "Ambient" +#define DPTF_TSR1_PASSIVE 46 +#define DPTF_TSR1_CRITICAL 75 + +#define DPTF_TSR2_SENSOR_ID 2 +#define DPTF_TSR2_SENSOR_NAME "Charger" +#define DPTF_TSR2_PASSIVE 58 +#define DPTF_TSR2_CRITICAL 90 + +#define DPTF_ENABLE_CHARGER + +/* Charger performance states, board-specific values from charger and EC */ +Name (CHPS, Package () { + Package () { 0, 0, 0, 0, 255, 0xBB8, "mA", 0 }, /* 3A (MAX) */ + Package () { 0, 0, 0, 0, 24, 0x600, "mA", 0 }, /* 1.5A */ + Package () { 0, 0, 0, 0, 16, 0x400, "mA", 0 }, /* 1.0A */ + Package () { 0, 0, 0, 0, 8, 0x200, "mA", 0 }, /* 0.5A */ + Package () { 0, 0, 0, 0, 0, 0x000, "mA", 0 }, /* 0.0A */ +}) + +Name (DTRT, Package () { + /* CPU Throttle Effect on CPU */ + Package () { \_SB.PCI0.TCPU, \_SB.PCI0.TCPU, 100, 100, 0, 0, 0, 0 }, + + /* CPU Effect on Temp Sensor 0 */ + Package () { \_SB.PCI0.TCPU, \_SB.DPTF.TSR0, 100, 1200, 0, 0, 0, 0 }, + +#ifdef DPTF_ENABLE_CHARGER + /* Charger Effect on Temp Sensor 2 */ + Package () { \_SB.DPTF.TCHG, \_SB.DPTF.TSR2, 200, 300, 0, 0, 0, 0 }, +#endif + + /* CPU Effect on Temp Sensor 1 */ + Package () { \_SB.PCI0.TCPU, \_SB.DPTF.TSR1, 100, 150, 0, 0, 0, 0 }, +}) + +Name (MPPC, Package () +{ + 0x2, /* Revision */ + Package () { /* Power Limit 1 */ + 0, /* PowerLimitIndex, 0 for Power Limit 1 */ + 3000, /* PowerLimitMinimum */ + 12000, /* PowerLimitMaximum */ + 1000, /* TimeWindowMinimum */ + 1000, /* TimeWindowMaximum */ + 200 /* StepSize */ + }, + Package () { /* Power Limit 2 */ + 1, /* PowerLimitIndex, 1 for Power Limit 2 */ + 8000, /* PowerLimitMinimum */ + 15000, /* PowerLimitMaximum */ + 1000, /* TimeWindowMinimum */ + 1000, /* TimeWindowMaximum */ + 1000 /* StepSize */ + } +}) diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c index 4e34710b97..58b8e7293b 100644 --- a/board/google/chromebook_coral/coral.c +++ b/board/google/chromebook_coral/coral.c @@ -4,6 +4,19 @@ */ #include +#include +#include +#include +#include +#include +#include "variant_gpio.h" + +struct cros_gpio_info { + const char *linux_name; + enum cros_gpio_t type; + int gpio_num; + int flags; +}; int arch_misc_init(void) { @@ -17,3 +30,94 @@ int board_run_command(const char *cmdline) return 0; } + +int chromeos_get_gpio(const struct udevice *dev, const char *prop, + enum cros_gpio_t type, struct cros_gpio_info *info) +{ + struct udevice *pinctrl; + struct gpio_desc desc; + int ret; + + ret = gpio_request_by_name((struct udevice *)dev, prop, 0, &desc, 0); + if (ret == -ENOTBLK) + info->gpio_num = CROS_GPIO_VIRTUAL; + else if (ret) + return log_msg_ret("gpio", ret); + else + info->gpio_num = desc.offset; + info->linux_name = dev_read_string(desc.dev, "linux-name"); + if (!info->linux_name) + return log_msg_ret("linux-name", -ENOENT); + info->type = type; + /* Get ACPI pin from GPIO library if available */ + if (info->gpio_num != CROS_GPIO_VIRTUAL) { + pinctrl = dev_get_parent(desc.dev); + info->gpio_num = intel_pinctrl_get_acpi_pin(pinctrl, + info->gpio_num); + } + info->flags = desc.flags & GPIOD_ACTIVE_LOW ? CROS_GPIO_ACTIVE_LOW : + CROS_GPIO_ACTIVE_HIGH; + + return 0; +} + +static int chromeos_acpi_gpio_generate(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct cros_gpio_info info[3]; + int count, i; + int ret; + + count = 3; + ret = chromeos_get_gpio(dev, "recovery-gpios", CROS_GPIO_REC, &info[0]); + if (ret) + return log_msg_ret("rec", ret); + ret = chromeos_get_gpio(dev, "write-protect-gpios", CROS_GPIO_WP, + &info[1]); + if (ret) + return log_msg_ret("rec", ret); + ret = chromeos_get_gpio(dev, "phase-enforce-gpios", CROS_GPIO_PE, + &info[2]); + if (ret) + return log_msg_ret("rec", ret); + acpigen_write_scope(ctx, "\\"); + acpigen_write_name(ctx, "OIPG"); + acpigen_write_package(ctx, count); + for (i = 0; i < count; i++) { + acpigen_write_package(ctx, 4); + acpigen_write_integer(ctx, info[i].type); + acpigen_write_integer(ctx, info[i].flags); + acpigen_write_integer(ctx, info[i].gpio_num); + acpigen_write_string(ctx, info[i].linux_name); + acpigen_pop_len(ctx); + } + + acpigen_pop_len(ctx); + acpigen_pop_len(ctx); + + return 0; +} + +static int coral_write_acpi_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + /* Add NHLT here */ + return 0; +} + +struct acpi_ops coral_acpi_ops = { + .write_tables = coral_write_acpi_tables, + .inject_dsdt = chromeos_acpi_gpio_generate, +}; + +static const struct udevice_id coral_ids[] = { + { .compatible = "google,coral" }, + { } +}; + +U_BOOT_DRIVER(coral_drv) = { + .name = "coral", + .id = UCLASS_BOARD, + .of_match = coral_ids, + acpi_ops_ptr(&coral_acpi_ops) +}; diff --git a/board/google/chromebook_coral/dsdt.asl b/board/google/chromebook_coral/dsdt.asl new file mode 100644 index 0000000000..c74f4145bf --- /dev/null +++ b/board/google/chromebook_coral/dsdt.asl @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2016 Google Inc. + */ + +#include "variant_ec.h" +#include "variant_gpio.h" +#include +#include + +DefinitionBlock( + "dsdt.aml", + "DSDT", + 0x02, // DSDT revision: ACPI v2.0 and up + OEM_ID, + ACPI_TABLE_CREATOR, + 0x20110725 // OEM revision +) +{ + /* global NVS and variables */ + #include + + /* CPU */ + #include + + Scope (\_SB) { + Device (PCI0) + { + #include + #include + #include + } + } + + /* Chrome OS specific */ + #include + + /* Chipset specific sleep states */ + #include + + /* Chrome OS Embedded Controller */ + Scope (\_SB.PCI0.LPCB) + { + /* ACPI code for EC SuperIO functions */ + #include + /* ACPI code for EC functions */ + #include + } + + /* Dynamic Platform Thermal Framework */ + Scope (\_SB) + { + /* Per board variant specific definitions. */ + #include "variant_dptf.asl" + /* Include soc specific DPTF changes */ + #include + /* Include common dptf ASL files */ + #include + } +} diff --git a/board/google/chromebook_coral/variant_dptf.asl b/board/google/chromebook_coral/variant_dptf.asl new file mode 100644 index 0000000000..943ebeaac2 --- /dev/null +++ b/board/google/chromebook_coral/variant_dptf.asl @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2016 Google Inc. + */ + +#include "baseboard_dptf.asl" diff --git a/board/google/chromebook_coral/variant_ec.h b/board/google/chromebook_coral/variant_ec.h new file mode 100644 index 0000000000..7d5e1a674c --- /dev/null +++ b/board/google/chromebook_coral/variant_ec.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC +/* + * Taken from coreboot file of the same name + */ + +#ifndef VARIANT_EC_H +#define VARIANT_EC_H + +#include "variant_gpio.h" +#include + +#define MAINBOARD_EC_SCI_EVENTS \ + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_CONNECTED) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_LOW) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_CRITICAL) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_STATUS) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_THRESHOLD) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_START) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_THROTTLE_STOP) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_USB_CHARGER) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_MKBP) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_MODE_CHANGE)) + +#define MAINBOARD_EC_SMI_EVENTS \ + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED)) + +/* EC can wake from S5 with lid or power button */ +#define MAINBOARD_EC_S5_WAKE_EVENTS \ + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON)) + +/* EC can wake from S3 with lid or power button or key press */ +#define MAINBOARD_EC_S3_WAKE_EVENTS \ + (MAINBOARD_EC_S5_WAKE_EVENTS |\ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED)) + +#define MAINBOARD_EC_S0IX_WAKE_EVENTS (MAINBOARD_EC_S3_WAKE_EVENTS) + +/* Log EC wake events plus EC shutdown events */ +#define MAINBOARD_EC_LOG_EVENTS \ + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_THERMAL_SHUTDOWN) | \ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_BATTERY_SHUTDOWN) | \ + EC_HOST_EVENT_MASK(EC_HOST_EVENT_PANIC)) + +/* + * ACPI related definitions for ASL code. + */ + +/* Enable EC backed ALS device in ACPI */ +#define EC_ENABLE_ALS_DEVICE + +/* Enable EC backed PD MCU device in ACPI */ +#define EC_ENABLE_PD_MCU_DEVICE + +/* Enable LID switch and provide wake pin for EC */ +#define EC_ENABLE_LID_SWITCH +#define EC_ENABLE_WAKE_PIN GPE_EC_WAKE + +#define EC_ENABLE_TBMC_DEVICE + +#define SIO_EC_MEMMAP_ENABLE /* EC Memory Map Resources */ +#define SIO_EC_HOST_ENABLE /* EC Host Interface Resources */ +#define SIO_EC_ENABLE_PS2K /* Enable PS/2 Keyboard */ + +/* Enable EC backed Keyboard Backlight in ACPI */ +#define EC_ENABLE_KEYBOARD_BACKLIGHT + +#endif diff --git a/board/google/chromebook_coral/variant_gpio.h b/board/google/chromebook_coral/variant_gpio.h new file mode 100644 index 0000000000..f516d88be5 --- /dev/null +++ b/board/google/chromebook_coral/variant_gpio.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + * + * Taken from coreboot file of the same name + */ + +#ifndef BASEBOARD_GPIO_H +#define BASEBOARD_GPIO_H + +#include +#include + +/* + * GPIO_11 for SCI is routed to GPE0_DW1 and maps to group GPIO_GPE_N_31_0 + * which is North community + */ +#define EC_SCI_GPI GPE0_DW1_11 + +/* EC SMI */ +#define EC_SMI_GPI GPIO_49 + +/* + * On lidopen/lidclose GPIO_22 from North Community gets toggled and + * is used in _PRW to wake up device from sleep. GPIO_22 maps to + * group GPIO_GPE_N_31_0 and the pad is configured as SCI with + * EDGE_SINGLE and INVERT. + */ +#define GPE_EC_WAKE GPE0_DW1_22 + +/* Write Protect and indication if EC is in RW code. */ +#define GPIO_PCH_WP GPIO_75 +#define GPIO_EC_IN_RW GPIO_41 +/* Determine if board is in final shipping mode. */ +#define GPIO_SHIP_MODE GPIO_10 + +/* Memory SKU GPIOs. */ +#define MEM_CONFIG3 GPIO_45 +#define MEM_CONFIG2 GPIO_38 +#define MEM_CONFIG1 GPIO_102 +#define MEM_CONFIG0 GPIO_101 + +/* DMIC_CONFIG_PIN: High for 1-DMIC and low for 4-DMIC's */ +#define DMIC_CONFIG_PIN GPIO_17 + +#ifndef __ASSEMBLY__ + +enum cros_gpio_t { + CROS_GPIO_REC = 1, /* Recovery */ + + /* Developer; * deprecated (chromium:942901) */ + CROS_GPIO_DEPRECATED_DEV = 2, + CROS_GPIO_WP = 3, /* Write Protect */ + CROS_GPIO_PE = 4, /* Phase enforcement for final product */ + + CROS_GPIO_ACTIVE_LOW = 0, + CROS_GPIO_ACTIVE_HIGH = 1, + + CROS_GPIO_VIRTUAL = -1, +}; +#endif + +#endif /* BASEBOARD_GPIO_H */ From patchwork Mon Jan 27 05:06:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229569 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=bEpFjgP5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dPw0S73z9sR1 for ; Mon, 27 Jan 2020 16:21:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2D9F818DD; Mon, 27 Jan 2020 06:12:51 +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="bEpFjgP5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D28B8173E; Mon, 27 Jan 2020 06:09:59 +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 655828182D for ; Mon, 27 Jan 2020 06:09:22 +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 t17so6410782ilm.13 for ; Sun, 26 Jan 2020 21:09:22 -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=tI8N+Nc1uOq213Te6p8ZfRdK1jK3HKgM7mQVxJhUsUo=; b=bEpFjgP5Df8+5uuARPsL7e6S6Ddg8oOdyn4AhjSXzERJvHWhiSztMQKKfCKO3w8CQj W/52N0r0Dl+He7ZcoDWHItw+0fVBXqqnlGdkQ0fmIpqf5inXX7MwZo1qvbgyYR5AwE8L mx6FmvzuUO4/y6rfma8KbzCakD7prnMbg4ah0= 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=tI8N+Nc1uOq213Te6p8ZfRdK1jK3HKgM7mQVxJhUsUo=; b=E+GXa6/KlGr9A64yA+A0L5hq7+Wf0Mo/GFMyh27C4pupyLHq4O1mR9wC4zCbZfBci4 KAf23S8awy/NpfCQ+dfROx6d70viXvdRMQ1be0xYy5B/onTeuERSgcQsqeyg81TuC1P1 9GErf2LI8xFvB1O7xvedQbElpKoly5HU/+K0RAo+ofp/Fa6IegQx0fCTkB74YEJLBSgn T4sft5JJZyZTliG5aa3EL4abE417pg/tBzi6DiKeP+3iqyOAQGnWES08Lz/gEt3NENEH lgfF+OpfdgRrPp9lAuFyAORQRVg/hVKFT+F/DdyyTl/PC20iI/kCQq7OWv/rXRMhZwsU 9drQ== X-Gm-Message-State: APjAAAWUI2CK0z+r2Xz0d4byG6qrHp6B9+l/+2vXFeYgcZVuYVvaBeBo FtNALMRxERuH3eUTlvYRvOXeqp9KkuMwZA== X-Google-Smtp-Source: APXvYqxzumF5w1XzOz+RkefjRJbfHHSLl8P/KQHempKt2gkDAoQhbpjWjjoYps8WaDBvqY/0HyL0KA== X-Received: by 2002:a92:dac3:: with SMTP id o3mr13841391ilq.237.1580101761070; Sun, 26 Jan 2020 21:09:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:20 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 071/108] x86: acpi: Support external GNVS tables Date: Sun, 26 Jan 2020 22:06:18 -0700 Message-Id: <20200126220508.71.Ic4e4767888256deed0503035fd4cc5c4d1060a62@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 At present U-Boot puts a magic number in the ASL for the GNVS table and searches for later. Add a Kconfig option to use a different approach, where the ASL files declare the table as an external symbol. U-Boot can then put it wherever it likes, without any magic numbers or searching. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 7 ++++ arch/x86/cpu/apollolake/Kconfig | 1 + arch/x86/include/asm/acpi/global_nvs.h | 3 ++ arch/x86/lib/acpi_table.c | 47 ++++++++++++++------------ 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c4a9a9f624..af44da1091 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -755,6 +755,13 @@ config GENERATE_ACPI_TABLE by the operating system. It defines platform-independent interfaces for configuration and power management monitoring. +config ACPI_GNVS_EXTERNAL + bool + help + Put the GNVS (Global Non-Volatile Sleeping) table separate from the + DSDT and add a pointer to the table from the DSDT. This allows + U-Boot to better control the address of the GNVS. + endmenu config HAVE_ACPI_RESUME diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index 2ae6837f75..c66863c52e 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -15,6 +15,7 @@ config INTEL_APOLLOLAKE select TPL_PCH_SUPPORT select PCH_SUPPORT select P2SB + select ACPI_GNVS_EXTERNAL imply ENABLE_MRC_CACHE imply AHCI_PCI imply SCSI diff --git a/arch/x86/include/asm/acpi/global_nvs.h b/arch/x86/include/asm/acpi/global_nvs.h index d56d35ca53..a552cf6374 100644 --- a/arch/x86/include/asm/acpi/global_nvs.h +++ b/arch/x86/include/asm/acpi/global_nvs.h @@ -11,6 +11,9 @@ * ACPI_GNVS_SIZE. They are to be used in platform's global_nvs.asl file * to declare the GNVS OperationRegion, as well as write_acpi_tables() * for the GNVS address runtime fix up. + * + * If using CONFIG_ACPI_GNVS_EXTERNAL, we don't need to locate the GNVS in + * DSDT, since it is created by code, so ACPI_GNVS_ADDR is unused. */ #define ACPI_GNVS_ADDR 0xdeadbeef #define ACPI_GNVS_SIZE 0x100 diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 68e0779357..4c35111c48 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -437,31 +437,34 @@ ulong write_acpi_tables(ulong start_addr) } acpi_align(ctx); - /* Pack GNVS into the ACPI table area */ - for (i = 0; i < dsdt->length; i++) { - u32 *gnvs = (u32 *)((u32)dsdt + i); - if (*gnvs == ACPI_GNVS_ADDR) { - ulong addr = (ulong)map_to_sysmem(ctx->current); - - debug("Fix up global NVS in DSDT to %#08lx\n", addr); - *gnvs = addr; - break; + if (!IS_ENABLED(CONFIG_ACPI_GNVS_EXTERNAL)) { + /* Pack GNVS into the ACPI table area */ + for (i = 0; i < dsdt->length; i++) { + u32 *gnvs = (u32 *)((u32)dsdt + i); + + if (*gnvs == ACPI_GNVS_ADDR) { + *gnvs = map_to_sysmem(ctx->current); + debug("Fix up global NVS in DSDT to %#08x\n", + *gnvs); + break; + } } - } - - /* Update DSDT checksum since we patched the GNVS address */ - dsdt->checksum = 0; - dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length); - /* - * Fill in platform-specific global NVS variables. If this fails we - * cannot return the error but this should only happen while debugging. - */ - addr = acpi_create_gnvs(ctx->current); - if (IS_ERR_VALUE(addr)) - printf("Error: Gailed to create GNVS\n"); + /* Update DSDT checksum since we patched the GNVS address */ + dsdt->checksum = 0; + dsdt->checksum = table_compute_checksum(dsdt, dsdt->length); - acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); + /* + * Fill in platform-specific global NVS variables. If this fails + * we cannot return the error but this should only happen while + * debugging. + */ + addr = acpi_create_gnvs(ctx->current); + if (IS_ERR_VALUE(addr)) + printf("Error: Gailed to create GNVS\n"); + acpi_create_gnvs(ctx->current); + acpi_inc_align(ctx, sizeof(struct acpi_global_nvs)); + } debug("ACPI: * FADT\n"); fadt = ctx->current; From patchwork Mon Jan 27 05:06:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229571 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=KcWTFEl9; 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 485dQH4WCZz9sR1 for ; Mon, 27 Jan 2020 16:21:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1D25818E4; Mon, 27 Jan 2020 06:12:56 +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="KcWTFEl9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A7BD81764; Mon, 27 Jan 2020 06:10:00 +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-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 7B847817D2 for ; Mon, 27 Jan 2020 06:09:23 +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-x12f.google.com with SMTP id f16so6422607ilk.11 for ; Sun, 26 Jan 2020 21:09:23 -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=zbpy9LwIJNGHHbaeQrF6SaaDoJ0K5HHbn7IUtoHQ11k=; b=KcWTFEl9xiLrR5wrtwyJpvaNYiURXdc+r2UkRZFPzRI8NyDif3Ygaj49hnCiygdbe1 VhSCCt8kllbmDcOYq5mfcKmYWpONHe2LEglPSyOLfWS48fZ3U2exgNezxc2T64BaLopd 1DxJwzkQMhX4yZwnVt+I+G7h8fBEsNJ5sfQPY= 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=zbpy9LwIJNGHHbaeQrF6SaaDoJ0K5HHbn7IUtoHQ11k=; b=Oc2DG1u3mkGGT0YJoehaDbuflqDucAofaITrT5+l2MVk4IpSU3nNvJ8o71BNGXKNxi w0CRYocOU45CbtavfUAKcmirZxSz145pLUMUgEi8jYUwwKR4j8+HewaX/5iVZDT+D0tL MdTjebkaWG8f0ewThN9S2Atn1K2nqhU9l426971UDyk1IKIl5LGOmUtzJkVc51OEqpoX HK1qUSciN4gnm0rthAHu8L5nX7HZa49pY66w9GR5ipsjnT2TgrQ90PAkBNUVVpPG0o3w 0wbgrXqRhohyqtmznDcFPpCrjPSEp3dfN+WV0ZE2v7VD4+cWcndWudxzfbFaGMgN0PGS rNsQ== X-Gm-Message-State: APjAAAVTgm6+koRUEqrDzzbtl7Z/yZpxzHHGhkaisoQCVIoTuaKiYHt0 qL5w6ZQU2sHm9xZmUeJ2BtImTDRPpmQYJQ== X-Google-Smtp-Source: APXvYqw+T3htQUYR5S92S/8QQDtx/+QByO8dCcTQ32Yedivyrd/uGuVG0g15XDFcCAgw0xfvxCFtsw== X-Received: by 2002:a05:6e02:f47:: with SMTP id y7mr3182565ilj.162.1580101761968; Sun, 26 Jan 2020 21:09:21 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:21 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 072/108] x86: acpi: Expand the GNVS Date: Sun, 26 Jan 2020 22:06:19 -0700 Message-Id: <20200126220508.72.I0d7d06404af2f2a88031aa0821faebb076dfe81b@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 Expand this to 4KB so that it is possible to add custom information to it. On Chromebooks this is used to pass verified-boot information. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi/global_nvs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/acpi/global_nvs.h b/arch/x86/include/asm/acpi/global_nvs.h index a552cf6374..46383629cc 100644 --- a/arch/x86/include/asm/acpi/global_nvs.h +++ b/arch/x86/include/asm/acpi/global_nvs.h @@ -16,6 +16,6 @@ * DSDT, since it is created by code, so ACPI_GNVS_ADDR is unused. */ #define ACPI_GNVS_ADDR 0xdeadbeef -#define ACPI_GNVS_SIZE 0x100 +#define ACPI_GNVS_SIZE 0x1000 #endif /* _ACPI_GNVS_H_ */ From patchwork Mon Jan 27 05:06:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229570 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=EeJr8qRT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dQ60VYTz9sR1 for ; Mon, 27 Jan 2020 16:21:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 789D2818DA; Mon, 27 Jan 2020 06:12:54 +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="EeJr8qRT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B1F6A815D3; Mon, 27 Jan 2020 06:09:59 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 28E4B8182F for ; Mon, 27 Jan 2020 06:09:24 +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-x143.google.com with SMTP id p8so6411952iln.12 for ; Sun, 26 Jan 2020 21:09:24 -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=QChMLx18BjEuNmlVeHOWPf3v/WmiGYSr0qBbdlrhWvo=; b=EeJr8qRT2f3RBMHfbCl2if7FA98CFJSsqfy/WKervLAhZlCuehf/usEfnKgCZuEU/v P0yQbwmxD1S9P9++Px9r21rT11u6Cf8vnD8HdJuF+f7ftpAZhcXK2i+CsACG4TnYPIrt HDXv2DDzfEaZGKgs6OeKkubhLH5nMAJO0wl/g= 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=QChMLx18BjEuNmlVeHOWPf3v/WmiGYSr0qBbdlrhWvo=; b=d0GnwDAkVzuUwJtyPD3oCXDaLubqP4d8RpgFuZnBJCCF1tJaSE01jTHpgmB6GaPMwm eNrvDBI4L2b6WoDfcizUY5RLyrnF1bTMCc3QmGlUJ7Jur9rcnJq1WrEAX1XZTS/RiEWi T+6t9wJWM+4CWAWW09a+R8bdGo/Lc6P1nC2+fj+sbQhgbFFGgHIqpXIRnVouzeRODYJF zByA/csWiSFKsyl3/tliVnEaDYn7gh7ut7itJfTfB41hoYtcRL5dqljWzICetSS6mDLt ovZfTPAdeeffv52MBl2shNtu7+29VJ/yZKoYCeFKoG4JzYcT/8qUhJzmzSg9D2uN6OAT +oYw== X-Gm-Message-State: APjAAAVNOpoO4p3nn8bdPyIy/1bPT08rEJXFJ1e9FO/3pztuyDQKd0Ta Gn8HHLA+1McJN/56drphY8fZqadGGwdx9g== X-Google-Smtp-Source: APXvYqxSofYXpsCcD3rVllsicnzg4Rox3k3trvVKMyoC43oY/UcLj+nnXrFORfdd6o/AJvZXFP9OsA== X-Received: by 2002:a92:9a90:: with SMTP id c16mr13467307ill.3.1580101762832; Sun, 26 Jan 2020 21:09:22 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 073/108] x86: Add wake sources for the acpi_gpe driver Date: Sun, 26 Jan 2020 22:06:20 -0700 Message-Id: <20200126220508.73.Ic0a30041ccecf67af5e4b77d0c50345bf5438c68@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 Some devices can wake the system from sleep, e.g opening the lid on a clamshell or moving a USB mouse. Add a wake to specify this for USB devices and add the settings for Apollo Lake. Signed-off-by: Simon Glass --- arch/x86/include/asm/arch-apollolake/gpe.h | 134 ++++++++++++++++++++ arch/x86/include/asm/arch-apollolake/gpio.h | 3 + doc/device-tree-bindings/device.txt | 4 + 3 files changed, 141 insertions(+) create mode 100644 arch/x86/include/asm/arch-apollolake/gpe.h diff --git a/arch/x86/include/asm/arch-apollolake/gpe.h b/arch/x86/include/asm/arch-apollolake/gpe.h new file mode 100644 index 0000000000..c0b86085b5 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/gpe.h @@ -0,0 +1,134 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2016 Intel Corporation. + * + * Taken from coreboot apl gpe.h + */ + +#ifndef _SOC_GPE_H_ +#define _SOC_GPE_H_ + +/* bit position in GPE0a_STS register */ +#define GPE0A_PCIE_SCI_STS 0 +#define GPE0A_SWGPE_STS 2 +#define GPE0A_PCIE_WAKE0_STS 3 +#define GPE0A_PUNIT_SCI_STS 4 +#define GPE0A_PCIE_WAKE1_STS 6 +#define GPE0A_PCIE_WAKE2_STS 7 +#define GPE0A_PCIE_WAKE3_STS 8 +#define GPE0A_PCIE_GPE_STS 9 +#define GPE0A_BATLOW_STS 10 +#define GPE0A_CSE_PME_STS 11 +#define GPE0A_XDCI_PME_STS 12 +#define GPE0A_XHCI_PME_STS 13 +#define GPE0A_AVS_PME_STS 14 +#define GPE0A_GPIO_TIER1_SCI_STS 15 +#define GPE0A_SMB_WAK_STS 16 +#define GPE0A_SATA_PME_STS 17 +#define GPE0A_CNVI_PME_STS 18 +#define GPE0A_ESPI_SCI_STS 20 /* Present in GLK */ + +/* Group DW0 is reserved in Apollolake */ + +/* GPE_63_32 */ +#define GPE0_DW1_00 32 +#define GPE0_DW1_01 33 +#define GPE0_DW1_02 34 +#define GPE0_DW1_03 36 +#define GPE0_DW1_04 36 +#define GPE0_DW1_05 37 +#define GPE0_DW1_06 38 +#define GPE0_DW1_07 39 +#define GPE0_DW1_08 40 +#define GPE0_DW1_09 41 +#define GPE0_DW1_10 42 +#define GPE0_DW1_11 43 +#define GPE0_DW1_12 44 +#define GPE0_DW1_13 45 +#define GPE0_DW1_14 46 +#define GPE0_DW1_15 47 +#define GPE0_DW1_16 48 +#define GPE0_DW1_17 49 +#define GPE0_DW1_18 50 +#define GPE0_DW1_19 51 +#define GPE0_DW1_20 52 +#define GPE0_DW1_21 53 +#define GPE0_DW1_22 54 +#define GPE0_DW1_23 55 +#define GPE0_DW1_24 56 +#define GPE0_DW1_25 57 +#define GPE0_DW1_26 58 +#define GPE0_DW1_27 59 +#define GPE0_DW1_28 60 +#define GPE0_DW1_29 61 +#define GPE0_DW1_30 62 +#define GPE0_DW1_31 63 +/* GPE_95_64 */ +#define GPE0_DW2_00 64 +#define GPE0_DW2_01 65 +#define GPE0_DW2_02 66 +#define GPE0_DW2_03 67 +#define GPE0_DW2_04 68 +#define GPE0_DW2_05 69 +#define GPE0_DW2_06 70 +#define GPE0_DW2_07 71 +#define GPE0_DW2_08 72 +#define GPE0_DW2_09 73 +#define GPE0_DW2_10 74 +#define GPE0_DW2_11 75 +#define GPE0_DW2_12 76 +#define GPE0_DW2_13 77 +#define GPE0_DW2_14 78 +#define GPE0_DW2_15 79 +#define GPE0_DW2_16 80 +#define GPE0_DW2_17 81 +#define GPE0_DW2_18 82 +#define GPE0_DW2_19 83 +#define GPE0_DW2_20 84 +#define GPE0_DW2_21 85 +#define GPE0_DW2_22 86 +#define GPE0_DW2_23 87 +#define GPE0_DW2_24 88 +#define GPE0_DW2_25 89 +#define GPE0_DW2_26 90 +#define GPE0_DW2_27 91 +#define GPE0_DW2_28 92 +#define GPE0_DW2_29 93 +#define GPE0_DW2_30 94 +#define GPE0_DW2_31 95 +/* GPE_127_96 */ +#define GPE0_DW3_00 96 +#define GPE0_DW3_01 97 +#define GPE0_DW3_02 98 +#define GPE0_DW3_03 99 +#define GPE0_DW3_04 100 +#define GPE0_DW3_05 101 +#define GPE0_DW3_06 102 +#define GPE0_DW3_07 103 +#define GPE0_DW3_08 104 +#define GPE0_DW3_09 105 +#define GPE0_DW3_10 106 +#define GPE0_DW3_11 107 +#define GPE0_DW3_12 108 +#define GPE0_DW3_13 109 +#define GPE0_DW3_14 110 +#define GPE0_DW3_15 111 +#define GPE0_DW3_16 112 +#define GPE0_DW3_17 113 +#define GPE0_DW3_18 114 +#define GPE0_DW3_19 115 +#define GPE0_DW3_20 116 +#define GPE0_DW3_21 117 +#define GPE0_DW3_22 118 +#define GPE0_DW3_23 119 +#define GPE0_DW3_24 120 +#define GPE0_DW3_25 121 +#define GPE0_DW3_26 122 +#define GPE0_DW3_27 123 +#define GPE0_DW3_28 124 +#define GPE0_DW3_29 125 +#define GPE0_DW3_30 126 +#define GPE0_DW3_31 127 + +#define GPE_MAX GPE0_DW3_31 +#endif diff --git a/arch/x86/include/asm/arch-apollolake/gpio.h b/arch/x86/include/asm/arch-apollolake/gpio.h index 10879c168e..ab5860c0fd 100644 --- a/arch/x86/include/asm/arch-apollolake/gpio.h +++ b/arch/x86/include/asm/arch-apollolake/gpio.h @@ -482,4 +482,7 @@ #define GPIO_72_IRQ 0x65 #define GPIO_73_IRQ 0x66 +/* This is needed by ACPI */ +#define GPIO_NUM_PAD_CFG_REGS 2 /* DW0, DW1 */ + #endif /* _ASM_ARCH_GPIO_H_ */ diff --git a/doc/device-tree-bindings/device.txt b/doc/device-tree-bindings/device.txt index 107b17589c..77aee20031 100644 --- a/doc/device-tree-bindings/device.txt +++ b/doc/device-tree-bindings/device.txt @@ -23,6 +23,8 @@ U-Boot provides for some optional properties which are documented here. - acpi,name : Provides the ACPI name for a device, which is a string consisting of four alphanumeric character (upper case) - acpi,uid : _UID value for device + - acpi,wake : Provides the GPE used to detect a request from a device to wake + from sleep Example @@ -36,6 +38,7 @@ synaptics_touchpad: synaptics-touchpad@2c { acpi,desc = "Synaptics Touchpad"; interrupts-extended = <&acpi_gpe GPIO_18_IRQ IRQ_TYPE_EDGE_FALLING>; + acpi,wake = ; acpi,probed; acpi,hid-desc-reg-offset = <0x20>; }; @@ -47,6 +50,7 @@ pcie-a0@14,0 { compatible = "intel,generic-wifi"; acpi,desc = "Intel WiFi"; acpi,name = "WF00"; + acpi,wake = ; interrupts-extended = <&acpi_gpe 0x3c 0>; }; }; From patchwork Mon Jan 27 05:06: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: 1229572 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=nqvAAnxO; 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 485dQT2vZNz9sR1 for ; Mon, 27 Jan 2020 16:21:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 21543818E6; Mon, 27 Jan 2020 06:12:59 +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="nqvAAnxO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E407B814F4; Mon, 27 Jan 2020 06:10:01 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 F0DE68182B for ; Mon, 27 Jan 2020 06:09:24 +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-xd42.google.com with SMTP id x1so8555981iop.7 for ; Sun, 26 Jan 2020 21:09:24 -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=VrIJh0+YtCwC6yT1Hiq3GOWMItOzLwHepciLBExeSAc=; b=nqvAAnxOY4Te/JOA0o7PDINTPgPxrCJ7k4autY9i2F3P9pk3l7MPh8ctCQ/fQPCyDl OIiPYrHXCJGkk+SLiRKEn1m1hnX/EL2ov1rrATS9u3a9CG2KUjDJ5DNMywjVcYj6oA8O pop0TeopcOC9E2U0geyjlZUi0HzTSIqhwDY+4= 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=VrIJh0+YtCwC6yT1Hiq3GOWMItOzLwHepciLBExeSAc=; b=Rxtbr55gct+keTbuwCEiqSN6FZCa+nG3ufDKWZe/NyctPnxz/uX7JuUbpXFDFcoq04 ez7hLMRcQNkvXACVtFcXRGin/OnQznGMPJ8desvqqKHrJujwA809novY80WEHE2kCmew 7VGNT5cQZLRIsKwT5znJM2bKeMrDG8uiXvQnzG4jlccswrwEIbKiTkCpWa9Cl79WgzKn m5S5boKRR7ogW1WLcjvFuYno1MWH4OgMzVEkmeHZ1ojJF8+qIVHrOI5VcNxsJaAt7RZ9 jw93o1Lb9tjKppJ75RQ1z5sWBCVy5p9e7qNWekfZ9NMdHFko1tx4V3pMpf9JX2/w7cpH 1wcg== X-Gm-Message-State: APjAAAXwWAaW8gd8GMbDI9A2xdt7N/F+E6pzd+qSxc8fjwbizpGU4/Dw HTNBc40Q3nC1VwANo1gIFfjKx+1W2KcDag== X-Google-Smtp-Source: APXvYqyVkOSy2ZjDBprbNfr2dDHS86mA38Dru72LZWXsvCZ4ld4qkacCoGkaimNGEJ4qz/k1j8ufmQ== X-Received: by 2002:a6b:b7d5:: with SMTP id h204mr11529436iof.238.1580101763712; Sun, 26 Jan 2020 21:09:23 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:23 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 074/108] x86: Add a config for the systemagent PCIEX regions size Date: Sun, 26 Jan 2020 22:06:21 -0700 Message-Id: <20200126220508.74.Ibf6615ca086fcd12272968cb3f86975a5a6cef51@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 Add a way to specify the required size for this region. This is used when generating ACPI tables. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 18 ++++++++++++++++++ arch/x86/cpu/apollolake/Kconfig | 1 + 2 files changed, 19 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index af44da1091..5e3357ccee 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -950,4 +950,22 @@ config TPL_ACPI_GPE See https://queue.acm.org/blogposting.cfm?id=18977 for more info +config SA_PCIEX_LENGTH + hex + default 0x10000000 if (PCIEX_LENGTH_256MB) + default 0x8000000 if (PCIEX_LENGTH_128MB) + default 0x4000000 if (PCIEX_LENGTH_64MB) + default 0x10000000 + help + This option allows you to select length of PCIEX region. + +config PCIEX_LENGTH_256MB + bool + +config PCIEX_LENGTH_128MB + bool + +config PCIEX_LENGTH_64MB + bool + endmenu diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index c66863c52e..7d7b5c3a0e 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -13,6 +13,7 @@ config INTEL_APOLLOLAKE select TPL_X86_TSC_TIMER_NATIVE select SPL_PCH_SUPPORT select TPL_PCH_SUPPORT + select PCIEX_LENGTH_256MB select PCH_SUPPORT select P2SB select ACPI_GNVS_EXTERNAL From patchwork Mon Jan 27 05:06:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229574 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=Qk9Wv2uW; 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 485dQt71fCz9sR1 for ; Mon, 27 Jan 2020 16:21:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7DB11818EE; Mon, 27 Jan 2020 06:13:03 +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="Qk9Wv2uW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABFA78173E; Mon, 27 Jan 2020 06:10:05 +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-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 3C43281836 for ; Mon, 27 Jan 2020 06:09:26 +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-x141.google.com with SMTP id f5so6452021ilq.5 for ; Sun, 26 Jan 2020 21:09:26 -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=LmUb7h3Ho75wlZuvNJpDLi16md9jf15tLWnOh0cy7N0=; b=Qk9Wv2uWdtVkmStBSr34ZPpAkwJvtoKNiMA68CHN6cNlt5DKSrXR+UIt37zQLayYbT qFPkXJIHmcVtI15Y59s9Aebg6ncieiE18ofS0NqtiJ/bVLok35z4aC+tgm8ZZuENQE/A 9AfAQAMVYoSdBRgLkN6Q/TX5VfXkiGBlVdKi0= 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=LmUb7h3Ho75wlZuvNJpDLi16md9jf15tLWnOh0cy7N0=; b=IRo+vsOP/JZFkn8Udzxb4jfcrXkL93sc3/3M54zBbaVjfOnCHqPYk6MF/xj3rH9cxy n41Gh4jkBGnId/Or0+y3+WySCVHK9H8tlHVVqL6aphMaLYI0C9zwnE3QPLIMYw+WMady k6iHbDBiv+Hd5PPMWY/lPGbYiCo7gYtipl/MCYhPKXAp6Iy3grFv/GjEnhQK/anDJlqn Nlnd+Rzb8oHSt2lpdhEXHAV8M3tQzZs0rFCvwE8/TTQanzKlMg6cIdoYKG5O/zl+j2MD PZPSHfeIQTxF6Jt8L9Cel2Dg2EZVlL1ayJejvBuT7Ydez+brbBzeGz7TEGxtaKv06LvG ga0Q== X-Gm-Message-State: APjAAAXmbk6bXjjw7xEimmqWYFuLZ3LqadijqgPalhBoTS0hKLnnjnUH t4PXqTW5FJOVoSZYkWjVbF76jsyNeNRY9Q== X-Google-Smtp-Source: APXvYqxXqbYuaXxpiUp2SueFRnZTS9d7wgfTlko4o42V+AeMWPcDh38dhXIcjD3ZuNbTJsy5rncD5g== X-Received: by 2002:a92:1f16:: with SMTP id i22mr14113646ile.206.1580101764508; Sun, 26 Jan 2020 21:09:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 075/108] x86: apl: Support writing the IntelGraphicsMem table Date: Sun, 26 Jan 2020 22:06:22 -0700 Message-Id: <20200126220508.75.Ib32571658caca395daef5ca4178e9c18eef7ee50@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 This table is needed by the Linux graphics driver to handle graphics correctly. Write it to ACPI. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 8 + arch/x86/cpu/apollolake/Kconfig | 1 + arch/x86/cpu/intel_common/Makefile | 2 + arch/x86/cpu/intel_common/intel_opregion.c | 168 ++++++++++++++ arch/x86/include/asm/intel_opregion.h | 247 +++++++++++++++++++++ arch/x86/lib/fsp/fsp_graphics.c | 28 +++ include/bloblist.h | 1 + 7 files changed, 455 insertions(+) create mode 100644 arch/x86/cpu/intel_common/intel_opregion.c create mode 100644 arch/x86/include/asm/intel_opregion.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5e3357ccee..23d2e04140 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -968,4 +968,12 @@ config PCIEX_LENGTH_128MB config PCIEX_LENGTH_64MB bool +config INTEL_GMA_ACPI + bool "Generate ACPI table for Intel GMA graphics" + help + The Intel GMA graphics driver in Linux expects an ACPI table + which describes the layout of the registers and the display + connected to the device. Enable this option to create this + table so that graphics works correctly. + endmenu diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index 7d7b5c3a0e..6c62da04f0 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -45,6 +45,7 @@ config INTEL_APOLLOLAKE imply CMD_CLK imply CLK_INTEL imply ACPI_GPE + imply INTEL_GMA_ACPI if INTEL_APOLLOLAKE diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile index cc4e1c962b..adaf53c35e 100644 --- a/arch/x86/cpu/intel_common/Makefile +++ b/arch/x86/cpu/intel_common/Makefile @@ -9,6 +9,8 @@ obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += report_platform.o obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += mrc.o endif +obj-$(CONFIG_INTEL_GMA_ACPI) += intel_opregion.o + ifdef CONFIG_INTEL_CAR_CQOS obj-$(CONFIG_TPL_BUILD) += car2.o ifndef CONFIG_SPL_BUILD diff --git a/arch/x86/cpu/intel_common/intel_opregion.c b/arch/x86/cpu/intel_common/intel_opregion.c new file mode 100644 index 0000000000..67c381d56d --- /dev/null +++ b/arch/x86/cpu/intel_common/intel_opregion.c @@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Writing IntelGraphicsMem table for ACPI + * + * Copyright 2019 Google LLC + * Modified from coreboot src/soc/intel/gma/opregion.c + */ + +#include +#include +#include +#include +#include +#include + +static char vbt_data[8 << 10]; + +static int locate_vbt(char **vbtp, int *sizep) +{ + struct binman_entry vbt; + struct udevice *dev; + u32 vbtsig = 0; + int size; + int ret; + + ret = binman_entry_find("intel-vbt", &vbt); + if (ret) + return log_msg_ret("find VBT", ret); + ret = uclass_first_device_err(UCLASS_SPI_FLASH, &dev); + if (ret) + return log_msg_ret("find flash", ret); + size = vbt.size; + if (size > sizeof(vbt_data)) + return log_msg_ret("vbt", -E2BIG); + ret = spi_flash_read_dm(dev, vbt.image_pos, size, vbt_data); + if (ret) + return log_msg_ret("read", ret); + + memcpy(&vbtsig, vbt_data, sizeof(vbtsig)); + if (vbtsig != VBT_SIGNATURE) { + log_err("Missing/invalid signature in VBT data file!\n"); + return -EINVAL; + } + + log_info("Found a VBT of %u bytes\n", size); + *sizep = size; + *vbtp = vbt_data; + + return 0; +} + +/* Write ASLS PCI register and prepare SWSCI register. */ +static int intel_gma_opregion_register(struct udevice *dev, ulong opregion) +{ + int sci_reg; + + if (!device_active(dev)) + return -ENOENT; + + /* + * Intel BIOS Specification + * Chapter 5.3.7 "Initialise Hardware State" + */ + dm_pci_write_config32(dev, ASLS, opregion); + + /* + * Atom-based platforms use a combined SMI/SCI register, + * whereas non-Atom platforms use a separate SCI register + */ + if (IS_ENABLED(CONFIG_INTEL_GMA_SWSMISCI)) + sci_reg = SWSMISCI; + else + sci_reg = SWSCI; + + /* + * Intel's Windows driver relies on this: + * Intel BIOS Specification + * Chapter 5.4 "ASL Software SCI Handler" + */ + dm_pci_clrset_config16(dev, sci_reg, GSSCIE, SMISCISEL); + + return 0; +} + +int intel_gma_init_igd_opregion(struct udevice *dev, + struct igd_opregion *opregion) +{ + struct optionrom_vbt *vbt = NULL; + char *vbt_buf; + int vbt_size; + int ret; + + ret = locate_vbt(&vbt_buf, &vbt_size); + if (ret) { + log_err("GMA: VBT couldn't be found\n"); + return log_msg_ret("find vbt", ret); + } + vbt = (struct optionrom_vbt *)vbt_buf; + + memset(opregion, '\0', sizeof(struct igd_opregion)); + + memcpy(&opregion->header.signature, IGD_OPREGION_SIGNATURE, + sizeof(opregion->header.signature)); + memcpy(opregion->header.vbios_version, vbt->coreblock_biosbuild, + ARRAY_SIZE(vbt->coreblock_biosbuild)); + /* Extended VBT support */ + if (vbt->hdr_vbt_size > sizeof(opregion->vbt.gvd1)) { + struct optionrom_vbt *ext_vbt; + + ret = bloblist_ensure_size(BLOBLISTT_INTEL_VBT, + vbt->hdr_vbt_size, + (void **)&ext_vbt); + if (ret) { + log_err("GMA: Unable to add Ext VBT to bloblist\n"); + return log_msg_ret("blob", ret); + } + + memcpy(ext_vbt, vbt, vbt->hdr_vbt_size); + opregion->mailbox3.rvda = (uintptr_t)ext_vbt; + opregion->mailbox3.rvds = vbt->hdr_vbt_size; + } else { + /* Raw VBT size which can fit in gvd1 */ + printf("copy to %p\n", opregion->vbt.gvd1); + memcpy(opregion->vbt.gvd1, vbt, vbt->hdr_vbt_size); + } + + /* 8kb */ + opregion->header.size = sizeof(struct igd_opregion) / 1024; + + /* + * Left-shift version field to accommodate Intel Windows driver quirk + * when not using a VBIOS. + * Required for Legacy boot + NGI, UEFI + NGI, and UEFI + GOP driver. + * + * No adverse effects when using VBIOS or booting Linux. + */ + opregion->header.version = IGD_OPREGION_VERSION << 24; + + /* FIXME We just assume we're mobile for now */ + opregion->header.mailboxes = MAILBOXES_MOBILE; + + /* TODO Initialise Mailbox 1 */ + opregion->mailbox1.clid = 1; + + /* TODO Initialise Mailbox 3 */ + opregion->mailbox3.bclp = IGD_BACKLIGHT_BRIGHTNESS; + opregion->mailbox3.pfit = IGD_FIELD_VALID | IGD_PFIT_STRETCH; + opregion->mailbox3.pcft = 0; /* should be (IMON << 1) & 0x3e */ + opregion->mailbox3.cblv = IGD_FIELD_VALID | IGD_INITIAL_BRIGHTNESS; + opregion->mailbox3.bclm[0] = IGD_WORD_FIELD_VALID + 0x0000; + opregion->mailbox3.bclm[1] = IGD_WORD_FIELD_VALID + 0x0a19; + opregion->mailbox3.bclm[2] = IGD_WORD_FIELD_VALID + 0x1433; + opregion->mailbox3.bclm[3] = IGD_WORD_FIELD_VALID + 0x1e4c; + opregion->mailbox3.bclm[4] = IGD_WORD_FIELD_VALID + 0x2866; + opregion->mailbox3.bclm[5] = IGD_WORD_FIELD_VALID + 0x327f; + opregion->mailbox3.bclm[6] = IGD_WORD_FIELD_VALID + 0x3c99; + opregion->mailbox3.bclm[7] = IGD_WORD_FIELD_VALID + 0x46b2; + opregion->mailbox3.bclm[8] = IGD_WORD_FIELD_VALID + 0x50cc; + opregion->mailbox3.bclm[9] = IGD_WORD_FIELD_VALID + 0x5ae5; + opregion->mailbox3.bclm[10] = IGD_WORD_FIELD_VALID + 0x64ff; + + /* Write ASLS PCI register and prepare SWSCI register. */ + ret = intel_gma_opregion_register(dev, (ulong)opregion); + if (ret) + return log_msg_ret("write asls", ret); + + return 0; +} diff --git a/arch/x86/include/asm/intel_opregion.h b/arch/x86/include/asm/intel_opregion.h new file mode 100644 index 0000000000..fb3e38617e --- /dev/null +++ b/arch/x86/include/asm/intel_opregion.h @@ -0,0 +1,247 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Writing IntelGraphicsMem table for ACPI + * + * Copyright 2019 Google LLC + * Modified from coreboot src/soc/intel/gma/opregion.h + */ + +#ifndef _ASM_INTEL_OPREGION_H_ +#define _ASM_INTEL_OPREGION_H_ + +#define VBT_SIGNATURE 0x54425624 + +/* IGD PCI Configuration register */ +#define ASLS 0xfc /* OpRegion Base */ +#define SWSCI 0xe8 /* SWSCI Register */ +#define SWSMISCI 0xe0 /* SWSMISCI Register */ +#define GSSCIE BIT(0) /* SCI Event trigger */ +#define SMISCISEL BIT(15) /* Select SMI or SCI event source */ + +/* mailbox 0: header */ +struct __packed opregion_header { + u8 signature[16]; /* Offset 0 OpRegion signature */ + u32 size; /* Offset 16 OpRegion size */ + u32 version; /* Offset 20 OpRegion structure version */ + u8 sbios_version[32]; /* Offset 24 System BIOS build version */ + u8 vbios_version[16]; /* Offset 56 Video BIOS build version */ + u8 driver_version[16]; /* Offset 72 Graphic drvr build version */ + u32 mailboxes; /* Offset 88 Mailboxes supported */ + u32 dmod; /* Offset 92 Driver Model */ + u32 pcon; /* Offset 96 Platform Capabilities */ + u16 dver[16]; /* Offset 100 GOP Version */ + u8 reserved[124]; /* Offset 132 Reserved */ +}; + +#define IGD_OPREGION_SIGNATURE "IntelGraphicsMem" +#define IGD_OPREGION_VERSION 2 + +#define IGD_MBOX1 BIT(0) +#define IGD_MBOX2 BIT(1) +#define IGD_MBOX3 BIT(2) +#define IGD_MBOX4 BIT(3) +#define IGD_MBOX5 BIT(4) + +#define MAILBOXES_MOBILE (IGD_MBOX1 | IGD_MBOX2 | IGD_MBOX3 | \ + IGD_MBOX4 | IGD_MBOX5) +#define MAILBOXES_DESKTOP (IGD_MBOX2 | IGD_MBOX4) + +#define SBIOS_VERSION_SIZE 32 + +/* mailbox 1: public ACPI methods */ +struct __packed opregion_mailbox1 { + u32 drdy; /* Offset 0 Driver readiness */ + u32 csts; /* Offset 4 Status */ + u32 cevt; /* Offset 8 Current event */ + u8 reserved[20]; /* Offset 12 Reserved */ + u32 didl; /* Offset 32 Supported display device 1 */ + u32 ddl2; /* Offset 36 Supported display device 2 */ + u32 ddl3; /* Offset 40 Supported display device 3 */ + u32 ddl4; /* Offset 44 Supported display device 4 */ + u32 ddl5; /* Offset 48 Supported display device 5 */ + u32 ddl6; /* Offset 52 Supported display device 6 */ + u32 ddl7; /* Offset 56 Supported display device 7 */ + u32 ddl8; /* Offset 60 Supported display device 8 */ + u32 cpdl; /* Offset 64 Currently present display device 1 */ + u32 cpl2; /* Offset 68 Currently present display device 2 */ + u32 cpl3; /* Offset 72 Currently present display device 3 */ + u32 cpl4; /* Offset 76 Currently present display device 4 */ + u32 cpl5; /* Offset 80 Currently present display device 5 */ + u32 cpl6; /* Offset 84 Currently present display device 6 */ + u32 cpl7; /* Offset 88 Currently present display device 7 */ + u32 cpl8; /* Offset 92 Currently present display device 8 */ + u32 cadl; /* Offset 96 Currently active display device 1 */ + u32 cal2; /* Offset 100 Currently active display device 2 */ + u32 cal3; /* Offset 104 Currently active display device 3 */ + u32 cal4; /* Offset 108 Currently active display device 4 */ + u32 cal5; /* Offset 112 Currently active display device 5 */ + u32 cal6; /* Offset 116 Currently active display device 6 */ + u32 cal7; /* Offset 120 Currently active display device 7 */ + u32 cal8; /* Offset 124 Currently active display device 8 */ + u32 nadl; /* Offset 128 Next active device 1 */ + u32 ndl2; /* Offset 132 Next active device 2 */ + u32 ndl3; /* Offset 136 Next active device 3 */ + u32 ndl4; /* Offset 140 Next active device 4 */ + u32 ndl5; /* Offset 144 Next active device 5 */ + u32 ndl6; /* Offset 148 Next active device 6 */ + u32 ndl7; /* Offset 152 Next active device 7 */ + u32 ndl8; /* Offset 156 Next active device 8 */ + u32 aslp; /* Offset 160 ASL sleep timeout */ + u32 tidx; /* Offset 164 Toggle table index */ + u32 chpd; /* Offset 168 Current hot plug enable indicator */ + u32 clid; /* Offset 172 Current lid state indicator */ + u32 cdck; /* Offset 176 Current docking state indicator */ + u32 sxsw; /* Offset 180 Display Switch notification on Sx State + * resume + */ + u32 evts; /* Offset 184 Events supported by ASL */ + u32 cnot; /* Offset 188 Current OS Notification */ + u32 nrdy; /* Offset 192 Reasons for DRDY = 0 */ + u32 ddl9; /* Offset 196 Extended Supported display device 1 */ + u32 dd10; /* Offset 200 Extended Supported display device 2 */ + u32 dd11; /* Offset 204 Extended Supported display device 3 */ + u32 dd12; /* Offset 208 Extended Supported display device 4 */ + u32 dd13; /* Offset 212 Extended Supported display device 5 */ + u32 dd14; /* Offset 216 Extended Supported display device 6 */ + u32 dd15; /* Offset 220 Extended Supported display device 7 */ + u32 cpl9; /* Offset 224 Extended Currently present device 1 */ + u32 cp10; /* Offset 228 Extended Currently present device 2 */ + u32 cp11; /* Offset 232 Extended Currently present device 3 */ + u32 cp12; /* Offset 236 Extended Currently present device 4 */ + u32 cp13; /* Offset 240 Extended Currently present device 5 */ + u32 cp14; /* Offset 244 Extended Currently present device 6 */ + u32 cp15; /* Offset 248 Extended Currently present device 7 */ + u8 reserved2[4]; /* Offset 252 Reserved 4 bytes */ +}; + +/* mailbox 2: software sci interface */ +struct __packed opregion_mailbox2 { + u32 scic; /* Offset 0 Software SCI function number parameters */ + u32 parm; /* Offset 4 Software SCI function number parameters */ + u32 dslp; /* Offset 8 Driver sleep timeout */ + u8 reserved[244]; /* Offset 12 Reserved */ +}; + +/* mailbox 3: power conservation */ +struct __packed opregion_mailbox3 { + u32 ardy; /* Offset 0 Driver readiness */ + u32 aslc; /* Offset 4 ASLE interrupt command / status */ + u32 tche; /* Offset 8 Technology enabled indicator */ + u32 alsi; /* Offset 12 Current ALS illuminance reading */ + u32 bclp; /* Offset 16 Backlight britness to set */ + u32 pfit; /* Offset 20 Panel fitting Request */ + u32 cblv; /* Offset 24 Brightness Current State */ + /* Offset 28 Backlight Brightness Level Duty Cycle Mapping Table */ + u16 bclm[20]; + u32 cpfm; /* Offset 68 Panel Fitting Current Mode */ + u32 epfm; /* Offset 72 Enabled Panel Fitting Modes */ + u8 plut[74]; /* Offset 76 Panel Look Up Table */ + /* Offset 150 PWM Frequency and Minimum Brightness */ + u32 pfmb; + u32 ccdv; /* Offset 154 Color Correction Default Values */ + u32 pcft; /* Offset 158 Power Conservation Features */ + u32 srot; /* Offset 162 Supported Rotation angle */ + u32 iuer; /* Offset 166 Intel Ultrabook Event Register */ + u64 fdsp; /* Offset 170 FFS Display Physical address */ + u32 fdss; /* Offset 178 FFS Display Size */ + u32 stat; /* Offset 182 State Indicator */ + /* + * Offset 186 (Igd opregion offset 0x3BAh) + * Physical address of Raw VBT data + */ + u64 rvda; + /* Offset 194 (Igd opregion offset 0x3C2h) Size of Raw VBT data */ + u32 rvds; + u8 reserved[58]; /* Offset 198 Reserved */ +}; + +#define IGD_BACKLIGHT_BRIGHTNESS 0xff +#define IGD_INITIAL_BRIGHTNESS 0x64 + +#define IGD_FIELD_VALID BIT(31) +#define IGD_WORD_FIELD_VALID BIT(15) +#define IGD_PFIT_STRETCH 6 + +/* mailbox 4: vbt */ +struct __packed opregion_vbt { + u8 gvd1[6 << 10]; +}; + +/* Mailbox 5: BIOS to Driver Notification Extension */ +struct __packed opregion_mailbox5 { + u32 phed; /* Offset 7168 Panel Header */ + u8 bddc[256]; /* Offset 7172 Panel EDID */ + u8 reserved[764]; /* Offset 7428 764 bytes */ +}; + +/* IGD OpRegion */ +struct __packed igd_opregion { + struct opregion_header header; + struct opregion_mailbox1 mailbox1; + struct opregion_mailbox2 mailbox2; + struct opregion_mailbox3 mailbox3; + struct opregion_vbt vbt; + struct opregion_mailbox5 mailbox5; +}; + +/* Intel Video BIOS (Option ROM) */ +struct __packed optionrom_header { + u16 signature; + u8 size; + u8 reserved[21]; + u16 pcir_offset; + u16 vbt_offset; +}; + +#define OPROM_SIGNATURE 0xaa55 + +struct __packed optionrom_pcir { + u32 signature; + u16 vendor; + u16 device; + u16 reserved1; + u16 length; + u8 revision; + u8 classcode[3]; + u16 imagelength; + u16 coderevision; + u8 codetype; + u8 indicator; + u16 reserved2; +}; + +struct __packed optionrom_vbt { + u8 hdr_signature[20]; + u16 hdr_version; + u16 hdr_size; + u16 hdr_vbt_size; + u8 hdr_vbt_checksum; + u8 hdr_reserved; + u32 hdr_vbt_datablock; + u32 hdr_aim[4]; + u8 datahdr_signature[16]; + u16 datahdr_version; + u16 datahdr_size; + u16 datahdr_datablocksize; + u8 coreblock_id; + u16 coreblock_size; + u16 coreblock_biossize; + u8 coreblock_biostype; + u8 coreblock_releasestatus; + u8 coreblock_hwsupported; + u8 coreblock_integratedhw; + u8 coreblock_biosbuild[4]; + u8 coreblock_biossignon[155]; +}; + +/** + * intel_gma_init_igd_opregion() - Initialise IGD OpRegion + * + * This is called from ACPI code and OS drivers + * + * @return 0 if OK, -ve on error + */ +int intel_gma_init_igd_opregion(struct udevice *dev, + struct igd_opregion *opregion); + +#endif /* _ASM_INTEL_OPREGION_H_ */ diff --git a/arch/x86/lib/fsp/fsp_graphics.c b/arch/x86/lib/fsp/fsp_graphics.c index 98b762209f..3b2f42f166 100644 --- a/arch/x86/lib/fsp/fsp_graphics.c +++ b/arch/x86/lib/fsp/fsp_graphics.c @@ -3,12 +3,17 @@ * Copyright (C) 2017, Bin Meng */ +#define LOG_CATEGORY UCLASS_VIDEO + #include +#include #include #include #include #include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -114,6 +119,28 @@ err: return ret; } +static int fsp_video_acpi_write_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct igd_opregion *opregion; + int ret; + + printf("ACPI: * IGD OpRegion\n"); + opregion = (struct igd_opregion *)ctx->current; + + ret = intel_gma_init_igd_opregion((struct udevice *)dev, opregion); + if (ret) + return ret; + + acpi_inc_align(ctx, sizeof(struct igd_opregion)); + + return 0; +} + +struct acpi_ops fsp_video_acpi_ops = { + .write_tables = fsp_video_acpi_write_tables, +}; + static const struct udevice_id fsp_video_ids[] = { { .compatible = "fsp-fb" }, { } @@ -124,6 +151,7 @@ U_BOOT_DRIVER(fsp_video) = { .id = UCLASS_VIDEO, .of_match = fsp_video_ids, .probe = fsp_video_probe, + acpi_ops_ptr(&fsp_video_acpi_ops) }; static struct pci_device_id fsp_video_supported[] = { diff --git a/include/bloblist.h b/include/bloblist.h index 609ac421d6..94b05c5a6f 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -27,6 +27,7 @@ enum bloblist_tag_t { BLOBLISTT_SPL_HANDOFF, /* Hand-off info from SPL */ BLOBLISTT_VBOOT_CTX, /* Chromium OS verified boot context */ BLOBLISTT_VBOOT_HANDOFF, /* Chromium OS internal handoff info */ + BLOBLISTT_INTEL_VBT, /* Intel Video-BIOS table */ }; /** From patchwork Mon Jan 27 05:06:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229575 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=Ox/uXR14; 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 485dR54Tq4z9sRR for ; Mon, 27 Jan 2020 16:22:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8893B817F8; Mon, 27 Jan 2020 06:13:06 +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="Ox/uXR14"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EDA5E8172D; Mon, 27 Jan 2020 06:10:06 +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 8537C8183F for ; Mon, 27 Jan 2020 06:09:26 +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 f10so6439032ils.8 for ; Sun, 26 Jan 2020 21:09:26 -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=Zj+JKRecdiGVK1OvzYqBPiWv4yPEMUbvCFN3IBLXvos=; b=Ox/uXR14lb8/eXphoanVgc+KVbNMGguU+aI7UOdCr/IeqxtOIKupA3rWhwX3NHJNR7 GNizX1Ef6kcvSuL+K2X3oqBGgd0Aas9C93yzN3a/W5uiy2XemeukNUXpGlYoNoD7bD1G MIsuc5ZESkXeFPUz7D29l+whOC2ytD5v19cPM= 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=Zj+JKRecdiGVK1OvzYqBPiWv4yPEMUbvCFN3IBLXvos=; b=csVT/TDvCXZwETAlLBotxD2ECWjk8CJG8UHZyaLiEAkLLutk8LKhwXbZbZ6OHXdIZq EutWeibfnlbWUVcjg1dUkcochBpj0xSzLqu5ti+8MZawutJGH8835bJCR07pNT18Vcf7 Mrcsfz0yAGIgqv+5400JksdvtOpFcENxPrPh2dGqYKAjLYBzCHYIP49WkDl8YA3z2FLy LEWH7PWLLHHv+2OcJCIinv1M4f5y8vW2SrQ25AdHsAflHhWcjGUk/pc4BoyMPVghBBbs gfQN8matIw6San/ox1WD7sYqhtSmGYh99ubz5HHmk0rgu68VISDpn2OKTnN+Ihy62MnG nPEw== X-Gm-Message-State: APjAAAUFU559LFCFF4zeQ0NuobWsIGeWak7zCBXB4HxCRDS6dFHp7vd7 VJr0sgNok9NNH0Ktwb0ssSrB/hZczbQRiw== X-Google-Smtp-Source: APXvYqx2P4SSTHtqozaGS8yo/EwcftP+Mww3ue7B8mn1mnf8yuUdVz//y9YKDIVmTnYwTgBY9OvSXg== X-Received: by 2002:a92:ca8b:: with SMTP id t11mr14278659ilo.227.1580101765239; Sun, 26 Jan 2020 21:09:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:24 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 076/108] x86: acpi: Add a common routine to write WiFi info Date: Sun, 26 Jan 2020 22:06:23 -0700 Message-Id: <20200126220508.76.I350ce805b1134011181122f4c297fa3f2ec1dfaa@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 Intel WiFi chips can use a common routine to write the information needed by linux. Add an implementation of this. Enable it for coral. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 8 ++ arch/x86/cpu/intel_common/Makefile | 1 + arch/x86/cpu/intel_common/generic_wifi.c | 119 +++++++++++++++++++++++ configs/chromebook_coral_defconfig | 3 +- 4 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 arch/x86/cpu/intel_common/generic_wifi.c diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 23d2e04140..61b6b48b81 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -976,4 +976,12 @@ config INTEL_GMA_ACPI connected to the device. Enable this option to create this table so that graphics works correctly. +config INTEL_GENERIC_WIFI + bool "Enable generation of ACPI tables for Intel WiFi " + help + Select this option to provide code to a build generic WiFi ACPI table + for Intel WiFi devices. This is not a WiFi driver and offers no + network functionality. It is only here to generate the ACPI tables + required by Linux. + endmenu diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile index adaf53c35e..084627f21d 100644 --- a/arch/x86/cpu/intel_common/Makefile +++ b/arch/x86/cpu/intel_common/Makefile @@ -22,6 +22,7 @@ obj-y += cpu.o obj-y += fast_spi.o obj-y += lpc.o obj-y += lpss.o +obj-$(CONFIG_INTEL_GENERIC_WIFI) += generic_wifi.o ifndef CONFIG_TARGET_EFI_APP obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o ifndef CONFIG_$(SPL_)X86_64 diff --git a/arch/x86/cpu/intel_common/generic_wifi.c b/arch/x86/cpu/intel_common/generic_wifi.c new file mode 100644 index 0000000000..a8430fcf3e --- /dev/null +++ b/arch/x86/cpu/intel_common/generic_wifi.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Generic WiFi ACPI info + * + * Copyright 2019 Google LLC + * Modified from coreboot src/drivers/wifi/generic.c + */ + +#include +#include +#include +#include +#include + +/* WRDS Spec Revision */ +#define WRDS_REVISION 0x0 + +/* EWRD Spec Revision */ +#define EWRD_REVISION 0x0 + +/* WRDS Domain type */ +#define WRDS_DOMAIN_TYPE_WIFI 0x7 + +/* EWRD Domain type */ +#define EWRD_DOMAIN_TYPE_WIFI 0x7 + +/* WGDS Domain type */ +#define WGDS_DOMAIN_TYPE_WIFI 0x7 + +/* + * WIFI ACPI NAME = "WF" + hex value of last 8 bits of dev_path_encode + '\0' + * The above representation returns unique and consistent name every time + * generate_wifi_acpi_name is invoked. The last 8 bits of dev_path_encode is + * chosen since it contains the bus address of the device. + */ +#define WIFI_ACPI_NAME_MAX_LEN 5 + +/** + * struct generic_wifi_config - Data structure to contain common wifi config + * @wake: Wake pin for ACPI _PRW + * @maxsleep: Maximum sleep state to wake from + */ +struct generic_wifi_config { + unsigned int wake; + unsigned int maxsleep; +}; + +static int generic_wifi_fill_ssdt(struct acpi_ctx *ctx, + const struct udevice *dev, + const struct generic_wifi_config *config) +{ + char name[ACPI_NAME_MAX]; + char path[ACPI_PATH_MAX]; + pci_dev_t bdf; + u32 address; + int ret; + + ret = acpi_device_path(dev_get_parent(dev), path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + /* Device */ + acpigen_write_scope(ctx, path); + acpigen_write_device(ctx, name); + acpigen_write_name_integer(ctx, "_UID", 0); + acpigen_write_name_string(ctx, "_DDN", + dev_read_string(dev, "acpi,desc")); + + /* Address */ + bdf = dm_pci_get_bdf(dev); + address = (PCI_DEV(bdf) << 16) | PCI_FUNC(bdf); + acpigen_write_name_dword(ctx, "_ADR", address); + + /* Wake capabilities */ + if (config) + acpigen_write_prw(ctx, config->wake, config->maxsleep); + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + +static int intel_wifi_acpi_fill_ssdt(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + struct generic_wifi_config config; + bool have_config; + int ret; + + ret = dev_read_u32(dev, "gpe-wake", &config.wake); + have_config = !ret; + /* By default, all intel wifi chips wake from S3 */ + config.maxsleep = 3; + ret = generic_wifi_fill_ssdt(ctx, dev, have_config ? &config : NULL); + if (ret) + return log_msg_ret("wifi", ret); + + return 0; +} + +struct acpi_ops wifi_acpi_ops = { + .fill_ssdt = intel_wifi_acpi_fill_ssdt, +}; + +static const struct udevice_id intel_wifi_ids[] = { + { .compatible = "intel,generic-wifi" }, + { } +}; + +U_BOOT_DRIVER(intel_wifi) = { + .name = "intel_wifi", + .id = UCLASS_MISC, + .of_match = intel_wifi_ids, + acpi_ops_ptr(&wifi_acpi_ops) +}; diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig index fcb2952d98..0999fb57c6 100644 --- a/configs/chromebook_coral_defconfig +++ b/configs/chromebook_coral_defconfig @@ -15,6 +15,7 @@ CONFIG_HAVE_ACPI_RESUME=y CONFIG_INTEL_CAR_CQOS=y CONFIG_X86_OFFSET_U_BOOT=0xffe00000 CONFIG_X86_OFFSET_SPL=0xffe80000 +CONFIG_INTEL_GENERIC_WIFI=y CONFIG_SPL_TEXT_BASE=0xfef10000 CONFIG_BOOTSTAGE=y CONFIG_SPL_BOOTSTAGE=y @@ -41,7 +42,6 @@ CONFIG_SPL_PCI=y CONFIG_HUSH_PARSER=y CONFIG_CMD_CPU=y CONFIG_CMD_PMC=y -# CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_PART=y @@ -89,7 +89,6 @@ CONFIG_SOUND_RT5677=y CONFIG_SPI=y CONFIG_ICH_SPI=y CONFIG_TPL_SYSRESET=y -CONFIG_TPM_TIS_LPC=y # CONFIG_TPM_V1 is not set CONFIG_TPM2_CR50_I2C=y CONFIG_USB_XHCI_HCD=y From patchwork Mon Jan 27 05:06:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229573 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GqSNBX0b; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dQh0vNyz9sR1 for ; Mon, 27 Jan 2020 16:21:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DFF36818EC; Mon, 27 Jan 2020 06:13:00 +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="GqSNBX0b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FE138177A; Mon, 27 Jan 2020 06:10:04 +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 40D7B8148F for ; Mon, 27 Jan 2020 06:09:27 +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 h8so8566445iob.2 for ; Sun, 26 Jan 2020 21:09:27 -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=34joPUrg144nkKOnfKyxBS++UtIp2B7spvrGMxgCgt0=; b=GqSNBX0bDJVbeSyiPmbMJUF9DaJWAR7Nf3lMA6r2harZrQ6KfKCv1HF/spEb6mfzam Mqkihtc0h3ZbralGJybuLU/jeHFzbMKQpWJwPZD4Cr2uM8jCF2cZrlqXjaROhR8u0RIU hJ2YxHMGU6fQGV8eVwhsWzQeavgb8772nVEtE= 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=34joPUrg144nkKOnfKyxBS++UtIp2B7spvrGMxgCgt0=; b=DZXcIUT+mzBXgQRnGcpORXzGdJMO9NTrNAEjPm8U6iVWJqDQHGZ+VC3Cw6vDlBMuZQ bEuAib8IB2W6BjDGAFvFaMs5+ndJjNFOjk2tFF0FSbq89MwOsL3adyLnZ9NynPoIX4iq JKAM7EyVUXfTyIgdT6F2nnNlqJ+HJqTdDJaESrEIFBM2qky08xNq8XJSYjQvPbINJ5p4 ThOHP21bIizm46yHjpJLEjMA/uASNT++WVIqM2wAli+tsIpAzl/2axCiMgbLEvxwISV+ P6gEnz4Wyx8oe14IM2kAFcPolU6AOYQg4c8TMqrATBv7rKjkV3kH2AiEsrxn8xYeEf2Q n56g== X-Gm-Message-State: APjAAAVr/09UN3NdRHQLuC2ZwOkpzXdGExQp4gaJAbw59ymfBCl6US72 vxmTTuQ0fxtiuu0yrxW/yjAFNK5z9pZkEg== X-Google-Smtp-Source: APXvYqzck4tamTewzL6G0BYgFAkGD3fZ4VQvmUhrAjy98CrYd4yDmcA81y5MnFy5CCY3CTHF6TjkaA== X-Received: by 2002:a5e:9609:: with SMTP id a9mr11801880ioq.78.1580101765980; Sun, 26 Jan 2020 21:09:25 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:25 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 077/108] x86: Add some definitions for SMM Date: Sun, 26 Jan 2020 22:06:24 -0700 Message-Id: <20200126220508.77.Ie0798fbf2b61afd6f2011e8b5f58cba679834675@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 U-Boot does not support SMM (System Management Mode) at present, but needs a few definitions to correctly set up the ACPI table. Add these. Signed-off-by: Simon Glass --- arch/x86/include/asm/smm.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 arch/x86/include/asm/smm.h diff --git a/arch/x86/include/asm/smm.h b/arch/x86/include/asm/smm.h new file mode 100644 index 0000000000..a74e3829b6 --- /dev/null +++ b/arch/x86/include/asm/smm.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * SMM definitions (U-Boot does not support SMM itself) + * + * Copyright (C) 2008-2009 coresystems GmbH + * Copyright 2019 Google LLC + * + * Modified from coreboot smm.h + */ + +#ifndef CPU_X86_SMM_H +#define CPU_X86_SMM_H + +#define SMM_DEFAULT_BASE 0x30000 +#define SMM_DEFAULT_SIZE 0x10000 + +/* used only by C programs so far */ +#define SMM_BASE 0xa0000 + +#define SMM_ENTRY_OFFSET 0x8000 +#define SMM_SAVE_STATE_BEGIN(x) (SMM_ENTRY_OFFSET + (x)) + +#define APM_CNT 0xb2 +#define APM_CNT_CST_CONTROL 0x85 +#define APM_CNT_PST_CONTROL 0x80 +#define APM_CNT_ACPI_DISABLE 0x1e +#define APM_CNT_ACPI_ENABLE 0xe1 +#define APM_CNT_MBI_UPDATE 0xeb +#define APM_CNT_GNVS_UPDATE 0xea +#define APM_CNT_FINALIZE 0xcb +#define APM_CNT_LEGACY 0xcc +#define APM_CNT_SMMSTORE 0xed +#define APM_CNT_ELOG_GSMI 0xef +#define APM_STS 0xb3 + +#endif /* CPU_X86_SMM_H */ From patchwork Mon Jan 27 05:06:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229576 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=SsxRONou; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dRJ0DzZz9sR1 for ; Mon, 27 Jan 2020 16:22:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F2EB818A3; Mon, 27 Jan 2020 06:13:09 +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="SsxRONou"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE0FA8173E; Mon, 27 Jan 2020 06:10:07 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 E8DCC817C1 for ; Mon, 27 Jan 2020 06:09:27 +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-x143.google.com with SMTP id f5so6452070ilq.5 for ; Sun, 26 Jan 2020 21:09:27 -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=LFZ+3W54LlSiZ5xoJrm2AbzBGd9faw+zm0311S40Ecs=; b=SsxRONouJ75dHTL0NUPv+BqZs4DHyaD9/hJcA9kzNvU5gdMdyg+kxpHK9P9pWG4wtV qUOCP5/y5qLgV3Lwsl12rkpz2d3KaOZuPxAUw6yWxyB7kiMgjFMoIxeCOXardkk9EbDq h4e2uUJu4MygWrfUmOItJ5O/rJl1qKnGBzfO4= 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=LFZ+3W54LlSiZ5xoJrm2AbzBGd9faw+zm0311S40Ecs=; b=aqCfXlZ1vcUJb16X/deH3CrXYUndciaeeD+rOjvh7dAkwyw+/7l2Y0gwqgzdTmkW1O AxKE9fx4UK8WhSVPC62qKLTBhErKxpzqolc+3D+zNyWVXeocNjMHvNzTL48XEPGAMGHP o7ZQdzbI7wSsp4UyGEN1Jn7o5c6kOA33LCodrGTfi789xWK9Doxg25jyNdZXXpj6I5DD 6ouMsivpQSDppOj8pncA1eJK1av7gKBbY26iUETxYmi1OGLNfYsropyPqbENRugy7S1K SNPmU5OY18cFZjI05sFzOJNf40/cBZFpp67XJCAfBcyMQ5CMS3TWTOiwkC8iadoyxMRQ 0jvA== X-Gm-Message-State: APjAAAX+l/wnVjbT5X4qiZdaeoVzD9olkzzo+ujDaXf+GV1zQB9gjWfs KpHcUo8KJoqRJMNBfBPpOSrbcOQxWIviUg== X-Google-Smtp-Source: APXvYqzkFWb9BpjxEZw2COSHJydE+pBq8+R7kxId0Wc9Mas5WWf1CZU9G20bBoLr2fIore0FAVWOtw== X-Received: by 2002:a92:85c1:: with SMTP id f184mr13026566ilh.221.1580101766677; Sun, 26 Jan 2020 21:09:26 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 078/108] x86: apl: Add power-management definitions Date: Sun, 26 Jan 2020 22:06:25 -0700 Message-Id: <20200126220508.78.Iee393a0fe215071fcdbf17b373ed3b54a881a4fa@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 Add SCI and power-state definitions required by ACPI tables. Update the guard on acpi_pmc.h to avoid an error when buiding ASL. Signed-off-by: Simon Glass --- arch/x86/include/asm/arch-apollolake/pm.h | 56 +++++++++++++++++++---- include/power/acpi_pmc.h | 4 +- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/arch-apollolake/pm.h b/arch/x86/include/asm/arch-apollolake/pm.h index 6718290c4f..b63d60cd69 100644 --- a/arch/x86/include/asm/arch-apollolake/pm.h +++ b/arch/x86/include/asm/arch-apollolake/pm.h @@ -1,19 +1,57 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2015-2016 Intel Corp. * (Written by Lance Zhao for Intel Corp.) + * Copyright 2019 Google LLC */ #ifndef _ASM_ARCH_PM_H #define _ASM_ARCH_PM_H -#define PMC_GPE_SW_31_0 0 -#define PMC_GPE_SW_63_32 1 -#define PMC_GPE_NW_31_0 3 -#define PMC_GPE_NW_63_32 4 -#define PMC_GPE_NW_95_64 5 -#define PMC_GPE_N_31_0 6 -#define PMC_GPE_N_63_32 7 -#define PMC_GPE_W_31_0 9 +#include + +#define PMC_GPE_SW_31_0 0 +#define PMC_GPE_SW_63_32 1 +#define PMC_GPE_NW_31_0 3 +#define PMC_GPE_NW_63_32 4 +#define PMC_GPE_NW_95_64 5 +#define PMC_GPE_N_31_0 6 +#define PMC_GPE_N_63_32 7 +#define PMC_GPE_W_31_0 9 + +#define IRQ_REG 0x106C +#define SCI_IRQ_ADJUST 24 +#define SCI_IRQ_SEL (255 << SCI_IRQ_ADJUST) +#define SCIS_IRQ9 9 +#define SCIS_IRQ10 10 +#define SCIS_IRQ11 11 +#define SCIS_IRQ20 20 +#define SCIS_IRQ21 21 +#define SCIS_IRQ22 22 +#define SCIS_IRQ23 23 + +/* P-state configuration */ +#define PSS_MAX_ENTRIES 8 +#define PSS_RATIO_STEP 2 +#define PSS_LATENCY_TRANSITION 10 +#define PSS_LATENCY_BUSMASTER 10 + +#ifndef __ASSEMBLY__ +/* Track power state from reset to log events. */ +struct __packed chipset_power_state { + u16 pm1_sts; + u16 pm1_en; + u32 pm1_cnt; + u32 gpe0_sts[GPE0_REG_MAX]; + u32 gpe0_en[GPE0_REG_MAX]; + u16 tco1_sts; + u16 tco2_sts; + u32 prsts; + u32 gen_pmcon1; + u32 gen_pmcon2; + u32 gen_pmcon3; + u32 prev_sleep_state; +}; +#endif /* !__ASSEMBLY__ */ #endif diff --git a/include/power/acpi_pmc.h b/include/power/acpi_pmc.h index 5fbf745136..222288b71a 100644 --- a/include/power/acpi_pmc.h +++ b/include/power/acpi_pmc.h @@ -6,7 +6,7 @@ #ifndef __ACPI_PMC_H #define __ACPI_PMC_H -#ifndef __ACPI__ +#ifndef __ASSEMBLY__ enum { GPE0_REG_MAX = 4, @@ -194,6 +194,6 @@ void pmc_dump_info(struct udevice *dev); */ int pmc_gpe_init(struct udevice *dev); -#endif /* !__ACPI__ */ +#endif /* !__ASSEMBLY__ */ #endif From patchwork Mon Jan 27 05:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229577 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=Xp1t9iEI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dRV2pBpz9sR1 for ; Mon, 27 Jan 2020 16:22:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D977A818F1; Mon, 27 Jan 2020 06:13:11 +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="Xp1t9iEI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 926F68172D; Mon, 27 Jan 2020 06:10:09 +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,T_SPF_HELO_TEMPERROR,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 E339B817DF for ; Mon, 27 Jan 2020 06:09:28 +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-xd44.google.com with SMTP id m25so8557058ioo.8 for ; Sun, 26 Jan 2020 21:09:28 -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=UzNe33ToxzXk4L9EfzRB40QwI8pUo8afG4I8W2AbWSo=; b=Xp1t9iEIeM1Bx5Sli1sb0mtsjl5DSNoDy2MasTjckkw9iep1GZNDOEMTEzPsrQCXB1 X5vhwnlr+OFK0VymXIvJoaBa1Nw1QZD1K0LeQOIPv9/76xkXYr0hXsOG+vZzi9ft6MlG WMXa8bq0xnm3oRczTv+H9CGn99mOFeVWjPpqQ= 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=UzNe33ToxzXk4L9EfzRB40QwI8pUo8afG4I8W2AbWSo=; b=oa8aR/xona1MGHqrcjwczNmcm1QROZHzhUX8x+Ag3wsnTSt1WssPEqRDTvH5b3DU1T DBGK3Be7yNbvArP4KojjmYr1/o5zIiNI5hYWCaTzb/ffi1D0YYtK0ojsgRxePQ6wRGrF Z6YUKcQA180DChz7rO5+3110PDaJ1agvhJPixkKmGQVIInY98eIJUZi/+FYIrnbTGhpQ tVfC+CHqVm/J47uqO1uiS2xYKcpQCfN0rJcPaL8LL5Vhl8wa8UImRdWYmlhJ2XUnJ1qa WkZl9rAggS2Bwt+ahFwJUw15H54LJXKav0I35N60vmcODvHcmhPMx/mVe2Pd1M3PZD9R wdcA== X-Gm-Message-State: APjAAAWSJgR5MXFFKoQpRgQCRI072UDySrKQ7M+N0Bu/+eaNDFKTrT6y KP9LMP3lkJFihr4mA42bF1ukmLvGIDLqXg== X-Google-Smtp-Source: APXvYqxM4siuabiV4yVqMltLBnMNmYfL6Uyll9HulZriXDGKmYlmEN+uwL1i64biRFUjfgJ7ItoZKw== X-Received: by 2002:a6b:6018:: with SMTP id r24mr10073454iog.284.1580101767479; Sun, 26 Jan 2020 21:09:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:27 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 079/108] x86: Add a common global NVS structure Date: Sun, 26 Jan 2020 22:06:26 -0700 Message-Id: <20200126220508.79.I394712a91fe47a73548a7452f49508553a8cdfa5@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 Add the definition of this structure common to Intel devices. It includes some optional Chrome OS pieces which are used when vboot is integrated. Signed-off-by: Simon Glass --- arch/x86/include/asm/intel_gnvs.h | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 arch/x86/include/asm/intel_gnvs.h diff --git a/arch/x86/include/asm/intel_gnvs.h b/arch/x86/include/asm/intel_gnvs.h new file mode 100644 index 0000000000..a4199ce0f3 --- /dev/null +++ b/arch/x86/include/asm/intel_gnvs.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 Intel Corporation. + * + * Taken from coreboot intelblocks/nvs.h + * Copyright 2019 Google LLC + */ + +#ifndef _INTEL_GNVS_H_ +#define _INTEL_GNVS_H_ + +struct __packed acpi_global_nvs { + /* Miscellaneous */ + u8 pcnt; /* 0x00 - Processor Count */ + u8 ppcm; /* 0x01 - Max PPC State */ + u8 lids; /* 0x02 - LID State */ + u8 pwrs; /* 0x03 - AC Power State */ + u8 dpte; /* 0x04 - Enable DPTF */ + u32 cbmc; /* 0x05 - 0x08 - coreboot Memory Console */ + u64 pm1i; /* 0x09 - 0x10 - System Wake Source - PM1 Index */ + u64 gpei; /* 0x11 - 0x18 - GPE Wake Source */ + u64 nhla; /* 0x19 - 0x20 - NHLT Address */ + u32 nhll; /* 0x21 - 0x24 - NHLT Length */ + u32 prt0; /* 0x25 - 0x28 - PERST_0 Address */ + u8 scdp; /* 0x29 - SD_CD GPIO portid */ + u8 scdo; /* 0x2a - GPIO pad offset relative to the community */ + u8 uior; /* 0x2b - UART debug controller init on S3 resume */ + u8 ecps; /* 0x2c - SGX Enabled status */ + u64 emna; /* 0x2d - 0x34 EPC base address */ + u64 elng; /* 0x35 - 0x3C EPC Length */ + u8 unused[195]; +#ifdef CONFIG_CHROMEOS + /* ChromeOS specific (0x100 - 0xfff) */ + struct chromeos_acpi chromeos; +#else + u8 unused2[0xf00]; +#endif +}; +#ifdef CONFIG_CHROMEOS +check_member(acpi_global_nvs, chromeos, GNVS_CHROMEOS_ACPI_OFFSET); +#endif + +#endif /* _INTEL_GNVS_H_ */ From patchwork Mon Jan 27 05:06:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229581 X-Patchwork-Delegate: sjg@chromium.org 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=C7eqmAI+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dSW277hz9sRR for ; Mon, 27 Jan 2020 16:23:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F40CF818F8; Mon, 27 Jan 2020 06:13:25 +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="C7eqmAI+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3D15181764; Mon, 27 Jan 2020 06:10:14 +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-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (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 1ADA48182E for ; Mon, 27 Jan 2020 06:09:30 +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-x144.google.com with SMTP id i7so3258139ilr.7 for ; Sun, 26 Jan 2020 21:09:29 -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=RGetFT3FNJ8lc6ZtRqSngva0XKmfUIOA+0NwsRH5v6I=; b=C7eqmAI+LOolpbrqSdth3/ejo87IbC2oBqyLzzULy58vyfk+Mgg3obPYBEexnsWJUO TNOp4Tnrvu2RcXn1EHtxIPchklYP4h2R3TGDROmVe5k3Ynv0K/RET4ckcfvUY02oXqPo mKrftQLRzTvDxNZJOWLga9CzAQ205V5QreVeo= 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=RGetFT3FNJ8lc6ZtRqSngva0XKmfUIOA+0NwsRH5v6I=; b=DwBo8NJCzHp3On3EY2a5Q1+hYgPQaK9LOLQhqazfdaV4EZSHgjSvVc5rg7Eg0UUJ2X 8ytdNrL3B35h0b3F7exxqtjFxYDIMAKJpj2LrdVcOG1XzUpNxvLl+0VwLBmDV78+HwXd +0033cVeDOzrINWge6/0S7hPkzqh35QWe0Nwd9KbbadP50fJsBZoOONlYC6LJCDzFJaN 4n897hQGu7G4wvbyPLjMePPiEntIvyvwRtoCaq+5B1DTSMTARfqb+cwOvS5n7NqOyFcV /PQjI0G15XfLFKocxwm+281vJ3uJzJ/yVAlv7BK4aiXq21CDksy4y+LVz+c06FLiDaoa QSKA== X-Gm-Message-State: APjAAAWTEf40q7YzuIzy2DUG9GhSs4jrBPxGSUG2l5izb8ftU96Gt5wJ 3zPl6ObxpsCXDF91RAY17rmdsjWgAF9Urg== X-Google-Smtp-Source: APXvYqxiHLIBg4IgHID1GLUEfczywgxWJ/PmywhfnC1NzkYO6FlvY0fi7/fd9UA9e76qTAfPJyp3hw== X-Received: by 2002:a92:8141:: with SMTP id e62mr13259755ild.119.1580101768439; Sun, 26 Jan 2020 21:09:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 080/108] cpu: Convert the methods to use a const udevice * Date: Sun, 26 Jan 2020 22:06:27 -0700 Message-Id: <20200126220508.80.I84a4bf40525636d8cb703ed4747fc2b6358dceea@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 These functions should not modify the device. Convert them to const so that callers don't need to cast if they have a const udevice *. Signed-off-by: Simon Glass --- arch/nios2/cpu/cpu.c | 8 +++++--- arch/x86/cpu/apollolake/cpu.c | 4 ++-- arch/x86/cpu/baytrail/cpu.c | 4 ++-- arch/x86/cpu/broadwell/cpu_full.c | 4 ++-- arch/x86/cpu/cpu_x86.c | 6 +++--- arch/x86/cpu/ivybridge/model_206ax.c | 5 +++-- arch/x86/cpu/qemu/cpu.c | 4 ++-- arch/x86/include/asm/cpu_x86.h | 4 ++-- drivers/cpu/bmips_cpu.c | 8 ++++---- drivers/cpu/cpu-uclass.c | 8 ++++---- drivers/cpu/cpu_sandbox.c | 8 ++++---- drivers/cpu/imx8_cpu.c | 8 ++++---- drivers/cpu/mpc83xx_cpu.c | 17 +++++++++-------- drivers/cpu/riscv_cpu.c | 6 +++--- include/cpu.h | 16 ++++++++-------- 15 files changed, 57 insertions(+), 53 deletions(-) diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 37ffa8f4a4..1938280cae 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -76,7 +76,8 @@ int arch_cpu_init_dm(void) return 0; } -static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size) +static int altera_nios2_get_desc(const struct udevice *dev, char *buf, + int size) { const char *cpu_name = "Nios-II"; @@ -87,7 +88,8 @@ static int altera_nios2_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info) +static int altera_nios2_get_info(const struct udevice *dev, + struct cpu_info *info) { info->cpu_freq = gd->cpu_clk; info->features = (1 << CPU_FEAT_L1_CACHE) | @@ -96,7 +98,7 @@ static int altera_nios2_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int altera_nios2_get_count(struct udevice *dev) +static int altera_nios2_get_count(const struct udevice *dev) { return 1; } diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index 3d05c82a5c..3ae99ccf04 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -9,12 +9,12 @@ #include #include -static int apl_get_info(struct udevice *dev, struct cpu_info *info) +static int apl_get_info(const struct udevice *dev, struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } -static int apl_get_count(struct udevice *dev) +static int apl_get_count(const struct udevice *dev) { return 4; } diff --git a/arch/x86/cpu/baytrail/cpu.c b/arch/x86/cpu/baytrail/cpu.c index 9394eab956..82b59576a9 100644 --- a/arch/x86/cpu/baytrail/cpu.c +++ b/arch/x86/cpu/baytrail/cpu.c @@ -148,7 +148,7 @@ static unsigned long tsc_freq(void) return bclk * ((platform_info.lo >> 8) & 0xff); } -static int baytrail_get_info(struct udevice *dev, struct cpu_info *info) +static int baytrail_get_info(const struct udevice *dev, struct cpu_info *info) { info->cpu_freq = tsc_freq(); info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU; @@ -156,7 +156,7 @@ static int baytrail_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int baytrail_get_count(struct udevice *dev) +static int baytrail_get_count(const struct udevice *dev) { int ecx = 0; diff --git a/arch/x86/cpu/broadwell/cpu_full.c b/arch/x86/cpu/broadwell/cpu_full.c index 895edeb4bc..6f8838c222 100644 --- a/arch/x86/cpu/broadwell/cpu_full.c +++ b/arch/x86/cpu/broadwell/cpu_full.c @@ -623,12 +623,12 @@ void cpu_set_power_limits(int power_limit_1_time) } } -static int broadwell_get_info(struct udevice *dev, struct cpu_info *info) +static int broadwell_get_info(const struct udevice *dev, struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); } -static int broadwell_get_count(struct udevice *dev) +static int broadwell_get_count(const struct udevice *dev) { return 4; } diff --git a/arch/x86/cpu/cpu_x86.c b/arch/x86/cpu/cpu_x86.c index 1aaf851bb4..96472db86c 100644 --- a/arch/x86/cpu/cpu_x86.c +++ b/arch/x86/cpu/cpu_x86.c @@ -26,7 +26,7 @@ int cpu_x86_bind(struct udevice *dev) return 0; } -int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size) { const char *vendor = cpu_vendor_name(gd->arch.x86_vendor); @@ -38,7 +38,7 @@ int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size) return 0; } -int cpu_x86_get_desc(struct udevice *dev, char *buf, int size) +int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size) { char *ptr; @@ -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) +static int cpu_x86_get_count(const struct udevice *dev) { int node, cpu; int num = 0; diff --git a/arch/x86/cpu/ivybridge/model_206ax.c b/arch/x86/cpu/ivybridge/model_206ax.c index 56ab6bf4ac..a3e1b5c570 100644 --- a/arch/x86/cpu/ivybridge/model_206ax.c +++ b/arch/x86/cpu/ivybridge/model_206ax.c @@ -409,14 +409,15 @@ static int model_206ax_init(struct udevice *dev) return 0; } -static int model_206ax_get_info(struct udevice *dev, struct cpu_info *info) +static int model_206ax_get_info(const struct udevice *dev, + struct cpu_info *info) { return cpu_intel_get_info(info, INTEL_BCLK_MHZ); return 0; } -static int model_206ax_get_count(struct udevice *dev) +static int model_206ax_get_count(const struct udevice *dev) { return 4; } diff --git a/arch/x86/cpu/qemu/cpu.c b/arch/x86/cpu/qemu/cpu.c index f40fb4d087..9ce86b379c 100644 --- a/arch/x86/cpu/qemu/cpu.c +++ b/arch/x86/cpu/qemu/cpu.c @@ -10,7 +10,7 @@ #include #include -int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size) +int cpu_qemu_get_desc(const struct udevice *dev, char *buf, int size) { if (size < CPU_MAX_NAME_LEN) return -ENOSPC; @@ -20,7 +20,7 @@ int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int cpu_qemu_get_count(struct udevice *dev) +static int cpu_qemu_get_count(const struct udevice *dev) { return qemu_fwcfg_online_cpus(); } diff --git a/arch/x86/include/asm/cpu_x86.h b/arch/x86/include/asm/cpu_x86.h index 19223f2c3b..ac46fd51f5 100644 --- a/arch/x86/include/asm/cpu_x86.h +++ b/arch/x86/include/asm/cpu_x86.h @@ -28,7 +28,7 @@ int cpu_x86_bind(struct udevice *dev); * @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_desc(struct udevice *dev, char *buf, int size); +int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size); /** * cpu_x86_get_vendor() - Get a vendor string for an x86 CPU @@ -41,6 +41,6 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size); * @size: Size of string space * @return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_x86_get_vendor(struct udevice *dev, char *buf, int size); +int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size); #endif /* _ASM_CPU_X86_H */ diff --git a/drivers/cpu/bmips_cpu.c b/drivers/cpu/bmips_cpu.c index fc047473f5..9ad2565be7 100644 --- a/drivers/cpu/bmips_cpu.c +++ b/drivers/cpu/bmips_cpu.c @@ -377,7 +377,7 @@ static const struct bmips_cpu_hw bmips_cpu_bcm6838 = { }; /* Generic CPU Ops */ -static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int bmips_cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -385,7 +385,7 @@ static int bmips_cpu_get_desc(struct udevice *dev, char *buf, int size) return hw->get_cpu_desc(priv, buf, size); } -static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info) +static int bmips_cpu_get_info(const struct udevice *dev, struct cpu_info *info) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -398,7 +398,7 @@ static int bmips_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int bmips_cpu_get_count(struct udevice *dev) +static int bmips_cpu_get_count(const struct udevice *dev) { struct bmips_cpu_priv *priv = dev_get_priv(dev); const struct bmips_cpu_hw *hw = priv->hw; @@ -406,7 +406,7 @@ static int bmips_cpu_get_count(struct udevice *dev) return hw->get_cpu_count(priv); } -static int bmips_cpu_get_vendor(struct udevice *dev, char *buf, int size) +static int bmips_cpu_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "Broadcom"); diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c index 457f77b7c8..0111b2f467 100644 --- a/drivers/cpu/cpu-uclass.c +++ b/drivers/cpu/cpu-uclass.c @@ -34,7 +34,7 @@ int cpu_probe_all(void) return 0; } -int cpu_get_desc(struct udevice *dev, char *buf, int size) +int cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -44,7 +44,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size) return ops->get_desc(dev, buf, size); } -int cpu_get_info(struct udevice *dev, struct cpu_info *info) +int cpu_get_info(const struct udevice *dev, struct cpu_info *info) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -54,7 +54,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info) return ops->get_info(dev, info); } -int cpu_get_count(struct udevice *dev) +int cpu_get_count(const struct udevice *dev) { struct cpu_ops *ops = cpu_get_ops(dev); @@ -64,7 +64,7 @@ int cpu_get_count(struct udevice *dev) return ops->get_count(dev); } -int cpu_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_get_vendor(const struct udevice *dev, char *buf, int size) { struct cpu_ops *ops = cpu_get_ops(dev); diff --git a/drivers/cpu/cpu_sandbox.c b/drivers/cpu/cpu_sandbox.c index 05b384f6a4..d80d2beeb2 100644 --- a/drivers/cpu/cpu_sandbox.c +++ b/drivers/cpu/cpu_sandbox.c @@ -8,14 +8,14 @@ #include #include -int cpu_sandbox_get_desc(struct udevice *dev, char *buf, int size) +int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"); return 0; } -int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) +int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info) { info->cpu_freq = 42 * 42 * 42 * 42 * 42; info->features = 0x42424242; @@ -24,12 +24,12 @@ int cpu_sandbox_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -int cpu_sandbox_get_count(struct udevice *dev) +int cpu_sandbox_get_count(const struct udevice *dev) { return 42; } -int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size) +int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "Languid Example Garbage Inc."); diff --git a/drivers/cpu/imx8_cpu.c b/drivers/cpu/imx8_cpu.c index 95653683ac..db2862aac5 100644 --- a/drivers/cpu/imx8_cpu.c +++ b/drivers/cpu/imx8_cpu.c @@ -85,7 +85,7 @@ static int cpu_imx_get_temp(void) } #endif -int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) +int cpu_imx_get_desc(const struct udevice *dev, char *buf, int size) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); int ret; @@ -107,7 +107,7 @@ int cpu_imx_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info) +static int cpu_imx_get_info(const struct udevice *dev, struct cpu_info *info) { struct cpu_imx_platdata *plat = dev_get_platdata(dev); @@ -116,12 +116,12 @@ static int cpu_imx_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int cpu_imx_get_count(struct udevice *dev) +static int cpu_imx_get_count(const struct udevice *dev) { return 4; } -static int cpu_imx_get_vendor(struct udevice *dev, char *buf, int size) +static int cpu_imx_get_vendor(const struct udevice *dev, char *buf, int size) { snprintf(buf, size, "NXP"); return 0; diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c index 1e58457742..cd1770f56a 100644 --- a/drivers/cpu/mpc83xx_cpu.c +++ b/drivers/cpu/mpc83xx_cpu.c @@ -58,7 +58,7 @@ static inline u32 get_spridr(void) * determine_type() - Determine CPU family of MPC83xx device * @dev: CPU device from which to read CPU family from */ -static inline void determine_family(struct udevice *dev) +static inline void determine_family(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 12 bits of PARTID field (bits 0-23 in SPRIDR) */ @@ -93,7 +93,7 @@ static inline void determine_family(struct udevice *dev) * determine_type() - Determine CPU type of MPC83xx device * @dev: CPU device from which to read CPU type from */ -static inline void determine_type(struct udevice *dev) +static inline void determine_type(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 16 bits of PVR (Processor Version Register) */ @@ -167,7 +167,7 @@ static inline void determine_type(struct udevice *dev) * determine_e300_type() - Determine e300 core type of MPC83xx device * @dev: CPU device from which to read e300 core type from */ -static inline void determine_e300_type(struct udevice *dev) +static inline void determine_e300_type(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); /* Upper 16 bits of PVR (Processor Version Register) */ @@ -196,7 +196,7 @@ static inline void determine_e300_type(struct udevice *dev) * determine_revid() - Determine revision ID of CPU device * @dev: CPU device from which to read revision ID */ -static inline void determine_revid(struct udevice *dev) +static inline void determine_revid(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); u32 REVID_MAJOR_MASK; @@ -219,7 +219,7 @@ static inline void determine_revid(struct udevice *dev) * determine_cpu_data() - Determine CPU information from hardware * @dev: CPU device from which to read information */ -static void determine_cpu_data(struct udevice *dev) +static void determine_cpu_data(const struct udevice *dev) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); const u32 E_FLAG_MASK = 0x00010000; @@ -237,7 +237,7 @@ static void determine_cpu_data(struct udevice *dev) priv->is_e_processor = !bitfield_extract_by_mask(spridr, E_FLAG_MASK); } -static int mpc83xx_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int mpc83xx_cpu_get_desc(const struct udevice *dev, char *buf, int size) { struct mpc83xx_cpu_priv *priv = dev_get_priv(dev); struct clk core_clk; @@ -301,13 +301,14 @@ static int mpc83xx_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int mpc83xx_cpu_get_count(struct udevice *dev) +static int mpc83xx_cpu_get_count(const struct udevice *dev) { /* We have one e300cX core */ return 1; } -static int mpc83xx_cpu_get_vendor(struct udevice *dev, char *buf, int size) +static int mpc83xx_cpu_get_vendor(const struct udevice *dev, char *buf, + int size) { snprintf(buf, size, "NXP"); diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index 28ad0aa30f..3af2df2f25 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -12,7 +12,7 @@ DECLARE_GLOBAL_DATA_PTR; -static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) +static int riscv_cpu_get_desc(const struct udevice *dev, char *buf, int size) { const char *isa; @@ -25,7 +25,7 @@ static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) return 0; } -static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) +static int riscv_cpu_get_info(const struct udevice *dev, struct cpu_info *info) { const char *mmu; @@ -38,7 +38,7 @@ static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info) return 0; } -static int riscv_cpu_get_count(struct udevice *dev) +static int riscv_cpu_get_count(const struct udevice *dev) { ofnode node; int num = 0; diff --git a/include/cpu.h b/include/cpu.h index 6b1b6b37b3..f2a9a3618b 100644 --- a/include/cpu.h +++ b/include/cpu.h @@ -61,7 +61,7 @@ struct cpu_ops { * @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ - int (*get_desc)(struct udevice *dev, char *buf, int size); + int (*get_desc)(const struct udevice *dev, char *buf, int size); /** * get_info() - Get information about a CPU @@ -70,7 +70,7 @@ struct cpu_ops { * @info: Returns CPU info * @return 0 if OK, -ve on error */ - int (*get_info)(struct udevice *dev, struct cpu_info *info); + int (*get_info)(const struct udevice *dev, struct cpu_info *info); /** * get_count() - Get number of CPUs @@ -78,7 +78,7 @@ struct cpu_ops { * @dev: Device to check (UCLASS_CPU) * @return CPU count if OK, -ve on error */ - int (*get_count)(struct udevice *dev); + int (*get_count)(const struct udevice *dev); /** * get_vendor() - Get vendor name of a CPU @@ -88,7 +88,7 @@ struct cpu_ops { * @size: Size of string space * @return 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ - int (*get_vendor)(struct udevice *dev, char *buf, int size); + int (*get_vendor)(const struct udevice *dev, char *buf, int size); }; #define cpu_get_ops(dev) ((struct cpu_ops *)(dev)->driver->ops) @@ -101,7 +101,7 @@ struct cpu_ops { * * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_desc(struct udevice *dev, char *buf, int size); +int cpu_get_desc(const struct udevice *dev, char *buf, int size); /** * cpu_get_info() - Get information about a CPU @@ -110,7 +110,7 @@ int cpu_get_desc(struct udevice *dev, char *buf, int size); * * Return: 0 if OK, -ve on error */ -int cpu_get_info(struct udevice *dev, struct cpu_info *info); +int cpu_get_info(const struct udevice *dev, struct cpu_info *info); /** * cpu_get_count() - Get number of CPUs @@ -118,7 +118,7 @@ int cpu_get_info(struct udevice *dev, struct cpu_info *info); * * Return: CPU count if OK, -ve on error */ -int cpu_get_count(struct udevice *dev); +int cpu_get_count(const struct udevice *dev); /** * cpu_get_vendor() - Get vendor name of a CPU @@ -128,7 +128,7 @@ int cpu_get_count(struct udevice *dev); * * Return: 0 if OK, -ENOSPC if buffer is too small, other -ve on error */ -int cpu_get_vendor(struct udevice *dev, char *buf, int size); +int cpu_get_vendor(const struct udevice *dev, char *buf, int size); /** * cpu_probe_all() - Probe all available CPUs From patchwork Mon Jan 27 05:06:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229578 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=ZBKG8eFX; 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 485dRh5QJbz9sR1 for ; Mon, 27 Jan 2020 16:22:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8902C818F5; Mon, 27 Jan 2020 06:13:13 +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="ZBKG8eFX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CD431816E1; Mon, 27 Jan 2020 06:10:11 +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-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) (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 665C881844 for ; Mon, 27 Jan 2020 06:09:30 +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-xd33.google.com with SMTP id x1so8556137iop.7 for ; Sun, 26 Jan 2020 21:09:30 -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=nGuKdCNKfpkpYx8OiAgYX8BEp6KBV7SMvAD+huesTNc=; b=ZBKG8eFXtzpLxOty78frfBVbsHNmoqlQDJj/8pv6O/yqsbWb9S5BWCbpgrP6/L6WcF WXbKFZursSPy3B7gnj3qbqzmQfWk+y/i0cpgCD+Qi937OjHDaZsmqTl313e10tSWwB2Z zqeFAv7wOhE2twmn1wOMl5te+51KHQR+v9KBs= 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=nGuKdCNKfpkpYx8OiAgYX8BEp6KBV7SMvAD+huesTNc=; b=BgV0FP/TWp32dOp8lWQ0KhXQljoZa+uIk8UIsXQIzVLUc4wI4bGoGnyliwJGlFyxJU D8EFFCB5IiBeR5fjSVxEEdsuKgs4uPB5+dkRVdrGQaMEmhTLIH6M3yeNJrP8o3iLHUQd lwqsRzcavoGDdIGQT9ObxttGh8U9rUicKMBKkcoQpGKkcCn84nBeqvSDfJzcw46InVuk PTzrVcRxUo0wMahh5xp8yUjDSl1z69kkL+5pV7CsWe5VNLt0uQ9AOMktjJZQfDMyMLCn JvZNuHn3bLiKg3imfLgcKgwlblGSs1NJPXylg6nfvoc0cC9S0ahjEAfAQ6zVKLUxku3O sQ4w== X-Gm-Message-State: APjAAAXdHgwyiA+jRReWKb539Rq3FCumda9M+tH18j4OZETCCsIsSneu We8ozCJxI9MwKcGqTWo/wLweizlv1u5yag== X-Google-Smtp-Source: APXvYqy3fb586+TLsFMgiA8AFZq4X94l7KPyFa+VHpLhtASELIYYO3TW7iG7C9GHL2xB2vFm17wHAQ== X-Received: by 2002:a05:6638:1a3:: with SMTP id b3mr12109114jaq.84.1580101769121; Sun, 26 Jan 2020 21:09:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:28 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 081/108] x86: apl: Update iomap for ACPI Date: Sun, 26 Jan 2020 22:06:28 -0700 Message-Id: <20200126220508.81.I917883a8fac7a88a31608348bfafd057fd49b801@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 Add some more definitions to the iomap. These will be used by ACPI-generation code as well as the device tree. Signed-off-by: Simon Glass --- arch/x86/include/asm/arch-apollolake/iomap.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/x86/include/asm/arch-apollolake/iomap.h b/arch/x86/include/asm/arch-apollolake/iomap.h index 4ce1017055..d12268c825 100644 --- a/arch/x86/include/asm/arch-apollolake/iomap.h +++ b/arch/x86/include/asm/arch-apollolake/iomap.h @@ -11,11 +11,28 @@ /* Put p2sb at 0xd0000000 in TPL */ #define IOMAP_P2SB_BAR 0xd0000000 +#define IOMAP_P2SB_SIZE 0x10000000 #define IOMAP_SPI_BASE 0xfe010000 #define IOMAP_ACPI_BASE 0x400 #define IOMAP_ACPI_SIZE 0x100 +#define ACPI_BASE_ADDRESS IOMAP_ACPI_BASE + +#define PMC_BAR0 0xfe042000 + +#define MCH_BASE_ADDRESS 0xfed10000 +#define MCH_SIZE 0x8000 +#ifdef __ACPI__ +#define HPET_BASE_ADDRESS 0xfed00000 + +#define PMC_BAR0 0xfe042000 + +#define SRAM_BASE_0 0xfe900000 +#define SRAM_SIZE_0 (8 * KiB) +#define SRAM_BASE_2 0xfe902000 +#define SRAM_SIZE_2 (4 * KiB) +#endif /* * Use UART2. To use UART1 you need to set '2' to '1', change device tree serial From patchwork Mon Jan 27 05:06:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229580 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=SWVQKGLK; 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 485dSM0lVpz9sR1 for ; Mon, 27 Jan 2020 16:23:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BB4181904; Mon, 27 Jan 2020 06:13:23 +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="SWVQKGLK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E57F88173E; Mon, 27 Jan 2020 06:10:12 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 3D652817B4 for ; Mon, 27 Jan 2020 06:09:31 +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-xd42.google.com with SMTP id s24so7030038iog.5 for ; Sun, 26 Jan 2020 21:09:31 -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=u+Jy2Bl5JhPWxyylGzF/zTox3Vi97L3iUPZ1uIBY11s=; b=SWVQKGLKMnczi2CpYU+eG+HCxPgQliyXk+EU/APo5Ae1FqzNlUC078WOxBaqo6YaPh zt+4XOg7Scnh099SNKlWQm+RT/AyCEMDzb2hqNViv5VKIhf1Taffjq8v7ZA95t4lJ364 ifDOy4vaeZINAQ24LJkNBmw6PY8NYn7EMiFa0= 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=u+Jy2Bl5JhPWxyylGzF/zTox3Vi97L3iUPZ1uIBY11s=; b=kb+vCJfND6LPPI/HHcVMNnAOQbSBijZEsuYyuMGxTj/vrsLM5upWIOm3LgvjlJGHKx 2zXcLZY8eE5wvWqVArrgcK0CwpUuyRyPkm4yikCDRtL4b/5iV/DiBhduJvsPfjsrDoBE VUHMXBqqfKPcMH4lYF9q7TPM65qOXxprPlzQC4qh6cuu/JN1DeNueLZAi8edIAS6qDLt N6SkjO4+uBDcWS0Q7xGadR2fWKkU9baoXDWWFUZL2ijLgMGh+/VD9Rqu0Tg7GkozteNF OcAhDelfqDabZA3JXAg2mNGGF9jSCHgHsFVcy3mHdWaPCF1WEIgrsYpJ2iQjqXqgkYu2 rTZw== X-Gm-Message-State: APjAAAVAA60bdA6hfPOqi2Tv3O/77/CB7MHWT1syzgqh1L7t9nRUoHa6 +8LwZ2YoVGevLs6KbrF1SA+iMKoFcAQwgg== X-Google-Smtp-Source: APXvYqwqY/vTXhEc4My0LlKDADVfFS+5gdsPOnDPDuGM9rArFz48wNsBayX3ZwdKCr2M2MDs6gLFFA== X-Received: by 2002:a02:c611:: with SMTP id i17mr12221776jan.28.1580101769843; Sun, 26 Jan 2020 21:09:29 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:29 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 082/108] x86: Add a few common Intel CPU functions Date: Sun, 26 Jan 2020 22:06:29 -0700 Message-Id: <20200126220508.82.I9e5c6c23522c6d47c569dccf41bfa7b48aeb554b@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 Add functions to query CPU information, needed for ACPI. Signed-off-by: Simon Glass --- arch/x86/cpu/intel_common/cpu.c | 59 +++++++++++++++++++++++++++++++ arch/x86/include/asm/cpu_common.h | 31 ++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/arch/x86/cpu/intel_common/cpu.c b/arch/x86/cpu/intel_common/cpu.c index 4d093a5391..106ff41e23 100644 --- a/arch/x86/cpu/intel_common/cpu.c +++ b/arch/x86/cpu/intel_common/cpu.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -226,3 +227,61 @@ void cpu_set_eist(bool eist_status) msr.lo &= ~MISC_ENABLE_ENHANCED_SPEEDSTEP; msr_write(MSR_IA32_MISC_ENABLE, msr); } + +int cpu_get_coord_type(void) +{ + return HW_ALL; +} + +uint32_t cpu_get_min_ratio(void) +{ + msr_t msr; + /* Get bus ratio limits and calculate clock speeds */ + msr = msr_read(MSR_PLATFORM_INFO); + + return (msr.hi >> 8) & 0xff; /* Max Efficiency Ratio */ +} + +uint32_t cpu_get_max_ratio(void) +{ + u32 ratio_max; + msr_t msr; + + if (cpu_config_tdp_levels()) { + /* Set max ratio to nominal TDP ratio */ + msr = msr_read(MSR_CONFIG_TDP_NOMINAL); + ratio_max = msr.lo & 0xff; + } else { + msr = msr_read(MSR_PLATFORM_INFO); + /* Max Non-Turbo Ratio */ + ratio_max = (msr.lo >> 8) & 0xff; + } + return ratio_max; +} + +uint32_t cpu_get_bus_clock(void) +{ + /* CPU bus clock is set by default here to 100MHz. + * This function returns the bus clock in KHz. + */ + return INTEL_BCLK_MHZ * 1000; +} + +uint32_t cpu_get_power_max(void) +{ + msr_t msr; + int power_unit; + + msr = msr_read(MSR_PKG_POWER_SKU_UNIT); + power_unit = 2 << ((msr.lo & 0xf) - 1); + msr = msr_read(MSR_PKG_POWER_SKU); + return (msr.lo & 0x7fff) * 1000 / power_unit; +} + +uint32_t cpu_get_max_turbo_ratio(void) +{ + msr_t msr; + + msr = msr_read(MSR_TURBO_RATIO_LIMIT); + return msr.lo & 0xff; +} diff --git a/arch/x86/include/asm/cpu_common.h b/arch/x86/include/asm/cpu_common.h index cdd99a90b7..c3f699ffd3 100644 --- a/arch/x86/include/asm/cpu_common.h +++ b/arch/x86/include/asm/cpu_common.h @@ -128,4 +128,35 @@ void cpu_set_eist(bool eist_status); */ void cpu_set_p_state_to_turbo_ratio(void); +/* + * cpu_get_bus_clock returns the bus clock frequency in KHz. + * This is the value the clock ratio is multiplied with. + */ +uint32_t cpu_get_bus_clock(void); + +int cpu_get_coord_type(void); + +/* + * cpu_get_min_ratio returns the minimum frequency ratio that is supported + * by this processor + */ +uint32_t cpu_get_min_ratio(void); + +/* + * cpu_get_max_ratio returns the nominal TDP ratio if available or the + * maximum non turbo frequency ratio for this processor + */ +uint32_t cpu_get_max_ratio(void); + +/* + * cpu_get_power_max calculates CPU TDP in mW + */ +uint32_t cpu_get_power_max(void); + +/* + * cpu_get_max_turbo_ratio returns the maximum turbo ratio limit for the + * processor + */ +uint32_t cpu_get_max_turbo_ratio(void); + #endif From patchwork Mon Jan 27 05:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229583 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=OY214nPG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 485dSw4S2cz9sPW for ; Mon, 27 Jan 2020 16:23:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4899081908; Mon, 27 Jan 2020 06:13:31 +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="OY214nPG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB4B7817B4; Mon, 27 Jan 2020 06:10:15 +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 0878B817A0 for ; Mon, 27 Jan 2020 06:09:32 +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 s24so7030069iog.5 for ; Sun, 26 Jan 2020 21:09:31 -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=4n6iLBXRjGJBdZbqpFk5B/ruaCbdrDCvjBX/3Mx2yjo=; b=OY214nPGMEgOa9h8YngnOMOpr4hF33uDBkKfjA7VeG1l/My2oFhR+hfR8/ZBOMcPqI aPiYp32jScv1eesSAzjv7JPRkfZT4ShjBdOrrdHN/nvI0VHkG1dgdyoxXot0viOaazct jwq6Ei6SmvD/ZogNNz82Fy5wvlvy47RFflCEM= 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=4n6iLBXRjGJBdZbqpFk5B/ruaCbdrDCvjBX/3Mx2yjo=; b=hOhv/+mmGQjHpCHAbTWh1YKpINcOeolmIZUCuaVFFjFXdkXKfFnEzeKakWaH+u3QXk yr+CcC2B5N7RzVKwk/Mdf/lj2+Uq3c9je5bjrmEF1dw87W9wodwUqLfwJcU5IAf5RZeQ 9LKl7jguSy1FbpfdNzrHIGuvv3pFkUwUGGZdupTJjlXqEpv013/273BrQN5uF+z3u1cB Ek5dOelRxr0XdDhDHDZnJiNcahfsu3a5E1swtofPFbSWS3FxPd5qj7kWArIubS1YueiP GgmPO7euA4VH0WDq0qsXjCQBdggc+NptEpB4YKLP6nFcxhJcOw6HFhuQGTsTyASjOINt Qt6w== X-Gm-Message-State: APjAAAXM3r6Ob4YkHol+mbT2ySWnLZ6FaBOMCeFhkk32qD2pB8kSgBbq 9olLtjOlz5bp1/KwTZnfRp63IaVugq2LBA== X-Google-Smtp-Source: APXvYqzzT4MM9WBMkFbWp85kOu2+lLLpdsp3HAIRfETHh346KgyF93uCsodf/hNAUuCiQFjzcdNZAA== X-Received: by 2002:a05:6638:97c:: with SMTP id o28mr12122968jaj.8.1580101770736; Sun, 26 Jan 2020 21:09:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:30 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 083/108] x86: acpi: Support generation of the HPET table Date: Sun, 26 Jan 2020 22:06:30 -0700 Message-Id: <20200126220508.83.If8823c046de531ba72920ef50bbae1dbc77d538b@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 Add an implementation of the HPET (High Precision Event Timer) ACPI table. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 54 +++++++++++++++++++++++++++++++++++++++ include/acpi_table.h | 32 ++++++++++++++++------- 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 4c35111c48..a810b12cfe 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -32,6 +32,26 @@ extern const unsigned char AmlCode[]; /* ACPI RSDP address to be used in boot parameters */ static ulong acpi_rsdp_addr; +int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev) +{ + struct acpi_hpet *hpet; + int ret; + + /* + * We explicitly add these tables later on: + */ + log_debug("ACPI: * HPET\n"); + + hpet = ctx->current; + acpi_inc_align(ctx, sizeof(struct acpi_hpet)); + acpi_create_hpet(hpet); + ret = acpi_add_table(ctx, hpet); + if (ret) + return log_msg_ret("add", ret); + + return 0; +} + static void acpi_create_facs(struct acpi_facs *facs) { memset((void *)facs, 0, sizeof(struct acpi_facs)); @@ -385,6 +405,40 @@ void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length); } +/* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ +int acpi_create_hpet(struct acpi_hpet *hpet) +{ + struct acpi_table_header *header = &hpet->header; + struct acpi_gen_regaddr *addr = &hpet->addr; + + memset((void *)hpet, 0, sizeof(struct acpi_hpet)); + if (!header) + return -EFAULT; + + /* Fill out header fields. */ + acpi_fill_header(header, "HPET"); + + header->aslc_revision = ASL_REVISION; + header->length = sizeof(struct acpi_hpet); + header->revision = acpi_get_table_revision(ACPITAB_HPET); + + /* Fill out HPET address. */ + addr->space_id = 0; /* Memory */ + addr->bit_width = 64; + addr->bit_offset = 0; + addr->addrl = CONFIG_HPET_ADDRESS & 0xffffffff; + addr->addrh = ((unsigned long long)CONFIG_HPET_ADDRESS) >> 32; + + hpet->id = *(unsigned int *)CONFIG_HPET_ADDRESS; + hpet->number = 0; + hpet->min_tick = 0; /* HPET_MIN_TICKS */ + + header->checksum = table_compute_checksum((void *)hpet, + sizeof(struct acpi_hpet)); + + return 0; +} + /* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ diff --git a/include/acpi_table.h b/include/acpi_table.h index e3dedc2496..1d78665abe 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -70,6 +70,15 @@ struct __packed acpi_table_header { u32 aslc_revision; /* ASL compiler revision number */ }; +struct acpi_gen_regaddr { + u8 space_id; /* Address space ID */ + u8 bit_width; /* Register size in bits */ + u8 bit_offset; /* Register bit offset */ + u8 access_size; /* Access size */ + u32 addrl; /* Register address, low 32 bits */ + u32 addrh; /* Register address, high 32 bits */ +}; + /* A maximum number of 32 ACPI tables ought to be enough for now */ #define MAX_ACPI_TABLES 32 @@ -85,6 +94,16 @@ struct acpi_xsdt { u64 entry[MAX_ACPI_TABLES]; }; +/* HPET timers */ +struct __packed acpi_hpet { + struct acpi_table_header header; + u32 id; + struct acpi_gen_regaddr addr; + u8 number; + u16 min_tick; + u8 attributes; +}; + /* FADT Preferred Power Management Profile */ enum acpi_pm_profile { ACPI_PM_UNSPECIFIED = 0, @@ -152,15 +171,6 @@ enum acpi_address_space_size { ACPI_ACCESS_SIZE_QWORD_ACCESS }; -struct acpi_gen_regaddr { - u8 space_id; /* Address space ID */ - u8 bit_width; /* Register size in bits */ - u8 bit_offset; /* Register bit offset */ - u8 access_size; /* Access size */ - u32 addrl; /* Register address, low 32 bits */ - u32 addrh; /* Register address, high 32 bits */ -}; - /* FADT (Fixed ACPI Description Table) */ struct __packed acpi_fadt { struct acpi_table_header header; @@ -617,6 +627,10 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table); */ void acpi_setup_base_tables(struct acpi_ctx *ctx, void *start); +int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev); + +int acpi_create_hpet(struct acpi_hpet *hpet); + #endif /* !__ACPI__*/ #include From patchwork Mon Jan 27 05:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229582 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=iUBQTA2l; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dSk35fjz9sPW for ; Mon, 27 Jan 2020 16:23:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6215F81907; Mon, 27 Jan 2020 06:13:28 +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="iUBQTA2l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AD3F817A0; Mon, 27 Jan 2020 06:10:16 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 D6DC28176E for ; Mon, 27 Jan 2020 06:09:32 +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-xd44.google.com with SMTP id x1so8556209iop.7 for ; Sun, 26 Jan 2020 21:09:32 -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=T1YTjF5c9LbM/hALP7SMD09ytwLFLKjx284OCjgxFU8=; b=iUBQTA2lU8uQK0T4txj7NayIuAtFgEFwPeMx7C74DG0DLMJAqD98869JJl47kVJFPT ti/w9D1TmTWsehkZo0iR9J6AB98+OuRWEdlCr05+jV3zvhMB4Hhf/feZpzTb0OgdUjgZ Ii/uUsatNTvK3f8gbp8TivSP0Dz6vM74M35Wc= 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=T1YTjF5c9LbM/hALP7SMD09ytwLFLKjx284OCjgxFU8=; b=p1CmL6ImHThVw1NV3RwrIbl6YnrNf+R3CKjTt5Huy+/6sAUMJFxPPC6P5t0Wqiu6qv xKL6XXiLzPa8DXAFVTco00fqt/ff4MXESAYyKtiovOA6ceCOzySXpMkEa5SKW+/HHtW+ MkFwgIhCjhly38t7xVMf5mFilTOjHpyFUpVQVRby3wkIx6vUpl6bfYpDpjezjNfERzcL F9zZsPZdNhTtIhBn7FChcQTxuW5LEqPSG1x139c94ZGGS0Wp1EtFsOCPSxXdrh5duaBn PVX9dtrI+WJe5veCmy3UK2JPuZGdLvipYKvyKE3aSHVSdsfY9/A8zh9Df3oDoy/n5n8H fx+g== X-Gm-Message-State: APjAAAXv8eFudiqL+FgVa/3jpfIKuEOAjSokQd6irHRYiPWTXrB7Vdx5 4qKnfVyjTPvQSroYHT+77dCgQfhcljiD/g== X-Google-Smtp-Source: APXvYqwueRMiDF/VbCg3Q9fvj/EaEG035gJ/agvCe1ko3+edxWGzvmmv/2fZHev/2fNx/AsIXFiYpQ== X-Received: by 2002:a02:aa10:: with SMTP id r16mr12231018jam.48.1580101771535; Sun, 26 Jan 2020 21:09:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 084/108] x86: acpi: Support generation of the DBG2 table Date: Sun, 26 Jan 2020 22:06:31 -0700 Message-Id: <20200126220508.84.I8f7a76fcf50225b3e105c3230c1c5cd66e76967b@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 Add an implementation of the DBG2 (Debug Port Table 2) ACPI table. Adjust one of the header includes to be in the correct order, before adding more. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 112 +++++++++++++++++++++++++++++++++++++- include/acpi_table.h | 31 +++++++++++ 2 files changed, 142 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index a810b12cfe..f12344de50 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include #include @@ -15,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +53,50 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev) return 0; } +int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev, + uint access_size) +{ + struct acpi_dbg2_header *dbg2 = ctx->current; + char path[ACPI_PATH_MAX]; + struct acpi_gen_regaddr address; + phys_addr_t addr; + int ret; + + if (!dev) { + log_err("Device not found\n"); + return -ENODEV; + } + if (!device_active(dev)) { + log_info("Device not enabled\n"); + return -EACCES; + } + /* + * PCI devices don't remember their resource allocation information in + * U-Boot at present. We assume that MMIO is used for the UART and that + * the address space is 32 bytes: ns16550 uses 8 registers of up to + * 32-bits each. This is only for debugging so it is not a big deal. + */ + addr = dm_pci_read_bar32(dev, 0); + printf("UART addr %lx\n", (ulong)addr); + + memset(&address, '\0', sizeof(address)); + address.space_id = ACPI_ADDRESS_SPACE_MEMORY; + address.addrl = (uint32_t)addr; + address.addrh = (uint32_t)((addr >> 32) & 0xffffffff); + address.access_size = access_size; + + ret = acpi_device_path(dev, path, sizeof(path)); + if (ret) + return log_msg_ret("path", ret); + acpi_create_dbg2(dbg2, ACPI_DBG2_SERIAL_PORT, + ACPI_DBG2_16550_COMPATIBLE, &address, 0x1000, path); + + acpi_inc_align(ctx, dbg2->header.length); + acpi_add_table(ctx, dbg2); + + return 0; +} + static void acpi_create_facs(struct acpi_facs *facs) { memset((void *)facs, 0, sizeof(struct acpi_facs)); @@ -439,6 +484,71 @@ int acpi_create_hpet(struct acpi_hpet *hpet) return 0; } +void acpi_create_dbg2(struct acpi_dbg2_header *dbg2, + int port_type, int port_subtype, + struct acpi_gen_regaddr *address, u32 address_size, + const char *device_path) +{ + uintptr_t current; + struct acpi_dbg2_device *device; + u32 *dbg2_addr_size; + struct acpi_table_header *header; + size_t path_len; + const char *path; + char *namespace; + + /* Fill out header fields. */ + current = (uintptr_t)dbg2; + memset(dbg2, '\0', sizeof(struct acpi_dbg2_header)); + header = &dbg2->header; + + header->revision = acpi_get_table_revision(ACPITAB_DBG2); + acpi_fill_header(header, "DBG2"); + header->aslc_revision = ASL_REVISION; + + /* One debug device defined */ + dbg2->devices_offset = sizeof(struct acpi_dbg2_header); + dbg2->devices_count = 1; + current += sizeof(struct acpi_dbg2_header); + + /* Device comes after the header */ + device = (struct acpi_dbg2_device *)current; + memset(device, 0, sizeof(struct acpi_dbg2_device)); + current += sizeof(struct acpi_dbg2_device); + + device->revision = 0; + device->address_count = 1; + device->port_type = port_type; + device->port_subtype = port_subtype; + + /* Base Address comes after device structure */ + memcpy((void *)current, address, sizeof(struct acpi_gen_regaddr)); + device->base_address_offset = current - (uintptr_t)device; + current += sizeof(struct acpi_gen_regaddr); + + /* Address Size comes after address structure */ + dbg2_addr_size = (uint32_t *)current; + device->address_size_offset = current - (uintptr_t)device; + *dbg2_addr_size = address_size; + current += sizeof(uint32_t); + + /* Namespace string comes last, use '.' if not provided */ + path = device_path ? : "."; + /* Namespace string length includes NULL terminator */ + path_len = strlen(path) + 1; + namespace = (char *)current; + device->namespace_string_length = path_len; + device->namespace_string_offset = current - (uintptr_t)device; + strncpy(namespace, path, path_len); + current += path_len; + + /* Update structure lengths and checksum */ + device->length = current - (uintptr_t)device; + header->length = current - (uintptr_t)dbg2; + header->checksum = table_compute_checksum((uint8_t *)dbg2, + header->length); +} + /* * QEMU's version of write_acpi_tables is defined in drivers/misc/qfw.c */ diff --git a/include/acpi_table.h b/include/acpi_table.h index 1d78665abe..6d91ae85e2 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -489,6 +489,29 @@ struct acpi_dmar { #define ACPI_DBG2_UNKNOWN 0x00FF +/* DBG2: Microsoft Debug Port Table 2 header */ +struct __packed acpi_dbg2_header { + struct acpi_table_header header; + u32 devices_offset; + u32 devices_count; +}; + +/* DBG2: Microsoft Debug Port Table 2 device entry */ +struct __packed acpi_dbg2_device { + u8 revision; + u16 length; + u8 address_count; + u16 namespace_string_length; + u16 namespace_string_offset; + u16 oem_data_length; + u16 oem_data_offset; + u16 port_type; + u16 port_subtype; + u8 reserved[2]; + u16 base_address_offset; + u16 address_size_offset; +}; + /* SPCR (Serial Port Console Redirection table) */ struct __packed acpi_spcr { struct acpi_table_header header; @@ -564,6 +587,11 @@ int acpi_get_table_revision(enum acpi_tables table); */ int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags); +void acpi_create_dbg2(struct acpi_dbg2_header *dbg2, + int port_type, int port_subtype, + struct acpi_gen_regaddr *address, uint32_t address_size, + const char *device_path); + /** * acpi_fill_header() - Set up a new table header * @@ -631,6 +659,9 @@ int acpi_write_hpet(struct acpi_ctx *ctx, const struct udevice *dev); int acpi_create_hpet(struct acpi_hpet *hpet); +int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev, + uint access_size); + #endif /* !__ACPI__*/ #include From patchwork Mon Jan 27 05:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229585 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=YxssXgVR; 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 485dTL3J8Pz9sR1 for ; Mon, 27 Jan 2020 16:24:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7AFEF8190C; Mon, 27 Jan 2020 06:13:36 +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="YxssXgVR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 764BA81764; Mon, 27 Jan 2020 06:10:17 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 DBC0F8172A for ; Mon, 27 Jan 2020 06:09:33 +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-xd43.google.com with SMTP id s24so7030125iog.5 for ; Sun, 26 Jan 2020 21:09:33 -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=3w5sFPAUDO0OJzAYnzjC8A4tuhOkS6/VpygcNawhPfY=; b=YxssXgVRgY1rzRDJiknIs5eLn29l2c5xncKWwjBc9xz5CzCJF7+S6YYiKP640h/MjM O/2U7bNLXd7/c027oo6Eexxjd+wRbh+cg4Hf4cbwCf14KrPMz4OilMmVy0pAKYMGSwSJ Sul/RJeWwz01MMcnYnqkfl31pGm6F2WdGBKVA= 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=3w5sFPAUDO0OJzAYnzjC8A4tuhOkS6/VpygcNawhPfY=; b=Q8Ebih42LqUc9UJ8hTiToVMw5urVn/g5x9nkODXwarBAy4r6UdPO77yKUlJqWmx1tb J+4q7MLdxx4hmCFPli60mjlRXCLDkXHNl5tK1qGV4NaYFtWXTJRSZqDgP3eKnf2e47gR GjSwsJ3vLPlQKUVm9y7luVbI4E6dJ79oFq1I6M/jGtYT1HN+FKelfRGLvuE/oCHuuPdY UYf3YtlotQ1b9M/o0lJnMfvw2h4vRk7JkqFxHoMKhB0AEhshKLQQoczOies7G041FY2m yUasl28m38MiZgcUOohYhSIyjCS79Kr3Fcf6YPJv/zLizDq57iGrcgA0B3k7WbZVmo8s 5a5g== X-Gm-Message-State: APjAAAW5IjIxXkV/YWWoFjzqx9FEJFFzyws2ninlKS+K+JlCsrPDpSPK XE+t5L9dw5tpnIiC5v/KXJoUhUS76h6YXg== X-Google-Smtp-Source: APXvYqwHmr9K2n0MK11lvMTjE1kTwExd/S4XZgBSmwbC3KV6orb7Y1/8LqePneKLXZ5x8oALGXgbhA== X-Received: by 2002:a02:51c3:: with SMTP id s186mr2599547jaa.127.1580101772474; Sun, 26 Jan 2020 21:09:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 085/108] x86: acpi: Add common Intel ACPI tables Date: Sun, 26 Jan 2020 22:06:32 -0700 Message-Id: <20200126220508.85.Icd34dc70072b3a0c962beea24d078454ee587714@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 Add various tables that are common to Intel CPUs. These functions can be used by arch-specific CPU code. Signed-off-by: Simon Glass --- arch/x86/cpu/intel_common/Makefile | 2 + arch/x86/cpu/intel_common/acpi.c | 441 +++++++++++++++++++++++++++++ arch/x86/include/asm/acpi_table.h | 5 + arch/x86/include/asm/cpu_common.h | 1 + arch/x86/include/asm/intel_acpi.h | 25 ++ include/bloblist.h | 5 + 6 files changed, 479 insertions(+) create mode 100644 arch/x86/cpu/intel_common/acpi.c create mode 100644 arch/x86/include/asm/intel_acpi.h diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile index 084627f21d..7e1be53630 100644 --- a/arch/x86/cpu/intel_common/Makefile +++ b/arch/x86/cpu/intel_common/Makefile @@ -2,6 +2,8 @@ # # Copyright (c) 2016 Google, Inc +obj-y += acpi.o + ifdef CONFIG_HAVE_MRC obj-$(CONFIG_$(SPL_TPL_)X86_16BIT_INIT) += car.o obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += me_status.o diff --git a/arch/x86/cpu/intel_common/acpi.c b/arch/x86/cpu/intel_common/acpi.c new file mode 100644 index 0000000000..df8a27dfaa --- /dev/null +++ b/arch/x86/cpu/intel_common/acpi.c @@ -0,0 +1,441 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Generic Intel ACPI table generation + * + * Copyright (C) 2017 Intel Corp. + * Copyright 2019 Google LLC + * + * Modified from coreboot src/soc/intel/common/block/acpi.c + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +__weak u32 acpi_fill_mcfg(u32 current) +{ + /* PCI Segment Group 0, Start Bus Number 0, End Bus Number is 255 */ + current += acpi_create_mcfg_mmconfig((void *)current, + CONFIG_MMCONF_BASE_ADDRESS, 0, 0, + (CONFIG_SA_PCIEX_LENGTH >> 20) + - 1); + return current; +} + +static int acpi_sci_irq(void) +{ + int sci_irq = 9; + uint scis; + int ret; + + ret = arch_read_sci_irq_select(); + if (IS_ERR_VALUE(ret)) + return log_msg_ret("sci_irq", ret); + scis = ret; + scis &= SCI_IRQ_SEL; + scis >>= SCI_IRQ_ADJUST; + + /* Determine how SCI is routed. */ + switch (scis) { + case SCIS_IRQ9: + case SCIS_IRQ10: + case SCIS_IRQ11: + sci_irq = scis - SCIS_IRQ9 + 9; + break; + case SCIS_IRQ20: + case SCIS_IRQ21: + case SCIS_IRQ22: + case SCIS_IRQ23: + sci_irq = scis - SCIS_IRQ20 + 20; + break; + default: + log_warning("Invalid SCI route! Defaulting to IRQ9\n"); + sci_irq = 9; + break; + } + + log_debug("SCI is IRQ%d\n", sci_irq); + + return sci_irq; +} + +static unsigned long acpi_madt_irq_overrides(unsigned long current) +{ + int sci = acpi_sci_irq(); + u16 flags = MP_IRQ_TRIGGER_LEVEL; + + if (sci < 0) + return log_msg_ret("sci irq", sci); + + /* INT_SRC_OVR */ + current += acpi_create_madt_irqoverride((void *)current, 0, 0, 2, 0); + + flags |= arch_madt_sci_irq_polarity(sci); + + /* SCI */ + current += + acpi_create_madt_irqoverride((void *)current, 0, sci, sci, flags); + + return current; +} + +u32 acpi_fill_madt(u32 current) +{ + /* Local APICs */ + current += acpi_create_madt_lapics(current); + + /* IOAPIC */ + current += acpi_create_madt_ioapic((void *)current, 2, IO_APIC_ADDR, 0); + + return acpi_madt_irq_overrides(current); +} + +__weak void soc_fill_fadt(struct acpi_fadt *fadt) +{ +} + +void intel_acpi_fill_fadt(struct acpi_fadt *fadt) +{ + const u16 pmbase = IOMAP_ACPI_BASE; + + /* Use ACPI 3.0 revision. */ + fadt->header.revision = acpi_get_table_revision(ACPITAB_FADT); + + fadt->sci_int = acpi_sci_irq(); + fadt->smi_cmd = APM_CNT; + fadt->acpi_enable = APM_CNT_ACPI_ENABLE; + fadt->acpi_disable = APM_CNT_ACPI_DISABLE; + fadt->s4bios_req = 0x0; + fadt->pstate_cnt = 0; + + fadt->pm1a_evt_blk = pmbase + PM1_STS; + fadt->pm1b_evt_blk = 0x0; + fadt->pm1a_cnt_blk = pmbase + PM1_CNT; + fadt->pm1b_cnt_blk = 0x0; + + fadt->gpe0_blk = pmbase + GPE0_STS; + + fadt->pm1_evt_len = 4; + fadt->pm1_cnt_len = 2; + + /* GPE0 STS/EN pairs each 32 bits wide. */ + fadt->gpe0_blk_len = 2 * GPE0_REG_MAX * sizeof(uint32_t); + + fadt->flush_size = 0x400; /* twice of cache size */ + fadt->flush_stride = 0x10; /* Cache line width */ + fadt->duty_offset = 1; + fadt->day_alrm = 0xd; + + fadt->flags = ACPI_FADT_WBINVD | ACPI_FADT_C1_SUPPORTED | + ACPI_FADT_C2_MP_SUPPORTED | ACPI_FADT_SLEEP_BUTTON | + ACPI_FADT_RESET_REGISTER | ACPI_FADT_SEALED_CASE | + ACPI_FADT_S4_RTC_WAKE | ACPI_FADT_PLATFORM_CLOCK; + + fadt->reset_reg.space_id = 1; + fadt->reset_reg.bit_width = 8; + fadt->reset_reg.addrl = IO_PORT_RESET; + fadt->reset_value = RST_CPU | SYS_RST; + + fadt->x_pm1a_evt_blk.space_id = 1; + fadt->x_pm1a_evt_blk.bit_width = fadt->pm1_evt_len * 8; + fadt->x_pm1a_evt_blk.addrl = pmbase + PM1_STS; + + fadt->x_pm1b_evt_blk.space_id = 1; + + fadt->x_pm1a_cnt_blk.space_id = 1; + fadt->x_pm1a_cnt_blk.bit_width = fadt->pm1_cnt_len * 8; + fadt->x_pm1a_cnt_blk.addrl = pmbase + PM1_CNT; + + fadt->x_pm1b_cnt_blk.space_id = 1; + + fadt->x_gpe1_blk.space_id = 1; +} + +int intel_southbridge_write_acpi_tables(const struct udevice *dev, + struct acpi_ctx *ctx) +{ + int ret; + + ret = acpi_write_dbg2_pci_uart(ctx, gd->cur_serial_dev, + ACPI_ACCESS_SIZE_DWORD_ACCESS); + if (ret) + return log_msg_ret("dbg2", ret); + + ret = acpi_write_hpet(ctx, dev); + if (ret) + return log_msg_ret("hpet", ret); + + return 0; +} + +__weak u32 acpi_fill_soc_wake(u32 generic_pm1_en, + const struct chipset_power_state *ps) +{ + return generic_pm1_en; +} + +__weak int acpi_create_gnvs(struct acpi_global_nvs *gnvs) +{ + return 0; +} + +int southbridge_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + struct acpi_global_nvs *gnvs; + int ret; + + ret = bloblist_ensure_size(BLOBLISTT_ACPI_GNVS, sizeof(*gnvs), + (void **)&gnvs); + if (ret) + return log_msg_ret("bloblist", ret); + memset(gnvs, '\0', sizeof(*gnvs)); + + ret = acpi_create_gnvs(gnvs); + if (ret) + return log_msg_ret("gnvs", ret); + + /* + * TODO(sjg@chromum.org): tell SMI about it + * smm_setup_structures(gnvs, NULL, NULL); + */ + + /* Add it to DSDT */ + acpigen_write_scope(ctx, "\\"); + acpigen_write_name_dword(ctx, "NVSA", (uintptr_t)gnvs); + acpigen_pop_len(ctx); + + return 0; +} + +static int calculate_power(int tdp, int p1_ratio, int ratio) +{ + u32 m; + u32 power; + + /* + * M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2 + * + * Power = (ratio / p1_ratio) * m * tdp + */ + + m = (110000 - ((p1_ratio - ratio) * 625)) / 11; + m = (m * m) / 1000; + + power = ((ratio * 100000 / p1_ratio) / 100); + power *= (m / 100) * (tdp / 1000); + power /= 1000; + + return power; +} + +static int get_cores_per_package(void) +{ + struct cpuid_result result; + int cores = 1; + + if (gd->arch.x86_vendor != X86_VENDOR_INTEL) + return 1; + + result = cpuid_ext(0xb, 1); + cores = result.ebx & 0xff; + + return cores; +} + +static void generate_c_state_entries(struct acpi_ctx *ctx) +{ + struct acpi_cstate *c_state_map; + size_t entries; + + c_state_map = arch_get_cstate_map(&entries); + + /* Generate C-state tables */ + acpigen_write_cst_package(ctx, c_state_map, entries); +} + +void generate_p_state_entries(struct acpi_ctx *ctx, int core, + int cores_per_package) +{ + int ratio_min, ratio_max, ratio_turbo, ratio_step; + int coord_type, power_max, num_entries; + int ratio, power, clock, clock_max; + bool turbo; + + coord_type = cpu_get_coord_type(); + ratio_min = cpu_get_min_ratio(); + ratio_max = cpu_get_max_ratio(); + clock_max = (ratio_max * cpu_get_bus_clock()) / 1000; + turbo = (turbo_get_state() == TURBO_ENABLED); + + /* Calculate CPU TDP in mW */ + power_max = cpu_get_power_max(); + + /* Write _PCT indicating use of FFixedHW */ + acpigen_write_empty_pct(ctx); + + /* Write _PPC with no limit on supported P-state */ + acpigen_write_ppc_nvs(ctx); + /* Write PSD indicating configured coordination type */ + acpigen_write_psd_package(ctx, core, 1, coord_type); + + /* Add P-state entries in _PSS table */ + acpigen_write_name(ctx, "_PSS"); + + /* Determine ratio points */ + ratio_step = PSS_RATIO_STEP; + do { + num_entries = ((ratio_max - ratio_min) / ratio_step) + 1; + if (((ratio_max - ratio_min) % ratio_step) > 0) + num_entries += 1; + if (turbo) + num_entries += 1; + if (num_entries > PSS_MAX_ENTRIES) + ratio_step += 1; + } while (num_entries > PSS_MAX_ENTRIES); + + /* _PSS package count depends on Turbo */ + acpigen_write_package(ctx, num_entries); + + /* P[T] is Turbo state if enabled */ + if (turbo) { + ratio_turbo = cpu_get_max_turbo_ratio(); + + /* Add entry for Turbo ratio */ + acpigen_write_pss_package(ctx, clock_max + 1, /* MHz */ + power_max, /* mW */ + PSS_LATENCY_TRANSITION,/* lat1 */ + PSS_LATENCY_BUSMASTER,/* lat2 */ + ratio_turbo << 8, /* control */ + ratio_turbo << 8); /* status */ + num_entries -= 1; + } + + /* First regular entry is max non-turbo ratio */ + acpigen_write_pss_package(ctx, clock_max, /* MHz */ + power_max, /* mW */ + PSS_LATENCY_TRANSITION,/* lat1 */ + PSS_LATENCY_BUSMASTER,/* lat2 */ + ratio_max << 8, /* control */ + ratio_max << 8); /* status */ + num_entries -= 1; + + /* Generate the remaining entries */ + for (ratio = ratio_min + ((num_entries - 1) * ratio_step); + ratio >= ratio_min; ratio -= ratio_step) { + /* Calculate power at this ratio */ + power = calculate_power(power_max, ratio_max, ratio); + clock = (ratio * cpu_get_bus_clock()) / 1000; + + acpigen_write_pss_package(ctx, clock, /* MHz */ + power, /* mW */ + PSS_LATENCY_TRANSITION,/* lat1 */ + PSS_LATENCY_BUSMASTER,/* lat2 */ + ratio << 8, /* control */ + ratio << 8); /* status */ + } + /* Fix package length */ + acpigen_pop_len(ctx); +} + +__weak struct acpi_tstate *soc_get_tss_table(int *entries) +{ + *entries = 0; + + return NULL; +} + +void generate_t_state_entries(struct acpi_ctx *ctx, int core, + int cores_per_package) +{ + struct acpi_tstate *soc_tss_table; + int entries; + + soc_tss_table = soc_get_tss_table(&entries); + if (entries == 0) + return; + + /* Indicate SW_ALL coordination for T-states */ + acpigen_write_tsd_package(ctx, core, cores_per_package, SW_ALL); + + /* Indicate FixedHW so OS will use MSR */ + acpigen_write_empty_ptc(ctx); + + /* Set NVS controlled T-state limit */ + acpigen_write_tpc(ctx, "\\TLVL"); + + /* Write TSS table for MSR access */ + acpigen_write_tss_package(ctx, entries, soc_tss_table); +} + +__weak void soc_power_states_generation(struct acpi_ctx *ctx, + int core_id, int cores_per_package) +{ +} + +int generate_cpu_entries(struct acpi_ctx *ctx, const struct udevice *dev) +{ + int core_id, cpu_id, pcontrol_blk = ACPI_BASE_ADDRESS; + int plen = 6; + int totalcores; + int cores_per_package; + int numcpus; + int ret; + + ret = cpu_get_count(dev); + if (ret < 0) + return log_msg_ret("count", ret); + totalcores = ret; + cores_per_package = get_cores_per_package(); + numcpus = totalcores / cores_per_package; + log_debug("Found %d CPU(s) with %d core(s) each.\n", numcpus, + cores_per_package); + + for (cpu_id = 0; cpu_id < numcpus; cpu_id++) { + for (core_id = 0; core_id < cores_per_package; core_id++) { + if (core_id > 0) { + pcontrol_blk = 0; + plen = 0; + } + + /* Generate processor \_PR.CPUx */ + acpigen_write_processor(ctx, + cpu_id * cores_per_package + + core_id, pcontrol_blk, plen); + + /* Generate C-state tables */ + generate_c_state_entries(ctx); + + /* Soc specific power states generation */ + soc_power_states_generation(ctx, core_id, + cores_per_package); + + acpigen_pop_len(ctx); + } + } + /* + * PPKG is usually used for thermal management of the first and only + * package + */ + acpigen_write_processor_package(ctx, "PPKG", 0, cores_per_package); + + /* Add a method to notify processor nodes */ + acpigen_write_processor_cnot(ctx, cores_per_package); + + return 0; +} diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 7b5217893f..1f2076753c 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -46,4 +46,9 @@ ulong write_acpi_tables(ulong start); */ ulong acpi_get_rsdp_addr(void); +int arch_read_sci_irq_select(void); +int arch_write_sci_irq_select(uint scis); +int arch_madt_sci_irq_polarity(int sci); +struct acpi_cstate *arch_get_cstate_map(size_t *entries); + #endif /* __ASM_ACPI_TABLE_H__ */ diff --git a/arch/x86/include/asm/cpu_common.h b/arch/x86/include/asm/cpu_common.h index c3f699ffd3..c50f4a3e40 100644 --- a/arch/x86/include/asm/cpu_common.h +++ b/arch/x86/include/asm/cpu_common.h @@ -14,6 +14,7 @@ enum { }; struct cpu_info; +struct acpi_ctx; /** * cpu_common_init() - Set up common CPU init diff --git a/arch/x86/include/asm/intel_acpi.h b/arch/x86/include/asm/intel_acpi.h new file mode 100644 index 0000000000..627f8b174a --- /dev/null +++ b/arch/x86/include/asm/intel_acpi.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018, Bin Meng + */ + +#ifndef __ASM_INTEL_ACPI_H__ +#define __ASM_INTEL_ACPI_H__ + +struct acpi_ctx; +struct udevice; + +int generate_cpu_entries(struct acpi_ctx *ctx, const struct udevice *device); +void soc_power_states_generation(struct acpi_ctx *ctx, + int core_id, int cores_per_package); + +void generate_p_state_entries(struct acpi_ctx *ctx, int core, + int cores_per_package); +void generate_t_state_entries(struct acpi_ctx *ctx, int core, + int cores_per_package); +int southbridge_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx); + +int intel_southbridge_write_acpi_tables(const struct udevice *dev, + struct acpi_ctx *ctx); + +#endif /* __ASM_INTEL_ACPI_H__ */ diff --git a/include/bloblist.h b/include/bloblist.h index 94b05c5a6f..7c5b93be4c 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -28,6 +28,11 @@ enum bloblist_tag_t { BLOBLISTT_VBOOT_CTX, /* Chromium OS verified boot context */ BLOBLISTT_VBOOT_HANDOFF, /* Chromium OS internal handoff info */ BLOBLISTT_INTEL_VBT, /* Intel Video-BIOS table */ + /* + * Advanced Configuration and Power Interface Global Non-Volatile + * Sleeping table. This forms part of the ACPI tables passed to Linux. + */ + BLOBLISTT_ACPI_GNVS, }; /** From patchwork Mon Jan 27 05:06:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229584 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=T/7jttZx; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dT759p7z9sR1 for ; Mon, 27 Jan 2020 16:23:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8007F818C1; Mon, 27 Jan 2020 06:13:34 +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="T/7jttZx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E3AC8817B6; Mon, 27 Jan 2020 06:10:16 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 7C402817DC for ; Mon, 27 Jan 2020 06:09: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-xd42.google.com with SMTP id k24so8560101ioc.4 for ; Sun, 26 Jan 2020 21:09: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=WttAahVvuXgfRWdQh01h3ujT5bnAald+HWtvT5n3rAs=; b=T/7jttZxWoJ16MKw/XobmEVuRmAiMPWPfnkoSUqo11oj7zy+reKfa0NFIiaHf/t5ys 7BwT1lfqKJivh6nlefPiRvblMbD2PwsFgUaMtjXR4MpVq6ixn4ZU7GXnbpSeENiXzSpA bg7Do7fxDeRwNcWnt1GAhawnpxZ5H6knpcyFI= 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=WttAahVvuXgfRWdQh01h3ujT5bnAald+HWtvT5n3rAs=; b=Fl2UV7Em22Wp6ZeQUExvHzb0woaHiNXphHU7MZ7B9zBtvdu8ImD+X5ha0pB9ziwVRL q17aMb/KprlxGLRIdrJOLh63KGno2FvCTouoYo0C3xOBUs82CnnJG2ubHakmeDL3y8mD x649x62AJVCNzyclAfuGEN1s3fTv9g8IulcMhhrCz8duqQVDMe8lse5DU6Jixi/4Qu2y ffXyw8OGQabrxzAAhEBOG0W/eArYSPFQg68QxZ4lJNki98osJoxqCHrspfwMdOZFfWvP LJ9SB5pL2lhw9mLE5blLCKoMKCizeui4mORTRzzztvcKR51x/FWuGnmBDn+D3WGDZyuk ZarA== X-Gm-Message-State: APjAAAXYgW0uLyAfylylKwH5ESco73d2x1bgmeKd4c+y074q/AO+/T7x yzwXo1HwYMjrWFPKQ2Fm+j7e7HFg9rqnWA== X-Google-Smtp-Source: APXvYqwWSLveqSIkHCg9UpkmQaLr8UhUvK+742wG90euH4AJPUMooAeNeJIjNBsTkGDqvBXatyPLoA== X-Received: by 2002:a02:c787:: with SMTP id n7mr11994645jao.85.1580101773227; Sun, 26 Jan 2020 21:09: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 h23sm4313195ilf.57.2020.01.26.21.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:32 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 086/108] x86: Support Atom SoCs using SWSMISCI rather than the SWSCI Date: Sun, 26 Jan 2020 22:06:33 -0700 Message-Id: <20200126220508.86.I50851bb823bec6a8e470befd7d68f5a6ca7b7b4e@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 Some Atom SoCs use SWSMISCI for SMI control. Add a Kconfig to select this. It is used on Apollo Lake. Signed-off-by: Simon Glass --- arch/x86/Kconfig | 6 ++++++ arch/x86/cpu/apollolake/Kconfig | 1 + 2 files changed, 7 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 61b6b48b81..930efc66cf 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -984,4 +984,10 @@ config INTEL_GENERIC_WIFI network functionality. It is only here to generate the ACPI tables required by Linux. +config INTEL_GMA_SWSMISCI + bool + help + Select this option for Atom-based platforms which use the SWSMISCI + register (0xe0) rather than the SWSCI register (0xe8). + endmenu diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig index 6c62da04f0..e8a9a75112 100644 --- a/arch/x86/cpu/apollolake/Kconfig +++ b/arch/x86/cpu/apollolake/Kconfig @@ -16,6 +16,7 @@ config INTEL_APOLLOLAKE select PCIEX_LENGTH_256MB select PCH_SUPPORT select P2SB + select INTEL_GMA_SWSMISCI select ACPI_GNVS_EXTERNAL imply ENABLE_MRC_CACHE imply AHCI_PCI From patchwork Mon Jan 27 05:06:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229586 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=Wr9V1EZm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dTj4d5jz9sR1 for ; Mon, 27 Jan 2020 16:24:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D496F81915; Mon, 27 Jan 2020 06:13:38 +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="Wr9V1EZm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CB08B81764; Mon, 27 Jan 2020 06:10:19 +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 3007C817BF for ; Mon, 27 Jan 2020 06:09:35 +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 g12so6460831ild.2 for ; Sun, 26 Jan 2020 21:09:35 -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=bJaPQCwOKX3e657cVwsAmcVVe0lXJnuAcVj7bnEdCfE=; b=Wr9V1EZmssvd9boClxka0EPEUH/HaF72mOXVwq8M0NECKbL6vjfQMkAs4xBMPpZ27h c5+4mMgHb2KbZ5Zn2WgK/qMdcapXlXskP2/JzZjQuKTKiiYmN2qN8+HP5X/s2yIqXC8P ZUbmrF9w/uLgM+bgchvEJqKOzQ4poHtZRjlvk= 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=bJaPQCwOKX3e657cVwsAmcVVe0lXJnuAcVj7bnEdCfE=; b=W94Gr+eKtfJ8gy2uTCmLR1GmzRINdgEI9gUAyguLWXyiGB+1Uv/weSmm6feWa8l2BJ tCdOeDTdIh67ZjUry5+wliCvZeEAb2toyEiWxakRhkgp9Bw+ojj+WZJhoGfevNTHP6N+ g+enK8n5gsOs8CcGXnKUUAW4/sxPPFkXjWsTEnnR9vzMvTruoF/HQoXi3WXkG9VgcLMj DOXSrhEzGbFpf6oZaZ9dqpnaHQ28hk0WRwm6xf+YY8rbOgSlmg37m0cPIdd+DDRke3l/ NPnr0/zi6rUCOP+wavFBaTN4evkydjNjDYHPgXdy9sKOyfw0dOtlZE1UrAmnQs2xMQL2 BYrw== X-Gm-Message-State: APjAAAW9rFXejUYqgC7JgNtJwVSp77kC48vTojsETlGcdDdAuAJ8mrky VzEqdUJVaFMxLqgzVfxvOnfm+WLDwOt8sg== X-Google-Smtp-Source: APXvYqw0+cwKXaQx7O65whCEuJysawyunm4zNSpJnQiFofU6H3wsP7wDb5nG7lDduyUfVJJ1jrasRg== X-Received: by 2002:a92:3991:: with SMTP id h17mr14018534ilf.131.1580101773995; Sun, 26 Jan 2020 21:09: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 h23sm4313195ilf.57.2020.01.26.21.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:33 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 087/108] x86: apl: Add a check for reading the FSP-S config Date: Sun, 26 Jan 2020 22:06:34 -0700 Message-Id: <20200126220508.87.Ia817c48e5544c95f117f45b37a2581f54d67392b@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 This currently fails as two required items are commented out. Put them back in and add a check that reading the config succeeds. Both of these items need a little more work to put them in an appropriate driver at some point. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/fsp_s.c | 6 ++++-- arch/x86/dts/chromebook_coral.dts | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c index e7e0c30873..d1aad7a094 100644 --- a/arch/x86/cpu/apollolake/fsp_s.c +++ b/arch/x86/cpu/apollolake/fsp_s.c @@ -350,8 +350,10 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset, apl = malloc(sizeof(*apl)); if (!apl) - return log_msg_ret("config", -ENOMEM); - get_config(dev, apl); + return log_msg_ret("alloc", -ENOMEM); + ret = get_config(dev, apl); + if (ret) + return log_msg_ret("config", ret); cfg->ish_enable = 0; cfg->enable_sata = 0; diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index 7ba38d7791..3c6f14310f 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -497,13 +497,13 @@ * If the Board has PERST_0 signal, assign the GPIO * If the Board does not have PERST_0, assign GPIO_PRT0_UDEF * - * This are not used yet, so comment them out for now. - * - * prt0-gpio = ; - * - * GPIO for SD card detect - * sdcard-cd-gpio = ; + * This should be converted to real GPIOs and ideally stored in the + * device they relate to. */ + prt0-gpio = ; + + /* GPIO for SD card detect */ + sdcard-cd-gpio = ; /* * Order is emmc-tx-data-cntl1, emmc-tx-data-cntl2, From patchwork Mon Jan 27 05:06:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229589 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=GekSPpd9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dVV6DbSz9sR1 for ; Mon, 27 Jan 2020 16:25:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24A7381924; Mon, 27 Jan 2020 06:13:46 +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="GekSPpd9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2368D817D4; 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-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) (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 64DDE817A5 for ; Mon, 27 Jan 2020 06:09:36 +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-xd2d.google.com with SMTP id t26so8542588ioi.13 for ; Sun, 26 Jan 2020 21:09:36 -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=W30PCLhiDkVKLHWif77ZUU6lMMFzw72ZDRken9Nbvgg=; b=GekSPpd9Ly7sCXKAs1B+br+YwmcuROI38/gM064hdBDsUjlQEOpnS0ydCT1pI6bGTQ Bj8BPvefNbQ7KTNGW3+RExID1ameQVJf+z6lwWa6wEaxj1anlfNpAbJDjxBIDC6kQfMt Sk4mZYUGcNIyODkz39Os5bXg/J1iLgNFoqQv8= 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=W30PCLhiDkVKLHWif77ZUU6lMMFzw72ZDRken9Nbvgg=; b=XXeeBI9DX3U3+TwOYF3/xb9Z6qLdDb1RQfibBGO4VH/3pHvWWvSUxb0FClFlWvnFvo LWRnzi1Os8ZnGRKyFKbG7wtPOPv4MELex7oSvbRIGS1IoLV14kmYtpJmi4WqPthdPhnj nqEjdKbYP4mriDXBcI/mRksCBrTwrGv9sWXDpUMnRtEOkTZ1IBmbTxEGbQQ+ocamorV9 86tnv6cl9/AIVdxVBGEIRvqvQWy2JULOVcm772XwE7ECyjt5bo6+LU+Psp+Z79CqrMKE ptmBhPzLSCW5pIyAhj4D08LlWMnDQsVQ1Rzd9NGmkR7NpPOWJ/t3uRCJoeZ02/Fbtb5i Yw/g== X-Gm-Message-State: APjAAAWAWHJ1ZUARaRdZ4z1nLaoaik3PckTpfT277sZ7zqumORvGS/eO jwvzVrtuuyUF1H6TWksYzNn9Me6xhE3bTg== X-Google-Smtp-Source: APXvYqwykd4lW5Eafn2uOBZ65CX+mW2kUVZxAYRmv8WUa/5gaNnndRCoZUfpBsWkt0dtnLNv/z4ZCA== X-Received: by 2002:a6b:c304:: with SMTP id t4mr47013iof.100.1580101774690; Sun, 26 Jan 2020 21:09:34 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:34 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 088/108] x86: apl: Store FSP-S config for later use Date: Sun, 26 Jan 2020 22:06:35 -0700 Message-Id: <20200126220508.88.I840429dc681a138d39647032b9356bfd7c77fbb4@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 Some ACPI tables need to include information from the FSP-S config. Rather than reading it again later, store a pointer to it for use by the ACPI code. The FSP-S config is read just after relocation, so can be used during this phase of U-Boot. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/fsp_s.c | 213 +---------------- .../include/asm/arch-apollolake/soc_config.h | 221 ++++++++++++++++++ arch/x86/include/asm/global_data.h | 1 + 3 files changed, 224 insertions(+), 211 deletions(-) create mode 100644 arch/x86/include/asm/arch-apollolake/soc_config.h diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c index d1aad7a094..939d59a398 100644 --- a/arch/x86/cpu/apollolake/fsp_s.c +++ b/arch/x86/cpu/apollolake/fsp_s.c @@ -17,222 +17,12 @@ #include #include #include +#include #include #include #include #include -#define INTEL_GSPI_MAX 3 -#define MAX_USB2_PORTS 8 - -enum { - CHIPSET_LOCKDOWN_FSP = 0, /* FSP handles locking per UPDs */ - CHIPSET_LOCKDOWN_COREBOOT, /* coreboot handles locking */ -}; - -/* Serial IRQ control. SERIRQ_QUIET is the default (0) */ -enum serirq_mode { - SERIRQ_QUIET, - SERIRQ_CONTINUOUS, - SERIRQ_OFF, -}; - -struct gspi_cfg { - /* Bus speed in MHz */ - u32 speed_mhz; - /* Bus should be enabled prior to ramstage with temporary base */ - u8 early_init; -}; - -/* - * This structure will hold data required by common blocks. - * These are soc specific configurations which will be filled by soc. - * We'll fill this structure once during init and use the data in common block. - */ -struct soc_intel_common_config { - int chipset_lockdown; - struct gspi_cfg gspi[INTEL_GSPI_MAX]; -}; - -enum pnp_settings { - PNP_PERF, - PNP_POWER, - PNP_PERF_POWER, -}; - -struct usb2_eye_per_port { - u8 per_port_tx_pe_half; - u8 per_port_pe_txi_set; - u8 per_port_txi_set; - u8 hs_skew_sel; - u8 usb_tx_emphasis_en; - u8 per_port_rxi_set; - u8 hs_npre_drv_sel; - u8 override_en; -}; - -struct apl_config { - /* Common structure containing soc config data required by common code*/ - struct soc_intel_common_config common_soc_config; - - /* - * Mapping from PCIe root port to CLKREQ input on the SOC. The SOC has - * four CLKREQ inputs, but six root ports. Root ports without an - * associated CLKREQ signal must be marked with "CLKREQ_DISABLED" - */ - u8 pcie_rp_clkreq_pin[MAX_PCIE_PORTS]; - - /* Enable/disable hot-plug for root ports (0 = disable, 1 = enable) */ - u8 pcie_rp_hotplug_enable[MAX_PCIE_PORTS]; - - /* De-emphasis enable configuration for each PCIe root port */ - u8 pcie_rp_deemphasis_enable[MAX_PCIE_PORTS]; - - /* - * [14:8] DDR mode Number of dealy elements.Each = 125pSec. - * [6:0] SDR mode Number of dealy elements.Each = 125pSec. - */ - u32 emmc_tx_cmd_cntl; - - /* - * [14:8] HS400 mode Number of dealy elements.Each = 125pSec. - * [6:0] SDR104/HS200 mode Number of dealy elements.Each = 125pSec. - */ - u32 emmc_tx_data_cntl1; - - /* - * [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. - * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. - * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. - * [6:0] SDR12/Compatibility mode Number of dealy elements. - * Each = 125pSec. - */ - u32 emmc_tx_data_cntl2; - - /* - * [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. - * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. - * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. - * [6:0] SDR12/Compatibility mode Number of dealy elements. - * Each = 125pSec. - */ - u32 emmc_rx_cmd_data_cntl1; - - /* - * [14:8] HS400 mode 1 Number of dealy elements.Each = 125pSec. - * [6:0] HS400 mode 2 Number of dealy elements.Each = 125pSec. - */ - u32 emmc_rx_strobe_cntl; - - /* - * [13:8] Auto Tuning mode Number of dealy elements.Each = 125pSec. - * [6:0] SDR104/HS200 Number of dealy elements.Each = 125pSec. - */ - u32 emmc_rx_cmd_data_cntl2; - - /* Select the eMMC max speed allowed */ - u32 emmc_host_max_speed; - - /* Specifies on which IRQ the SCI will internally appear */ - u32 sci_irq; - - /* Configure serial IRQ (SERIRQ) line */ - enum serirq_mode serirq_mode; - - /* Configure LPSS S0ix Enable */ - bool lpss_s0ix_enable; - - /* Enable DPTF support */ - bool dptf_enable; - - /* TCC activation offset value in degrees Celsius */ - int tcc_offset; - - /* - * Configure Audio clk gate and power gate - * IOSF-SB port ID 92 offset 0x530 [5] and [3] - */ - bool hdaudio_clk_gate_enable; - bool hdaudio_pwr_gate_enable; - bool hdaudio_bios_config_lockdown; - - /* SLP S3 minimum assertion width */ - int slp_s3_assertion_width_usecs; - - /* GPIO pin for PERST_0 */ - u32 prt0_gpio; - - /* USB2 eye diagram settings per port */ - struct usb2_eye_per_port usb2eye[MAX_USB2_PORTS]; - - /* GPIO SD card detect pin */ - unsigned int sdcard_cd_gpio; - - /* - * PRMRR size setting with three options - * 0x02000000 - 32MiB - * 0x04000000 - 64MiB - * 0x08000000 - 128MiB - */ - u32 PrmrrSize; - - /* - * Enable SGX feature. - * Enabling SGX feature is 2 step process, - * (1) set sgx_enable = 1 - * (2) set PrmrrSize to supported size - */ - bool sgx_enable; - - /* - * Select PNP Settings. - * (0) Performance, - * (1) Power - * (2) Power & Performance - */ - enum pnp_settings pnp_settings; - - /* - * PMIC PCH_PWROK delay configuration - IPC Configuration - * Upd for changing PCH_PWROK delay configuration : I2C_Slave_Address - * (31:24) + Register_Offset (23:16) + OR Value (15:8) + AND Value (7:0) - */ - u32 pmic_pmc_ipc_ctrl; - - /* - * Options to disable XHCI Link Compliance Mode. Default is FALSE to not - * disable Compliance Mode. Set TRUE to disable Compliance Mode. - * 0:FALSE(Default), 1:True. - */ - bool disable_compliance_mode; - - /* - * Options to change USB3 ModPhy setting for the Integrated Filter (IF) - * value. Default is 0 to not changing default IF value (0x12). Set - * value with the range from 0x01 to 0xff to change IF value. - */ - u32 mod_phy_if_value; - - /* - * Options to bump USB3 LDO voltage. Default is FALSE to not increasing - * LDO voltage. Set TRUE to increase LDO voltage with 40mV. - * 0:FALSE (default), 1:True. - */ - bool mod_phy_voltage_bump; - - /* - * Options to adjust PMIC Vdd2 voltage. Default is 0 to not adjusting - * the PMIC Vdd2 default voltage 1.20v. Upd for changing Vdd2 Voltage - * configuration: I2C_Slave_Address (31:23) + Register_Offset (23:16) - * + OR Value (15:8) + AND Value (7:0) through BUCK5_VID[3:2]: - * 00=1.10v, 01=1.15v, 10=1.24v, 11=1.20v (default). - */ - u32 pmic_vdd2_voltage; - - /* Option to enable VTD feature */ - bool enable_vtd; -}; - static int get_config(struct udevice *dev, struct apl_config *apl) { const u8 *ptr; @@ -354,6 +144,7 @@ int fsps_update_config(struct udevice *dev, ulong rom_offset, ret = get_config(dev, apl); if (ret) return log_msg_ret("config", ret); + gd->arch.soc_config = apl; cfg->ish_enable = 0; cfg->enable_sata = 0; diff --git a/arch/x86/include/asm/arch-apollolake/soc_config.h b/arch/x86/include/asm/arch-apollolake/soc_config.h new file mode 100644 index 0000000000..663c524801 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/soc_config.h @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef _ASM_ARCH_SOC_CONFIG_H +#define _ASM_ARCH_SOC_CONFIG_H + +#include + +#define INTEL_GSPI_MAX 3 +#define INTEL_I2C_DEV_MAX 8 +#define MAX_USB2_PORTS 8 +#define MAX_PCIE_PORTS 6 + +enum { + CHIPSET_LOCKDOWN_FSP = 0, /* FSP handles locking per UPDs */ + CHIPSET_LOCKDOWN_COREBOOT, /* coreboot handles locking */ +}; + +/* Serial IRQ control. SERIRQ_QUIET is the default (0) */ +enum serirq_mode { + SERIRQ_QUIET, + SERIRQ_CONTINUOUS, + SERIRQ_OFF, +}; + +struct gspi_cfg { + /* Bus speed in MHz */ + u32 speed_mhz; + /* Bus should be enabled prior to ramstage with temporary base */ + u8 early_init; +}; + +/* + * This structure will hold data required by common blocks. + * These are soc specific configurations which will be filled by soc. + * We'll fill this structure once during init and use the data in common block. + */ +struct soc_intel_common_config { + int chipset_lockdown; + struct gspi_cfg gspi[INTEL_GSPI_MAX]; +}; + +enum pnp_settings { + PNP_PERF, + PNP_POWER, + PNP_PERF_POWER, +}; + +struct usb2_eye_per_port { + u8 per_port_tx_pe_half; + u8 per_port_pe_txi_set; + u8 per_port_txi_set; + u8 hs_skew_sel; + u8 usb_tx_emphasis_en; + u8 per_port_rxi_set; + u8 hs_npre_drv_sel; + u8 override_en; +}; + +struct apl_config { + /* Common structure containing soc config data required by common code*/ + struct soc_intel_common_config common_soc_config; + + /* + * Mapping from PCIe root port to CLKREQ input on the SOC. The SOC has + * four CLKREQ inputs, but six root ports. Root ports without an + * associated CLKREQ signal must be marked with "CLKREQ_DISABLED" + */ + u8 pcie_rp_clkreq_pin[MAX_PCIE_PORTS]; + + /* Enable/disable hot-plug for root ports (0 = disable, 1 = enable) */ + u8 pcie_rp_hotplug_enable[MAX_PCIE_PORTS]; + + /* De-emphasis enable configuration for each PCIe root port */ + u8 pcie_rp_deemphasis_enable[MAX_PCIE_PORTS]; + + /* [14:8] DDR mode Number of dealy elements.Each = 125pSec. + * [6:0] SDR mode Number of dealy elements.Each = 125pSec. + */ + u32 emmc_tx_cmd_cntl; + + /* [14:8] HS400 mode Number of dealy elements.Each = 125pSec. + * [6:0] SDR104/HS200 mode Number of dealy elements.Each = 125pSec. + */ + u32 emmc_tx_data_cntl1; + + /* [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. + * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. + * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. + * [6:0] SDR12/Compatibility mode Number of dealy elements. + * Each = 125pSec. + */ + u32 emmc_tx_data_cntl2; + + /* [30:24] SDR50 mode Number of dealy elements.Each = 125pSec. + * [22:16] DDR50 mode Number of dealy elements.Each = 125pSec. + * [14:8] SDR25/HS50 mode Number of dealy elements.Each = 125pSec. + * [6:0] SDR12/Compatibility mode Number of dealy elements. + * Each = 125pSec. + */ + u32 emmc_rx_cmd_data_cntl1; + + /* [14:8] HS400 mode 1 Number of dealy elements.Each = 125pSec. + * [6:0] HS400 mode 2 Number of dealy elements.Each = 125pSec. + */ + u32 emmc_rx_strobe_cntl; + + /* [13:8] Auto Tuning mode Number of dealy elements.Each = 125pSec. + * [6:0] SDR104/HS200 Number of dealy elements.Each = 125pSec. + */ + u32 emmc_rx_cmd_data_cntl2; + + /* Select the eMMC max speed allowed */ + u32 emmc_host_max_speed; + + /* Specifies on which IRQ the SCI will internally appear */ + u32 sci_irq; + + /* Configure serial IRQ (SERIRQ) line */ + enum serirq_mode serirq_mode; + + /* Configure LPSS S0ix Enable */ + bool lpss_s0ix_enable; + + /* Enable DPTF support */ + bool dptf_enable; + + /* TCC activation offset value in degrees Celsius */ + int tcc_offset; + + /* Configure Audio clk gate and power gate + * IOSF-SB port ID 92 offset 0x530 [5] and [3] + */ + bool hdaudio_clk_gate_enable; + bool hdaudio_pwr_gate_enable; + bool hdaudio_bios_config_lockdown; + + /* SLP S3 minimum assertion width */ + int slp_s3_assertion_width_usecs; + + /* GPIO pin for PERST_0 */ + u32 prt0_gpio; + + /* USB2 eye diagram settings per port */ + struct usb2_eye_per_port usb2eye[MAX_USB2_PORTS]; + + /* GPIO SD card detect pin */ + unsigned int sdcard_cd_gpio; + + /* + * PRMRR size setting with three options + * 0x02000000 - 32MiB + * 0x04000000 - 64MiB + * 0x08000000 - 128MiB + */ + u32 PrmrrSize; + + /* + * Enable SGX feature. + * Enabling SGX feature is 2 step process, + * (1) set sgx_enable = 1 + * (2) set PrmrrSize to supported size + */ + bool sgx_enable; + + /* + * Select PNP Settings. + * (0) Performance, + * (1) Power + * (2) Power & Performance + */ + enum pnp_settings pnp_settings; + + /* + * PMIC PCH_PWROK delay configuration - IPC Configuration + * Upd for changing PCH_PWROK delay configuration : I2C_Slave_Address + * (31:24) + Register_Offset (23:16) + OR Value (15:8) + AND Value (7:0) + */ + u32 PmicPmcIpcCtrl; + + /* + * Options to disable XHCI Link Compliance Mode. Default is FALSE to not + * disable Compliance Mode. Set TRUE to disable Compliance Mode. + * 0:FALSE(Default), 1:True. + */ + bool DisableComplianceMode; + + /* + * Options to change USB3 ModPhy setting for the Integrated Filter (IF) + * value. Default is 0 to not changing default IF value (0x12). Set + * value with the range from 0x01 to 0xff to change IF value. + */ + u32 ModPhyIfValue; + + /* + * Options to bump USB3 LDO voltage. Default is FALSE to not increasing + * LDO voltage. Set TRUE to increase LDO voltage with 40mV. + * 0:FALSE (default), 1:True. + */ + bool ModPhyVoltageBump; + + /* + * Options to adjust PMIC Vdd2 voltage. Default is 0 to not adjusting + * the PMIC Vdd2 default voltage 1.20v. Upd for changing Vdd2 Voltage + * configuration: I2C_Slave_Address (31:23) + Register_Offset (23:16) + * + OR Value (15:8) + AND Value (7:0) through BUCK5_VID[3:2]: + * 00=1.10v, 01=1.15v, 10=1.24v, 11=1.20v (default). + */ + u32 PmicVdd2Voltage; + + /* + * Option to enable VTD feature. Default is 0 which disables VTD + * capability in FSP. Setting this option to 1 in devicetree will enable + * the Upd parameter VtdEnable. + */ + bool enable_vtd; +}; + +#endif diff --git a/arch/x86/include/asm/global_data.h b/arch/x86/include/asm/global_data.h index 4aee2f3e8c..1a2c7746ed 100644 --- a/arch/x86/include/asm/global_data.h +++ b/arch/x86/include/asm/global_data.h @@ -122,6 +122,7 @@ struct arch_global_data { #endif #ifdef CONFIG_FSP_VERSION2 struct fsp_header *fsp_s_hdr; /* Pointer to FSP-S header */ + const void *soc_config; /* SOC-specific configuration */ #endif ulong acpi_start; /* Start address of ACPI tables */ }; From patchwork Mon Jan 27 05:06:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229587 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=EDmJ6zPK; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 485dV14GHCz9sR1 for ; Mon, 27 Jan 2020 16:24:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D21D8191A; Mon, 27 Jan 2020 06:13:41 +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="EDmJ6zPK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A56D8817B4; Mon, 27 Jan 2020 06:10:19 +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-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (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 958B0817F2 for ; Mon, 27 Jan 2020 06:09:36 +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-x141.google.com with SMTP id t17so6411091ilm.13 for ; Sun, 26 Jan 2020 21:09:36 -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=AM+Nim904mbOcJmsvQv4hmWvcPmCRYsO8OOkFGVrPyE=; b=EDmJ6zPK3WMMg7yY2KjEIdyZJWA449xLJ2G+TRnCL7VvNeHlJ7pLhi3YHSNBrkdvRA WmY5542uKRrWxuUBRQTon3Sn9w6JjDXBbdqOddAAEKq2+rNWwmez861brD1rfnR/nUEs gNkn2Jc5MUVjrskZQsWjv3l6QdIKbgdID7D00= 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=AM+Nim904mbOcJmsvQv4hmWvcPmCRYsO8OOkFGVrPyE=; b=GOIhOyDIkR1OCqhwgeCOz2vdTgOhEcr2U/YYFdOMxo6ng1nJEpYnTSZfSprPPZvrsy Mo7r+YoHHIR/GDBsQYR9W9vXTIWa+1fpFMelFFoo7vqeGgHp7o4LKVErukLw9ReoA4lF wk8u2VqQnfldBPqEd+g+2I3FKMQnFdIr8raVVlHQM1KEkWs5Nrf7Hc9cav3f3O7WaJ0x GdEpzlzQ2KWCjplVidVZkCRF3oH2ByD+TEpCb95mYRHsSHCxn/xdbheSkzD7ri0eBnTt qsytv302VQRRcVykUuStPdlnddfvvzLhWJfpiTa4k44OcEberqzrx7R3wpBlCc2vifz3 4S2g== X-Gm-Message-State: APjAAAV2v5xw5JXputhG/4YlvPONNnEVcgCJa2yd8FN+s8D7PHRp5F1I oPUuloNm5sylgVal9ueP1d9wmSWy5KzKAg== X-Google-Smtp-Source: APXvYqyxKxl8TAxnhiUVJfYNZbkCmXqJDc7RVN1kH+Q1Hy35/JB5PpYUcPXJP6/oP7NK7zVbbPx1bg== X-Received: by 2002:a92:4982:: with SMTP id k2mr4770018ilg.57.1580101775349; Sun, 26 Jan 2020 21:09:35 -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.34 (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 089/108] p2sb: Add some definitions used for ACPI Date: Sun, 26 Jan 2020 22:06:36 -0700 Message-Id: <20200126220508.89.I1bec907198d64e445613010c4455b6f800f6b0a8@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 Allow this header to be included in ASL files by adding a header guard and a few definitions that are needed. Signed-off-by: Simon Glass --- include/p2sb.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/p2sb.h b/include/p2sb.h index 93e1155dca..a25170e3d1 100644 --- a/include/p2sb.h +++ b/include/p2sb.h @@ -10,6 +10,12 @@ /* Port Id lives in bits 23:16 and register offset lives in 15:0 of address */ #define PCR_PORTID_SHIFT 16 +#if !defined(__ACPI__) + +/* These registers contain IOAPIC and HPET devfn */ +#define PCH_P2SB_IBDF 0x6c +#define PCH_P2SB_HBDF 0x70 + /** * struct p2sb_child_platdata - Information about each child of a p2sb device * @@ -164,4 +170,6 @@ int p2sb_get_port_id(struct udevice *dev); */ void *pcr_reg_address(struct udevice *dev, uint offset); +#endif /* !__ACPI__ */ + #endif 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 From patchwork Mon Jan 27 05:06:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229590 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=hZUnq+pT; 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 485dVm6nr1z9sR1 for ; Mon, 27 Jan 2020 16:25:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A3988192A; Mon, 27 Jan 2020 06:13:47 +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="hZUnq+pT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AADF5817D2; Mon, 27 Jan 2020 06:10:24 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 7EFB8816D8 for ; Mon, 27 Jan 2020 06:09:38 +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-x143.google.com with SMTP id f70so1425996ill.6 for ; Sun, 26 Jan 2020 21:09:38 -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=CJ5p98PBLs1D/c4ztHOLGydSYzEE2VHJSNhUAUNjvLw=; b=hZUnq+pTnP+DdHmZm7q8MiPdu10sg+B/leOhTHF0fonhD5J76Z+K4ClFyySZ0JoaTT 29KSNCYe1ZNKiELZcKqn2CukpTqzusAyOT+E/OOQi80Xdpse4ZQZfb5qaR7VbQ6ix8eh KBdhrnbOs/A1Eiong5RzQY9pwCeyMHL1GXesE= 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=CJ5p98PBLs1D/c4ztHOLGydSYzEE2VHJSNhUAUNjvLw=; b=HjWAze6CTU7p2U/E0A667y0H602e4mVJDf0kk4KtCU6LknTI+ljsNKaaWSeXEO/hdc surt31k+9fFEEFCpDyn7bDHdXO9x9euvEG8hT2Ji+6H+SmmMuixf0u48VXs5YVLSATCn xxCVxE1Pa47SfiJExCW7+qIipuj7CPkaQSBFdjqYiK2ymNx6Mirmn54/BbMz95EPKRnT t6MXbZ8+ugdFrZy78JM2X4lo9lZAyEGgEzqHV8LxbS68ezVaHvKeIYbn04xcPWhb8MLV W9NndYASbAnheROmmsA01f96vMQMU8uwTcD7oNzO9BHUWuAjRcT58nskSkvZMxoVkdVa VMlg== X-Gm-Message-State: APjAAAVdKzbLENUeEMooZ2FBvIxz3sC1GJIKNktJdKD7C71jhYcWwXWC jbxydXKhHWJuYMjGuJlKxMppx57MJKyayw== X-Google-Smtp-Source: APXvYqzIziSo6oWkcmPeAuJmOZUFLd6veWMs2bd/BNN3h/MgHcMXaLpMduvdJzppN7U1U+YvTQF+0Q== X-Received: by 2002:a92:d9ce:: with SMTP id n14mr13764940ilq.25.1580101776891; 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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:36 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 091/108] x86: apl: Generate required ACPI tables Date: Sun, 26 Jan 2020 22:06:38 -0700 Message-Id: <20200127050655.170614-2-sjg@chromium.org> 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 Add support for generating various ACPI tables for Apollo Lake. Add a few S3 definitions that are needed. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/Makefile | 1 + arch/x86/cpu/apollolake/acpi.c | 437 ++++++++++++++++++++ arch/x86/include/asm/arch-apollolake/acpi.h | 13 + include/acpi_s3.h | 4 + 4 files changed, 455 insertions(+) create mode 100644 arch/x86/cpu/apollolake/acpi.c create mode 100644 arch/x86/include/asm/arch-apollolake/acpi.h diff --git a/arch/x86/cpu/apollolake/Makefile b/arch/x86/cpu/apollolake/Makefile index 1760df54d8..14e254545f 100644 --- a/arch/x86/cpu/apollolake/Makefile +++ b/arch/x86/cpu/apollolake/Makefile @@ -15,6 +15,7 @@ obj-y += fsp_m.o endif endif ifndef CONFIG_SPL_BUILD +obj-y += acpi.o obj-y += fsp_s.o endif diff --git a/arch/x86/cpu/apollolake/acpi.c b/arch/x86/cpu/apollolake/acpi.c new file mode 100644 index 0000000000..dc8b5c6ad7 --- /dev/null +++ b/arch/x86/cpu/apollolake/acpi.c @@ -0,0 +1,437 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 Intel Corp. + * Copyright (C) 2017-2019 Siemens AG + * (Written by Lance Zhao for Intel Corp.) + * Copyright 2019 Google LLC + * + * Modified from coreboot apollolake/acpi.c + */ + +#define LOG_CATEGORY LOGC_ACPI + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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, + }, + }, +}; + +int arch_read_sci_irq_select(void) +{ + struct acpi_pmc_upriv *upriv; + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev); + if (ret) + return log_msg_ret("pmc", ret); + upriv = dev_get_uclass_priv(dev); + + return readl(upriv->pmc_bar0 + IRQ_REG); +} + +int arch_write_sci_irq_select(uint scis) +{ + struct acpi_pmc_upriv *upriv; + struct udevice *dev; + int ret; + + ret = uclass_first_device_err(UCLASS_ACPI_PMC, &dev); + if (ret) + return log_msg_ret("pmc", ret); + upriv = dev_get_uclass_priv(dev); + writel(scis, upriv->pmc_bar0 + IRQ_REG); + + return 0; +} + +struct acpi_cstate *arch_get_cstate_map(size_t *entries) +{ + *entries = ARRAY_SIZE(cstate_map); + return cstate_map; +} + +int acpi_create_gnvs(struct acpi_global_nvs *gnvs) +{ + const struct apl_config *cfg = gd->arch.soc_config; + struct udevice *cpu, *pinctrl; + uint offset; + int ret; + + if (!cfg) + return log_msg_ret("cfg", -EINVAL); + + /* Clear out GNV */ + memset(gnvs, '\0', sizeof(*gnvs)); + + /* TODO(sjg@chromium.org): Add the console log to gnvs->cbmc */ + +#ifdef CONFIG_CHROMEOS + /* Initialise Verified Boot data */ + chromeos_init_acpi(&gnvs->chromeos); + gnvs->chromeos.vbt2 = ACTIVE_ECFW_RO; +#endif + /* Set unknown wake source */ + gnvs->pm1i = ~0ULL; + + /* CPU core count */ + gnvs->pcnt = 1; + ret = uclass_find_first_device(UCLASS_CPU, &cpu); + if (cpu) { + ret = cpu_get_count(cpu); + if (ret > 0) + gnvs->pcnt = ret; + } + + /* Enable DPTF based on mainboard configuration */ + gnvs->dpte = cfg->dptf_enable; + + /* Assign address of PERST_0 if GPIO is defined in devicetree */ + if (cfg->prt0_gpio != GPIO_PRT0_UDEF) { + ret = intel_pinctrl_get_pad(cfg->prt0_gpio, &pinctrl, &offset); + if (ret) + return log_msg_ret("prt0", ret); + gnvs->prt0 = intel_pinctrl_get_config_reg_addr(pinctrl, offset); + } + + /* + * Get sdcard cd GPIO portid if GPIO is defined in devicetree. + * Get offset of sdcard cd pin. + */ + if (cfg->sdcard_cd_gpio) { + ret = intel_pinctrl_get_pad(cfg->sdcard_cd_gpio, &pinctrl, + &offset); + if (ret) + return log_msg_ret("prt0", ret); + gnvs->scdp = p2sb_get_port_id(pinctrl); + gnvs->scdo = intel_pinctrl_get_acpi_pin(pinctrl, offset); + } + + return 0; +} + +uint32_t acpi_fill_soc_wake(uint32_t generic_pm1_en) +{ + /* + * WAK_STS bit is set when the system is in one of the sleep states + * (via the SLP_EN bit) and an enabled wake event occurs. Upon setting + * this bit, the PMC will transition the system to the ON state and + * can only be set by hardware and can only be cleared by writing a one + * to this bit position. + */ + generic_pm1_en |= WAK_STS | RTC_EN | PWRBTN_EN; + + return generic_pm1_en; +} + +int arch_madt_sci_irq_polarity(int sci) +{ + return MP_IRQ_POLARITY_LOW; +} + +void fill_fadt(struct acpi_fadt *fadt) +{ + const struct apl_config *cfg = gd->arch.soc_config; + + assert(cfg); + fadt->pm_tmr_blk = IOMAP_ACPI_BASE + PM1_TMR; + + fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; + fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; + + fadt->pm_tmr_len = 4; + fadt->duty_width = 3; + + fadt->iapc_boot_arch = ACPI_FADT_LEGACY_DEVICES | ACPI_FADT_8042; + + fadt->x_pm_tmr_blk.space_id = 1; + fadt->x_pm_tmr_blk.bit_width = fadt->pm_tmr_len * 8; + fadt->x_pm_tmr_blk.addrl = IOMAP_ACPI_BASE + PM1_TMR; + + if (cfg->lpss_s0ix_enable) + fadt->flags |= ACPI_FADT_LOW_PWR_IDLE_S0; +} + +void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, + void *dsdt) +{ + const struct apl_config *cfg = gd->arch.soc_config; + struct acpi_table_header *header = &fadt->header; + + assert(cfg); + acpi_fadt_common(fadt, facs, dsdt); + intel_acpi_fill_fadt(fadt); + fill_fadt(fadt); + header->checksum = table_compute_checksum(fadt, header->length); +} + +int apl_acpi_fill_dmar(struct acpi_ctx *ctx) +{ + struct udevice *dev, *sa_dev; + u64 gfxvtbar = readq(MCHBAR_REG(GFXVTBAR)) & VTBAR_MASK; + u64 defvtbar = readq(MCHBAR_REG(DEFVTBAR)) & VTBAR_MASK; + bool gfxvten = readl(MCHBAR_REG(GFXVTBAR)) & VTBAR_ENABLED; + bool defvten = readl(MCHBAR_REG(DEFVTBAR)) & VTBAR_ENABLED; + void *tmp; + int ret; + + uclass_find_first_device(UCLASS_VIDEO, &dev); + ret = uclass_first_device_err(UCLASS_NORTHBRIDGE, &sa_dev); + if (ret) + return log_msg_ret("no sa", ret); + + /* IGD has to be enabled, GFXVTBAR set and enabled */ + if (dev && device_active(dev) && gfxvtbar && gfxvten) { + tmp = ctx->current; + + ret = acpi_create_dmar_drhd(ctx, 0, 0, gfxvtbar); + if (ret) + return log_msg_ret("drhd", ret); + ret = acpi_create_dmar_ds_pci(ctx, PCI_BDF(0, 2, 0)); + if (ret) + return log_msg_ret("ds_pci", ret); + acpi_dmar_drhd_fixup(ctx, tmp); + + /* Add RMRR entry */ + tmp = ctx->current; + ctx->current += acpi_create_dmar_rmrr(ctx->current, 0, + sa_get_gsm_base(sa_dev), + sa_get_tolud_base(sa_dev) - 1); + ctx->current += acpi_create_dmar_ds_pci(ctx->current, + PCI_BDF(0, 2, 0)); + acpi_dmar_rmrr_fixup(ctx, tmp); + } + + /* DEFVTBAR has to be set and enabled */ + if (defvtbar && defvten) { + struct udevice *p2sb_dev; + u16 ibdf, hbdf; + uint ioapic, hpet; + int ret; + + tmp = ctx->current; + /* + * P2SB may already be hidden. There's no clear rule, when. + * It is needed to get bus, device and function for IOAPIC and + * HPET device which is stored in P2SB device. So unhide it to + * get the info and hide it again when done. + * + * TODO(sjg@chromium.org): p2sb_unhide() ? + */ + ret = uclass_first_device_err(UCLASS_P2SB, &p2sb_dev); + if (ret) + return log_msg_ret("p2sb", ret); + + dm_pci_read_config16(p2sb_dev, PCH_P2SB_IBDF, &ibdf); + ioapic = PCI_TO_BDF(ibdf); + dm_pci_read_config16(p2sb_dev, PCH_P2SB_HBDF, &hbdf); + hpet = PCI_TO_BDF(hbdf); + /* TODO(sjg@chromium.org): p2sb_hide() ? */ + + acpi_create_dmar_drhd(ctx, DRHD_INCLUDE_PCI_ALL, 0, defvtbar); + acpi_create_dmar_ds_ioapic(ctx, 2, ioapic); + acpi_create_dmar_ds_msi_hpet(ctx, 0, hpet); + acpi_dmar_drhd_fixup(tmp, ctx->current); + } + + return 0; +} + +void soc_power_states_generation(struct acpi_ctx *ctx, int core_id, + int cores_per_package) +{ + /* 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); +} + +static void acpigen_soc_get_dw0_in_local5(struct acpi_ctx *ctx, ulong addr) +{ + /* + * Store (\_SB.GPC0 (addr), Local5) + * \_SB.GPC0 is used to read cfg0 value from dw0. It is defined in + * gpiolib.asl. + */ + acpigen_write_store(ctx); + acpigen_emit_namestring(ctx, "\\_SB.GPC0"); + acpigen_write_integer(ctx, addr); + acpigen_emit_byte(ctx, LOCAL5_OP); +} + +static int acpigen_soc_get_gpio_val(struct acpi_ctx *ctx, uint gpio_num, + uint32_t mask) +{ + assert(gpio_num < TOTAL_PADS); + struct udevice *dev; + uintptr_t addr; + uint offset; + int ret; + + ret = intel_pinctrl_get_pad(gpio_num, &dev, &offset); + if (ret) + return log_msg_ret("pad", ret); + addr = intel_pinctrl_get_config_reg_addr(dev, offset); + + acpigen_soc_get_dw0_in_local5(ctx, addr); + + /* If (And (Local5, mask)) */ + acpigen_write_if_and(ctx, LOCAL5_OP, mask); + + /* Store (One, Local0) */ + acpigen_write_store_ops(ctx, ONE_OP, LOCAL0_OP); + + acpigen_pop_len(ctx); /* If */ + + /* Else */ + acpigen_write_else(ctx); + + /* Store (Zero, Local0) */ + acpigen_write_store_ops(ctx, ZERO_OP, LOCAL0_OP); + + acpigen_pop_len(ctx); /* Else */ + + return 0; +} + +static int acpigen_soc_set_gpio_val(struct acpi_ctx *ctx, uint gpio_num, + uint32_t val) +{ + assert(gpio_num < TOTAL_PADS); + struct udevice *dev; + uintptr_t addr; + uint offset; + int ret; + + ret = intel_pinctrl_get_pad(gpio_num, &dev, &offset); + if (ret) + return log_msg_ret("pad", ret); + addr = intel_pinctrl_get_config_reg_addr(dev, offset); + + acpigen_soc_get_dw0_in_local5(ctx, addr); + + if (val) { + /* Or (Local5, PAD_CFG0_TX_STATE, Local5) */ + acpigen_write_or(ctx, LOCAL5_OP, PAD_CFG0_TX_STATE, LOCAL5_OP); + } else { + /* Not (PAD_CFG0_TX_STATE, Local6) */ + acpigen_write_not(ctx, PAD_CFG0_TX_STATE, LOCAL6_OP); + + /* And (Local5, Local6, Local5) */ + acpigen_write_and(ctx, LOCAL5_OP, LOCAL6_OP, LOCAL5_OP); + } + + /* + * \_SB.SPC0 (addr, Local5) + * \_SB.SPC0 is used to write cfg0 value in dw0. It is defined in + * gpiolib.asl. + */ + acpigen_emit_namestring(ctx, "\\_SB.SPC0"); + acpigen_write_integer(ctx, addr); + acpigen_emit_byte(ctx, LOCAL5_OP); + + return 0; +} + +int acpigen_soc_read_rx_gpio(struct acpi_ctx *ctx, uint gpio_num) +{ + int ret; + + ret = acpigen_soc_get_gpio_val(ctx, gpio_num, PAD_CFG0_RX_STATE); + if (ret) + return log_msg_ret("val", ret); + + return 0; +} + +int acpigen_soc_get_tx_gpio(struct acpi_ctx *ctx, uint gpio_num) +{ + int ret; + + ret = acpigen_soc_get_gpio_val(ctx, gpio_num, PAD_CFG0_TX_STATE); + if (ret) + return log_msg_ret("val", ret); + + return 0; +} + +int acpigen_soc_set_tx_gpio(struct acpi_ctx *ctx, uint gpio_num) +{ + int ret; + + ret = acpigen_soc_set_gpio_val(ctx, gpio_num, 1); + if (ret) + return log_msg_ret("val", ret); + + return 0; +} + +int acpigen_soc_clear_tx_gpio(struct acpi_ctx *ctx, uint gpio_num) +{ + int ret; + + ret = acpigen_soc_set_gpio_val(ctx, gpio_num, 0); + if (ret) + return log_msg_ret("val", ret); + + return 0; +} diff --git a/arch/x86/include/asm/arch-apollolake/acpi.h b/arch/x86/include/asm/arch-apollolake/acpi.h new file mode 100644 index 0000000000..b5b9aaa2b9 --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/acpi.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef _ASM_ARCH_ACPI_H +#define _ASM_ARCH_ACPI_H + +struct acpi_ctx; + +int apl_acpi_fill_dmar(struct acpi_ctx *ctx); + +#endif /* _ASM_ARCH_CPU_H */ diff --git a/include/acpi_s3.h b/include/acpi_s3.h index baa848dcd1..847139baa0 100644 --- a/include/acpi_s3.h +++ b/include/acpi_s3.h @@ -28,6 +28,10 @@ #define SLP_TYP_S4 6 #define SLP_TYP_S5 7 +/* PM1_STS register */ +#define RTC_EN BIT(10) +#define PWRBTN_EN BIT(8) + /* Memory size reserved for S3 resume */ #define S3_RESERVE_SIZE 0x1000 From patchwork Mon Jan 27 05:06:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229592 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=QoxW6L8P; 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 485dWC30Bvz9sR1 for ; Mon, 27 Jan 2020 16:25:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 067A1818FD; Mon, 27 Jan 2020 06:13:53 +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="QoxW6L8P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7128A817D4; Mon, 27 Jan 2020 06:10:25 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 0C1BD817F3 for ; Mon, 27 Jan 2020 06:09:39 +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-xd42.google.com with SMTP id e7so8540755iof.11 for ; Sun, 26 Jan 2020 21:09:38 -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=q0igDQ+b+2nVq/C5QIxkQAVKZkEmAbeE6nftBf1M8uo=; b=QoxW6L8PqU3tLfWw+qXN5LEjcVzK1qdI/pUZ+Ea+BBvKZgHq/dPc23WzQv1KoJQMfp QpnjUdkS8Bb8X1EG/3YZwQTe9LB+n883UjBG3AgCZm0VearjhdpQUPHo/O0hWtp9JMOg iBI+mmFKO1dYxhW+iALD1a2QRV5nYrZwMKARM= 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=q0igDQ+b+2nVq/C5QIxkQAVKZkEmAbeE6nftBf1M8uo=; b=iUPI43b1kmyic/9ZyL7ZiaKMX1lZMtJjpxGAGNuBRzobrQSs/FFPvlKdM2jwSLrMuB r+YN9LpvL011bs6aN0Gu1vnA5Hgk/OCwFZhNa6WND2YvZbrLCgaWLMJOP8O6CQWIURE7 pa+8XIXsfx6HjfMmL8opm4yCPoBKxPYttgs5XtlQO9mgiCaRESawxE0kop4GNwx/mEj7 3+t7RjrCm91ptWEN6EO2HMGDZy+ZgCWUyAQqUJ+5i0ZKhxAabajxhOFaMe5S28yTFT7/ Z2knEahJWAbUjPT6CKj2k8C68LSV+gspt4TfiNFpOpeLWvovRB0a0tTXKEn58WGcA35r 1Hfg== X-Gm-Message-State: APjAAAUJDFqo29TF25S6KwJ+b16y7wyBpTdTGVhjeJYOuJV3fglMDvi3 GSw+WQu37urKxeHQh4f5UdYSjsIPe58iZA== X-Google-Smtp-Source: APXvYqwe0fmHwXy10EuP9ND7gx8AmVHyipOmJe56VNMhDZzqaRSE5flXxhaVbdAVaVj/IzoZ+2hl/A== X-Received: by 2002:a6b:e411:: with SMTP id u17mr10501958iog.39.1580101777734; Sun, 26 Jan 2020 21:09:37 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 092/108] x86: acpi: Add support for additional DMAR tables Date: Sun, 26 Jan 2020 22:06:39 -0700 Message-Id: <20200126220508.92.I8aa77aa9037dc3d08929270b114eac2f8fc9daa3@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 Apollo Lake needs to generate a few more table types. Add support for these into the x86 ACPI code. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 115 ++++++++++++++++++++++++++++++++++++++ include/acpi_table.h | 37 ++++++++++++ 2 files changed, 152 insertions(+) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index f12344de50..886960a5fa 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -450,6 +450,121 @@ void acpi_create_ssdt(struct acpi_ctx *ctx, struct acpi_table_header *ssdt, ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length); } +void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs, + void *dsdt) +{ + struct acpi_table_header *header = &fadt->header; + + memset((void *)fadt, '\0', sizeof(struct acpi_fadt)); + + acpi_fill_header(header, "FACP"); + header->length = sizeof(struct acpi_fadt); + header->revision = 4; + memcpy(header->oem_id, OEM_ID, 6); + memcpy(header->oem_table_id, ACPI_TABLE_CREATOR, 8); + memcpy(header->aslc_id, ASLC_ID, 4); + header->aslc_revision = 1; + + fadt->firmware_ctrl = (unsigned long)facs; + fadt->dsdt = (unsigned long)dsdt; + + fadt->x_firmware_ctl_l = (unsigned long)facs; + fadt->x_firmware_ctl_h = 0; + fadt->x_dsdt_l = (unsigned long)dsdt; + fadt->x_dsdt_h = 0; + + fadt->preferred_pm_profile = ACPI_PM_MOBILE; + + /* Use ACPI 3.0 revision */ + fadt->header.revision = 4; +} + +int acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment, + u64 bar) +{ + struct dmar_entry *drhd = ctx->current; + + memset(drhd, 0, sizeof(*drhd)); + drhd->type = DMAR_DRHD; + drhd->length = sizeof(*drhd); /* will be fixed up later */ + drhd->flags = flags; + drhd->segment = segment; + drhd->bar = bar; + acpi_inc(ctx, drhd->length); + + return 0; +} + +int acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar, + u64 limit) +{ + struct dmar_rmrr_entry *rmrr = ctx->current; + + memset(rmrr, 0, sizeof(*rmrr)); + rmrr->type = DMAR_RMRR; + rmrr->length = sizeof(*rmrr); /* will be fixed up later */ + rmrr->segment = segment; + rmrr->bar = bar; + rmrr->limit = limit; + acpi_inc(ctx, rmrr->length); + + return 0; +} + +void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base) +{ + struct dmar_entry *drhd = base; + + drhd->length = ctx->current - base; +} + +void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base) +{ + struct dmar_rmrr_entry *rmrr = base; + + rmrr->length = ctx->current - base; +} + +static int acpi_create_dmar_ds(struct acpi_ctx *ctx, enum dev_scope_type type, + uint enumeration_id, pci_dev_t bdf) +{ + /* we don't support longer paths yet */ + const size_t dev_scope_length = sizeof(struct dev_scope) + 2; + struct dev_scope *ds = ctx->current; + + memset(ds, 0, dev_scope_length); + ds->type = type; + ds->length = dev_scope_length; + ds->enumeration = enumeration_id; + ds->start_bus = PCI_BUS(bdf); + ds->path[0].dev = PCI_DEV(bdf); + ds->path[0].fn = PCI_FUNC(bdf); + + return ds->length; +} + +int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf) +{ + return acpi_create_dmar_ds(ctx, SCOPE_PCI_SUB, 0, bdf); +} + +int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf) +{ + return acpi_create_dmar_ds(ctx, SCOPE_PCI_ENDPOINT, 0, bdf); +} + +int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id, + pci_dev_t bdf) +{ + return acpi_create_dmar_ds(ctx, SCOPE_IOAPIC, enumeration_id, bdf); +} + +int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id, + pci_dev_t bdf) +{ + return acpi_create_dmar_ds(ctx, SCOPE_MSI_HPET, enumeration_id, bdf); +} + /* http://www.intel.com/hardwaredesign/hpetspec_1.pdf */ int acpi_create_hpet(struct acpi_hpet *hpet) { diff --git a/include/acpi_table.h b/include/acpi_table.h index 6d91ae85e2..17f2a90af9 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -418,6 +418,26 @@ enum acpi_upc_type { UPC_TYPE_HUB }; +enum dev_scope_type { + SCOPE_PCI_ENDPOINT = 1, + SCOPE_PCI_SUB = 2, + SCOPE_IOAPIC = 3, + SCOPE_MSI_HPET = 4, + SCOPE_ACPI_NAMESPACE_DEVICE = 5 +}; + +struct __packed dev_scope { + u8 type; + u8 length; + u8 reserved[2]; + u8 enumeration; + u8 start_bus; + struct { + u8 dev; + u8 fn; + } __packed path[0]; +}; + enum dmar_type { DMAR_DRHD = 0, DMAR_RMRR = 1, @@ -578,6 +598,13 @@ enum acpi_tables { */ int acpi_get_table_revision(enum acpi_tables table); +int acpi_create_dmar_drhd(struct acpi_ctx *ctx, uint flags, uint segment, + u64 bar); +int acpi_create_dmar_rmrr(struct acpi_ctx *ctx, uint segment, u64 bar, + u64 limit); +void acpi_dmar_rmrr_fixup(struct acpi_ctx *ctx, void *base); +void acpi_dmar_drhd_fixup(struct acpi_ctx *ctx, void *base); + /** * acpi_create_dmar() - Create a DMA Remapping Reporting (DMAR) table * @@ -592,6 +619,16 @@ void acpi_create_dbg2(struct acpi_dbg2_header *dbg2, struct acpi_gen_regaddr *address, uint32_t address_size, const char *device_path); +int acpi_create_dmar_ds_pci_br(struct acpi_ctx *ctx, pci_dev_t bdf); +int acpi_create_dmar_ds_pci(struct acpi_ctx *ctx, pci_dev_t bdf); +int acpi_create_dmar_ds_ioapic(struct acpi_ctx *ctx, uint enumeration_id, + pci_dev_t bdf); +int acpi_create_dmar_ds_msi_hpet(struct acpi_ctx *ctx, uint enumeration_id, + pci_dev_t bdf); +void acpi_fadt_common(struct acpi_fadt *fadt, struct acpi_facs *facs, + void *dsdt); +void intel_acpi_fill_fadt(struct acpi_fadt *fadt); + /** * acpi_fill_header() - Set up a new table header * From patchwork Mon Jan 27 05:06:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229591 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=RNku9W+2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dW00plRz9sR1 for ; Mon, 27 Jan 2020 16:25:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A63C8191D; Mon, 27 Jan 2020 06:13:50 +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="RNku9W+2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB1E6817D3; Mon, 27 Jan 2020 06:10:25 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 BE6C981726 for ; Mon, 27 Jan 2020 06:09:39 +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-xd44.google.com with SMTP id c16so8568082ioh.6 for ; Sun, 26 Jan 2020 21:09:39 -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=ozbqBibQdR00lC4Cf5Mweg3smuJz+nkLTZCkiA8gsxM=; b=RNku9W+2u/d/WOs1rr0bYDgjxhq6AEL8+pzvCQaKwHI/FLUaD6z04SyK+3e76c+6Kj XQO7RFzLwS6q2VXPRD+yOM9hSMLPNjpfKzodzzC1Cd6wIpsAGB6zvgUmEUMgVNshfshd ciniZ/Zlt2aTLIAbp8j+qZzOoidVfaIcluD9o= 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=ozbqBibQdR00lC4Cf5Mweg3smuJz+nkLTZCkiA8gsxM=; b=cSILVSCX8xogvJHQUNMN/SDwd54mrVlH1FVPmCeQ1QksNpKQlvOeOR8UK6JnD6SvI6 afBKbq4YkKhidSa3zJnSagifGuvbaiYlRIotHGGbqCj54Zbur1KryQw7KmbacuJEYXjL /pgDXjujwSiGKflvrdi8xrIHwO7LmoRCTgT0gnnV3PYqnF39Bbq3RZ1yW3biuVSEoN9S 8UqFZQ56Oom6CnWVMHi8mFFz732KKx/ZjKNpIc14lFg0qkaPohOvKuuYeYhIjZ4fTBqG mIaLpzofu46SJTHru6Vu2fEy831d0KJ2c7Z3jCM5QJkY1RpjW0Y+FH+xsb+hszZNzCen LY7A== X-Gm-Message-State: APjAAAW9SAygOTJAfo65+67z3QW6Zpt9qzyTuHfQ1GHeoC+YtKeC3RBU OSOTW6025HC0utgcZBaFuuSAxEDiEF94Aw== X-Google-Smtp-Source: APXvYqyj5JtvRjmeGW26u3gH+wBWgq2blMpT0wq+vTLwbr5Ptgrbt+bSpmj418Bhup//OTUYqwj6xQ== X-Received: by 2002:a5d:8448:: with SMTP id w8mr11451029ior.161.1580101778516; Sun, 26 Jan 2020 21:09:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 093/108] x86: apl: Generate CPU tables Date: Sun, 26 Jan 2020 22:06:40 -0700 Message-Id: <20200126220508.93.I2a86b43205b9beb2d6a9a77e9baff15f52fcf97e@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 Add ACPI generation to the APL CPU driver. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/cpu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/cpu/apollolake/cpu.c b/arch/x86/cpu/apollolake/cpu.c index 3ae99ccf04..0af1b0c2cb 100644 --- a/arch/x86/cpu/apollolake/cpu.c +++ b/arch/x86/cpu/apollolake/cpu.c @@ -8,6 +8,9 @@ #include #include #include +#include +#include +#include static int apl_get_info(const struct udevice *dev, struct cpu_info *info) { @@ -19,6 +22,25 @@ static int apl_get_count(const struct udevice *dev) return 4; } +static int acpi_cpu_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + struct cpu_platdata *plat = dev_get_parent_platdata(dev); + int ret; + + /* Trigger off the first CPU */ + if (!plat->cpu_id) { + ret = generate_cpu_entries(ctx, dev); + if (ret) + return log_msg_ret("generate", 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, @@ -37,5 +59,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, }; From patchwork Mon Jan 27 05:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229593 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=Z9VJ8+ja; 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 485dWQ5T9Vz9sR1 for ; Mon, 27 Jan 2020 16:25:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 05D308192E; Mon, 27 Jan 2020 06:13:55 +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="Z9VJ8+ja"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB287817DF; Mon, 27 Jan 2020 06:10:27 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 84AEA817FB for ; Mon, 27 Jan 2020 06:09:40 +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-xd42.google.com with SMTP id m25so8557414ioo.8 for ; Sun, 26 Jan 2020 21:09:40 -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=EIF7zRdlYtJZzfPt615FxMQaUhME2QMyKTebziCEUnc=; b=Z9VJ8+jalnqusEuwqKoL6kUcGneKiM+ucpd4zJHGq1RSCwCmBvr3fcu9ImXkJTf1aH Z/zygL1TB4WMNiS9LyRaQI7pHMgASXH0QTqJ1ltxJTI7p0QSaIalhKbK/ve8bdP5zg27 tj81g6dLhK+ji1/bZTlqpsLXiixNwhEALriTI= 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=EIF7zRdlYtJZzfPt615FxMQaUhME2QMyKTebziCEUnc=; b=Ybd5H6nGoEZzvQO4Ysxt7Rr/qdM/Sd3FPTQdygFzCIvv72Y5CtODIHovxu16XsARDh l0rSK50lsgX+ueG+ZAOqJBwbthl5e8zR/n+zIO+IbqAV09zaCgPpVkHqtg8xB5eoarUP 3NkUGlZHG4aAzKUgYQDGkj7zJbeCK58Kr6HwZK2JSO51uwA2lruWaAhtRFHRk/bBDnEQ yFiL9kclr8SzVBhX8AF5UgA3JEJiLwNA9CY0rn7IXtGmMenF0N0QQKwS7DgLeHzN/RYF WyqVmmKVQ19rA4PYyQalLJBtimHTOXjpYPZlonZivXCgx3kHwaqsWofLg2BXeV27jA7c 00Cg== X-Gm-Message-State: APjAAAXNiwQhAfRpu4H8rvVJN5c58FjGJOBW0m7NOh1ljlpV+B/R+Et8 WjBRHXVN4CjzY0adivhSYtnIlcMxRInXSA== X-Google-Smtp-Source: APXvYqy4wyHqjiyT3OlUGGH3aVWqjOGOvsmoplYZhVXq2Z/CLWMV1RZOpBuJ+U/ULpmFtYdn+lPqjg== X-Received: by 2002:a5d:8a10:: with SMTP id w16mr500951iod.216.1580101779325; Sun, 26 Jan 2020 21:09:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:38 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 094/108] x86: apl: Generate ACPI table for LPC Date: Sun, 26 Jan 2020 22:06:41 -0700 Message-Id: <20200126220508.94.Ie219a98cd7e07d939f53d36c407ed88e7089b54a@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 Add an ACPI table for the LPC on Apollo Lake. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/lpc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/cpu/apollolake/lpc.c b/arch/x86/cpu/apollolake/lpc.c index 45b2144fc6..7c0ebf332b 100644 --- a/arch/x86/cpu/apollolake/lpc.c +++ b/arch/x86/cpu/apollolake/lpc.c @@ -6,12 +6,16 @@ */ #include +#include #include #include +#include +#include #include #include #include #include +#include #include void lpc_enable_fixed_io_ranges(uint io_enables) @@ -109,6 +113,17 @@ void lpc_io_setup_comm_a_b(void) lpc_enable_fixed_io_ranges(com_enable); } +static int apl_acpi_lpc_get_name(const struct udevice *dev, char *out_name) +{ + return acpi_return_name(out_name, "LPCB"); +} + +struct acpi_ops apl_lpc_acpi_ops = { + .get_name = apl_acpi_lpc_get_name, + .write_tables = intel_southbridge_write_acpi_tables, + .inject_dsdt = southbridge_inject_dsdt, +}; + static const struct udevice_id apl_lpc_ids[] = { { .compatible = "intel,apl-lpc" }, { } @@ -119,4 +134,5 @@ U_BOOT_DRIVER(apl_lpc_drv) = { .name = "intel_apl_lpc", .id = UCLASS_LPC, .of_match = apl_lpc_ids, + acpi_ops_ptr(&apl_lpc_acpi_ops) }; From patchwork Mon Jan 27 05:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229594 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=PTd8JQi6; 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 485dWd5yVFz9sR1 for ; Mon, 27 Jan 2020 16:26:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E90681935; Mon, 27 Jan 2020 06:13:57 +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="PTd8JQi6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A592E817DC; Mon, 27 Jan 2020 06:10:29 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 496F1817E6 for ; Mon, 27 Jan 2020 06:09:41 +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-xd43.google.com with SMTP id m25so8557431ioo.8 for ; Sun, 26 Jan 2020 21:09:41 -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=ZZr0fdNa2Ro0uEkWZeO78zDMa26cQtJ/fI7NIcBv3ZU=; b=PTd8JQi6QiwMAcv+Mi9KURX1qTkOE8i29+7/Iz/iHThpfhYYUxE+L4P0uKRYxSJAtf NIgPx2IdjC60WyGmNfAPYxzFLmRZ6G0WkKYXiHwGqxWen2clxcqzuJI7p2625yVQ02y8 upiY1pm3JPji/WsfDrk1QNZpjLEKqjt4pEDPk= 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=ZZr0fdNa2Ro0uEkWZeO78zDMa26cQtJ/fI7NIcBv3ZU=; b=etMoixx1IkIyAw7OQVtKoTGWYX6eA9CS2cY3WSDqURqhf5YLpXinrBEG0XgVthwYEl LQ0FS6AUxS6sPzCHlQAs5xgGJ/i5SVtGgDh58fp8sLVertaVPGltfrOohKVWc6dn6Jqk Rew+kqfYbOWOh5sbfmlRrhdchvVEl0i1f2FSwB/tSQ2FAwPDA06t5VXrwgTw1mKx2eTk ZMLGhFIm0g+baxWRGmSR9oj73x4FXyH0LjaBxlxcS16WLmsCI72KgonNEIWJo/ITWtJ7 bNB69up5po8FkFNsEQut0ltDHT6xDigAbAnRlGUMKO/o2y4bJ+IpxuM+9YLVFiIqWow/ o/RQ== X-Gm-Message-State: APjAAAUJOtQi2UfhdBLyPYh7vXfCyFXH0pWTnEAE5t8dfMZsfFMBsn6C pw8oC00DakdPwiKq8C/UME7g8WyonrBCjA== X-Google-Smtp-Source: APXvYqwcQAZtwc+uG/9gNSGQKCK/6zN+UEJz3A64FYIj0h0joXyBTn1O9trGCyIpqBeydALQbr9USQ== X-Received: by 2002:a02:a48d:: with SMTP id d13mr11918614jam.141.1580101779972; Sun, 26 Jan 2020 21:09:39 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:39 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 095/108] x86: apl: Drop unnecessary code in PMC driver Date: Sun, 26 Jan 2020 22:06:42 -0700 Message-Id: <20200126220508.95.Iebe5efc358267d65f014f9fe65f2907afe5e7052@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 We don't have CONFIG_PCI in TPL but it is present in SPL, etc. So this code is not needed. Drop it, and fix a code-style nit just above. Signed-off-by: Simon Glass --- arch/x86/cpu/apollolake/pmc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c index 9390c54a8e..a2547a580d 100644 --- a/arch/x86/cpu/apollolake/pmc.c +++ b/arch/x86/cpu/apollolake/pmc.c @@ -116,7 +116,8 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev) int size; int ret; - ret = dev_read_u32_array(dev, "early-regs", base, ARRAY_SIZE(base)); + ret = dev_read_u32_array(dev, "early-regs", base, + ARRAY_SIZE(base)); if (ret) return log_msg_ret("Missing/short early-regs", ret); if (spl_phase() == PHASE_TPL) { @@ -131,11 +132,6 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev) } upriv->acpi_base = base[4]; - /* Since PCI is not enabled, we must get the BDF manually */ - plat->bdf = pci_get_devfn(dev); - if (plat->bdf < 0) - return log_msg_ret("Cannot get PMC PCI address", plat->bdf); - /* Get the dwX values for pmc gpe settings */ size = dev_read_size(dev, "gpe0-dw"); if (size < 0) From patchwork Mon Jan 27 05:06:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229595 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=fr+Eapj/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dWr31Fzz9sR1 for ; Mon, 27 Jan 2020 16:26:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F9218193E; Mon, 27 Jan 2020 06:13:59 +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="fr+Eapj/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A762817EC; Mon, 27 Jan 2020 06:10:31 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 E4451817EE for ; Mon, 27 Jan 2020 06:09:41 +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-xd43.google.com with SMTP id d15so8579310iog.3 for ; Sun, 26 Jan 2020 21:09:41 -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=Fnz37EwQeZYOETbUtfr9KU6n+7mt/VxCcek/Lyj0Mkw=; b=fr+Eapj/pne21jE5CpDxvyx4p1vo7GFHuTRRWSiUuZRaIk9jJWI3KhmQ2BrmdYQMkv ouxOgnf/HIcWcgZ2LDh8WT+gA0Dc9Y7P2Cyzr1Eps/eEqZDS6xlhRXJCdPFPPsUJvANL /psK/qIAClMp8eFdD0CHQhFiXsoqjlNQ1TdWo= 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=Fnz37EwQeZYOETbUtfr9KU6n+7mt/VxCcek/Lyj0Mkw=; b=YEij/3ccwrQ8+VkKxxNeuL/Xm3CHNQLNSwHNijFWj+YVaUtrSvw8nqypg6tM0pz0B7 yVuyWz3VftkhPzt2P6esG7es28sRzPrWADckIvHiOeBIXu6Ofttw2GDBTYqCEvg0LCfR N4DMl3KqdfJuOKHAYQAoPW2cnl4uOxTSTn1aMhB8Q02ZbVOwYIGfxoQqIEYjHOdw5FWs Cns68DWW/bbJuN2f1VNf13Yv6d+hG0Gt4yDDp1zV6YEJ+5vGOAw0Wqt6DT6YBNpha3Ab XQYsCF0XOQaXVfsI4E+sEV1SGB0P9ddB9reax96rBWHlmadTZWwTpoG2aFakuG3koVn2 sMbw== X-Gm-Message-State: APjAAAWVvIZuK2AblRhqGf4gekRCTxLnjcfDUz2lZFR6c9cSUiCn3zw3 jCPJaS3P+C+WrywRax2+Zt8eU+ubnmhFAg== X-Google-Smtp-Source: APXvYqz0gya5fHrnpFRJwX7s3phb03ls9+UFN5Oe8W/FIC505O6R1HfNt2NACRiTXs7RHf9rXaKvUQ== X-Received: by 2002:a5e:df47:: with SMTP id g7mr11308851ioq.31.1580101780710; Sun, 26 Jan 2020 21:09:40 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 096/108] tpm: cr50: Add ACPI support Date: Sun, 26 Jan 2020 22:06:43 -0700 Message-Id: <20200126220508.96.I1a9174fd9af26d0891e4ccfac247c7359b28b23e@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 Generate ACPI information for this device so that Linux can use it correctly. Signed-off-by: Simon Glass --- drivers/tpm/cr50_i2c.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index d68534e7a9..5a3db87125 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -8,6 +8,8 @@ #define LOG_CATEGORY UCLASS_TPM #include +#include +#include #include #include #include @@ -17,6 +19,7 @@ #include #include #include +#include enum { TIMEOUT_INIT_MS = 30000, /* Very long timeout for TPM init */ @@ -580,6 +583,53 @@ static int cr50_i2c_cleanup(struct udevice *dev) return 0; } +static int cr50_acpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx) +{ + char scope[ACPI_PATH_MAX]; + char name[ACPI_NAME_MAX]; + const char *hid; + int ret; + + ret = acpi_device_scope(dev, scope, sizeof(scope)); + if (ret) + return log_msg_ret("scope", ret); + ret = acpi_device_name(dev, name); + if (ret) + return log_msg_ret("name", ret); + + hid = dev_read_string(dev, "acpi,hid"); + if (!hid) + return log_msg_ret("hid", ret); + + /* Device */ + acpigen_write_scope(ctx, scope); + acpigen_write_device(ctx, name); + acpigen_write_name_string(ctx, "_HID", hid); + acpigen_write_name_integer(ctx, "_UID", + dev_read_u32_default(dev, "acpi,uid", 0)); + acpigen_write_name_string(ctx, "_DDN", + dev_read_string(dev, "acpi,desc")); + acpigen_write_sta(ctx, acpi_device_status(dev)); + + /* Resources */ + acpigen_write_name(ctx, "_CRS"); + acpigen_write_resourcetemplate_header(ctx); + ret = acpi_device_write_i2c_dev(ctx, dev); + if (ret) + return log_msg_ret("i2c", ret); + ret = acpi_device_write_interrupt_or_gpio(ctx, (struct udevice *)dev, + "ready-gpios"); + if (ret) + return log_msg_ret("irq_gpio", ret); + + acpigen_write_resourcetemplate_footer(ctx); + + acpigen_pop_len(ctx); /* Device */ + acpigen_pop_len(ctx); /* Scope */ + + return 0; +} + enum { TPM_TIMEOUT_MS = 5, SHORT_TIMEOUT_MS = 750, @@ -652,6 +702,10 @@ static int cr50_i2c_probe(struct udevice *dev) return 0; } +struct acpi_ops cr50_acpi_ops = { + .fill_ssdt = cr50_acpi_fill_ssdt, +}; + static const struct tpm_ops cr50_i2c_ops = { .open = cr50_i2c_open, .get_desc = cr50_i2c_get_desc, @@ -674,5 +728,6 @@ U_BOOT_DRIVER(cr50_i2c) = { .probe = cr50_i2c_probe, .remove = cr50_i2c_cleanup, .priv_auto_alloc_size = sizeof(struct cr50_priv), + acpi_ops_ptr(&cr50_acpi_ops) .flags = DM_FLAG_OS_PREPARE, }; From patchwork Mon Jan 27 05:06:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229597 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=XJSt+OON; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dXF0gV3z9sR1 for ; Mon, 27 Jan 2020 16:26:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A8AE78193A; Mon, 27 Jan 2020 06:14:05 +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="XJSt+OON"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 80731817D4; Mon, 27 Jan 2020 06:10:32 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 B41BC817D8 for ; Mon, 27 Jan 2020 06:09:42 +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-xd42.google.com with SMTP id x1so8556438iop.7 for ; Sun, 26 Jan 2020 21:09:42 -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=nzMpw6jsZpaN7Vu4orvqqoAdcoRoZnYmrQHKNyzBUlA=; b=XJSt+OONjFOnivq3BuPqMi3F7KAOFbj+az5h9jkPIb20QAsbptW1pV2DmSOownTcLu GvLs4s4yYWz+1OPswVqy1D3DEqG1b905rjeo3+pWqHltca8HVqOdf7RNIdsFsgrep+/Q jZMgtb+2ahhaKCQpc0emTppqr9dnEafQbyZDQ= 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=nzMpw6jsZpaN7Vu4orvqqoAdcoRoZnYmrQHKNyzBUlA=; b=K6ifYn8XM/LPEVpgvtoMKp+BhTDxUX2WUUqXnR1m+znDY2fUsKAI5scJM0jxe5OqzT Xi1TCj1eicHUTzLVlbxM8y+yF4q/p1hpoTJa0S5pBCk32dSCg/J342/OKE7VR/Cv4dlJ k2VnTPoyuOG4BU4xtZKdgle1kSC+sEQ/WUJA8nNxCTHFE2VXM0JOgBWv/50w4Dfs5A4H NIP1QuIkWmzt+Qq3sfB1dukt5IG/ggvBaF8OQzNiCAEwPNNMB/UCrFZ/CktHZKGYcWuj y5BWWzKOInhryxRoYo1UzE5nJjBNHiWk6UU3wJl/w0f6nXL2365QNq6bsG3RhHH9Hmau THmQ== X-Gm-Message-State: APjAAAV4z2pLe4k6FagXf3fVFt5BVwVHoyz9vyPHlk6Pk4NjXmFmmC4b Xr4Tb4o+fROHROTbyXBjKDGyLu5T5zy8lg== X-Google-Smtp-Source: APXvYqz/rBnh04F9S9cbYH4wlxQC7FbUFB9/GtHwA/sjJJRMuwD6fycMOoFxjLMa6qPNxIIEoY10Kw== X-Received: by 2002:a6b:8ec9:: with SMTP id q192mr11421158iod.237.1580101781419; Sun, 26 Jan 2020 21:09:41 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 097/108] x86: fsp: Update the FSP API with the end-firmware method Date: Sun, 26 Jan 2020 22:06:44 -0700 Message-Id: <20200126220508.97.Ie333ce385111e0f6aff34920acf69bd06f1d053a@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 This new method is intended to be called when UEFI shuts down the 'boot services', i.e. any lingering code in the boot loader that might be used by the OS. Add a definition for this new method and update the comments a little. Signed-off-by: Simon Glass --- arch/x86/include/asm/fsp/fsp_api.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/fsp/fsp_api.h b/arch/x86/include/asm/fsp/fsp_api.h index e9ac86b2da..c39581c4e5 100644 --- a/arch/x86/include/asm/fsp/fsp_api.h +++ b/arch/x86/include/asm/fsp/fsp_api.h @@ -8,9 +8,18 @@ enum fsp_phase { /* Notification code for post PCI enuermation */ - INIT_PHASE_PCI = 0x20, - /* Notification code before transferring control to the payload */ - INIT_PHASE_BOOT = 0x40 + INIT_PHASE_PCI = 0x20, + /* + * Notification code before transferring control to the payload. + * This is issued at the end of init before starting main(), i.e. + * the command line / boot script. + */ + INIT_PHASE_BOOT = 0x40, + /* + * Notification code before existing boot services. This is issued + * just before removing devices and booting the kernel. + */ + INIT_PHASE_END_FIRMWARE = 0xf0, }; struct fsp_notify_params { From patchwork Mon Jan 27 05:06:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229596 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=WX9toV4b; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dX23z3jz9sR1 for ; Mon, 27 Jan 2020 16:26:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DADBD81930; Mon, 27 Jan 2020 06:14:01 +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="WX9toV4b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5BD7A817EE; Mon, 27 Jan 2020 06:10:32 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 9263081793 for ; Mon, 27 Jan 2020 06:09:43 +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-xd42.google.com with SMTP id i11so8536752ioi.12 for ; Sun, 26 Jan 2020 21:09:43 -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=QXjWlVtgGjNAzto2LTR+xw97ixbNGKrtrWewF3dEcW8=; b=WX9toV4bCFPhfgJBYkuUGddoYmb/NZehIfFgbRKMtv2sGPIjNgitjmwKcL4RuQqw1t iBZdIHpH2tfUHMaqbjALtIxiin6yuuliwWQBScQGRuR7uDw2SKm73v7f22+SB9Rgviv1 8Rd4CjMHW54vnnckR+mCTvwawEM7FniBdt5+w= 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=QXjWlVtgGjNAzto2LTR+xw97ixbNGKrtrWewF3dEcW8=; b=sb7LOlW1zXL+9uAou5PfB4Ff0VvHRgqlsRFl+x1dahmhhyiZzISLdd4sLRn6y0EUES YP9ZvXC9Lqs+Ac82WMU/da/+uAHShN/MPuatvmlrYIKvLiS4U9+T4AMyOwFEQ6XN7NKE Rch4qf41dfIZau41Fym9S2stEqqhTVkDF+QnoGANgdqqq204gr+P+5nqdkmU4flBKLzQ WFpZeZpGkvbXj5+8SwDexj/DGXSlDzayd6SifR9h9GBwAf4V2L0lnArXpslBcTECaD7H hLpetkxSwDMcmcnTODcdIec5uQugvJW1GD1/2HL6F7bkpvrEH3dttpQkCKyntFrV2bxw 8cTA== X-Gm-Message-State: APjAAAU9C/hOqT+v2LWbVaZqyulXW1hqssbdw4u3PmAvCaBXNhxQkbeq UHb+KtZMsNlfEF7Uz7L1GGlhExYO7nl8eg== X-Google-Smtp-Source: APXvYqwzE5hWNlzzGLB1d1iEyJdzNyw92UcrGcXQhcYQSo8BZQqUow+l0GIVTmC/A2LT1UGUAThApw== X-Received: by 2002:a02:cbd9:: with SMTP id u25mr12189100jaq.106.1580101782195; Sun, 26 Jan 2020 21:09:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:41 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 098/108] x86: cpu: Report address width from cpu_get_info() Date: Sun, 26 Jan 2020 22:06:45 -0700 Message-Id: <20200126220508.98.I118f06c4ecc36bca1be6229e54e03511110a84a0@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 Add support for this new field in the common code used by most x86 CPU drivers. Signed-off-by: Simon Glass --- arch/x86/cpu/i386/cpu.c | 23 +++++++++++++++++++++++ arch/x86/cpu/intel_common/cpu.c | 1 + arch/x86/include/asm/cpu.h | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/arch/x86/cpu/i386/cpu.c b/arch/x86/cpu/i386/cpu.c index 2b27617ca3..5904cdcd48 100644 --- a/arch/x86/cpu/i386/cpu.c +++ b/arch/x86/cpu/i386/cpu.c @@ -31,6 +31,10 @@ DECLARE_GLOBAL_DATA_PTR; +#define CPUID_FEATURE_PAE BIT(6) +#define CPUID_FEATURE_PSE36 BIT(17) +#define CPUID_FEAURE_HTT BIT(28) + /* * Constructor for a conventional segment GDT (or LDT) entry * This is a macro so it can be used in initialisers @@ -376,6 +380,25 @@ static void setup_identity(void) } } +static uint cpu_cpuid_extended_level(void) +{ + return cpuid_eax(0x80000000); +} + +int cpu_phys_address_size(void) +{ + if (!has_cpuid()) + return 32; + + if (cpu_cpuid_extended_level() >= 0x80000008) + return cpuid_eax(0x80000008) & 0xff; + + if (cpuid_edx(1) & (CPUID_FEATURE_PAE | CPUID_FEATURE_PSE36)) + return 36; + + return 32; +} + /* Don't allow PCI region 3 to use memory in the 2-4GB memory hole */ static void setup_pci_ram_top(void) { diff --git a/arch/x86/cpu/intel_common/cpu.c b/arch/x86/cpu/intel_common/cpu.c index 106ff41e23..f45d94825f 100644 --- a/arch/x86/cpu/intel_common/cpu.c +++ b/arch/x86/cpu/intel_common/cpu.c @@ -126,6 +126,7 @@ int cpu_intel_get_info(struct cpu_info *info, int bclk) info->cpu_freq = ((msr.lo >> 8) & 0xff) * bclk * 1000000; info->features = 1 << CPU_FEAT_L1_CACHE | 1 << CPU_FEAT_MMU | 1 << CPU_FEAT_UCODE | 1 << CPU_FEAT_DEVICE_ID; + info->address_width = cpu_phys_address_size(); return 0; } diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 21a05dab7d..5b001bbee2 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -288,4 +288,13 @@ u32 cpu_get_family_model(void); */ u32 cpu_get_stepping(void); +/** + * cpu_phys_address_size() - Get the physical address size in bits + * + * This is 32 for older CPUs but newer ones may support 36. + * + * @return address size (typically 32 or 36) + */ +int cpu_phys_address_size(void); + #endif From patchwork Mon Jan 27 05:06:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229598 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=Vfc88M6n; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dXR5BRQz9sR1 for ; Mon, 27 Jan 2020 16:26:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A681181942; Mon, 27 Jan 2020 06:14:08 +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="Vfc88M6n"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A3242817F0; Mon, 27 Jan 2020 06:10:34 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 45F2B81782 for ; Mon, 27 Jan 2020 06:09:44 +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-xd43.google.com with SMTP id s24so7030392iog.5 for ; Sun, 26 Jan 2020 21:09:44 -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=gcqYwRkzYNPGqSa4Gevh+IEB46GaKOFitcyqatPBEYU=; b=Vfc88M6nEK5Dx96jKSUVDmXsyKJCJMz6AlIoZJuoxiqHj7H95u7dSLXtrtt2LKxyEo HOTnKRmFJkDf608W8yk9MWvwaYb36B2rvE6RGrIUCvM+6q7PX2HlaohceWhk6u789z2D UQHejf/LdliI2C8t32xHJpx1VzCIG4ZOaQMts= 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=gcqYwRkzYNPGqSa4Gevh+IEB46GaKOFitcyqatPBEYU=; b=O+j1h6G34vbUb0PSRpCeVpa8FhKOhv0SsFOQSpqL4XzdGlFRpk9ynXpmdDZHDmHez+ cVsp3pNbVERafopENQ9W23HcAy0y2Huqmkmbs3y4uNqQkpsBPQ55u6pC+hvxq54vOcR9 Z7n2FqX76EgDFieaAFW9azglHdUjg2QDmsRQlOnoneCCLcSZu+rQziHzqOCFYCeWIw/8 QuD1ju8VcPvEgSrz1DxSb08NWJ8qnlj5e7JIpj4MUzg1uPXHbDiQDONwVvJoIIYoFiHm 0tNMo5SWEDbrUQT5d8Roul7WQebJ8Z5h4YenghmXNcv4T6IRz+QFRY/XXnA8dXRtrJfA 1efQ== X-Gm-Message-State: APjAAAXrkXOtY9w+XTLNym7Hk1c/7nzv39glOO0/I2DTolIsqcY88Xub OtuW6gFVNIBV3IO/xY4Wfku/NwyntNKL3Q== X-Google-Smtp-Source: APXvYqwEzu+bixrW8bvH6EyxoK0QXTthHTangjlsbBr1Le0BmSqpzl+O4QsH99dzDNiSTO6q9F3m/w== X-Received: by 2002:a6b:dd07:: with SMTP id f7mr11069299ioc.3.1580101782986; Sun, 26 Jan 2020 21:09:42 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:42 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 099/108] x86: Sort the MTRR table Date: Sun, 26 Jan 2020 22:06:46 -0700 Message-Id: <20200126220508.99.I889d71c12fa7f745008c16751f9a6d71009242a8@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 At present the MTRR registers are programmed with the list the U-Boot builds up in the same order. In some cases this list may be out of order. It looks better in Linux to have the registers in order, so sort them, Signed-off-by: Simon Glass --- arch/x86/cpu/mtrr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c index a43cb7fc15..5a4eb648fb 100644 --- a/arch/x86/cpu/mtrr.c +++ b/arch/x86/cpu/mtrr.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,16 @@ static void set_var_mtrr(uint reg, uint type, uint64_t start, uint64_t size) wrmsrl(MTRR_PHYS_MASK_MSR(reg), mask | MTRR_PHYS_MASK_VALID); } +static int h_comp_mtrr(const void *p1, const void *p2) +{ + const struct mtrr_request *req1 = p1; + const struct mtrr_request *req2 = p2; + + s64 diff = req1->start - req2->start; + + return diff < 0 ? -1 : diff > 0 ? 1 : 0; +} + int mtrr_commit(bool do_caches) { struct mtrr_request *req = gd->arch.mtrr_req; @@ -75,6 +86,7 @@ int mtrr_commit(bool do_caches) debug("open\n"); mtrr_open(&state, do_caches); debug("open done\n"); + qsort(req, gd->arch.mtrr_req_count, sizeof(*req), h_comp_mtrr); for (i = 0; i < gd->arch.mtrr_req_count; i++, req++) set_var_mtrr(i, req->type, req->start, req->size); From patchwork Mon Jan 27 05:06:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229601 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=KBHNjfMH; 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 485dY610hBz9sR1 for ; Mon, 27 Jan 2020 16:27:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B0A181946; Mon, 27 Jan 2020 06:14:16 +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="KBHNjfMH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF0AF817EC; Mon, 27 Jan 2020 06:10:35 +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 224B88180B for ; Mon, 27 Jan 2020 06:09:45 +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 n11so8554231iom.9 for ; Sun, 26 Jan 2020 21:09:45 -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=oUAGBLrGd77h/osOkTR0xjkfvLcYkH4jVKBo/rCUlyc=; b=KBHNjfMHox451FcBu7zqGJXcOkqo8KPo29VHYJDrQhkv2L0cGBLGA8o9ExICx7she9 BawR8ihi9nhmJyfb8tHCQKpdtn+0w86d8E32GfMqCdbdlAnAlpY1Gw/qKwdnAvIeV3a1 wjNuQ9Yo7hYHJ40rrWtf9vM9UMSQKh97XxeGY= 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=oUAGBLrGd77h/osOkTR0xjkfvLcYkH4jVKBo/rCUlyc=; b=EtfA52xsP+9Pc8xd5YICdQJmzXK9btF0Hh38e4F7iyIlaOtt9yDv4KwXMkSARiMX+X JMk1Ck/9xpoq+z2qqdHe+hngX5PGcATncNFHPaJiIqJ9VRwE+sOvYH48R9iCknh0ICD3 wHTUgpdIjvLsuz2jAk4za7khcQTCCcN9o7zFA8IA8+6U4uMen/LxEN4p7RPh1W31GAnC 8g1Uz1fRMKCSBekYTA43BqJ9Wwv/pXWrZEuYvU10y3YZOkQcArNAIyJMyzNQ+YNRkgVR NVqh9dXGcbyTw5sRz5WOVElF4cKdT3HY/EMxxZ/Q8xwHcV7S+DojF96H8V0J0ptoYtMJ psxg== X-Gm-Message-State: APjAAAV03iD+WjqTdhpQX8GCEmU70OTWon8eMtHs8fnJNURNPZn9mo33 1A0c5kqPBSkIOH4Orsx2K/tFgfZptIo3gQ== X-Google-Smtp-Source: APXvYqxRkcCxWGHXTzr0kgbHEg5KKu8YkAVkPxFQorNSh/3amblEIsjww5bS2NsTFbIu5wBS25zE9w== X-Received: by 2002:a02:c942:: with SMTP id u2mr12219505jao.49.1580101783837; Sun, 26 Jan 2020 21:09:43 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:43 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 100/108] x86: Add a way to add to the e820 memory table Date: Sun, 26 Jan 2020 22:06:47 -0700 Message-Id: <20200126220508.100.I76d2863227979dc3dd80af26759ff2ef51dc5553@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 Some boards want to reserve extra regions of memory. Add a 'chosen' property to support this. Signed-off-by: Simon Glass --- arch/x86/lib/fsp/fsp_dram.c | 16 ++++++++++++++++ doc/device-tree-bindings/chosen.txt | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/arch/x86/lib/fsp/fsp_dram.c b/arch/x86/lib/fsp/fsp_dram.c index 15e82de2fe..ec391e29e7 100644 --- a/arch/x86/lib/fsp/fsp_dram.c +++ b/arch/x86/lib/fsp/fsp_dram.c @@ -11,6 +11,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -91,6 +92,8 @@ unsigned int install_e820_map(unsigned int max_entries, unsigned int num_entries = 0; const struct hob_header *hdr; struct hob_res_desc *res_desc; + const fdt64_t *prop; + int size; hdr = gd->arch.hob_list; @@ -127,6 +130,19 @@ unsigned int install_e820_map(unsigned int max_entries, entries[num_entries].type = E820_RESERVED; num_entries++; #endif + prop = ofnode_get_chosen_prop("e820-entries", &size); + if (prop) { + int count = size / (sizeof(u64) * 3); + int i; + + if (num_entries + count >= max_entries) + return -ENOSPC; + for (i = 0; i < count; i++, num_entries++, prop += 3) { + entries[num_entries].addr = fdt64_to_cpu(prop[0]); + entries[num_entries].size = fdt64_to_cpu(prop[1]); + entries[num_entries].type = fdt64_to_cpu(prop[2]); + } + } return num_entries; } diff --git a/doc/device-tree-bindings/chosen.txt b/doc/device-tree-bindings/chosen.txt index d4dfc05847..e5ba6720ce 100644 --- a/doc/device-tree-bindings/chosen.txt +++ b/doc/device-tree-bindings/chosen.txt @@ -143,3 +143,21 @@ This provides the ordering to use when writing device data to the ACPI SSDT node to add. The ACPI information is written in this order. If the ordering does not include all nodes, an error is generated. + +e820-entries +------------ + +This provides a way to add entries to the e820 table which tells the OS about +the memory map. The property contains three sets of 64-bit values: + + address - Start address of region + size - Size of region + flags - Flags (E820_...) + +Example: + +chosen { + e820-entries = /bits/ 64 < + IOMAP_P2SB_BAR IOMAP P2SB_SIZE E820_RESERVED + MCH_BASE_ADDRESS MCH_SIZE E820_RESERVED>; +}; From patchwork Mon Jan 27 05:06:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229599 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=Ua3eZsbI; 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 485dXf3yZ5z9sR1 for ; Mon, 27 Jan 2020 16:26:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 846C381947; Mon, 27 Jan 2020 06:14:10 +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="Ua3eZsbI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0C5CE817DC; Mon, 27 Jan 2020 06:10:35 +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 EDAC7817B8 for ; Mon, 27 Jan 2020 06:09:45 +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 i7so3258478ilr.7 for ; Sun, 26 Jan 2020 21:09:45 -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=Sj7L449U862y/kdjPCCPNDp+EQwcoo++bMf3g0XzJaM=; b=Ua3eZsbIoyrzscdvm09j0v3SPZLCks9zFJFuegCqyyO96SRDosaCR4fGiWBXGKNhMS H5cvsFFdoyJzzPT3lgKV7R3rIyEWRjFtAqTHnLCv3oFDq16stDAqHT9/K5AX/SmexQmW 7AYMH1a7eonnqpgJYJJ9vgsvuv2QnY3uA9eQc= 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=Sj7L449U862y/kdjPCCPNDp+EQwcoo++bMf3g0XzJaM=; b=gBh6sWKjQ3Tu/LKrAzQ7j7GO0c83cLVYcsJyTg5EuVtYfQgdDfMlSVwoKADOGQjGzy 2SDhVpFgotqHv/ZbmDF8VzllZ4E1GEOaXnUf2qlp99uIqhwOdSPZLfv8tOtXdHgPpQQB JvZH2mn4ffSMTZRYO0Q459coiQWnQwo8YYhjFrXhy1iykXCNTNcZhxBzqvGjPE+fDNMX 57PU6ee9xSDmVXhfp0pLr3Xhufkz1Z6ruzrfjwKSmgmVvx4w3hqOdvUk9K9xS+kSG+p2 KYaEJX5manc7mas8/uA9Kht1eY6hSu+84jucrmbAYj7/WXthmkPuH5waTVSyIuySdizR AX9g== X-Gm-Message-State: APjAAAUdLmmS0V2n7y4+mPNRvP1Q3WyOgJeBYnYD6u3rnAx62ZS+tq9u n6LUNXfaGvYbea31nVgvRXu114l+eTrCUA== X-Google-Smtp-Source: APXvYqz6x4m98dAs2vq+T0rNb1wkZVSRtyZtvek7vOgeYnLBnVpFwXp5Gz2Y6DaEikMn8WLyNwBCTA== X-Received: by 2002:a92:290a:: with SMTP id l10mr13556884ilg.151.1580101784616; Sun, 26 Jan 2020 21:09:44 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:44 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 101/108] x86: Notify the FSP of the 'end firmware' event Date: Sun, 26 Jan 2020 22:06:48 -0700 Message-Id: <20200126220508.101.Ia7eec1e1c8296f88a09208428f654efffa8f4d4c@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 Send this notification when U-Boot is about to boot into Linux, as requested by the FSP. Signed-off-by: Simon Glass --- arch/x86/cpu/cpu.c | 15 +++++++++++++++ arch/x86/lib/fsp/fsp_common.c | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index a2df92cec9..15c76ff3cb 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -182,6 +182,14 @@ __weak void board_final_init(void) { } +/* + * Implement a weak default function for boards that need to do some final + * processing before booting the OS. + */ +__weak void board_final_cleanup(void) +{ +} + int last_stage_init(void) { struct acpi_fadt __maybe_unused *fadt; @@ -210,6 +218,13 @@ int last_stage_init(void) } #endif + /* + * TODO(sjg@chromium.org): Move this to bootm_announce_and_cleanup() + * once APL FSP-S at 0x200000 does not overlap with the bzimage at + * 0x100000. + */ + board_final_cleanup(); + return 0; } #endif diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c index 8a6108fb32..2eeb697ad7 100644 --- a/arch/x86/lib/fsp/fsp_common.c +++ b/arch/x86/lib/fsp/fsp_common.c @@ -58,6 +58,22 @@ void board_final_init(void) debug("OK\n"); } +void board_final_cleanup(void) +{ + u32 status; + + /* TODO(sjg@chromium.org): This causes Linux to crash */ + return; + + /* call into FspNotify */ + debug("Calling into FSP (notify phase INIT_PHASE_END_FIRMWARE): "); + status = fsp_notify(NULL, INIT_PHASE_END_FIRMWARE); + if (status) + debug("fail, error code %x\n", status); + else + debug("OK\n"); +} + #ifdef CONFIG_HAVE_ACPI_RESUME int fsp_save_s3_stack(void) { From patchwork Mon Jan 27 05:06:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229602 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=LUaBimM6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dYJ3h9xz9sR1 for ; Mon, 27 Jan 2020 16:27:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5064C8194E; Mon, 27 Jan 2020 06:14:18 +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="LUaBimM6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4ED6F817F8; Mon, 27 Jan 2020 06:10:38 +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-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (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 ABAA38177D for ; Mon, 27 Jan 2020 06:09:46 +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-xd42.google.com with SMTP id n11so8554280iom.9 for ; Sun, 26 Jan 2020 21:09:46 -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=EJQutg0W/2cyqpx7DVXztLh5TNq9ECnaPV6xTSRYlaQ=; b=LUaBimM6Um/xNRjqDov+mVEIW56tdMtJ0sOTO1rhHMxLLkHy0mR8mT14tfXPIpK7t/ G4gT7q3ZpJOLYIRdTmJHmkd/2IT93eLF/CAMN/p3UNq0k1HaTLNfy8IptCaVrD5GeBXa FP8MDdANzCoBLDAViDE6OaI21PVW1qmK9CzeQ= 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=EJQutg0W/2cyqpx7DVXztLh5TNq9ECnaPV6xTSRYlaQ=; b=HcZGerwemyG4KQMpG+rifvdcwIUC238NWb2/lXDuwY3FiD1p590TnbFME8+sty5fvw WBCpoWtjbpUCZSgL9TF1Jly/AxjoEIExBy/pXKaVaryywkSDZXDnn9CkhonhYke73SKy g9as427uIO2rQwEMCsv8KNTS70IaeZJQ1aB9vBhzRTAM/xn+AOeHUO6XkRAQhacRBSVW lHCoTGXmSrS8Oa7X19h18nhAzJLhXQ9tf4M/oMxFKhIIQK50VsDarxwjwKPV+tBGkKld 2PZ0fALVvGFZz4eTcIJHf//MW7WMmAOh3XqxwMlIPwqBw2DmGf7ArwYktYmMTNhHa+Lo 2ZQQ== X-Gm-Message-State: APjAAAXLgDUz8gAK/RfaZLpe6bjiJ5fe2jT6510lM8A+v391hRZasA8q oYTKhjPn6tpc2qxhhMTmEMc8vKPM2MHfYA== X-Google-Smtp-Source: APXvYqyT9SY2wCtAgx8chEHdFq2cC0mFxywpBTviV7BsMU37VbKxhOadDT4G1qHGqy4KRC0Thu68Sw== X-Received: by 2002:a05:6602:2113:: with SMTP id x19mr6696637iox.227.1580101785447; Sun, 26 Jan 2020 21:09:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 102/108] x86: Add a layout for Chrome OS verified boot Date: Sun, 26 Jan 2020 22:06:49 -0700 Message-Id: <20200126220508.102.I7705f4557d04102288614f5c447395fdadebc36f@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 Add definitions for part of the vboot context used with verified boot. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi/vbnv_layout.h | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 arch/x86/include/asm/acpi/vbnv_layout.h diff --git a/arch/x86/include/asm/acpi/vbnv_layout.h b/arch/x86/include/asm/acpi/vbnv_layout.h new file mode 100644 index 0000000000..377ff1d5cc --- /dev/null +++ b/arch/x86/include/asm/acpi/vbnv_layout.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __VBOOT_VBNV_LAYOUT_H__ +#define __VBOOT_VBNV_LAYOUT_H__ + +#define VBOOT_VBNV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */ + +/* Constants for NV storage. We use this rather than structs and + * bitfields so the data format is consistent across platforms and + * compilers. + */ +#define HEADER_OFFSET 0 +#define HEADER_MASK 0xC0 +#define HEADER_SIGNATURE 0x40 +#define HEADER_FIRMWARE_SETTINGS_RESET 0x20 +#define HEADER_KERNEL_SETTINGS_RESET 0x10 + +#define BOOT_OFFSET 1 +#define BOOT_DEBUG_RESET_MODE 0x80 +#define BOOT_DISABLE_DEV_REQUEST 0x40 +#define BOOT_DISPLAY_REQUEST 0x20 +#define BOOT_TRY_B_COUNT_MASK 0x0F + +#define RECOVERY_OFFSET 2 +#define LOCALIZATION_OFFSET 3 + +#define DEV_FLAGS_OFFSET 4 +#define DEV_BOOT_USB_MASK 0x01 +#define DEV_BOOT_SIGNED_ONLY_MASK 0x02 +#define DEV_ENABLE_UDC 0x40 + +#define MISC_FLAGS_OFFSET 8 +#define MISC_FLAGS_BATTERY_CUTOFF_MASK 0x08 + +#define KERNEL_FIELD_OFFSET 11 +#define CRC_OFFSET 15 + +#endif /* __VBOOT_VBNV_LAYOUT_H__ */ From patchwork Mon Jan 27 05:06:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229600 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=b8Z8kYMt; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dXt2VDdz9sR1 for ; Mon, 27 Jan 2020 16:27:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A70D281948; Mon, 27 Jan 2020 06:14:13 +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="b8Z8kYMt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A421C817DC; Mon, 27 Jan 2020 06:10:36 +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 53F3D80929 for ; Mon, 27 Jan 2020 06:09:47 +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 x1so8556548iop.7 for ; Sun, 26 Jan 2020 21:09:47 -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=+STQbh/bPot9/2k1WDFKesh2JcuoaIpNiOlmQpk96Ww=; b=b8Z8kYMt1nVdkXELTZAOyhHuHLPHVLGNUrCJNBcPjU8peAn/pXMORKf7TfUjJYDUY7 U7iam0PG9ADbCQos/PLT3h2d5pnY0G1GvJpCWodAxSWclO5t0OIDpVsUcMfphYRLInF6 /uCnT8l06H6gM77NjlbkkxtWfFyBOdj35uc2Y= 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=+STQbh/bPot9/2k1WDFKesh2JcuoaIpNiOlmQpk96Ww=; b=mYcG09l3SJWJUN1KRR+TaoWBc+jIsbs3LE+Rjkgd/oRSdE8oN0S/BxxJCZktKEcg38 Z1xM6hLpcG/EjoREmo7nAzE69EJ+d4c8qVdcebvNut8zw2ot5FaCC8ubcORUwJoMWVcU wwtDsdhxqw432OafY+gkNHybJsDDmIFiBvG8giYR88jLWSELQvwrtDRRwVp4LaxcEDJI kolvzt5vNuOJ4j5ASuRHo2uFwWxkG3yIRJZkRsBUu3nQLZG2gX2r+BaaCkS65jf89i0l 1CkfBfshTFVrYXKvLRvWlcNgv/JQZdfnF1eeci1OyhijETQYyF8Jhh0rTireip8Rhq+Q 7oVQ== X-Gm-Message-State: APjAAAUdkY4hOJ2X5/CfW8a6YozF4USXioAiiFgUbpjHrbpDbWaOFMiY rpkJy3/1xOwF/7o3ECHTuSKYIC4eIgs44w== X-Google-Smtp-Source: APXvYqzhAe/uBRpWny9+2dBCgWvlPNWkD15frCMjhRHFy304U4th5aLZK3j89dLsN8NPhj+IRxqfQQ== X-Received: by 2002:a02:b683:: with SMTP id i3mr10506105jam.105.1580101786126; Sun, 26 Jan 2020 21:09:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:45 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 103/108] x86: Correct the assembly guard in e802.h Date: Sun, 26 Jan 2020 22:06:50 -0700 Message-Id: <20200126220508.103.I53dd50cd3b5d7b10e23a609538b86989ba9b580a@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 This is currently in the wrong place so including the file in the device tree fails. Fix it. Signed-off-by: Simon Glass --- arch/x86/include/asm/e820.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index 9d29f82f97..87af0f492e 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h @@ -21,10 +21,9 @@ struct e820_entry { #define ISA_START_ADDRESS 0xa0000 #define ISA_END_ADDRESS 0x100000 -#endif /* __ASSEMBLY__ */ - /* Implementation defined function to install an e820 map */ unsigned int install_e820_map(unsigned int max_entries, struct e820_entry *); +#endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_E820_H */ From patchwork Mon Jan 27 05:06:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229603 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=RLwAJLh4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dYV5561z9sR1 for ; Mon, 27 Jan 2020 16:27:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA01581955; Mon, 27 Jan 2020 06:14:20 +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="RLwAJLh4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEF9A817FB; Mon, 27 Jan 2020 06:10:38 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 0861C817EB for ; Mon, 27 Jan 2020 06:09:48 +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-xd44.google.com with SMTP id c16so8568301ioh.6 for ; Sun, 26 Jan 2020 21:09:47 -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=On24iE7RHkp6qqW5VUTNe5hCMtxmPuwbQz+Qx1QJMPA=; b=RLwAJLh4/i5Mq9jD7d/XX+RbR+H7bxyOyYNeI9p8Qm3Phed2p3zlRAdtbkArOChqob 9sdpiWBVh88lmqvTxR4HDn28rB3unBIPb0DOB5jHhJR2bEQe9+iUIU7F1pOBxF8DSoyu FROdO5MkJMT/GZIGaK+QcPm9J83nTRTPisgcg= 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=On24iE7RHkp6qqW5VUTNe5hCMtxmPuwbQz+Qx1QJMPA=; b=ZWuHO8FcLAflni7Gl1+5ih4fBlsujBXNk/Pyy9KJoL09EM4xVoz1S2WaGW5QgYdlYf L97oCm8oF5PRkUVW4zkoyJ5EcnrI3kyA9Uh8A1DhiUfXDO8m3UydNfwbHhglijF6DoFa yryjElzIZOKlVhOFvZbkJKsj2iM54R3CVwjah0FOk6oiSbj8Mf25wboT00n3q/ZWTMzT HnXPiQ3eIrd9dlShlFghqOq5pPgFMIcJkIL7YH7modWeY05QUBcVJkjhvY6CHmnwBlgp E1ScFZ0E3tt4/6VxaAuts+EGall17mgqY/ppC/KgZieIlze82l+SPGxTEp+R5ewqNi5C s9Vw== X-Gm-Message-State: APjAAAVUCzOjs/ifb5CeYa3y/RIAPpXoIj6/XMkH5J+6rWgPMyVEkVAT feFt3URfAHMezDW5Xq3/+VfrQ2kFbVVIoQ== X-Google-Smtp-Source: APXvYqwmeTisvPFfe0s2GQWh7DyhgEluvj14+ikXwcFXbqT4Xt3gi3D+JdWQywUKSweuKOr6Bbetfw== X-Received: by 2002:a6b:8e47:: with SMTP id q68mr10823391iod.274.1580101786821; Sun, 26 Jan 2020 21:09:46 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:46 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 104/108] x86: Add a header guard to asm/acpi_table.h Date: Sun, 26 Jan 2020 22:06:51 -0700 Message-Id: <20200126220508.104.I9e03b830f5f0096a5b4c9c6355280a5e09429fa9@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 This file cannot currently be included in ASL files. Add a header guard to permit this. Signed-off-by: Simon Glass --- arch/x86/include/asm/acpi_table.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 1f2076753c..17b92a41fa 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -9,6 +9,8 @@ #ifndef __ASM_ACPI_TABLE_H__ #define __ASM_ACPI_TABLE_H__ +#ifndef __ACPI__ + /* These can be used by the target port */ void acpi_fill_header(struct acpi_table_header *header, char *signature); @@ -51,4 +53,6 @@ int arch_write_sci_irq_select(uint scis); int arch_madt_sci_irq_polarity(int sci); struct acpi_cstate *arch_get_cstate_map(size_t *entries); +#endif /* !__ACPI__ */ + #endif /* __ASM_ACPI_TABLE_H__ */ From patchwork Mon Jan 27 05:06:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229604 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=fwtp+Qkb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dYk011zz9sR1 for ; Mon, 27 Jan 2020 16:27:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABF018195B; Mon, 27 Jan 2020 06:14:23 +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="fwtp+Qkb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8297817F8; Mon, 27 Jan 2020 06:10: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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 A6151817BC for ; Mon, 27 Jan 2020 06:09:48 +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-xd44.google.com with SMTP id z8so8589371ioh.0 for ; Sun, 26 Jan 2020 21:09:48 -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=3mLAtaFlnZA76ffWQGiv42v9Zt/uSj3slspIoqwxon4=; b=fwtp+QkbapwjRphY/rZc6jCd6U1MlOSXmBtxDQh9Vc9CJ30zzpRz7Et1CYcCeM+lrL woGDV4AvHwvg8oVIpBg2rPz6Wa60RG+wFidtV5JS+cSRPvTONU66pxelN6zlisCoV3ki s4W0N4FRIZpdcnNi5gRzaF+8LL88OPiQOTxCo= 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=3mLAtaFlnZA76ffWQGiv42v9Zt/uSj3slspIoqwxon4=; b=AxAmJITKF7qibdabf/silUyjI2I1NV8K7NKnUBBqgRIGQGc/1EerXv+Q8XAAIBt6He vuLyUqyyyJP/v0AkV2o1riX07ErUreQtKVXVhQXHA/9a+X0cx3rtCzh1tZciQJWCwK57 4IM/Lz8AHB7OgxaBGR3iwj+dNTd/NTR7uH+fLvBWIXhDTZ4ENFsBHzx2oPk+fFP5pwrb mRO/Urv6p2JpPk+rgZJGhsMEwQdkxX4g5Q3yV3ffh/MNyyVf+jFm77FqECSj+wL9L2oM Vw94onfeszysGFfd7MwxAM0gy1ArGa3nRYyswaI6PshCYoCN0TU3Cgg/E3amQLFxOPXY j+Sw== X-Gm-Message-State: APjAAAWxDaynvQM32EWqieFu52GB8rLRx+IZJFvBW2DY22PN4v3N2RMw dXwimNGxNU6MhlCxAGSuFUoAAI3mf4rEEA== X-Google-Smtp-Source: APXvYqyu1L1ukSX1vTfHpKCaqGj1+/33CtxDf/rQ+WehZvsj+mCTuf1i1IhUwvNItaDfCu3gRc+AQA== X-Received: by 2002:a02:3312:: with SMTP id c18mr11794958jae.24.1580101787505; Sun, 26 Jan 2020 21:09:47 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 105/108] x86: Correct handling of MADT table CPUs Date: Sun, 26 Jan 2020 22:06:52 -0700 Message-Id: <20200126220508.105.I8e0b81d8cce09072a295de1c034a2d84757a26af@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 At present if hyperthreading is disabled the CPU numbering is not sequential. Fix this. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 886960a5fa..e757dc419a 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -128,14 +128,17 @@ int acpi_create_madt_lapics(u32 current) { struct udevice *dev; int total_length = 0; + int cpu_num = 0; for (uclass_find_first_device(UCLASS_CPU, &dev); dev; uclass_find_next_device(&dev)) { struct cpu_platdata *plat = dev_get_parent_platdata(dev); - int length = acpi_create_madt_lapic( - (struct acpi_madt_lapic *)current, - plat->cpu_id, plat->cpu_id); + int length; + + length = acpi_create_madt_lapic( + (struct acpi_madt_lapic *)current, cpu_num++, + plat->cpu_id); current += length; total_length += length; } From patchwork Mon Jan 27 05:06:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229606 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=JPnVCo1g; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dZ73Tcgz9sR1 for ; Mon, 27 Jan 2020 16:28:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5610181813; Mon, 27 Jan 2020 06:14:28 +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="JPnVCo1g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7F8E817FB; Mon, 27 Jan 2020 06:10:41 +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-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 68D70817A7 for ; Mon, 27 Jan 2020 06:09:49 +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-x143.google.com with SMTP id f5so6452515ilq.5 for ; Sun, 26 Jan 2020 21:09:49 -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=EsUWe7HMUF98hDGyB2RxcTLnF/jb3eRNVG4XAA0c024=; b=JPnVCo1gpnQy0VQJ4Ah5gZ8yZjyot+EBimypoGEwlV5zcVEaQBiTmOfrKgvqBEH+tF StkfaHFzV5wiX68VtGHTtpZlRJVg8k6p9s5M5svIlkXg8HU9z+QnM/n/Tf2x3rcXzGlY +pUc4R7keYIPIIQbPwP7ENR/VGjnaVFTS0jgk= 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=EsUWe7HMUF98hDGyB2RxcTLnF/jb3eRNVG4XAA0c024=; b=eRhh4xs2WlSDPGfEdrVblTqwKuEvGDuWz5lEAJDQZWFSQecJZaCksKqhYqCf9Dlffz g5aM8xcG8M3kutbLoTZ1TlEDnpowr1A+8NaeZ02zAlLnPebSB4ZGC6EnpP7DVSq7z8Vm 1aSq6MEqOsLuG7Q5oqTPIWWFREij94FITN0e+97F2++pj2MSnpRSscSy4XDvU+KlpWaP 9OcXtRzjay92tfTYMlAp1ZfY8Godppq5aRZCch/T1dj08QmxfFpae4UNRrcDcjku5DGw 5FBIJFrbxgXKvbJ2KLSWIDf0aGRyNrG6agVEvpzm3Z+IDYchI/5hycpB6x4WMvZRHxUz vZgQ== X-Gm-Message-State: APjAAAX6qccenX0Ur29v52HFKHHC0yuPnSdQzY7a1WpwmFsRY3MfAYsX JTUoWrV4XdcFWRg8eXdYJ3+bNDsAYK4NhQ== X-Google-Smtp-Source: APXvYqxT0yiViQNxe7cIgPS8LzLI8Syd7jPKPLjWiSknH3IviuDTCNQrkqEPtlJf/XGh+HRng0gkSw== X-Received: by 2002:a92:d708:: with SMTP id m8mr12949129iln.244.1580101788178; Sun, 26 Jan 2020 21:09:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:47 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 106/108] acpi: tpm: Add a TPM2 table Date: Sun, 26 Jan 2020 22:06:53 -0700 Message-Id: <20200126220508.106.I01fe3266661295f6b3a4f1aebefb75d3838bdb32@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 This provides information about a v2 TPM in the system. Generate this table if the TPM is present. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 74 +++++++++++++++++++++++++++++++++++++++ include/acpi_table.h | 11 ++++++ include/bloblist.h | 1 + 3 files changed, 86 insertions(+) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index e757dc419a..1d12e58508 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -276,6 +277,64 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg) header->checksum = table_compute_checksum((void *)mcfg, header->length); } +static int get_tpm2_log(void **ptrp, int *sizep) +{ + const int tpm2_default_log_len = 0x10000; + int size; + int ret; + + *sizep = 0; + size = tpm2_default_log_len; + ret = bloblist_ensure_size_ret(BLOBLISTT_TPM2_TCG_LOG, &size, ptrp); + if (ret) + return log_msg_ret("blob", ret); + *sizep = size; + + return 0; +} + +static int acpi_create_tpm2(struct acpi_tpm2 *tpm2) +{ + struct acpi_table_header *header = &tpm2->header; + int tpm2_log_len; + void *lasa; + int ret; + + memset((void *)tpm2, 0, sizeof(struct acpi_tpm2)); + + /* + * Some payloads like SeaBIOS depend on log area to use TPM2. + * Get the memory size and address of TPM2 log area or initialize it. + */ + ret = get_tpm2_log(&lasa, &tpm2_log_len); + if (ret) + return ret; + + /* Fill out header fields. */ + acpi_fill_header(header, "TPM2"); + memcpy(header->aslc_id, ASLC_ID, 4); + + header->length = sizeof(struct acpi_tpm2); + header->revision = acpi_get_table_revision(ACPITAB_TPM2); + + /* Hard to detect for coreboot. Just set it to 0 */ + tpm2->platform_class = 0; + + /* Must be set to 0 for FIFO-interface support */ + tpm2->control_area = 0; + tpm2->start_method = 6; + memset(tpm2->msp, 0, sizeof(tpm2->msp)); + + /* Fill the log area size and start address fields. */ + tpm2->laml = tpm2_log_len; + tpm2->lasa = (uintptr_t)lasa; + + /* Calculate checksum. */ + header->checksum = table_compute_checksum((void *)tpm2, header->length); + + return 0; +} + __weak u32 acpi_fill_csrt(u32 current) { return current; @@ -768,6 +827,21 @@ ulong write_acpi_tables(ulong start_addr) acpi_inc_align(ctx, mcfg->header.length); acpi_add_table(ctx, mcfg); + if (IS_ENABLED(CONFIG_TPM_V2)) { + struct acpi_tpm2 *tpm2; + int ret; + + debug("ACPI: * TPM2\n"); + tpm2 = (struct acpi_tpm2 *)ctx->current; + ret = acpi_create_tpm2(tpm2); + if (!ret) { + acpi_inc_align(ctx, tpm2->header.length); + acpi_add_table(ctx, tpm2); + } else { + log_warning("TPM2 table creation failed\n"); + } + } + debug("ACPI: * MADT\n"); madt = ctx->current; acpi_create_madt(madt); diff --git a/include/acpi_table.h b/include/acpi_table.h index 17f2a90af9..3d51942d32 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -104,6 +104,17 @@ struct __packed acpi_hpet { u8 attributes; }; +struct __packed acpi_tpm2 { + struct acpi_table_header header; + u16 platform_class; + u8 reserved[2]; + u64 control_area; + u32 start_method; + u8 msp[12]; + u32 laml; + u64 lasa; +}; + /* FADT Preferred Power Management Profile */ enum acpi_pm_profile { ACPI_PM_UNSPECIFIED = 0, diff --git a/include/bloblist.h b/include/bloblist.h index 7c5b93be4c..d8dccf91fc 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -33,6 +33,7 @@ enum bloblist_tag_t { * Sleeping table. This forms part of the ACPI tables passed to Linux. */ BLOBLISTT_ACPI_GNVS, + BLOBLISTT_TPM2_TCG_LOG, /* TPM v2 log space */ }; /** From patchwork Mon Jan 27 05:06:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229605 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; 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=WKUu977r; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 485dYx1ZGwz9sR1 for ; Mon, 27 Jan 2020 16:28:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FE028195E; Mon, 27 Jan 2020 06:14:26 +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="WKUu977r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5AF32817FF; Mon, 27 Jan 2020 06:10:40 +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-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 2846A81810 for ; Mon, 27 Jan 2020 06:09:50 +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-xd43.google.com with SMTP id m25so8557778ioo.8 for ; Sun, 26 Jan 2020 21:09:50 -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=Nj8sai1K30YRw6Xi3Q8ECZpbugJMM4shULJzLjrc4ME=; b=WKUu977r4xwS2KMzqmu0EMjLrEjvLA/dkoT43+Jsnx+q+6LFqFqCOPJwRuzCn1EUu3 eCY3TWlp4Kjoh1Ur5tPmCA1qojWf4voCf6PTo8xGB5rQWRSs1UJzXwRS99n0Bm6L65z/ 1LbTQf09Dap/f1BKUR9rcfoXypnuK/zTMG5k4= 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=Nj8sai1K30YRw6Xi3Q8ECZpbugJMM4shULJzLjrc4ME=; b=S3Ij5GR5VZRkHmmshY/VH71foI4PN9HcWW2GpVu/CcxqLm4UQiu7u4yi8DT8vrBzz0 hiqbuDsfDvTzjwCZTwhURxYXO3LdkNgg0qNVTu+r00rg2/20P4DsWLeTgzrmTdCyr8cm KjHK6sQja9vDXysXHfNAKlG126Pv/LMJvj09J8UsJCGMqM/UHro2YT7DnhYSunNT0WPP G+Es5AJXXVGk20aDiNBIKrDmDITiipAEjIaV9Att1fqeTEnv0nyUcKjNg/8UlHlShQ9L lHtd7g5RK77dvQ5Ky4eS/9kzM5cWvsWqYxpN3vMEPVuMUWjRM4vVnWUqxSA0t0Q/EaOx pkWg== X-Gm-Message-State: APjAAAWbDH+e+sD0XXQPgaxvXOUSQ4Vl/TFrBU/7a0l2VqZ8mh0QWG5D q8rHOyeUbKyRF06h63kmzXC38IzO2Rc8cA== X-Google-Smtp-Source: APXvYqwL5AjHvqasn8Ga09I8J00jL0yGh8RgVA/Ln9rhpcyffcF1bqCWX1+obJ8yXJIGoHTfFVR/cg== X-Received: by 2002:a02:c78f:: with SMTP id n15mr11986052jao.100.1580101788867; Sun, 26 Jan 2020 21:09:48 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:48 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 107/108] acpi: tpm: Add a TPM1 table Date: Sun, 26 Jan 2020 22:06:54 -0700 Message-Id: <20200126220508.107.I01fe3266661295f6b3a4f1aebefb75d3838bdb32@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 This provides information about a v1 TPM in the system. Generate this table if the TPM is present. Add a required new bloblist type and correct the header order of one header file. Signed-off-by: Simon Glass --- arch/x86/lib/acpi_table.c | 52 ++++++++++++++++++++++++++++++++++++++- include/acpi_table.h | 7 ++++++ include/bloblist.h | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 1d12e58508..564c5167c9 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -277,6 +277,45 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg) header->checksum = table_compute_checksum((void *)mcfg, header->length); } +/** + * acpi_create_tcpa() - Create a TCPA table + * + * @tcpa: Pointer to place to put table + * + * Trusted Computing Platform Alliance Capabilities Table + * TCPA PC Specific Implementation SpecificationTCPA is defined in the PCI + * Firmware Specification 3.0 + */ +static int acpi_create_tcpa(struct acpi_tcpa *tcpa) +{ + struct acpi_table_header *header = &tcpa->header; + u32 current = (u32)tcpa + sizeof(struct acpi_tcpa); + int size = 0x10000; /* Use this as the default size */ + void *log; + int ret; + + memset(tcpa, '\0', sizeof(struct acpi_tcpa)); + + /* Fill out header fields */ + acpi_fill_header(header, "TCPA"); + header->length = sizeof(struct acpi_tcpa); + header->revision = 1; + + ret = bloblist_ensure_size_ret(BLOBLISTT_TCPA_LOG, &size, &log); + if (ret) + return log_msg_ret("blob", ret); + + tcpa->platform_class = 0; + tcpa->laml = size; + tcpa->lasa = (ulong)log; + + /* (Re)calculate length and checksum */ + header->length = current - (u32)tcpa; + header->checksum = table_compute_checksum((void *)tcpa, header->length); + + return 0; +} + static int get_tpm2_log(void **ptrp, int *sizep) { const int tpm2_default_log_len = 0x10000; @@ -737,11 +776,13 @@ ulong write_acpi_tables(ulong start_addr) struct acpi_fadt *fadt; struct acpi_table_header *ssdt; struct acpi_mcfg *mcfg; + struct acpi_tcpa *tcpa; struct acpi_madt *madt; struct acpi_csrt *csrt; struct acpi_spcr *spcr; void *start; ulong addr; + int ret; int i; start = map_sysmem(start_addr, 0); @@ -829,7 +870,6 @@ ulong write_acpi_tables(ulong start_addr) if (IS_ENABLED(CONFIG_TPM_V2)) { struct acpi_tpm2 *tpm2; - int ret; debug("ACPI: * TPM2\n"); tpm2 = (struct acpi_tpm2 *)ctx->current; @@ -848,6 +888,16 @@ ulong write_acpi_tables(ulong start_addr) acpi_inc_align(ctx, madt->header.length); acpi_add_table(ctx, madt); + debug("ACPI: * TCPA\n"); + tcpa = (struct acpi_tcpa *)ctx->current; + ret = acpi_create_tcpa(tcpa); + if (ret) { + log_warning("Failed to create TCPA table (err=%d)\n", ret); + } else { + acpi_inc_align(ctx, tcpa->header.length); + acpi_add_table(ctx, tcpa); + } + debug("ACPI: * CSRT\n"); csrt = ctx->current; acpi_create_csrt(csrt); diff --git a/include/acpi_table.h b/include/acpi_table.h index 3d51942d32..b5ba37cd28 100644 --- a/include/acpi_table.h +++ b/include/acpi_table.h @@ -115,6 +115,13 @@ struct __packed acpi_tpm2 { u64 lasa; }; +struct __packed acpi_tcpa { + struct acpi_table_header header; + u16 platform_class; + u32 laml; + u64 lasa; +}; + /* FADT Preferred Power Management Profile */ enum acpi_pm_profile { ACPI_PM_UNSPECIFIED = 0, diff --git a/include/bloblist.h b/include/bloblist.h index d8dccf91fc..d7661bc111 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -34,6 +34,7 @@ enum bloblist_tag_t { */ BLOBLISTT_ACPI_GNVS, BLOBLISTT_TPM2_TCG_LOG, /* TPM v2 log space */ + BLOBLISTT_TCPA_LOG, /* TPM log space */ }; /** From patchwork Mon Jan 27 05:06:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1229607 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=EWpJyN4Q; 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 485dZL2kSJz9sR1 for ; Mon, 27 Jan 2020 16:28:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16F6781923; Mon, 27 Jan 2020 06:14:31 +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="EWpJyN4Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA03C817FF; Mon, 27 Jan 2020 06:10:43 +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-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (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 ED6E28178D for ; Mon, 27 Jan 2020 06:09:50 +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-xd44.google.com with SMTP id s24so7030587iog.5 for ; Sun, 26 Jan 2020 21:09:50 -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=Bt38lXPhuIQH8VsOJFi4RH0eO6qSdLGoIbLo2miRewQ=; b=EWpJyN4QE//dHESh6vGzSIUUcLNlsPMicrPFMDpuMrIImR5LE3lcDlKkt91bqOI0CY 6jbeZbTiMTkdDvvro2ST4EQF/FEVZlsLxAjUZyJ5iRAwMdUZ//ez9l3z9kOSeByHcLTg HsMale2rLCJhnn3bnyqzxrVTg5XR5qP9Gr9bI= 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=Bt38lXPhuIQH8VsOJFi4RH0eO6qSdLGoIbLo2miRewQ=; b=UCkRfIoC2YEgjl01mwc5ptT8S8peqkyTJeD4jB7eBstem/4u2pPmqvSNwlUj1EDy8s aqNuxwrw1ZaF1SSNX15/rZodVOngzT+5KAQuE7LJnoW8A22Q7tJ8SN9/Xg3Huv/WbiOk XsjTtXSEM+H4si790miD+fAYFpfug9metVMSpBXoxh3LPJroGKqSTPS+ziAy4DpyfPid A3hnYVn3vjxqIx+hYcJK4JWegWEV9RyFig9HlN2psloUbVExoYtS0GB2TD7AF0ikBsrb 4rldOIxEa3MZTGse3uwYje4nPdy8AlbLfbbd9qNh+5o1+I9jU+8mGwj0h/D/p00n8Dvm Dvnw== X-Gm-Message-State: APjAAAUu1f1daB/dQb4k7tvHLtFHd2ok+sufMKgS8xGCm1tj7lqnA0To uou0Fh5QxK7/IwafLGbSYtFtvKQmyMjNHg== X-Google-Smtp-Source: APXvYqx9mu9H2K0+/sS9wn9pE9g7HZxWzwoCD3UGmjA5y9mztgdKq6ftNOr3F2dqzW6+Iqdu3ws4Iw== X-Received: by 2002:a5e:aa18:: with SMTP id s24mr3092944ioe.221.1580101789604; Sun, 26 Jan 2020 21:09:49 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 21:09:49 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 108/108] x86: coral: Update config and device tree for ACPI Date: Sun, 26 Jan 2020 22:06:55 -0700 Message-Id: <20200126220508.108.I8e5bc7fe3b0140af9d245362e844d1d3eb3f8bf4@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 Enable new features and provide require device-tree config so that U-Boot produces the correct ACPI tables on Coral. Signed-off-by: Simon Glass --- arch/x86/dts/chromebook_coral.dts | 193 ++++++++++++++++++++++++++++- configs/chromebook_coral_defconfig | 14 ++- 2 files changed, 199 insertions(+), 8 deletions(-) diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index 3c6f14310f..1d16975f5c 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -16,8 +16,12 @@ #endif #include +#include +#include +#include #include #include +#include #include #include #include @@ -38,6 +42,14 @@ i2c5 = &i2c_5; i2c6 = &i2c_6; i2c7 = &i2c_7; + mmc1 = &sdmmc; + }; + + board: board { + compatible = "google,coral"; + recovery-gpios = <&gpio_nw (-1) GPIO_ACTIVE_LOW>; + write-protect-gpios = <&gpio_nw GPIO_75 GPIO_ACTIVE_HIGH>; + phase-enforce-gpios = <&gpio_n GPIO_10 GPIO_ACTIVE_HIGH>; }; config { @@ -46,6 +58,15 @@ chosen { stdout-path = &serial; + e820-entries = /bits/ 64 < + IOMAP_P2SB_BAR IOMAP_P2SB_SIZE E820_RESERVED + MCH_BASE_ADDRESS MCH_SIZE E820_RESERVED>; + u-boot,acpi-ssdt-order = <&cpu_0 + &i2c_0 &i2c_1 &i2c_2 &i2c_3 &i2c_4 &i2c_5 + &sdmmc &maxim_codec &wifi &da_codec &tpm + &elan_touchscreen &raydium_touchscreen + &elan_touchpad &synaptics_touchpad &wacom_digitizer>; + u-boot,acpi-dsdt-order = <&board &lpc>; }; clk: clock { @@ -58,7 +79,7 @@ #address-cells = <1>; #size-cells = <0>; - cpu@0 { + cpu_0: cpu@0 { u-boot,dm-pre-reloc; device_type = "cpu"; compatible = "intel,apl-cpu"; @@ -133,21 +154,29 @@ compatible = "intel,apl-punit"; }; + gma@2,0 { + reg = <0x00001000 0 0 0 0>; + compatible = "intel,gma"; + }; + p2sb: p2sb@d,0 { u-boot,dm-pre-reloc; reg = <0x02006810 0 0 0 0>; compatible = "intel,apl-p2sb"; early-regs = ; + pci,no-autoconfig; n { compatible = "intel,apl-pinctrl"; u-boot,dm-pre-reloc; intel,p2sb-port-id = ; + acpi,path = "\\_SB.GPO0"; gpio_n: gpio-n { compatible = "intel,gpio"; u-boot,dm-pre-reloc; gpio-controller; #gpio-cells = <2>; + linux-name = "INT3452:00"; }; }; @@ -156,11 +185,13 @@ compatible = "intel,apl-pinctrl"; intel,p2sb-port-id = ; #gpio-cells = <2>; + acpi,path = "\\_SB.GPO1"; gpio_nw: gpio-nw { compatible = "intel,gpio"; u-boot,dm-pre-reloc; gpio-controller; #gpio-cells = <2>; + linux-name = "INT3452:01"; }; }; @@ -169,11 +200,13 @@ compatible = "intel,apl-pinctrl"; intel,p2sb-port-id = ; #gpio-cells = <2>; + acpi,path = "\\_SB.GPO2"; gpio_w: gpio-w { compatible = "intel,gpio"; u-boot,dm-pre-reloc; gpio-controller; #gpio-cells = <2>; + linux-name = "INT3452:02"; }; }; @@ -182,11 +215,13 @@ compatible = "intel,apl-pinctrl"; intel,p2sb-port-id = ; #gpio-cells = <2>; + acpi,path = "\\_SB.GPO3"; gpio_sw: gpio-sw { compatible = "intel,gpio"; u-boot,dm-pre-reloc; gpio-controller; #gpio-cells = <2>; + linux-name = "INT3452:03"; }; }; @@ -235,6 +270,23 @@ gpe0-en = <0x30>; }; + audio@e,0 { + reg = <0x7000 0 0 0 0>; + compatible = "simple-bus"; + acpi,name = "HDAS"; + i2s { + compatible = "fred"; + }; + maxim_codec: maxim-codec { + compatible = "maxim,max98357a"; + acpi,desc = "Maxim Integrated 98357A Amplifier"; + sdmode-gpios = <&gpio_n GPIO_76 GPIO_ACTIVE_HIGH>; + sdmode-delay = <5>; + acpi,name = "MAXM"; + acpi,hid = "MX98357A"; + }; + }; + spi: fast-spi@d,2 { u-boot,dm-pre-reloc; reg = <0x02006a10 0 0 0 0>; @@ -264,19 +316,60 @@ }; }; + /* WiFi */ + pcie-a0@14,0 { + reg = <0x0000a000 0 0 0 0>; + acpi,name = "RP01"; + wifi: wifi { + compatible = "intel,generic-wifi"; + acpi,desc = "Intel WiFi"; + acpi,name = "WF00"; + acpi,wake = ; + interrupts-extended = <&acpi_gpe 0x3c 0>; + }; + }; + i2c_0: i2c2@16,0 { compatible = "intel,apl-i2c"; reg = <0x0200b010 0 0 0 0>; clocks = <&clk CLK_I2C>; i2c-scl-rising-time-ns = <104>; i2c-scl-falling-time-ns = <52>; + clock-frequency = <400000>; + i2c,speeds = <100000 400000 1000000>; + #address-cells = <1>; + #size-cells = <0>; + da_codec: da-codec { + reg = <0x1a>; + compatible = "dlg,da7219"; + interrupts-extended = <&acpi_gpe GPIO_116_IRQ + (IRQ_TYPE_LEVEL_LOW | X86_IRQ_TYPE_SHARED)>; + acpi,name = "DLG7"; + acpi,desc = "Dialog Semiconductor DA7219 Audio Codec"; + dlg,btn-cfg = <50>; + dlg,mic-det-thr = <500>; + dlg,jack-ins-deb = <20>; + dlg,jack-det-rate = "32ms_64ms"; + dlg,jack-rem-deb = <1>; + dlg,a-d-btn-thr = <0xa>; + dlg,d-b-btn-thr = <0x16>; + dlg,b-c-btn-thr = <0x21>; + dlg,c-mic-btn-thr = <0x3e>; + dlg,btn-avg = <4>; + dlg,adc-1bit-rpt = <1>; + dlg,micbias-lvl = <2600>; + dlg,mic-amp-in-sel = "diff"; + }; }; i2c_1: i2c2@16,1 { compatible = "intel,apl-i2c"; reg = <0x0200b110 0 0 0 0>; clocks = <&clk CLK_I2C>; - status = "disabled"; + clock-frequency = <400000>; + i2c,speeds = <100000 400000 1000000 3400000>; + i2c-scl-rising-time-ns = <52>; + i2c-scl-falling-time-ns = <52>; }; i2c_2: i2c2@16,2 { @@ -285,41 +378,119 @@ #address-cells = <1>; #size-cells = <0>; clock-frequency = <400000>; + i2c,speeds = <100000 400000 1000000>; clocks = <&clk CLK_I2C>; i2c-scl-rising-time-ns = <57>; i2c-scl-falling-time-ns = <28>; - tpm@50 { + tpm: tpm@50 { reg = <0x50>; compatible = "google,cr50"; u-boot,i2c-offset-len = <0>; ready-gpios = <&gpio_n 28 GPIO_ACTIVE_LOW>; - interrupts-extended = <&acpi_gpe 0x3c 0>; + interrupts-extended = <&acpi_gpe GPIO_28_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,hid = "GOOG0005"; + acpi,desc = "I2C TPM"; + acpi,name = "TPMI"; }; }; i2c_3: i2c2@16,3 { compatible = "intel,apl-i2c"; reg = <0x0200b110 0 0 0 0>; + #address-cells = <1>; + #size-cells = <0>; clocks = <&clk CLK_I2C>; i2c-scl-rising-time-ns = <76>; i2c-scl-falling-time-ns = <164>; + clock-frequency = <400000>; + i2c,speeds = <100000 400000>; + elan_touchscreen: elan-touchscreen@10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,desc = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>; + reset-delay-ms = <20>; + enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>; + enable-delay-ms = <1>; + acpi,has-power-resource; + }; + + raydium_touchscreen: raydium-touchscreen@39 { + compatible = "i2c-chip"; + reg = <0x39>; + acpi,hid = "RAYD0001"; + acpi,desc = "Raydium Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,probed; + reset-gpios = <&gpio_n GPIO_36 GPIO_ACTIVE_HIGH>; + reset-delay-ms = <1>; + enable-gpios = <&gpio_n GPIO_152 GPIO_ACTIVE_HIGH>; + enable-delay-ms = <50>; + acpi,has-power-resource; + }; }; i2c_4: i2c2@17,0 { compatible = "intel,apl-i2c"; reg = <0x0200b110 0 0 0 0>; + #address-cells = <1>; + #size-cells = <0>; clocks = <&clk CLK_I2C>; i2c-sda-hold-time-ns = <350>; i2c-scl-rising-time-ns = <114>; i2c-scl-falling-time-ns = <164>; + clock-frequency = <400000>; + i2c,speeds = <100000 400000>; + elan_touchpad: elan-touchpad@15 { + compatible = "i2c-chip"; + reg = <0x15>; + acpi,hid = "ELAN0000"; + acpi,desc = "ELAN Touchpad"; + interrupts-extended = <&acpi_gpe GPIO_18_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,wake = ; + acpi,probed; + }; + synaptics_touchpad: synaptics-touchpad@2c { + compatible = "i2c-chip"; + reg = <0x2c>; + acpi,hid = "PNP0C50"; + acpi,cid = "PNP0C50"; + acpi,desc = "Synaptics Touchpad"; + interrupts-extended = <&acpi_gpe GPIO_18_IRQ + IRQ_TYPE_EDGE_FALLING>; + acpi,wake = ; + acpi,probed; + acpi,hid-desc-reg-offset = <0x20>; + }; }; i2c_5: i2c2@17,1 { compatible = "intel,apl-i2c"; reg = <0x0200b110 0 0 0 0>; + #address-cells = <1>; + #size-cells = <0>; clocks = <&clk CLK_I2C>; i2c-scl-rising-time-ns = <76>; i2c-scl-falling-time-ns = <164>; + clock-frequency = <400000>; + i2c,speeds = <100000 400000 1000000>; + wacom_digitizer: wacom-digitizer@9 { + compatible = "i2c-chip"; + reg = <0x9>; + acpi,hid = "WCOM50C1"; + acpi,cid = "PNP0C50"; + acpi,desc = "WCOM Digitizer"; + interrupts-extended = <&acpi_gpe GPIO_13_IRQ + (IRQ_TYPE_LEVEL_LOW | X86_IRQ_TYPE_SHARED)>; + acpi,hid-desc-reg-offset = <0x1>; + }; }; i2c_6: i2c2@17,2 { @@ -344,6 +515,15 @@ reg-shift = <2>; clock-frequency = <1843200>; current-speed = <115200>; + acpi,name = "URT3"; + pci,no-autoconfig; + }; + + sdmmc: sdmmc@1b,0 { + reg = <0x0000d800 0 0 0 0>; + compatible = "intel,apl-sd"; + cd-gpios = <&gpio_n GPIO_177 GPIO_ACTIVE_LOW>; + acpi,name = "SDCD"; }; pch: pch@1f,0 { @@ -353,7 +533,7 @@ #address-cells = <1>; #size-cells = <1>; - lpc { + lpc: lpc { compatible = "intel,apl-lpc"; #address-cells = <1>; #size-cells = <0>; @@ -505,6 +685,9 @@ /* GPIO for SD card detect */ sdcard-cd-gpio = ; + prt0-gpio = ; + sdcard-cd-gpio = ; + /* * Order is emmc-tx-data-cntl1, emmc-tx-data-cntl2, * emmc-rx-cmd-data-cntl1, emmc-rx-cmd-data-cntl2 diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig index 0999fb57c6..131c37c798 100644 --- a/configs/chromebook_coral_defconfig +++ b/configs/chromebook_coral_defconfig @@ -1,6 +1,7 @@ CONFIG_X86=y CONFIG_SYS_TEXT_BASE=0x1110000 CONFIG_SYS_MALLOC_F_LEN=0x3d00 +CONFIG_MAX_CPUS=8 CONFIG_SPL_SYS_MALLOC_F_LEN=0xf000 CONFIG_NR_DRAM_BANKS=8 CONFIG_BOOTSTAGE_STASH_ADDR=0xfef00000 @@ -11,9 +12,11 @@ CONFIG_VENDOR_GOOGLE=y CONFIG_TARGET_CHROMEBOOK_CORAL=y CONFIG_DEBUG_UART=y CONFIG_FSP_VERSION2=y +CONFIG_GENERATE_PIRQ_TABLE=y +CONFIG_GENERATE_ACPI_TABLE=y CONFIG_HAVE_ACPI_RESUME=y CONFIG_INTEL_CAR_CQOS=y -CONFIG_X86_OFFSET_U_BOOT=0xffe00000 +CONFIG_X86_OFFSET_U_BOOT=0xffd00000 CONFIG_X86_OFFSET_SPL=0xffe80000 CONFIG_INTEL_GENERIC_WIFI=y CONFIG_SPL_TEXT_BASE=0xfef10000 @@ -24,14 +27,15 @@ CONFIG_BOOTSTAGE_REPORT=y CONFIG_SPL_BOOTSTAGE_RECORD_COUNT=10 CONFIG_BOOTSTAGE_STASH=y CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro earlyprintk console=tty0 console=ttyS0,115200" +CONFIG_BOOTARGS="nr_cpus=1 console=ttyS2,115200n8 cros_legacy loglevel=9 init=/sbin/init oops=panic panic=-1 root=PARTUUID=35c775e7-3735-d745-93e5-d9e0238f7ed0/PARTNROFF=1 rootwait rw noinitrd vt.global_cursor_default=0 add_efi_memmap boot=local noresume noswap i915.modeset=1 nmi_watchdog=panic,lapic disablevmx=off" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_SPL_LOG=y -CONFIG_LOG_DEFAULT_LEVEL=7 +CONFIG_LOG_DEFAULT_LEVEL=4 CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_LAST_STAGE_INIT=y CONFIG_BLOBLIST=y # CONFIG_TPL_BLOBLIST is not set +CONFIG_BLOBLIST_SIZE=0x30000 CONFIG_BLOBLIST_ADDR=0x100000 CONFIG_HANDOFF=y CONFIG_TPL_SYS_MALLOC_SIMPLE=y @@ -71,8 +75,10 @@ CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_CPU=y +CONFIG_BOARD=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_DW=y +CONFIG_MISC=y CONFIG_TPL_MISC=y CONFIG_CROS_EC=y CONFIG_CROS_EC_LPC=y @@ -84,7 +90,9 @@ CONFIG_PINCTRL=y CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYS_NS16550=y CONFIG_SOUND=y +CONFIG_SOUND_DA7219=y CONFIG_SOUND_I8254=y +CONFIG_SOUND_MAX98357A=y CONFIG_SOUND_RT5677=y CONFIG_SPI=y CONFIG_ICH_SPI=y