From patchwork Wed Apr 8 03:00: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: 1267697 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MeYsAeGo; 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 48xpvY02TXz9sPF for ; Wed, 8 Apr 2020 13:01:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B1EE48180F; Wed, 8 Apr 2020 05:01:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MeYsAeGo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E8C3A81720; Wed, 8 Apr 2020 05:01:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 943BC81720 for ; Wed, 8 Apr 2020 05:01:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id e79so5655409iof.5 for ; Tue, 07 Apr 2020 20:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uvepUIA4dRC4l9UjPd47wYkfzdQWKAJDF9d7YRgZ0qw=; b=MeYsAeGotoGGdI1LR2vc8PzkYeLr70SQF9dIexzfsx/kkmMCsMEWQrAr4LBXUuLB5k m4vnBH82uIfxocQhXU5fZBPSQc4J8xAm1niyMQP4BNeD/Lx1P0coYgmXS7uojEhQXdWD t+bVpztUqR2M5moiqLst/NbKqypzkdHj8JFgU= 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=uvepUIA4dRC4l9UjPd47wYkfzdQWKAJDF9d7YRgZ0qw=; b=c+0VGUSDIcZE9+DYtS0PN1iUI8YeRhagW+EfAPDQW9qsFNXpbOKng2XHExcdc400kp BxD5uqCRJTy+CEK0Ppcfk+pdVUX494Ucv2SMfgO08zY3bqVAFGrvDXqMn233A3um8/vW 4X9KBPp4jIkvWF6B6JasiHJSVNyvN7xtNbVk6r1yo6Cv/FrijY8jyStaR2miYm1FWZ13 i6l7WdfSJ/WRTwMjlHQW+oifHcXN5Lg2b/xXQFsU4AmPm0t/jtbiv6zMyaZS7tqxLPWO T+AZtiR+NkDgdMskMpAql5G8XKWLjWyDiLv8id8ueaSN6gFl/JsYwxrGCWKgyAXxfmRs My3g== X-Gm-Message-State: AGi0PuZrtT4mA3UptvihBwRkR5TNA1OmdlxYRNWiscpQTYso7MuU8dCy WuO/ABdF2MxEFBQoPELB1LsCldWnLNqAaA== X-Google-Smtp-Source: APiQypJDPgpctCmdkeDDQu+2MPaIB1z+Fg4S+TLxVgqIj+vywzsIilTWe32k3rFe2GW4Yx2tyuyQOg== X-Received: by 2002:a05:6602:199:: with SMTP id m25mr5087736ioo.13.1586314879178; Tue, 07 Apr 2020 20:01:19 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:18 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Heiko Stuebner , Philippe Reynes Subject: [PATCH v4 01/31] test: Add the beginnings of some string tests Date: Tue, 7 Apr 2020 21:00:37 -0600 Message-Id: <20200407210023.v4.1.I9544b8bcada571406f30889eda869246c2b7cc7e@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean There are quite a few string functions in U-Boot with no tests. Make a start by adding a test for strtoul(). Signed-off-by: Simon Glass --- Changes in v4: - Add a new patch with some string tests Changes in v3: None Changes in v2: None include/test/suites.h | 1 + test/Makefile | 1 + test/cmd_ut.c | 5 ++++ test/str_ut.c | 68 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 test/str_ut.c diff --git a/include/test/suites.h b/include/test/suites.h index 0748185eaf7..6d4270fa33b 100644 --- a/include/test/suites.h +++ b/include/test/suites.h @@ -32,6 +32,7 @@ int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); diff --git a/test/Makefile b/test/Makefile index 2fe41f489c3..917e54a3fcc 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_UNIT_TEST) += ut.o obj-$(CONFIG_SANDBOX) += command_ut.o obj-$(CONFIG_SANDBOX) += compression.o obj-$(CONFIG_SANDBOX) += print_ut.o +obj-$(CONFIG_SANDBOX) += str_ut.o obj-$(CONFIG_UT_TIME) += time_ut.o obj-$(CONFIG_UT_UNICODE) += unicode_ut.o obj-$(CONFIG_$(SPL_)LOG) += log/ diff --git a/test/cmd_ut.c b/test/cmd_ut.c index a3a9d49f7ec..b342c35e68e 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -71,6 +71,8 @@ static cmd_tbl_t cmd_ut_sub[] = { "", ""), U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, "", ""), + U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, + "", ""), #endif }; @@ -131,6 +133,9 @@ static char ut_help_text[] = #ifdef CONFIG_UT_OVERLAY "ut overlay [test-name]\n" #endif +#ifdef CONFIG_SANDBOX + "ut str - Basic test of string functions\n" +#endif #ifdef CONFIG_UT_TIME "ut time - Very basic test of time functions\n" #endif diff --git a/test/str_ut.c b/test/str_ut.c new file mode 100644 index 00000000000..0ce6b055792 --- /dev/null +++ b/test/str_ut.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 Google LLC + */ + +#include +#include +#include +#include +#include + +/* This is large enough for any of the test strings */ +#define TEST_STR_SIZE 200 + +static const char str1[] = "I'm sorry I'm late."; +static const char str2[] = "1099abNo, don't bother apologising."; +static const char str3[] = "0xbI'm sorry you're alive."; + +/* Declare a new str test */ +#define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) + +static int run_strtoul(struct unit_test_state *uts, const char *str, int base, + ulong expect_val, int expect_endp_offset) +{ + char *endp; + ulong val; + + val = simple_strtoul(str, &endp, base); + ut_asserteq(expect_val, val); + ut_asserteq(expect_endp_offset, endp - str); + + return 0; +} + +static int str_simple_strtoul(struct unit_test_state *uts) +{ + /* Base 10 and base 16 */ + ut_assertok(run_strtoul(uts, str2, 10, 1099, 4)); + ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6)); + + /* Invalid string */ + ut_assertok(run_strtoul(uts, str1, 10, 0, 0)); + + /* Base 0 */ + ut_assertok(run_strtoul(uts, str1, 0, 0, 0)); + ut_assertok(run_strtoul(uts, str2, 0, 1099, 4)); + ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3)); + + /* Base 2 */ + ut_assertok(run_strtoul(uts, str1, 2, 0, 0)); + ut_assertok(run_strtoul(uts, str2, 2, 2, 2)); + + /* Check endp being NULL */ + ut_asserteq(1099, simple_strtoul(str2, NULL, 0)); + + return 0; +} +STR_TEST(str_simple_strtoul, 0); + + +int do_ut_str(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, + str_test); + const int n_ents = ll_entry_count(struct unit_test, str_test); + + return cmd_ut_category("str", "str_", tests, n_ents, argc, argv); +} From patchwork Wed Apr 8 03:00: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: 1267698 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LZZK2DxK; 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 48xpvq2cMzz9sPF for ; Wed, 8 Apr 2020 13:01:43 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B2524818F1; Wed, 8 Apr 2020 05:01:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LZZK2DxK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C32B81885; Wed, 8 Apr 2020 05:01:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 1121981819 for ; Wed, 8 Apr 2020 05:01:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x141.google.com with SMTP id f16so5342969ilj.9 for ; Tue, 07 Apr 2020 20:01:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/D2Yha8FlDLhpwf2EKGAaxSuQrSrdXl6b3QmAln7+ls=; b=LZZK2DxKwSiOdywdN5TuRASmRT/Oasp5xgrE6Pe9LLxbWcW+hpKvtFR4dIBo6frES/ jMz0NCs1pSlnM4n6x6u6F4CAqmnkChIM2fzHBY0U5wMbM9rNrKIA0zb0FyPHkLmxMPap 8qhebD0cOclbf9auMyszgYE67Ds9lyUIBqN1w= 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=/D2Yha8FlDLhpwf2EKGAaxSuQrSrdXl6b3QmAln7+ls=; b=qZUcut+SFzE9hOhMcXxLrE0fjLeF1s3ao0R1gbjx/mzjjQWtk6axo2Oyeu+qRq6wXa t835UlPQ/YZp3elxEGz+GmX+61jGz3OOf/1i/JnCFz++vCos3WmrMwJUj1yGTHG9PCQA i34OtmoRtLuamL2WcM8h3rG5YJJaMXdHRz45SQRPyIQcZjW3VWIe1Stskldp5xKECd0p Ej1TuGfD0caiVNqjd72dHfut3SwqZNK4ODA8milpB/6dZQa2btDW6BjXlrldkpfY9sCk HqohjhDrR5tcojNDCbOUCrKcTdrWX1RrIwMQDfqRAh70qhgMfdbw+fT38Ha5r4uk5wZz qTQg== X-Gm-Message-State: AGi0PubBKLLNHxQveLJ9kCA4wlttaKRFNQCZm09SyKGl1Hv3eUPdC6nF AYz+bEjLMWAJ3OZQLughp0r3pghYROFakw== X-Google-Smtp-Source: APiQypJ7AVM44ncI6SALW3Nz4nFj3y+KD0KwU4+yCSzv1LF8HgLB/dYwCi74fiftZuEV7b8cF2QrAQ== X-Received: by 2002:a92:8d0e:: with SMTP id s14mr5644182ild.117.1586314881564; Tue, 07 Apr 2020 20:01:21 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:20 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , AKASHI Takahiro , Heinrich Schuchardt , Marek Szyprowski Subject: [PATCH v4 02/31] lib: Add a function to convert a string to upper case Date: Tue, 7 Apr 2020 21:00:38 -0600 Message-Id: <20200407210023.v4.2.I1ca01985ee4914667e7a2ba006de71c2546eada3@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add a helper function for this operation. Update the strtoul() tests to check upper case as well. Update FAT writing to use this new function. Signed-off-by: Simon Glass --- Changes in v4: - Add a new patch to convert a string to upper case Changes in v3: None Changes in v2: None fs/fat/fat_write.c | 13 ++------- include/vsprintf.h | 12 ++++++++ lib/strto.c | 8 +++++ test/str_ut.c | 73 ++++++++++++++++++++++++++++++++++------------ 4 files changed, 77 insertions(+), 29 deletions(-) diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 4f96699e363..472c206f64c 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -17,16 +18,6 @@ #include #include "fat.c" -static void uppercase(char *str, int len) -{ - int i; - - for (i = 0; i < len; i++) { - *str = toupper(*str); - str++; - } -} - static int total_sector; static int disk_write(__u32 block, __u32 nr_blocks, void *buf) { @@ -65,7 +56,7 @@ static void set_name(dir_entry *dirent, const char *filename) return; strcpy(s_name, filename); - uppercase(s_name, len); + str_to_upper(s_name, s_name, len); period = strchr(s_name, '.'); if (period == NULL) { diff --git a/include/vsprintf.h b/include/vsprintf.h index 56844dd2de8..d3f1292ae4d 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -222,4 +222,16 @@ bool str2long(const char *p, ulong *num); * @hz: Value to convert */ char *strmhz(char *buf, unsigned long hz); + +/** + * str_to_upper() - Convert a string to upper case + * + * This simply uses toupper() on each character of the string. + * + * @in: String to convert (must be large enough to hold the output string) + * @out: Converting string + * @len: Number of characters to convert (-1 for all) + */ +void str_to_upper(const char *in, char *out, int len); + #endif diff --git a/lib/strto.c b/lib/strto.c index 55ff9f7437d..563892a52c0 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -163,3 +163,11 @@ long trailing_strtol(const char *str) { return trailing_strtoln(str, NULL); } + +void str_to_upper(const char *in, char *out, int len) +{ + while ((len == -1 || len-- > 0) && *in) + *out++ = toupper(*in++); + if (len && !*in) + *out = '\0'; +} diff --git a/test/str_ut.c b/test/str_ut.c index 0ce6b055792..09726b076fe 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -19,36 +19,73 @@ static const char str3[] = "0xbI'm sorry you're alive."; /* Declare a new str test */ #define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) +static int str_test_upper(struct unit_test_state *uts) +{ + char out[TEST_STR_SIZE]; + + /* Make sure it adds a terminator */ + out[strlen(str1)] = 'a'; + str_to_upper(str1, out, -1); + ut_asserteq_str("I'M SORRY I'M LATE.", out); + + /* In-place operation */ + strcpy(out, str2); + str_to_upper(out, out, -1); + ut_asserteq_str("1099ABNO, DON'T BOTHER APOLOGISING.", out); + + /* Limited length */ + str_to_upper(str1, out, 7); + ut_asserteq_str("I'M SORO, DON'T BOTHER APOLOGISING.", out); + + /* In-place with limited length */ + strcpy(out, str2); + str_to_upper(out, out, 7); + ut_asserteq_str("1099ABNo, don't bother apologising.", out); + + return 0; +} +STR_TEST(str_test_upper, 0); + static int run_strtoul(struct unit_test_state *uts, const char *str, int base, - ulong expect_val, int expect_endp_offset) + ulong expect_val, int expect_endp_offset, bool upper) { + char out[TEST_STR_SIZE]; char *endp; ulong val; - val = simple_strtoul(str, &endp, base); + strcpy(out, str); + if (upper) + str_to_upper(out, out, -1); + + val = simple_strtoul(out, &endp, base); ut_asserteq(expect_val, val); - ut_asserteq(expect_endp_offset, endp - str); + ut_asserteq(expect_endp_offset, endp - out); return 0; } static int str_simple_strtoul(struct unit_test_state *uts) { - /* Base 10 and base 16 */ - ut_assertok(run_strtoul(uts, str2, 10, 1099, 4)); - ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6)); - - /* Invalid string */ - ut_assertok(run_strtoul(uts, str1, 10, 0, 0)); - - /* Base 0 */ - ut_assertok(run_strtoul(uts, str1, 0, 0, 0)); - ut_assertok(run_strtoul(uts, str2, 0, 1099, 4)); - ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3)); - - /* Base 2 */ - ut_assertok(run_strtoul(uts, str1, 2, 0, 0)); - ut_assertok(run_strtoul(uts, str2, 2, 2, 2)); + int upper; + + /* Check that it is case-insentive */ + for (upper = 0; upper < 2; upper++) { + /* Base 10 and base 16 */ + ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper)); + ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper)); + + /* Invalid string */ + ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper)); + + /* Base 0 */ + ut_assertok(run_strtoul(uts, str1, 0, 0, 0, upper)); + ut_assertok(run_strtoul(uts, str2, 0, 1099, 4, upper)); + ut_assertok(run_strtoul(uts, str3, 0, 0xb, 3, upper)); + + /* Base 2 */ + ut_assertok(run_strtoul(uts, str1, 2, 0, 0, upper)); + ut_assertok(run_strtoul(uts, str2, 2, 2, 2, upper)); + } /* Check endp being NULL */ ut_asserteq(1099, simple_strtoul(str2, NULL, 0)); From patchwork Wed Apr 8 03:00: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: 1267699 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ACAXKdWn; 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 48xpw65ty0z9sPF for ; Wed, 8 Apr 2020 13:01:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4912681904; Wed, 8 Apr 2020 05:01:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ACAXKdWn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5B4E881885; Wed, 8 Apr 2020 05:01:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 F335A8006F for ; Wed, 8 Apr 2020 05:01:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id i3so5583803ioo.13 for ; Tue, 07 Apr 2020 20:01:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VztLUXadQiwhgG5++Jh0QSdKumdd6b/6UYcLfSDrFHc=; b=ACAXKdWnEhOvaUVDz+5bFz1oX/E9xZrVSyjrtMcwm/vc1PzMwOjXWWLkeydC75bjoB 6eB8F1W16mRPQNU5DeAVqiJHi1lJioQZiK7xnxstYeZ8yfQ/J31kka4ySgZduwzipQz8 A1WnShQN5r5/mAUA7Iz3EAg1zm7rN/JKvYWlw= 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=VztLUXadQiwhgG5++Jh0QSdKumdd6b/6UYcLfSDrFHc=; b=NYqx3dTzH/f3bochvuptVu+6pZU7AnPC/Q7mzM6f0tZaR6WPj+8rI9tihqMFre0g82 57k4OQaO/1eFX8dCj74uCwQroEHxT2avj4NmvilsLKZM6WXQw1pJ4lXG934VNActPHPK TDk7beeKaorIy1LBgxd3x1aqYS/gGRht0sGlRioALaOuKM5sJgsim0rJcLYzSh6drkbW fb5h2J4TGlOOjiGoaARTsvQUlj5zonKXxP2TBT0a3iPiceTK8CjDWLqEUq/9FHkbb1ma e0Xfm5FdgiaDycMntUGrzV9/s0FLpQMlAN5sVN5iwPty4A58hmZCl2SibaZWLetyDrmJ rqsg== X-Gm-Message-State: AGi0PuYa8j6KYZMpjZbFqMhguDD6KQ2nJG0CLaNbLxP6wKImR16cr7Zm PxXd9ljLUBDH1/+83ex1JxRRCYYQJErTgA== X-Google-Smtp-Source: APiQypIVNSm4wBEkwHdEtaN/aMwGpMqsSp/0eefiAz1+7/oXWQpymRAj4WUH7P8wGe/9SlVyCz/Kfg== X-Received: by 2002:a02:9988:: with SMTP id a8mr4883694jal.3.1586314883652; Tue, 07 Apr 2020 20:01:23 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:23 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 03/31] cpu: Support querying the address width Date: Tue, 7 Apr 2020 21:00:39 -0600 Message-Id: <20200407210023.v4.3.I094ecfe5a8a83eabccd2ac9f6dc5f6fccbdcea5f@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: None Changes in v2: None 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 ff87e8adca3..05b384f6a45 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 28dd48feb8f..6b1b6b37b3b 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 f5f1caef716..e6dc576ea3c 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 Wed Apr 8 03:00: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: 1267700 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FeYSrI3e; 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 48xpwT1xjXz9sSX for ; Wed, 8 Apr 2020 13:02:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5AA44818F3; Wed, 8 Apr 2020 05:01:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FeYSrI3e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20DBA818E7; Wed, 8 Apr 2020 05:01:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 F100D818E6 for ; Wed, 8 Apr 2020 05:01:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id i19so3665382ioh.12 for ; Tue, 07 Apr 2020 20:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Owsae58fx+aNMxLYHlFd+NZgFhiDIIuuVMeNPWeEI2k=; b=FeYSrI3eOYxC6TTAMrNlXUd1fima8JwZfYuFEoqzna/6rMbBL4fxNg/hzFgwBLebRK 8jPNFkL95iYTCnPuM588PZPaMaLXtotN56NYQa+gAIKOO8QqYMcc0Ftdu/gbM6t5k0Yf /ssNtjXLUIL5rmQ49ziQop9DzpkGxrmsbPqa0= 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=Owsae58fx+aNMxLYHlFd+NZgFhiDIIuuVMeNPWeEI2k=; b=IR3bfkMoFFIOru/h+LxB3hH24nm/dBv86gX6wSAVr/LOV7E1WMGOFYx6n5It+wuerr AKhgguf5o/oJgfqhHu5BFlGoZuVoRN6DTIbAzdHNm7XcpSihcYbaMJZ4M353UGFvDasA vKsjLO0OMoFww8VgMhu5tj22vXT9AKYXZst8RK/lMYF+EajV+/oT2wRSv8u/OWDp/hJm g69xTNtJifbyPUCXZOWw49xwFTT0rcTE/7huWD5BxamIjXfBZo5CM04hvIU50II1Bpnx WOaf6HSw2jZI7CCculRsgaOVv9lbscwOoOtJco5ppe3bfcMUeZqXtTLNt8ncDFzOOyPK RCFA== X-Gm-Message-State: AGi0Pua2isqFYaGMnIki1K/DgcxyGvqTyov6W/VuOSz9QgrK1cvTqZoX BTX5d23GajzFr16yxjG0XYnthuQ2VP5f6w== X-Google-Smtp-Source: APiQypLM15EWVa1S/e1NHflCuyOVXjiN4WvH0EDeAtgQApD89Zy1L/vOBPlwgDtqF0G4DyaLG6C7eg== X-Received: by 2002:a6b:cb04:: with SMTP id b4mr4855069iog.95.1586314885660; Tue, 07 Apr 2020 20:01:25 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Jagan Teki , Jagannadha Sutradharudu Teki Subject: [PATCH v4 04/31] spi: Add SPI mode enums Date: Tue, 7 Apr 2020 21:00:40 -0600 Message-Id: <20200407210023.v4.4.I83a459a3914c56ca81dcdfa7e01d83c54f7ab914@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: - Don't bracket the definitions with DM_SPI - Add trailing commas to enum include/spi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/spi.h b/include/spi.h index 852f570eaa8..2b4929fc79d 100644 --- a/include/spi.h +++ b/include/spi.h @@ -66,6 +66,39 @@ struct dm_spi_slave_platdata { #endif /* CONFIG_DM_SPI */ +/** + * 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, +}; + /** * struct spi_slave - Representation of a SPI slave * From patchwork Wed Apr 8 03:00: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: 1267702 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KkpSrKoR; 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 48xpx62xZcz9sSX for ; Wed, 8 Apr 2020 13:02:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E77BF8190C; Wed, 8 Apr 2020 05:01:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KkpSrKoR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7081E818F3; Wed, 8 Apr 2020 05:01:33 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 1FE2F8006F for ; Wed, 8 Apr 2020 05:01:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id f3so5683457ioj.1 for ; Tue, 07 Apr 2020 20:01:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CGnMowJb1G+sykdInI/T70VT1sesFyk7ThAC19C/sbg=; b=KkpSrKoRIMGsm8rjSlavwsAJYNh7Yk+rJOALQcLxYufHacDthF3qQZPHtgEJjEsNIi UoIfdbAs5A9iTsPjscIqR0B3FnH7Vw59PrNBkW2zNrVdBv8ZGwqM756Uk/fRrViOyzxi MGQZ0iKz0wGbNWHhbB57JnsZ8N5FZUyVrCrv8= 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=CGnMowJb1G+sykdInI/T70VT1sesFyk7ThAC19C/sbg=; b=i6obfUNYCiEvucqGpCHe3aSP+DvpFbDVgQu+UNVmcVb70dOMC9wlV5fWTTYBd9RfjS kiSDPdSNGknYsYuhsu7zqxahC7bJeBdUmiGFckjqoS9eIXiC7bIx0uxBv6rj0rZbCKqa hSlbrh/v34JpCkyHapW1/KcKcOwHzVQGnt0HbAl2oKF2h08IuKtlNcboMOrHO3GZ6GBZ fadgZ/yQz2nhx+RVXwMXasdCgPcxABHDOAslovGFjW+jlDE/kqVbzDSN+E8ojf8cjGEA qyhCo9DSDgp7qdYDlvXcQG1z6ZEjVkYQ2CYzinHFK0IdyqQs618WVTlRBuOywerZU0Vl gEXA== X-Gm-Message-State: AGi0PuafLj6MYNQ+/RYeNrutPtn/UKYGIaW7yDBhtRdlhz4Q+zqiT1Aj NgYtPZho9GNPmvwaWfTPqVz6tpYdwims/w== X-Google-Smtp-Source: APiQypKneEWhB4KDV0ZDPTkge/cdJdFRzc4y2BxtWqlaNgam87DYoB1iAbcwMyVqigkydXFgIr/1xg== X-Received: by 2002:a6b:6d1a:: with SMTP id a26mr5099506iod.32.1586314887782; Tue, 07 Apr 2020 20:01:27 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:27 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 05/31] tpm: cr50: Release locality on exit Date: Tue, 7 Apr 2020 21:00:41 -0600 Message-Id: <20200407210023.v4.5.Ic7bc756f1622775532c4536a2dfd4ee783ee4a35@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: None Changes in v2: None 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 b904a7d426e..b30f55b40d3 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -206,7 +206,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; } @@ -499,6 +499,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; @@ -525,6 +526,7 @@ static int claim_locality(struct udevice *dev, int loc) return -EPERM; } log_info("Claimed locality %d\n", loc); + priv->locality = loc; return 0; } @@ -559,7 +561,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; } @@ -631,6 +637,7 @@ static int cr50_i2c_probe(struct udevice *dev) return log_msg_ret("vendor-id", -EXDEV); } priv->vendor = vendor; + priv->locality = -1; return 0; } @@ -655,5 +662,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 Wed Apr 8 03:00: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: 1267701 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XWZM5M9k; 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 48xpwn2983z9sPF for ; Wed, 8 Apr 2020 13:02:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3728C81948; Wed, 8 Apr 2020 05:01:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XWZM5M9k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C54E181915; Wed, 8 Apr 2020 05:01:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 DDC43818FC for ; Wed, 8 Apr 2020 05:01:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id f3so5683495ioj.1 for ; Tue, 07 Apr 2020 20:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pjepcV+HYLhv+df/ibZvOvYkCGJ/enfnBlEIB8k6dpU=; b=XWZM5M9kiPZmlQEeCPod8sYDhu//miW7qQOPUHzn76EkEVt1zlxrLqvvabK6ULsY1Y GyPQhT+R83ElyskX9DL62aoKnIw49ePMJbCweY8JnQIbHWGipUqDKYgz1saka+BKVXh/ hOTH1wL3eNKJ6GhS70EYeNataJL4LtxlqW15E= 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=pjepcV+HYLhv+df/ibZvOvYkCGJ/enfnBlEIB8k6dpU=; b=keYnb/7Yyn5U7Ddgq+3dAYzInOaAcZNhFpM/a8zCeVw8WrtK1wJfbiBLYs8NnyD6vx amo8VeOGq3tuocVgElVC44hd+g7wWTleJYzd80aVbIR3yGQISBsPE1KArvTJFiXZfVLl Lvoa8HhoTRRa4IVlXHhjdoa3Zm1u3Ndive56/X23ADryptbYG0+/fLMiti2L09R5fjDB +xJuNHi9CW+gcL2U3AKkgyGCkL4trl43ACoCgCZFMfrInUPX5M8+nM3WefOlZ4S9jGMd 52LvUyxCmiF5Kv0apzsjXjH/XrVA6sPDsqLkqcgVNGyT89wRy6er6RE/J2bRldt1PiTS URpg== X-Gm-Message-State: AGi0Pua6YIfZRFg+V+p/Vh4rSS36bYzTtboEvwwo5+fmpXjsAv+v1WE8 td3M1FOX2gj1JWyrIyDjzi+uh/3EVY4Lqw== X-Google-Smtp-Source: APiQypIpkvvV6Xs95LjaCO9TOJop1wAJkoXn0nRDeMe/c1G7QXRGrSqL34TRhKB0BL1+8Z2YMhlBiw== X-Received: by 2002:a6b:7903:: with SMTP id i3mr5227984iop.66.1586314889627; Tue, 07 Apr 2020 20:01:29 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 06/31] tpm: cr50: Add a comment for cr50_priv Date: Tue, 7 Apr 2020 21:00:42 -0600 Message-Id: <20200407210023.v4.6.I405998b384e2bb25cbfb3179a8375c586bf0ce7a@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add a comment for the private structure Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v4: None Changes in v3: None Changes in v2: - Drop the other comment change since it is already applied drivers/tpm/cr50_i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tpm/cr50_i2c.c b/drivers/tpm/cr50_i2c.c index b30f55b40d3..c1d2d2fa381 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; From patchwork Wed Apr 8 03:00: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: 1267703 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=C7zhuGFz; 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 48xpxj06vzz9sPF for ; Wed, 8 Apr 2020 13:03:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B88F6819AF; Wed, 8 Apr 2020 05:01:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="C7zhuGFz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7D593818E7; Wed, 8 Apr 2020 05:01:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 A85AF8190C for ; Wed, 8 Apr 2020 05:01:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id i19so3665580ioh.12 for ; Tue, 07 Apr 2020 20:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/lW34NYsYIUju3iL2Zg7XI3OqL2L87/AxH3XSfINSoQ=; b=C7zhuGFz4LVXHJNDbTcSukNoxwqy6psmBxlvPBpmzQLeoo8UiZaXdAZ4IuNtwW7Fbe rgd1KNmsSeR/XhXfvVwXnySik2STrboxA/RSqACZ5PI8YLz51ymfQ1MOX1hmSiZGZLLU n46QJjU9jDp1KVnwAQIoWYzV3RwbrnFnZgsG4= 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=/lW34NYsYIUju3iL2Zg7XI3OqL2L87/AxH3XSfINSoQ=; b=dNHUyoodnbnkh3rqxhUpPWoK8I22nDUO9QWylkAYH3TXeixpEBdXvzc8qZPjfLgULd TmNJcdYcWy4bnOErQJok0TIx2aYobnlVdSnA4Qf9/BaIdR+3tl6aOhwWbFXhwuK3/M+F pviUZv5LEIk3aG4ie+j4t03r+Af1Ifi1+4zQDsvvfkugM8nBWlJX/79kQsoDuoxTbpnS dJMxGGQPZNrorvK/8yptb0dwmgqzaZnLb1JriVieqFpnoRIarw1bk584/SD6DasBjcKY WY8EDN0xQ6+iRTbZ+vKsonQ4rH1HTZ5mCCZHLxJZulSoqAztO8P7tjLM9KgyDjtebWrd UrYA== X-Gm-Message-State: AGi0PuaI4yBCILL2tlpK4Rpbcv056GG2PjwhxZaEAWh4puA4vbNVNtnL ycSf8S8Z2BHmtXDBFDn7FcdC/1yL13TSIQ== X-Google-Smtp-Source: APiQypKICIPwmmrcsX/WC3PP2cFOLiNe8PhtkRxpx3+ULaWxlcf3sRYd1FtTecQlPZ1uC9ap15Oz2Q== X-Received: by 2002:a05:6602:154a:: with SMTP id h10mr5153856iow.137.1586314891286; Tue, 07 Apr 2020 20:01:31 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 07/31] tpm: cr50: Use the correct GPIO binding Date: Tue, 7 Apr 2020 21:00:43 -0600 Message-Id: <20200407210023.v4.7.Iffff549a1b63fedb9e8ec87cdc5e9e28478a4587@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: None Changes in v2: None 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 af52e11c89a..d48ef3573ec 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 cf0659b70ec..8422ff63abd 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 d9252bf29f7..2fe02d8a227 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 c1d2d2fa381..b67051af26a 100644 --- a/drivers/tpm/cr50_i2c.c +++ b/drivers/tpm/cr50_i2c.c @@ -607,7 +607,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 Wed Apr 8 03:00: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: 1267704 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=FYPmE3sS; 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 48xpy21v1Wz9sPF for ; Wed, 8 Apr 2020 13:03:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EDA6A819BC; Wed, 8 Apr 2020 05:01:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FYPmE3sS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D87268198D; Wed, 8 Apr 2020 05:01:44 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 7B2BE8190C for ; Wed, 8 Apr 2020 05:01:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id u2so5634047iop.10 for ; Tue, 07 Apr 2020 20:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e3EBODb2YX8zhtNYn9I3G1QuxUrzaeCu43TJBuRtk9I=; b=FYPmE3sST2NmfBteOhaa8TSYmGCDzeaPWpnudUwJ2kSa8nu2j7BX1idYy9+rXU6azW H8nO/rNibh01bozKAAyugBYsUElsU736duAa4Ffkh0azB9qA3jPs7vJX50bfbUiKG8pr JsDuPnfS4fY+NnW3jUEWT2xFibkBuVr3Vl2jA= 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=e3EBODb2YX8zhtNYn9I3G1QuxUrzaeCu43TJBuRtk9I=; b=Swziv4ETpiuCxefYjDHJbCrKliyoOwpkZjRrkBhuuF2FeFzR1314pBl9/XDgzoLVvt 5Fm5M+ZhY1oPKCI85M6iv0flGXMte5I6zrX+jpfOyEcXl4qCiYFBQKSZ+Jt77CN3+fhm XYo+35fxvoWcUYaKKJhxbYQTZ1rjtYwlxGfY715odJpl30rY/3lHN12yI/qrGr9xl08C nONVXbK0WkesLmA0rnrzQu8f+0EGiB84Git1lys2IQe1Owq1OKcK5JoCEE+ZKc+dkAM5 KQOxkG1p0OL9jF/SANQSEhPQgt/ibGdlhyNpu7Y7PHB9m36/jnrFor7zhFZyD7apQiTB R2Tw== X-Gm-Message-State: AGi0PuZFd8qoRxGnwKbzUxbWQfm2f2lpNf4UmaoFrBN3TYncd8wrePsE UNsWzFQXqga7wH/YBomO1utVaBR3GF3H1g== X-Google-Smtp-Source: APiQypIHXVd4KPayZguqgTCOZ+TECut1I1nKeymaE3GMjwPiwKQO1UeH71GLaXbV5I+F/4kVYPcftg== X-Received: by 2002:a02:2715:: with SMTP id g21mr3465348jaa.18.1586314899212; Tue, 07 Apr 2020 20:01:39 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 08/31] tpm: Don't cleanup unless an error happens Date: Tue, 7 Apr 2020 21:00:44 -0600 Message-Id: <20200407210023.v4.8.Ic7e63c1f960c3adab3a1c03a61a56c4199fc7074@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: None Changes in v2: None 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 1b11c93194d..71d58070062 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 Wed Apr 8 03:00: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: 1267705 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=L0PFSxup; 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 48xpyH5V8Fz9sPF for ; Wed, 8 Apr 2020 13:03:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D91A819DD; Wed, 8 Apr 2020 05:02:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="L0PFSxup"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 264FB8199A; Wed, 8 Apr 2020 05:01:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 236BD81942 for ; Wed, 8 Apr 2020 05:01:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id w1so57748iot.7 for ; Tue, 07 Apr 2020 20:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6lAm1JarQPm6sH8F/lx64MMGGLt8y9OeRj58FLUvKRQ=; b=L0PFSxup+bZhXfsQJx5ZA+H9ECSiwC4gfXBTH67OTuSYAKm8sG2Mp+jZGO0DcNW7cC Iyv3f6JLmg+JROkbjtC59EKmZm3/zF9ZW/PeV5+jGKv1uppmjugD1xYMP9zMvYoqyNWN MIIW+2wHBl19QXI96lXEBFtCHbEScfhVX839M= 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=6lAm1JarQPm6sH8F/lx64MMGGLt8y9OeRj58FLUvKRQ=; b=IwPb8Oc9G8EkIrMkz1pYilOKsDML4Y1wxKAIL/goEiPswUtkeKVbTZHWZspGk7v7o+ N8Xqqmm1oLM7Xa093BT/V/NHh0mKuRdXJGkWDrva4VqBVMCqYWUulFQxNdNrEMe40B8M W8Xd/sZIqpGGQPDXdcrw2DYzzoDcGNkfCye/1nKWgCL22zTGlfAjCS9Bvybj9una7Z2T M+5U0AKUDmSGJRDc9Ua0MGk63cxq1P6XbQGq34RP1wRJlxkqWUQuTGUdO11HHYjnRciy Jy7fyS83r18TVqFjKiqmZ4nd5xTd/Bdqwtm4HH473CnvzNtY6KnQIaCfYJYUIv33vAdU VxMA== X-Gm-Message-State: AGi0PuZ35XznFkiTzmqkWVl4rqxsYryoKzzmOEVZx7Sz2iFrpW0x608M KfxnJD0xvuzWPE0V4pKqjHlvcSFUFU6ahA== X-Google-Smtp-Source: APiQypKP1Pcyw5svwFZPKbC7qHa7UK8xt8D7gFm4ZAwMQX8ES9y6SQAdK8GeUF3d67IgSIzIAWpurg== X-Received: by 2002:a6b:ee10:: with SMTP id i16mr5054079ioh.114.1586314900874; Tue, 07 Apr 2020 20:01:40 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Alex Marginean , =?utf-8?q?Marek_Beh=C3=BAn?= , Marek Vasut , Michael Walle , Pavel Herrmann , Thierry Reding Subject: [PATCH v4 09/31] dm: pci: Allow disabling auto-config for a device Date: Tue, 7 Apr 2020 21:00:45 -0600 Message-Id: <20200407210023.v4.9.I66a7bcb7db931e196e8319d2dbca4e418274f39b@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: Drop acpi,name in example Changes in v2: None doc/device-tree-bindings/pci/x86-pci.txt | 23 +++++++++++++++++++++++ drivers/pci/pci-uclass.c | 2 ++ 2 files changed, 25 insertions(+) diff --git a/doc/device-tree-bindings/pci/x86-pci.txt b/doc/device-tree-bindings/pci/x86-pci.txt index 3aa5bd9a46c..95e370b3e72 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,16 @@ 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>; + pci,no-autoconfig; + }; }; diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index e2882e3b634..ceb64517047 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -536,6 +536,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 Wed Apr 8 03:00: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: 1267706 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Sr9F2rtO; 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 48xpyX4r3Kz9sPF for ; Wed, 8 Apr 2020 13:04:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F1416818F1; Wed, 8 Apr 2020 05:02:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Sr9F2rtO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDD32819DD; Wed, 8 Apr 2020 05:01:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 6CB4781994 for ; Wed, 8 Apr 2020 05:01:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id y17so5604921iow.9 for ; Tue, 07 Apr 2020 20:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OjKeHmPrn438k9M7oIShoF5nPkeLfOs7GPAin63B/uI=; b=Sr9F2rtOoEjIvJd98wyHrU78ONEtIY7E2oNEW1Dltb5dU2CQV3ev2d2CzLFGRijkOO n3L++dSSg0YfvfrCFuyRx6N4HU8Hcu0se9rYF8PUwo7BjHHfyJA9aWvW/SpuXHxakmHe UnCtd00fgKc8V7PiDuxz0ojDaKzMbMxnuk6aI= 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=OjKeHmPrn438k9M7oIShoF5nPkeLfOs7GPAin63B/uI=; b=gdeikG2G/Z5KHLHbgaGAFlJglzBKJN9p5UJFw1kSweye8yCrm28Yyt5NZmn3StK2qq +hzB/EBZYKoxYiWh0odelVUmFxZBxfXiIhyX4OjHjAG/6f2n6pifawUCOL1BmZXCyg1d FtsiVBMc6AFMNn3YiQaHpoB6QZV8pQt6Pw7a7heG71aDUj1fNYJ2UUPs1CmRyUr5O+mB mKa18bOmV5ELOBcP4ojips6qOl+Ek5eBQcIBDEWeLW937cYOVejVZ1X28zU54z/njxSu aza6PpC/fzHbTHmjNJKNUOCbbaoWuTo1SZ9Jk0ZMheVZbiQylZZPFQSZ7JS0bVn499EZ aIFA== X-Gm-Message-State: AGi0PuYJQD2fQO09h1d3QY0toCFgaCZgvRZ2tIQaLKUArxlQX/oeVHE5 GeKd/p/qNathPvNmrbd63trK983gU3qZdA== X-Google-Smtp-Source: APiQypIXer7izk80gMFdU+UQeeO3wZ70nEZUEsEt8DTqFO4McqeC3ZdTFcMuuHSW8eTGvBk7bUQC0Q== X-Received: by 2002:a6b:c087:: with SMTP id q129mr5083339iof.57.1586314903064; Tue, 07 Apr 2020 20:01:43 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:42 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 10/31] x86: Correct wording of coreboot source code Date: Tue, 7 Apr 2020 21:00:46 -0600 Message-Id: <20200407210023.v4.10.I0e67688e96b62650b8218c3d536f9fc4de9d13b4@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None 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 e698200d704..e8ccaf22129 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 9320afba561..85d42c02c46 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 6da06bb52b4..1ea141f082f 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 Wed Apr 8 03:00: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: 1267707 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=n0wHATnk; 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 48xpyn0jQbz9sPF for ; Wed, 8 Apr 2020 13:04:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1432D819BB; Wed, 8 Apr 2020 05:02:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="n0wHATnk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6B3098199A; Wed, 8 Apr 2020 05:01:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 964A581942 for ; Wed, 8 Apr 2020 05:01:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id y17so5604985iow.9 for ; Tue, 07 Apr 2020 20:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SJ7ls4z2crgPPvyIzuT3om04XuCIqPA08/h0YqO5h6U=; b=n0wHATnklSAbzPpvluIKkHgl0pYXyi7S1rnMDj6rebdPz7AkssPYXSLEhV5Z4z6awJ H6IAgcPQGeCgIEI7i3e8e0kRfnesCpN/vZKDqy1O0TPMOP5Ukk1+Ts1KlxG5v765ULWU VOswlejfwbaJmUPp1svX95kCSwQ59MPGg5wE4= 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=SJ7ls4z2crgPPvyIzuT3om04XuCIqPA08/h0YqO5h6U=; b=pvVH5qBJ5ibU1OFcWnYU7zi7UDyH/LCKqNuNcRdCU4H8bZONYUaCMoUYNLw2r6dAUm yKZSB7iRABBK0cF/adTlWYZjYE6CbSUr6MOxkgEX08tJduvIeatGj2w+MXV2JrkvtEoa m/MO7KOFZVNe/5biXtJ93GoXhcf2zgEGwzRohCdqgypOSdvOHfXw8dMtZ8dQRyJmgu6O +TadY4kMiMe4KWK8uXWDtRHjc3p+CVUgAAGv0XzI/BCNeMy59H7MXnY3hyuScueQMi1l HuPILrWTwy+khmbY9i7wrOcrINPGir52VAn2IW/WpANFWtBefb6sO3EEOzQyai3Zrvua qSfg== X-Gm-Message-State: AGi0Pub6mzNDLHFlatZkz3UElZUjdkUUrCSFkvb0Bk3EpDnca0nOPnJ0 a+t1JEfw9QGYPwI/utqzyH9ZDCRhauHI2w== X-Google-Smtp-Source: APiQypLPk4A5WKyLAV/BqSUT7nj3M2X/SdApsuttdNACIMxHVMzrqbU0o9gCYFvFn0XyMOsPAHXeZQ== X-Received: by 2002:a02:6a1e:: with SMTP id l30mr4855494jac.98.1586314905280; Tue, 07 Apr 2020 20:01:45 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:44 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 11/31] x86: apl: Move p2sb ofdata reading to the correct method Date: Tue, 7 Apr 2020 21:00:47 -0600 Message-Id: <20200407210023.v4.11.Iff8dfbeef5f76f776cf3a84807b0ff3fd5a491ac@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: None Changes in v3: - Fix indenting error mentioned by Andy Shevchenko Changes in v2: None arch/x86/cpu/intel_common/p2sb.c | 33 +++++++++++--------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/arch/x86/cpu/intel_common/p2sb.c b/arch/x86/cpu/intel_common/p2sb.c index d5b4846e0a2..6f3c4416186 100644 --- a/arch/x86/cpu/intel_common/p2sb.c +++ b/arch/x86/cpu/intel_common/p2sb.c @@ -92,46 +92,35 @@ int 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); } + 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; } static int p2sb_probe(struct udevice *dev) { - if (spl_phase() == PHASE_TPL) { + if (spl_phase() == PHASE_TPL) return 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 p2sb_spl_init(dev); - } + else if (spl_phase() == PHASE_SPL) + return p2sb_spl_init(dev); return 0; } From patchwork Wed Apr 8 03:00: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: 1267708 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=XPZC/4pE; 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 48xpz03TBdz9sPF for ; Wed, 8 Apr 2020 13:04:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E90A819D7; Wed, 8 Apr 2020 05:02:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="XPZC/4pE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5770C8197B; Wed, 8 Apr 2020 05:01:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 B533C8180F for ; Wed, 8 Apr 2020 05:01:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x143.google.com with SMTP id n13so5381492ilm.5 for ; Tue, 07 Apr 2020 20:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r0+RTcaskgBD9mb/PvvUKD70yh6aifN3mrow/fFbpRY=; b=XPZC/4pE8OiYdNgHRRuA1PkAT+q6RpsJRQCFkJM6GfkG3ceqkO3q5FGWv/H49W7Akx 3mCwM9ltMTSxF7GzXj0V4ff648KxxVLua/JuhOjJbPmH2DNyePr8sCpAhQe6iNJbt/fa WWvFpV7eVkcgf07OvKa3Q2aULizoiQuE7hDYA= 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=r0+RTcaskgBD9mb/PvvUKD70yh6aifN3mrow/fFbpRY=; b=Q8//86yAyTBQTNnqNEAGALCMSFhGVP9Il+Al6uGEuBnlWA+W1clFmu+ZwSE+LdAPo0 DUNE141yM11uVsZfvuERuzw+0r9vgSzouSfni3sKYX5fYICD703SHaBkT9EaIFSXLw+G llLmtQK/DefoMJHpYxJbs2cDvduNdXqqgnfwJkiVoIfVS/JVM3d2VS9vPgrx0EW3Cytq SwdQS/NRAM1xyIA1eEBJWyvVeDMeJc9CSLL6R0FllFdzU9R02gWAQNMbtPLYe+iTCGek SFEwoQS9Ig396LNphVcXAorbvwJDq72BC14gEnG9KyMtpJssmyy56H4ZEJ+crlrPikRI YzKQ== X-Gm-Message-State: AGi0PuYQ+GyPnYmfTo1VwvSAEWnDvOgwFQgGE0JF7rsfouqHdnthl9ec Yludf0GQb9sD2M4BH55CGADSnypyK9m7eQ== X-Google-Smtp-Source: APiQypL01JpBdrOAzFy5ylEb7YHEbgIQ6lnkycbQHjFA8G+T3M3MuHAkhYu5oLZZNSZBkDSJGp7W4Q== X-Received: by 2002:a92:7e82:: with SMTP id q2mr5572719ill.188.1586314907473; Tue, 07 Apr 2020 20:01:47 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:47 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Alex Marginean , =?utf-8?q?Marek_Beh=C3=BAn?= , Michael Walle , Thierry Reding Subject: [PATCH v4 12/31] pci: Adjust dm_pci_read_bar32() to return errors correctly Date: Tue, 7 Apr 2020 21:00:48 -0600 Message-Id: <20200407210023.v4.12.I36321d5e30daf051900f01f6289dfc58439871ea@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None 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 ceb64517047..d2e10d6868a 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -1213,7 +1213,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 Wed Apr 8 03:00: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: 1267709 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Mybib92f; 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 48xpzF0NMfz9sPF for ; Wed, 8 Apr 2020 13:04:40 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 277D981720; Wed, 8 Apr 2020 05:02:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Mybib92f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B5A458195D; Wed, 8 Apr 2020 05:01:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 4133C819DF for ; Wed, 8 Apr 2020 05:01:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id i3so5584603ioo.13 for ; Tue, 07 Apr 2020 20:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pr4ETNNmEdqvTnbF96RY1Ifrecxl2FiLHJcCvVOiJu0=; b=Mybib92fpBVdKy9+qYedFhz3Tn2Z5nsKtRFRnCnRNxucMS/vZx0L1L+Dsl5EgpkpWd MNP9y3cPBB1y6a80iifyfs2IJN3BAP5o5dg3QZpsNPcv5a2gLG6mO3+or5hSqw3S6uEI /gM+qPqJvcHVf0OAXf2SYAPYUW0bgIqj9CK+o= 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=Pr4ETNNmEdqvTnbF96RY1Ifrecxl2FiLHJcCvVOiJu0=; b=J6JT5Ynk+M5skeM8ux0opYsgoG/XSfkbmxM6O6mfd58e4wCdIeFsVtDTSFB2PCFa/+ BPWgESuu4ImKzdYY95V4X8/yosNZHhxAi+mmaPwsqW5w0HTzr9COEAiVwCMHPnpxk7v1 ASpSbOyDZ3EUwFO7lRa0w3E0Boj0MPVH+tSOFfw1i0z4M4YNC+fEAgpfzRYwz1z6a/8g dUl+F0UmT6AMqy92sEefnjMI0UjohtQHRfjv7gXkadqNp5o47C/R0QNbc1eRSgl0aHN9 wIAPCJCpk4beGgoRWsUJ7B/RGodgjLMZSGcawYsIgKsSZk3q0PYnKX2PG6SsyZBL+1tb 8SJg== X-Gm-Message-State: AGi0PuZn6Y8jAzNM5AFzEXg847bRCgWtqrZJtGxJhoGtHw1FfowVJEqQ Z2lknfX+jPzCUHXtL7HFrl0zWAumE5R4Ng== X-Google-Smtp-Source: APiQypLPhZIfeJAJuKjjMfARmAgWbDCmU8LScpZ1FEPO6dsuqe+fp4X4TxTgDhbmx0H1ORQuLfBFOw== X-Received: by 2002:a05:6602:2ace:: with SMTP id m14mr5201285iov.131.1586314908881; Tue, 07 Apr 2020 20:01:48 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Wolfgang Wallner Subject: [PATCH v4 13/31] x86: apl: Add Global NVS table header Date: Tue, 7 Apr 2020 21:00:49 -0600 Message-Id: <20200407210023.v4.13.I4aa2fe09882dcf5a040603469bac136e4342d350@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: - Fix indentation of unused - Calculate the padding Changes in v3: - Fix stray #endif Changes in v2: - Drop the Chrome OS pieces - Rename the 'coreboot' console to 'U-Boot' .../include/asm/arch-apollolake/global_nvs.h | 36 +++++++++++++++++++ 1 file changed, 36 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 00000000000..9351a008f2f --- /dev/null +++ b/arch/x86/include/asm/arch-apollolake/global_nvs.h @@ -0,0 +1,36 @@ +/* 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 - U-Boot 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[0x100 - 0x3d]; /* Pad out to 0x100 */ + u8 unused2[0x1000 - 0x100]; /* Pad out to 4KB */ +}; + +#endif /* _GLOBAL_NVS_H_ */ From patchwork Wed Apr 8 03:00: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: 1267710 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=i+6RM+lJ; 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 48xpzS6kx2z9sPF for ; Wed, 8 Apr 2020 13:04:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E381181994; Wed, 8 Apr 2020 05:02:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="i+6RM+lJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE45A819BA; Wed, 8 Apr 2020 05:01:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 3AFF08196B for ; Wed, 8 Apr 2020 05:01:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x144.google.com with SMTP id p13so5366145ilp.3 for ; Tue, 07 Apr 2020 20:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7JsWOnPi5BXoKIqr38Y+N4MNAYR/uutAUTwsqTH1fkA=; b=i+6RM+lJaSy9U5AbOarZaduip7dEaHpbyHrbyG6A65mOyQ7nNNtzzNfHfIe8Q5oipX uwzaePoy0p8n0bR0fx9uqQjIs5Mq8E9t6MyTIj9lZfzR7WwgD7+HeiJAf9Tmwi3ourca xM277WBpZ47iIfj7gv/AFS68djBu6p3KfFqGY= 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=7JsWOnPi5BXoKIqr38Y+N4MNAYR/uutAUTwsqTH1fkA=; b=RKkI+wVbSxeNAicw5SzSSfEiCMxCirqVjuXUWvVkLhNreQdec4H6aSp8JdsEdIxWXe OR3HEpgGsmjBL4gCivcAm6YgaBP1z4YDRULp3gasZ86v2OJG3zc3+SqxbT+ZKSruREbw 2Zj8tKKwfqiaq12t/Quw6vO62/BXQzN480Dm/+yH37jBMDsz6PEWQdVcFiN2ELznLKG4 ywXLmdIzKzVL+l+3Vp53Ldu8dlnWlsxGKOO41lciswJMudYiW24h3YRA6+1VFL1F1MgI 1+NXK3zeRwkP2T0f+pDWoa0NApet3COeT3V+ttc6zkA68tDEkS6s+2PXBbM+mE+PEYma RPgw== X-Gm-Message-State: AGi0PuZNRoh2FTP5j0Wiij8XKMqE5DPFaXVoYok15TONjio3fSI1ftYq Y5NcbxllbDlDCOVC0LozTZMbNXGxhgsgqQ== X-Google-Smtp-Source: APiQypL0pGf58xExsV75yq69PVcg6B+UcZoFIOtGl3ktyyl0iELsv215fmP5bnixXBZAuERIJ1/hHg== X-Received: by 2002:a92:9fd0:: with SMTP id z77mr5825697ilk.257.1586314910730; Tue, 07 Apr 2020 20:01:50 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:50 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Heinrich Schuchardt , Marek Vasut , Pavel Herrmann , Sean Anderson Subject: [PATCH v4 14/31] dm: core: Add basic ACPI support Date: Tue, 7 Apr 2020 21:00:50 -0600 Message-Id: <20200407210023.v4.14.Ia5e9ba1f146567b18e9183395484bf04d2e5ba6a@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean ACPI (Advanced Configuration and Power Interface) is a standard for specifying information about a platform. It is a little like device tree but the bindings are part of the specification and 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. Reviewed-by: Bin Meng Reviewed-by: Wolfgang Wallner Signed-off-by: Simon Glass --- Changes in v4: None Changes in v3: - Drop 'Intel' from 'Intel ACPI' - Reword commit message to drop the bit about ACPI being complicated - Compute ACPI_NAME_MAX from ACPI_NAME_LEN - Rename acpi_return_name() to acpi_copy_name() - Use strncpy() instead of strcpy() in acpi_copy_name() Changes in v2: - Move LOGC_ACPI definition to this patch drivers/core/Kconfig | 9 ++++++ drivers/core/Makefile | 1 + drivers/core/acpi.c | 33 +++++++++++++++++++ include/dm/acpi.h | 73 +++++++++++++++++++++++++++++++++++++++++++ include/dm/device.h | 5 +++ include/log.h | 2 ++ 6 files changed, 123 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 3b95b5387b9..a3b03993423 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 bce7467da1d..c707026a3a0 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 00000000000..0e64c21bf5b --- /dev/null +++ b/drivers/core/acpi.c @@ -0,0 +1,33 @@ +// 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_copy_name(char *out_name, const char *name) +{ + strncpy(out_name, name, ACPI_NAME_MAX); + out_name[ACPI_NAME_LEN] = '\0'; + + 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 00000000000..c13d0c8448a --- /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 (ACPI_NAME_LEN + 1) + +/** + * 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_copy_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_copy_name(out_name, "WIBB"); + * } + * + * @out_name: Place to put the name + * @name: Name to copy + * @return 0 (always) + */ +int acpi_copy_name(char *out_name, const char *name); + +#endif diff --git a/include/dm/device.h b/include/dm/device.h index a56164b19bb..35e19d87005 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -245,6 +245,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; @@ -264,6 +266,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 */ diff --git a/include/log.h b/include/log.h index 62fb8afbd0e..fbcbd42fb4b 100644 --- a/include/log.h +++ b/include/log.h @@ -51,6 +51,8 @@ enum log_category_t { LOGC_SANDBOX, /* Related to the sandbox board */ LOGC_BLOBLIST, /* Bloblist */ LOGC_DEVRES, /* Device resources (devres_... functions) */ + /* Advanced Configuration and Power Interface (ACPI) */ + LOGC_ACPI, LOGC_COUNT, /* Number of log categories */ LOGC_END, /* Sentinel value for a list of log categories */ From patchwork Wed Apr 8 03:00: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: 1267711 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=DDIKQZbn; 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 48xpzg3rtyz9sPF for ; Wed, 8 Apr 2020 13:05:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A19E819DC; Wed, 8 Apr 2020 05:02:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DDIKQZbn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8C79819A1; Wed, 8 Apr 2020 05:01:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 882C0819B0 for ; Wed, 8 Apr 2020 05:01:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x141.google.com with SMTP id g15so5328650ilj.10 for ; Tue, 07 Apr 2020 20:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OzCjgELMGr6j+xMP8JryA8jVZJchOfvCIF1MDJFRo1A=; b=DDIKQZbnM0NqzUQp88PiAcriXzJbdXvwdTGJMsgQqGchNNwHLHMvaN+6DCP4iOnaH9 LKuHY8EKzeLxoXc4+VVSae/4fHzUjLXhr5gxWV9j5jpnnQLE443zJ6i2scgx3XzIJwMI pfC/EO/n57trrKwDzRTTq5ONeU6/+cljHi+nQ= 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=OzCjgELMGr6j+xMP8JryA8jVZJchOfvCIF1MDJFRo1A=; b=temBBP+19IgQtPIMdquEK+P+Tdj+puhxORCmhTI+WS4TQkumarSVW6fCFL1cMd/k0g rrONJ+jo6SNQ07yZM5+55KvLq91eI1ya8nXrL3otBu25ypG37mFm5AudxmB6692SJVNm WJesehvuzRxPKeJZ1nSTFI8DH5oy98FmzGxYBwAuskDEYEbpGUpJwvatwJUe/IbKQjpp BOyUSv81ND4HHIIr+zvp8jK0CHKiQaLJbO7rT2X5S1xxTsoxb7F429035WtcRt7BaOEZ ynNUeUzL1w/6GFUEay3ogkqoIZf01yicI6mGVpbDftjbgHnKS0bQsDUnqsBS/HzACLRN gwUw== X-Gm-Message-State: AGi0PuZ5E+l07SSdUJJJZnbEo3yPKPsfJBusQOJV+Iv/zoC3N7EjJbw8 kUqlOe5kFLC6YiFPsRcjFCaUr1dH8sDIwQ== X-Google-Smtp-Source: APiQypK5fSvrEiAK9EoKihycKE5cEJJ4iuaCZjz3VKXNVgoA9XPqvu1+f2+pCL2PBniFR0wb3ad7MA== X-Received: by 2002:a92:9a59:: with SMTP id t86mr6141256ili.78.1586314912284; Tue, 07 Apr 2020 20:01:52 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 15/31] dts: Add a binding for hid-over-i2c Date: Tue, 7 Apr 2020 21:00:51 -0600 Message-Id: <20200408030107.168474-2-sjg@chromium.org> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Add this binding from Linux v5.4. Signed-off-by: Simon Glass --- Changes in v4: None Changes in v3: - Split out hid-over-i2c into its own patch Changes in v2: None .../input/hid-over-i2c.txt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/device-tree-bindings/input/hid-over-i2c.txt diff --git a/doc/device-tree-bindings/input/hid-over-i2c.txt b/doc/device-tree-bindings/input/hid-over-i2c.txt new file mode 100644 index 00000000000..c76bafaf98d --- /dev/null +++ b/doc/device-tree-bindings/input/hid-over-i2c.txt @@ -0,0 +1,44 @@ +* HID over I2C Device-Tree bindings + +HID over I2C provides support for various Human Interface Devices over the +I2C bus. These devices can be for example touchpads, keyboards, touch screens +or sensors. + +The specification has been written by Microsoft and is currently available here: +http://msdn.microsoft.com/en-us/library/windows/hardware/hh852380.aspx + +If this binding is used, the kernel module i2c-hid will handle the communication +with the device and the generic hid core layer will handle the protocol. + +Required properties: +- compatible: must be "hid-over-i2c" +- reg: i2c slave address +- hid-descr-addr: HID descriptor address +- interrupts: interrupt line + +Additional optional properties: + +Some devices may support additional optional properties to help with, e.g., +power sequencing. The following properties can be supported by one or more +device-specific compatible properties, which should be used in addition to the +"hid-over-i2c" string. + +- compatible: + * "wacom,w9013" (Wacom W9013 digitizer). Supports: + - vdd-supply (3.3V) + - vddl-supply (1.8V) + - post-power-on-delay-ms + +- vdd-supply: phandle of the regulator that provides the supply voltage. +- post-power-on-delay-ms: time required by the device after enabling its regulators + or powering it on, before it is ready for communication. + +Example: + + i2c-hid-dev@2c { + compatible = "hid-over-i2c"; + reg = <0x2c>; + hid-descr-addr = <0x0020>; + interrupt-parent = <&gpx3>; + interrupts = <3 2>; + }; From patchwork Wed Apr 8 03:00: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: 1267712 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LnPgB9u5; 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 48xpzt2CN5z9sPF for ; Wed, 8 Apr 2020 13:05:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB6B6819B0; Wed, 8 Apr 2020 05:02:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LnPgB9u5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1E6F819B0; Wed, 8 Apr 2020 05:02:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 0332D819C9 for ; Wed, 8 Apr 2020 05:01:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x142.google.com with SMTP id t6so5344579ilj.8 for ; Tue, 07 Apr 2020 20:01:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CeYlJ7JAQzr3S9+C47B2Q5RJuifAqAT1bWC7WEBGOXU=; b=LnPgB9u5JlDSPZzEYAsWOl7o5CCVn1Rlatg8K3D3Co9tdrtbJQ+8ZfABe0MGuT0MP0 QXZDowCmqr2IEPF89sYV3l8L5+y5JBqxGnAv/o+mnQPoU5s9OGFoxnsGThbFmTQDauaG 34s7QtjRwFb0fPcQhjSdrY8NBLxPfWbqBN788= 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=CeYlJ7JAQzr3S9+C47B2Q5RJuifAqAT1bWC7WEBGOXU=; b=OuLxGktFxpDdlx7shDbimO26iw9hsShmeE9eXrUoQN0JB/eJ/I8MGaArtLTfHatKw1 kx2s0c5xBrIWuF9X3JtbRSiX5FtgSk+Lh2mQJ8rD4qsfzuNrgNT6jk6l3s5nqZoS9bHB z4UBH2ZHtiDMmRrabA73vzU5RauINB87B7Tw83AuTPv/KuaSv87f6COtAayTPgS31PFh bXg4rf14QkBz1zHvpI99h/uFukkh6LW6vY89f39XDGhiyGDp+zwzWMksozifWG19fSer 2DosFjuZL4OmAOGb+2IUhmIS7kSBZtxbVsG66cQ7IlhDquto/jzbj03K7OWR2mVV0CQ8 Smkg== X-Gm-Message-State: AGi0PuZxU3fVnyr8ppdtgyObJgyf2YcbCIZcaOdJCZbV4sfMqj7m40wt yx6V6o+QTINPw+kjNPOSdzXXkfwx27RXEg== X-Google-Smtp-Source: APiQypIjApJxPK82mxmjvQGstUX2DQuZ2SzIaKs9UbqrunujHsejTOMlZjS0MVrLy9GkXivdna2S6w== X-Received: by 2002:a92:3c1c:: with SMTP id j28mr5767522ila.304.1586314916693; Tue, 07 Apr 2020 20:01:56 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 16/31] acpi: Add a binding for ACPI settings in the device tree Date: Tue, 7 Apr 2020 21:00:52 -0600 Message-Id: <20200407210023.v4.16.I7842b2dd0d6b475301fc044c6640d8089873053f@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: - Put 'interrupts-extended' property on one line - Rename acpi-probed to linux,probed - Note that linux,probed is an out-of-tree feature Changes in v3: - Drop mention of PRIC - Rename acpi,desc to acpi,ddn - Correct description of acpi,probed - Drop hid-descr-addr - Just add the device.txt binding file in this patch - Change the example to ELAN - Add a pointer to information about acpi,compatible Changes in v2: - Fix definition of HID - Infer hid-over-i2c CID value - Add the hid-over-i2c binding document doc/device-tree-bindings/device.txt | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 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 00000000000..27bd3978d98 --- /dev/null +++ b/doc/device-tree-bindings/device.txt @@ -0,0 +1,36 @@ +Devices +======= + +Device bindings are described by their own individual binding files. + +U-Boot provides for some optional properties which are documented here. See +also hid-over-i2c.txt which describes HID devices. See also +Documentation/firmware-guide/acpi/enumeration.rst in the Linux kernel for +the acpi,compatible property. + + - acpi,has-power-resource : (boolean) true if this device has a power resource. + This causes an 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,compatible : compatible string to report + - acpi,ddn : Contains the string to use as the _DDN (DOS (Disk Operating + System) Device Name) + - acpi,hid : Contains the string to use as the HID (Hardware ID) + identifier _HID + - acpi,uid : _UID value for device + - linux,probed : Tells U-Boot to add 'linux,probed' to the ACPI tables so that + Linux will only load the driver if the device can be detected (e.g. on I2C + bus). Note that this is an out-of-tree Linux feature. + + +Example +------- + +elan_touchscreen: elan-touchscreen@10 { + compatible = "i2c-chip"; + reg = <0x10>; + acpi,hid = "ELAN0001"; + acpi,ddn = "ELAN Touchscreen"; + interrupts-extended = <&acpi_gpe GPIO_21_IRQ IRQ_TYPE_EDGE_FALLING>; + linux,probed; +}; From patchwork Wed Apr 8 03:00: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: 1267714 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NixU9MNR; 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 48xq0K0CLsz9sPF for ; Wed, 8 Apr 2020 13:05:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 33758819FA; Wed, 8 Apr 2020 05:02:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NixU9MNR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0FA10819D4; Wed, 8 Apr 2020 05:02:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 C2627819C7 for ; Wed, 8 Apr 2020 05:02:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x142.google.com with SMTP id k29so5379228ilg.0 for ; Tue, 07 Apr 2020 20:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rt5sM13qa/NQP7nZVFuzrjiijbU6w9z+l2pNtja4fcg=; b=NixU9MNR7PTLKm3SaIJfEitije2ywtpwm1tDtQx2WNounqdvyaeSsCRPPwyb10B0VG bD5HrGVv2LCxXe1weiv0dzgBnHU2Q54gzsQTOf420GIPUG6MyRcWP0++GLz8tgUXbkO7 EvljSMMhfDGnVIdOpjqoGhF026sg9jUoDEU80= 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=Rt5sM13qa/NQP7nZVFuzrjiijbU6w9z+l2pNtja4fcg=; b=D9STL5fdSbzNRwjSoy0jNHaMjbbYTKswmr8BcpAWnjE5PNNDduqu7M7tioUbT3rhnn 69pTv9eC35aAjobwvqVlBhtmMTCvhBsBCLOgHeixD528Q2Cg0132syjkhGmIWvOsM+Hv 4w5wzatV1qNDGEqGyMLGotkdHbcXsXhUNayiei0Yh+Eg+NuimfhobOU9gG+49QqKBZVa m/QMrXUBFUaBdrW8Z+xfEjAoBDXhtKp+zV9VzkzK82aju9iCDnS+sEot7sH6CL9an/Az cbalx0jRvsV2OqLU1JKs4BBeBuNh29SVNf6CK/j3foXXXBhiM217GQQspFEa4tSTDmxE qfpA== X-Gm-Message-State: AGi0PubR6/vII86Lyo4r3BAf4yN6b1Hh3QLl6OYrguzJtXpYnbhiGStl F5Lpr+fb7oNNmo1h/yJVEsSzrjja/iMIOA== X-Google-Smtp-Source: APiQypKKvj9g26dzDQ8Vf/ap763g6VtiMLVWpfjW6AxaNuAck7WI4vvMwQAGtyoiTJyBbfMwIwfeLA== X-Received: by 2002:a92:b6d5:: with SMTP id m82mr5588067ill.17.1586314919496; Tue, 07 Apr 2020 20:01:59 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:01:59 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , AKASHI Takahiro , Alex Marginean , Jean-Jacques Hiblot , Joe Hershberger , Lukasz Majewski Subject: [PATCH v4 17/31] acpi: Add a simple sandbox test Date: Tue, 7 Apr 2020 21:00:53 -0600 Message-Id: <20200407210023.v4.17.Ife90d6e6cfa90e642e73328168a00804b1dc6fd4@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: - Add in the acpi_table.h header file to this patch arch/sandbox/dts/test.dts | 4 ++ arch/sandbox/include/asm/acpi_table.h | 9 +++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/acpi.c | 55 +++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 arch/sandbox/include/asm/acpi_table.h create mode 100644 test/dm/acpi.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 4a277934a71..5fa951ad4b6 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/arch/sandbox/include/asm/acpi_table.h b/arch/sandbox/include/asm/acpi_table.h new file mode 100644 index 00000000000..921c7f4201d --- /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/dm/uclass-id.h b/include/dm/uclass-id.h index 598f65ea7a3..37ada51f9f7 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 dd1ceff86c0..3daf8a544ea 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 00000000000..429993b9cc0 --- /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_copy_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 Wed Apr 8 03:00: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: 1267713 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=H3UMy1ho; 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 48xq054fmnz9sPF for ; Wed, 8 Apr 2020 13:05:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EE66B819DA; Wed, 8 Apr 2020 05:02:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="H3UMy1ho"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D23A78196B; Wed, 8 Apr 2020 05:02:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 132C3819DA for ; Wed, 8 Apr 2020 05:02:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id y17so5605502iow.9 for ; Tue, 07 Apr 2020 20:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KjcOvQM3NOZCjcOs6FNbogvtPMHmydLpsRhptrRTlJE=; b=H3UMy1ho6bnxOhQzsyRFOWLolWqS3a3p9lZALbBWlC+6HwwGDhkb0Vo8bSjGO1Sc+5 NHeVTF1aSyAeJfCyxpN47Kobld93ZF0ZANylP2TxxzNrnpnh0js0IRKaGOfVL6ff/QfO G7ykngzSuOx9hI45Ev66oIEtVzEHj0V9EhjFA= 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=KjcOvQM3NOZCjcOs6FNbogvtPMHmydLpsRhptrRTlJE=; b=qARxfJH3V98+Iy8Xs1rKCE9orPEv62tqiefY9b8F7UVQ+dhujARNDGkvkjzwS2XwqT 6SoCc/RSLh4lUU/qmzo13Mk1CWHXPvkrkhKrtSwcXet9+gzH6dlXiBXdUeJ6arwEFxhH OO7R3dWkBI3OWvDf3nCePrk0ij6e4n4KuvWdsCCAN2Gt6mApCNZdN9V+JYXt8m0TASVR 0rT3AQjIMVBveWe53AvUzINvVxI15Z9vtGRZ4I50jEL29VvyYTJezzRD/h9xUsAWnZvH d+CgYnI2UgpfQm6/o6zhQw4SmByMaOfj9oEJdbEK+yUBv1D1mfuZ/eTJd9mSSAxlIZMD Scbg== X-Gm-Message-State: AGi0PuapdFbueL3wQZt4N5Dba4ATzgOH/TyXDdpyKUEjc8c9GDijn6+M MP8gHUUdFowaePNGj2ZTJFFUwbo4sR/0xw== X-Google-Smtp-Source: APiQypICuZdvZT+dRjfcGdxjkgeZZds/4WWC+TP52XUaRAc2T/6pbcihJt/xLoHNYNo8rzif+iUFPg== X-Received: by 2002:a02:304a:: with SMTP id q71mr5146366jaq.131.1586314923503; Tue, 07 Apr 2020 20:02:03 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:03 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Jaehoon Chung , Vagrant Cascadian Subject: [PATCH v4 18/31] x86: Move acpi_s3.h to include/acpi/ Date: Tue, 7 Apr 2020 21:00:54 -0600 Message-Id: <20200407210023.v4.18.Ie511d0d0f8ddd84e9c49768b0b68f7bedd402428@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This header relates to ACPI and we are about to add some more ACPI headers. Move this one into a new directory so they are together. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- Changes in v4: None Changes in v3: - Add new patch to move acpi_s3.h to include/acpi/ Changes in v2: None arch/x86/cpu/apollolake/cpu_spl.c | 2 +- arch/x86/cpu/apollolake/fsp_s.c | 2 +- arch/x86/cpu/apollolake/pmc.c | 2 +- arch/x86/cpu/baytrail/acpi.c | 4 ++-- arch/x86/cpu/cpu.c | 2 +- arch/x86/cpu/wakeup.S | 2 +- arch/x86/lib/acpi_s3.c | 2 +- arch/x86/lib/coreboot_table.c | 2 +- arch/x86/lib/fsp/fsp_common.c | 2 +- arch/x86/lib/fsp1/fsp_common.c | 2 +- arch/x86/lib/fsp2/fsp_dram.c | 2 +- drivers/pci/pci_rom.c | 4 +--- drivers/power/acpi_pmc/acpi-pmc-uclass.c | 2 +- drivers/sysreset/sysreset_x86.c | 2 +- include/{ => acpi}/acpi_s3.h | 0 15 files changed, 15 insertions(+), 17 deletions(-) rename include/{ => acpi}/acpi_s3.h (100%) diff --git a/arch/x86/cpu/apollolake/cpu_spl.c b/arch/x86/cpu/apollolake/cpu_spl.c index 8a39c3128e0..e2509e391fa 100644 --- a/arch/x86/cpu/apollolake/cpu_spl.c +++ b/arch/x86/cpu/apollolake/cpu_spl.c @@ -6,13 +6,13 @@ */ #include -#include #include #include #include #include #include #include +#include #include #include #include diff --git a/arch/x86/cpu/apollolake/fsp_s.c b/arch/x86/cpu/apollolake/fsp_s.c index 1f22c1ea3c6..17cf1682ad0 100644 --- a/arch/x86/cpu/apollolake/fsp_s.c +++ b/arch/x86/cpu/apollolake/fsp_s.c @@ -5,11 +5,11 @@ */ #include -#include #include #include #include #include +#include #include #include #include diff --git a/arch/x86/cpu/apollolake/pmc.c b/arch/x86/cpu/apollolake/pmc.c index aec0c8394c2..4ea7c7447bc 100644 --- a/arch/x86/cpu/apollolake/pmc.c +++ b/arch/x86/cpu/apollolake/pmc.c @@ -9,10 +9,10 @@ #define LOG_CATEGORY UCLASS_ACPI_PMC #include -#include #include #include #include +#include #include #include #include diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c index f44228e6939..3c27391873c 100644 --- a/arch/x86/cpu/baytrail/acpi.c +++ b/arch/x86/cpu/baytrail/acpi.c @@ -4,15 +4,15 @@ */ #include -#include #include #include -#include +#include #include #include #include #include #include +#include void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, void *dsdt) diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index dae06949cc6..246ee50948c 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -19,7 +19,6 @@ */ #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/x86/cpu/wakeup.S b/arch/x86/cpu/wakeup.S index 244ca1276af..093bf3bcc5c 100644 --- a/arch/x86/cpu/wakeup.S +++ b/arch/x86/cpu/wakeup.S @@ -5,7 +5,7 @@ * From coreboot src/arch/x86/wakeup.S */ -#include +#include #include #include diff --git a/arch/x86/lib/acpi_s3.c b/arch/x86/lib/acpi_s3.c index 197636c4b50..c3759ec8492 100644 --- a/arch/x86/lib/acpi_s3.c +++ b/arch/x86/lib/acpi_s3.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include #include diff --git a/arch/x86/lib/coreboot_table.c b/arch/x86/lib/coreboot_table.c index 2943e11d2a4..c996fc588df 100644 --- a/arch/x86/lib/coreboot_table.c +++ b/arch/x86/lib/coreboot_table.c @@ -4,9 +4,9 @@ */ #include -#include #include #include +#include #include #include diff --git a/arch/x86/lib/fsp/fsp_common.c b/arch/x86/lib/fsp/fsp_common.c index 5eff0f99aad..267527eb344 100644 --- a/arch/x86/lib/fsp/fsp_common.c +++ b/arch/x86/lib/fsp/fsp_common.c @@ -4,11 +4,11 @@ */ #include -#include #include #include #include #include +#include #include #include #include diff --git a/arch/x86/lib/fsp1/fsp_common.c b/arch/x86/lib/fsp1/fsp_common.c index aee2a05044f..0a726807c2b 100644 --- a/arch/x86/lib/fsp1/fsp_common.c +++ b/arch/x86/lib/fsp1/fsp_common.c @@ -4,11 +4,11 @@ */ #include -#include #include #include #include #include +#include #include #include #include diff --git a/arch/x86/lib/fsp2/fsp_dram.c b/arch/x86/lib/fsp2/fsp_dram.c index 90a238a2245..c8f2c09b6a7 100644 --- a/arch/x86/lib/fsp2/fsp_dram.c +++ b/arch/x86/lib/fsp2/fsp_dram.c @@ -5,9 +5,9 @@ */ #include -#include #include #include +#include #include #include #include diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index 90f224b0452..6b17f18bc07 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -33,12 +33,10 @@ #include #include #include +#include #include -#ifdef CONFIG_X86 -#include DECLARE_GLOBAL_DATA_PTR; -#endif __weak bool board_should_run_oprom(struct udevice *dev) { diff --git a/drivers/power/acpi_pmc/acpi-pmc-uclass.c b/drivers/power/acpi_pmc/acpi-pmc-uclass.c index d43de87126c..1c79f835c66 100644 --- a/drivers/power/acpi_pmc/acpi-pmc-uclass.c +++ b/drivers/power/acpi_pmc/acpi-pmc-uclass.c @@ -6,9 +6,9 @@ #define LOG_CATEGORY UCLASS_ACPI_PMC #include -#include #include #include +#include #ifdef CONFIG_X86 #include #endif diff --git a/drivers/sysreset/sysreset_x86.c b/drivers/sysreset/sysreset_x86.c index 8e2d1eaa7a1..bc911435602 100644 --- a/drivers/sysreset/sysreset_x86.c +++ b/drivers/sysreset/sysreset_x86.c @@ -6,11 +6,11 @@ */ #include -#include #include #include #include #include +#include #include #include diff --git a/include/acpi_s3.h b/include/acpi/acpi_s3.h similarity index 100% rename from include/acpi_s3.h rename to include/acpi/acpi_s3.h From patchwork Wed Apr 8 03:00: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: 1267716 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=lDswcNoz; 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 48xq0l2nLqz9sPF for ; Wed, 8 Apr 2020 13:05:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6D08819C7; Wed, 8 Apr 2020 05:02:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lDswcNoz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F1C6819E7; Wed, 8 Apr 2020 05:02:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 49559819AD for ; Wed, 8 Apr 2020 05:02:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id h6so5595842iok.11 for ; Tue, 07 Apr 2020 20:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZmAE7kUtLLB9J3PZBsrLRAG9tn6SgEIe8eYjP7Re+2c=; b=lDswcNoznXNeN4ZBtd1+t4tmkpbbeoY+LI4vMPE6MH6PiOV4kpOBhPNeM2l3SbU/uo 2aMvd7y4TfFfczx5VbxI0PIfKn2FanwBZ3U16n/sIuiA4GilWPAahzGxcifP1mIbyGl2 Y9Df2QTFwiHocRBiLEjEj5zGmg0Qvfk+l0VM4= 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=ZmAE7kUtLLB9J3PZBsrLRAG9tn6SgEIe8eYjP7Re+2c=; b=C9h+C6snj/SrEPjPpLQDR1HvdpNa3UIBuJWM7ZEAgp/nuwPq+ObfZzX9aRA287r8b+ XZvliZJINvr3r6mG+t5mW0SrTa5m/VX8oNaNTfzOwZfDGz525nwtlhEsMsNiCW7FDUY9 jcGwA2dPOdhW8uuPgmEzpb5DgI7alQru37+gVObfJYQ+3gh3PHx9C6kDZzgIWy4Sn4o3 UypoMlWsrFgeuqb+5d6CDE/TLBICLCz6zGiiG99R0G6WnuELizK7G7ffyEB1bApFBfxV OoIM+9e20hr6qcAfJz1jcVSgRsD/s7J9ftWRHcTEIGuK0WyF9lpauq8UmkQaf610MO4P NBKA== X-Gm-Message-State: AGi0Pua9WxIzsaTpe1wGqAsMt0nNv+kUB+w3C4uTdBjzwtDQ9Vvg3EXO yqakEnJJW5HCCeIg55juOv1GiLVtEWlASg== X-Google-Smtp-Source: APiQypJGuthq7Wg69CzuVNam0UR3jiaFu5pF2xgqaxGe2MAIJBSgOrnYwuorxHu7Im9IX80IM+4BZg== X-Received: by 2002:a5e:9e0a:: with SMTP id i10mr5100358ioq.173.1586314928114; Tue, 07 Apr 2020 20:02:08 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:07 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Alexander Graf , Heinrich Schuchardt , Joe Hershberger Subject: [PATCH v4 19/31] x86: Move acpi_table header to main include/ directory Date: Tue, 7 Apr 2020 21:00:55 -0600 Message-Id: <20200407210023.v4.19.If8795289f9cb41804659b2b37b17185f588b3175@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This file is potentially useful to other architectures saddled with ACPI so move most of its contents to a common location. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: - Update commit message to say that we move most of its contents - Move acpi_table.h to include/acpi - Add forward declarations for the functions Changes in v2: None 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 | 4 +- arch/x86/include/asm/acpi_table.h | 381 +---------------------------- 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/acpi_table.h | 394 ++++++++++++++++++++++++++++++ lib/efi_loader/efi_acpi.c | 2 +- 12 files changed, 412 insertions(+), 385 deletions(-) create mode 100644 include/acpi/acpi_table.h diff --git a/arch/x86/cpu/baytrail/acpi.c b/arch/x86/cpu/baytrail/acpi.c index 3c27391873c..57723109796 100644 --- a/arch/x86/cpu/baytrail/acpi.c +++ b/arch/x86/cpu/baytrail/acpi.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c index 246ee50948c..cec04b481b9 100644 --- a/arch/x86/cpu/cpu.c +++ b/arch/x86/cpu/cpu.c @@ -27,8 +27,8 @@ #include #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 7b6fc2f4a53..26cda3b3376 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 8b128138b0d..4ec8fdd6f89 100644 --- a/arch/x86/cpu/tangier/acpi.c +++ b/arch/x86/cpu/tangier/acpi.c @@ -8,13 +8,13 @@ #include #include #include -#include -#include +#include #include #include #include #include #include +#include void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, void *dsdt) diff --git a/arch/x86/include/asm/acpi_table.h b/arch/x86/include/asm/acpi_table.h index 7588913f937..928475cef4e 100644 --- a/arch/x86/include/asm/acpi_table.h +++ b/arch/x86/include/asm/acpi_table.h @@ -9,381 +9,14 @@ #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_facs; +struct acpi_fadt; 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; -}; +struct acpi_madt_ioapic; +struct acpi_madt_irqoverride; +struct acpi_madt_lapic_nmi; +struct acpi_mcfg_mmconfig; +struct acpi_table_header; /* These can be used by the target port */ diff --git a/arch/x86/lib/acpi.c b/arch/x86/lib/acpi.c index cba9c24dd45..7431458dcf2 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 c3759ec8492..52410a515df 100644 --- a/arch/x86/lib/acpi_s3.c +++ b/arch/x86/lib/acpi_s3.c @@ -5,8 +5,8 @@ #include #include +#include #include -#include #include #include diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 66e32f21bdb..4832364f3ca 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index 7aea722d0b8..574d331d76f 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -6,10 +6,10 @@ #include #include #include +#include #include #include #include -#include #include /** diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 9b5e767ccc2..ffc09630b7d 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/acpi_table.h b/include/acpi/acpi_table.h new file mode 100644 index 00000000000..b4404a632c0 --- /dev/null +++ b/include/acpi/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 a4e5e53d15e..9ae9c25c51e 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 Wed Apr 8 03:00: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: 1267715 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=J2bUMF7W; 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 48xq0X3GVCz9sPF for ; Wed, 8 Apr 2020 13:05:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 601CC81A0B; Wed, 8 Apr 2020 05:02:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="J2bUMF7W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35149819E8; Wed, 8 Apr 2020 05:02:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 74491818E8 for ; Wed, 8 Apr 2020 05:02:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id u2so5635147iop.10 for ; Tue, 07 Apr 2020 20:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/JDyulpx41aXOubE8NCrYkKEtpMpX4+ngUrAsqc/jW0=; b=J2bUMF7WrBzzLT2fwdbKMDB3u+RJw+6cIIGHGUkvu+kYefbGH5LB/Nn0tJbieEzQCm 9tcwjovUC7OmXubvg8nNYAKY8ELrWuT62ktV5eBLlBqxK4ddYGuvBRmHsKJhwRHVi28k HrWfGtfMOuPap6ltxvquok54PH3rZB2yFiC5Y= 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=/JDyulpx41aXOubE8NCrYkKEtpMpX4+ngUrAsqc/jW0=; b=OWIQd0B61syYiPn6CP0cMqZqtamGKz0L02yp3OHs5vyXcE3xyOTXQF6gKkEXMxCp23 YsTfGxH5CywOFtGhGtue9G0QmDR5abL5lGVYA/ZhuVMweTRuHXrR1S21qnsgQ0aT+iH8 pzdWYz6JzHxlvLBWoc6gqwEyfx1VmA0Dx3EHdwhzgQbq9osK438YrucnHhlmC6+WGXCF RXtwILU6lOpI1QxkOZFA4BQNZOifWfgmlKjqsIj0Ris1733bZk/0Eu6IZMEM3E3g2d6R wNUX0JWeWSH9enTjuEkhgYLXPc6ZDnMA4mC7CSJCIaOaLa20kbgop4DAnDa33cERQh8R 4WgA== X-Gm-Message-State: AGi0PubwVCqtGx2kMsh21H7KGWBHdDdSA8Ny3eeNvkoWLp3c3ivCg8hx P3q+UiaK9FXzcI1jRhxJiG8sbmeNoH4+AA== X-Google-Smtp-Source: APiQypLSt7MKwKyQhYevm8nna4DZJT2WE1RHkgYJzMP67mpZ3E9Hx45FN4ktfUed/n2NRHP75IN3mA== X-Received: by 2002:a5e:9b13:: with SMTP id j19mr5055653iok.86.1586314933212; Tue, 07 Apr 2020 20:02:13 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Anatolij Gustschin , Heinrich Schuchardt , Jean-Jacques Hiblot , Patrick Delaunay Subject: [PATCH v4 20/31] acpi: Add an __ACPI__ preprocessor symbol Date: Tue, 7 Apr 2020 21:00:56 -0600 Message-Id: <20200407210023.v4.20.I6e674b2388c5a74a6912deb2dcc9c8acc8875da0@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None include/acpi/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/acpi_table.h b/include/acpi/acpi_table.h index b4404a632c0..dd748958136 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/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 c13d0c8448a..ee218b44e85 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 (ACPI_NAME_LEN + 1) +#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_copy_name(char *out_name, const char *name); +#endif /* __ACPI__ */ + #endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 30f392fdfb0..aebdb38d0d2 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -413,8 +413,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 Wed Apr 8 03:00: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: 1267717 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=iFb3RJfH; 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 48xq0z3ttgz9sSX for ; Wed, 8 Apr 2020 13:06:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0E0ED81A08; Wed, 8 Apr 2020 05:02:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iFb3RJfH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E89A819F2; Wed, 8 Apr 2020 05:02:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 2E718819DC for ; Wed, 8 Apr 2020 05:02:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id b12so5626178ion.8 for ; Tue, 07 Apr 2020 20:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JjSSue0d9HqpSg/xUPZt0VxtRHyTrHS4p4cpJF8Kg+k=; b=iFb3RJfHChC2xZPZ86VisCwA+zf9wnQgE12BZimVlmmDpaHUx4zUZHhD8Yj1FWs5vx yOyvNxuwuZLTzYEaMQasJQw39h99jX/NBsuzK7QFEre1Nv7rUPgnGtyhlxXknvnXsWTl YvlEkxpvowbQ4BuTQCL1yuNJ9/EwR69JxD15U= 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=JjSSue0d9HqpSg/xUPZt0VxtRHyTrHS4p4cpJF8Kg+k=; b=ZyLY4JjiK7/TYwmNDymqQrpHXO4dPS3GXf1BS1Y5MyblqhrdfCcDETwTnzQgY/T3tu aItfYCxTsY0usCl80DGP9h9Wduie4rN6AU4zM1kuvcz17yQViBMqRrKfakx56fylSPrn JgfTdNlbOKfaRoQxZMhoub9sDOwyTk9teCqLZXwChlKLnw7qlsxAyA+4ZKzLNWK8HAPy 9fNXUhmuws7EzkZvQo6grlo6X3WcmGJv4nMBTMA1MCChqQeZQE7UXVpYK6Qos3cO9uY9 AwmTlpzDzTxiZeYoNJ2x3KviwxnLKRwrB7dKEnnbatzNqvOJ5LklbOxQbpKu0f9i/mdY NNSQ== X-Gm-Message-State: AGi0PuZxFgL4xxvpkGC5CBnmM+GyAVMLsCUJXmybAB6aq9sGVgGH+HLq hJ5cl7ekevtoqEXwsAmJi+Q9iDorOijRFA== X-Google-Smtp-Source: APiQypItQSXMEAHSDVwxFO8SAI1N2/jMozjJe2a3IiryRSqoxBw4CmiDS+U2YA7WIcevEb6vdrQiCg== X-Received: by 2002:a02:9a0d:: with SMTP id b13mr5042308jal.60.1586314934840; Tue, 07 Apr 2020 20:02:14 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , AKASHI Takahiro , Heinrich Schuchardt , =?utf-8?q?Marek_Beh=C3=BAn?= , Peng Fan , Philippe Reynes Subject: [PATCH v4 21/31] acpi: Add a central location for table version numbers Date: Tue, 7 Apr 2020 21:00:57 -0600 Message-Id: <20200407210023.v4.21.I19e38d6d49d8a7ac5fbe8a724e5ab3e71f857208@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: - Move ACPI makefile line outside the ifdef CONFIG_SPL_BUILD - Add a comment about the MADT table version - Add SPCR - Update comment to include tables defined or reserved by ACPI Changes in v3: - Fix file comment for acpi_table.c - Fix a few typos Changes in v2: - Move the sandbox acpi_table.h header file to an earlier patch - Use #defines for MADT and MCFG version numbers include/acpi/acpi_table.h | 62 +++++++++++++++++++++++++++++++++++++++ lib/Makefile | 1 + lib/acpi/Makefile | 4 +++ lib/acpi/acpi_table.c | 62 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 14 +++++++++ 5 files changed, 143 insertions(+) create mode 100644 lib/acpi/Makefile create mode 100644 lib/acpi/acpi_table.c diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h index dd748958136..286ff2a20d6 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -202,6 +202,26 @@ 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 + +/* MADT TABLE Revision values - note these do not match the ACPI revision */ +#define ACPI_MADT_REV_ACPI_3_0 2 +#define ACPI_MADT_REV_ACPI_4_0 3 +#define ACPI_MADT_REV_ACPI_5_0 3 +#define ACPI_MADT_REV_ACPI_6_0 5 + +#define ACPI_MCFG_REV_ACPI_3_0 1 + +/* 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 +411,48 @@ struct __packed acpi_spcr { u32 reserved2; }; +/* Tables defined/reserved by ACPI and generated by U-Boot */ +enum acpi_tables { + ACPITAB_BERT, + ACPITAB_DBG2, + ACPITAB_DMAR, + ACPITAB_DSDT, + ACPITAB_ECDT, + ACPITAB_FACS, + ACPITAB_FADT, + ACPITAB_HEST, + ACPITAB_HPET, + ACPITAB_IVRS, + ACPITAB_MADT, + ACPITAB_MCFG, + ACPITAB_RSDP, + ACPITAB_RSDT, + ACPITAB_SLIT, + ACPITAB_SPCR, + ACPITAB_SRAT, + ACPITAB_SSDT, + ACPITAB_TCPA, + ACPITAB_TPM2, + ACPITAB_XSDT, + + /* Additional proprietary tables */ + ACPITAB_NHLT, + ACPITAB_SPMI, + ACPITAB_VFCT, + + 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 15259d0473c..5bd6f57482e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_TPM_V1) += tpm-v1.o obj-$(CONFIG_TPM_V2) += tpm-v2.o endif +obj-$(CONFIG_$(SPL_)ACPIGEN) += acpi/ obj-$(CONFIG_$(SPL_)RSA) += rsa/ obj-$(CONFIG_SHA1) += sha1.o obj-$(CONFIG_SHA256) += sha256.o diff --git a/lib/acpi/Makefile b/lib/acpi/Makefile new file mode 100644 index 00000000000..660491ef711 --- /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 00000000000..3268430cd1e --- /dev/null +++ b/lib/acpi/acpi_table.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Generic code used to generate ACPI tables + * + * 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: + return ACPI_MADT_REV_ACPI_3_0; + case ACPITAB_MCFG: + return ACPI_MCFG_REV_ACPI_3_0; + case ACPITAB_TCPA: + /* This version and the rest are open-coded */ + 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 to 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 to 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; + case ACPITAB_SPCR: + return 2; + default: + return -EINVAL; + } +} diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 429993b9cc0..e5510e4323b 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -8,6 +8,7 @@ #include #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 Wed Apr 8 03:00: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: 1267718 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=WC61vqSX; 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 48xq1B2QTTz9sPF for ; Wed, 8 Apr 2020 13:06:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AB56081A29; Wed, 8 Apr 2020 05:02:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WC61vqSX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DECE819E8; Wed, 8 Apr 2020 05:02:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 B1C05819E1 for ; Wed, 8 Apr 2020 05:02:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id f3so5685032ioj.1 for ; Tue, 07 Apr 2020 20:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sf5L6fAsSdYuDk5fO+egZU5y8Urs/YE5IA/MLllDbIE=; b=WC61vqSX4mwdPpWW9YV2LFLtM5eYUq0+nk/PqpZXwgXV4nw1SOtTurE4yl82/0s9FH ho3zPCSEpNDzOFPQW4s1M4dP5uHmHGK6Z5ihdU/3SqPng4ZvTcryQpZ3D6tGSRm9HIzK cCFzBgUuyYtklKjOBQbXw90fPoilJDp5sDf5k= 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=Sf5L6fAsSdYuDk5fO+egZU5y8Urs/YE5IA/MLllDbIE=; b=RViyGWcJnyOo3dqYvGZ6q8GFkPgi4k5iTJ+YWh3ulN0J63lPKDPm1OWqNsH7pqIOMa y9/awRL0M9X/0Lf8aTugFespf3NGFISKcnrySIiEC2bavBdv/Ww0Le6Gw8gD9zud3T3/ hwZNQE0ZROvhMKxkTXPzqUA+9QvDcSWyswfP0YKWXq83QINa6Z2BrZHfrMI6vweDYufa R5lslFp+u+oN8z53srYWSwM5i0RGcV3mOegPteNAuMN6TWPmmB5aNBJqPRHQ0/6NhQcj Iacr1znHsfuxLQy9oNIORzOrPu7KXwnLrphIU6lJ+qnq3X2fDAutwSjEv4TrtSUmgT2P qkqw== X-Gm-Message-State: AGi0PubYQglz0Njx8FVmtu5xeQ2mFlxK20zwCH3tvKpLOxaM5H+02Tyv E3t/IbebprhhmQWj7/SRsNnNYr+ZhpjXXw== X-Google-Smtp-Source: APiQypKUAu1q8GH5hP5AmWK3el5d1q0qR0tBnxWO2qNRcwH6Y/8dZ/tiC2edKHtG68Ss1zUt2txtWQ== X-Received: by 2002:a5d:9911:: with SMTP id x17mr5168631iol.52.1586314936338; Tue, 07 Apr 2020 20:02:16 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 22/31] acpi: Add support for DMAR Date: Tue, 7 Apr 2020 21:00:58 -0600 Message-Id: <20200407210023.v4.22.Iffd9fd365ee53abc99a8f1e85c40d30c9368c19d@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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. Reviewed-by: Bin Meng Reviewed-by: Wolfgang Wallner Signed-off-by: Simon Glass --- Changes in v4: None Changes in v3: - Make use of BIT() - Fix DMA_ typo - Add missing error check in acpi_create_dmar() - Drop duplicate assert - Drop ASL_REVISION Changes in v2: - Drop two unnecessary __packed - Move __packed to after struct include/acpi/acpi_table.h | 54 +++++++++++++++++++++++++++++++++++++++ lib/acpi/acpi_table.c | 28 ++++++++++++++++++++ test/dm/acpi.c | 13 ++++++++++ 3 files changed, 95 insertions(+) diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h index 286ff2a20d6..16048437a3f 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -360,6 +360,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 = BIT(0) +}; + +enum dmar_flags { + DMAR_INTR_REMAP = BIT(0), + DMAR_X2APIC_OPT_OUT = BIT(1), + DMAR_CTRL_PLATFORM_OPT_IN_FLAG = BIT(2), +}; + +struct dmar_entry { + u16 type; + u16 length; + u8 flags; + u8 reserved; + u16 segment; + u64 bar; +}; + +struct dmar_rmrr_entry { + u16 type; + u16 length; + u16 reserved; + u16 segment; + u64 bar; + u64 limit; +}; + +/* DMAR (DMA Remapping Reporting Structure) */ +struct __packed acpi_dmar { + struct acpi_table_header header; + u8 host_address_width; + u8 flags; + u8 reserved[10]; + struct dmar_entry structure[0]; +}; + /* DBG2 definitions are partially used for SPCR interface_type */ /* Types for port_type field */ @@ -453,6 +498,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 3268430cd1e..ec354102f87 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -7,6 +7,34 @@ #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); + if (ret) + return log_msg_ret("info", ret); + 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 e5510e4323b..21ed7c74409 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -67,3 +67,16 @@ 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(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 Wed Apr 8 03:00: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: 1267719 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Q5O2Tg7O; 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 48xq1Q1nkfz9sPF for ; Wed, 8 Apr 2020 13:06:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99A4E81A4E; Wed, 8 Apr 2020 05:02:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Q5O2Tg7O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8C58819E3; Wed, 8 Apr 2020 05:02:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 08E1D803D9 for ; Wed, 8 Apr 2020 05:02:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id e79so5657326iof.5 for ; Tue, 07 Apr 2020 20:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=33djj9xJWOGhIEeZrHqZCCXRm9623nHWYWkfJIsXm7w=; b=Q5O2Tg7OIysKeBKSHlp8KdkH5rkshJLzHRB3qEPeu/2dVpiVRbvW7NLgzwZs3LV1Lu B7xNjGDMSqi+2BxxbMXQQYNDfsRXkQjYEetyoYgy2jmJhtX0PA3yQG2rx69QT0G+tc3+ mTaOv/SWW8jUnuulTwwwFXmb4fAMxkYMKDOjE= 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=33djj9xJWOGhIEeZrHqZCCXRm9623nHWYWkfJIsXm7w=; b=Uc6BhbMf4WC+OugKHdpcl4iI7Hn8jBHls0XpMBJ+ukPM+OyaLgOv94yrEno5tDfQsX I15302qyfvgwMIjQ1HH7jzR76nvHufUml1SwfmIjA0JVd07fE3ID7Bm92CqygC+X3Xdf QlVSbv9/2DADTWxB5pEfGa9Qyxhf/W+lUV3YTtTUnKjWRIVsMzsDbx0P2ALvezf5aXv1 7sYu8UdX2W41Ikyngk2aRCAL3d/04vRUAKFhI9v6/TTQnfEUJlvviyx8BtuLwj2yWziz EP8aixaBXvtp+HJJCJkz27qCcxrEAo7nFeAX7lXgZrTB5ZT5TtdXK//4mSo5MWZ4oC+b WgDg== X-Gm-Message-State: AGi0PuZ/hWOflvrWU9k5TJiIZSqQ2g4WpIvwgQhsK8KhFtDOlaRKOJYe bta0LtoeKI9VHORM6996b7eaGDGmxoaIXw== X-Google-Smtp-Source: APiQypIYV6/J4D5OIT8X7IHvHJEblGYoK6bDc1afL5d5ZnXSM4J12uFd9r9/a0klX2Uh00PD3IkcEw== X-Received: by 2002:a02:84a1:: with SMTP id f30mr4774388jai.39.1586314937814; Tue, 07 Apr 2020 20:02:17 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:17 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 23/31] test: Add hexdump.h to the unit test header Date: Tue, 7 Apr 2020 21:00:59 -0600 Message-Id: <20200407210023.v4.23.I67bf7678070abfc440b46c9440446b3089f94f5d@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Since ut_asserteq_mem() uses bin2hex() we should include this header in ut.h to avoid errors. Add it. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: - Add new patch to add hexdump.h to the unit test header Changes in v2: None include/test/ut.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/test/ut.h b/include/test/ut.h index 04df8ba3af3..39d15953ed3 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -8,6 +8,7 @@ #ifndef __TEST_UT_H #define __TEST_UT_H +#include #include struct unit_test_state; From patchwork Wed Apr 8 03:01: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: 1267720 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=D2i56YS9; 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 48xq1d6N86z9sPF for ; Wed, 8 Apr 2020 13:06:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF36581BB5; Wed, 8 Apr 2020 05:02:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="D2i56YS9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77120819F2; Wed, 8 Apr 2020 05:02:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 37C00819DA for ; Wed, 8 Apr 2020 05:02:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id y17so5606006iow.9 for ; Tue, 07 Apr 2020 20:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AloKVDrSCR+QGuQCgrrqcbkE7yoeO+3WW4oJDANnsM4=; b=D2i56YS9XTzB8kLOoFFhvIj7+zsz+lX+gjE/MHWueCABvkw8uwxqlM6vwfDe+yZ691 MmtrGE4UtTatNQ1layGvSbY/8m2lfUDt9V6AMfVrUk0sS3lf/XgmETXttksbOYgI79TK tSxQ6S65mbfLVD4/bamZ00g+xpDvE6WY3KOIc= 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=AloKVDrSCR+QGuQCgrrqcbkE7yoeO+3WW4oJDANnsM4=; b=cUU/ItEvffhF3nsZ0ENio1mU9DENyq3bYQ7ItbsudSGpV0sLDAXYbQHqtV1C1nfpL5 5lfktUh7p2ux4YKjicvXh38ZyXO/unHt+qevTt0qwGBZ0Rrsoceeu7/soOVm0Z1ikyaL YZRtGWWPDhpdlEDVD5qEosKglj4ud05ERdSptyCngKkx8CIcaLsNiTk+iN0bfW7RJVy7 SmtQ21oHHQEuovlDzkOOht15FpqU9yUVaLNIoc4BtAQz48yeWW3DY8qO62SkcBtkJUlL xxDfdYvcDIUpVi4d7RE0uUyoL1GeVBhPKy4l4/uIARI7ljmMi3jxAbXl1wqQrL5XtOtb psvw== X-Gm-Message-State: AGi0PuZ4Io9rTnwYQDgLhKHdgvwvTAzNhF/YN/8+lUgHXI3h+lqAsGcV tkhjc6Hbzmd992p89F1sfUXv29zfIJ82Iw== X-Google-Smtp-Source: APiQypLSJRYVgdEEaYoiApjqgbagOIa7Tbf9mWWDYDY/397CvaBF/vpw++wPsw1BrF0lJ828B49UWA== X-Received: by 2002:a6b:3e42:: with SMTP id l63mr5257575ioa.140.1586314939685; Tue, 07 Apr 2020 20:02:19 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:19 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , AKASHI Takahiro , Alex Marginean , Jean-Jacques Hiblot , Lukasz Majewski Subject: [PATCH v4 24/31] acpi: Add a method to write tables for a device Date: Tue, 7 Apr 2020 21:01:00 -0600 Message-Id: <20200407210023.v4.24.I04c496e973a0d5eb09ed6f6e4674c300fc34b605@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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. Reviewed-by: Wolfgang Wallner Signed-off-by: Simon Glass --- Changes in v4: - Separate out the log newline Changes in v3: None Changes in v2: - Drop definition of ACPI_TABLE_CREATOR - Make _acpi_write_dev_tables() static and switch argument order - Generalise the ACPI function recursion with acpi_recurse_method() arch/sandbox/dts/test.dts | 4 +++ arch/x86/lib/acpi_table.c | 9 ----- drivers/core/acpi.c | 62 ++++++++++++++++++++++++++++++++++ include/acpi/acpi_table.h | 10 ++++++ include/dm/acpi.h | 30 +++++++++++++++++ lib/acpi/acpi_table.c | 10 ++++++ test/dm/acpi.c | 71 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 187 insertions(+), 9 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 5fa951ad4b6..1204c14b079 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/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 4832364f3ca..98f97208339 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -60,15 +60,6 @@ static void acpi_write_rsdp(struct acpi_rsdp *rsdp, struct acpi_rsdt *rsdt, 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); diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 0e64c21bf5b..8a6570c3b95 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -11,8 +11,17 @@ #include #include #include +#include #include +/* Type of method to call */ +enum method_t { + METHOD_WRITE_TABLES, +}; + +/* Prototype for all methods */ +typedef int (*acpi_method)(const struct udevice *dev, struct acpi_ctx *ctx); + int acpi_copy_name(char *out_name, const char *name) { strncpy(out_name, name, ACPI_NAME_MAX); @@ -31,3 +40,56 @@ int acpi_get_name(const struct udevice *dev, char *out_name) return -ENOSYS; } + +acpi_method acpi_get_method(struct udevice *dev, enum method_t method) +{ + struct acpi_ops *aops; + + aops = device_get_acpi_ops(dev); + if (aops) { + switch (method) { + case METHOD_WRITE_TABLES: + return aops->write_tables; + } + } + + return NULL; +} + +int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent, + enum method_t method) +{ + struct udevice *dev; + acpi_method func; + int ret; + + func = acpi_get_method(parent, method); + if (func) { + log_debug("\n"); + log_debug("- %s %p\n", parent->name, func); + ret = device_ofdata_to_platdata(parent); + if (ret) + return log_msg_ret("ofdata", ret); + ret = func(parent, ctx); + if (ret) + return log_msg_ret("func", ret); + } + device_foreach_child(dev, parent) { + ret = acpi_recurse_method(ctx, dev, method); + if (ret) + return log_msg_ret("recurse", ret); + } + + return 0; +} + +int acpi_write_dev_tables(struct acpi_ctx *ctx) +{ + int ret; + + log_debug("Writing device tables\n"); + ret = acpi_recurse_method(ctx, dm_root(), METHOD_WRITE_TABLES); + log_debug("Writing finished, err=%d\n", ret); + + return ret; +} diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h index 16048437a3f..7f44b0434b9 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -507,6 +507,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/include/dm/acpi.h b/include/dm/acpi.h index ee218b44e85..9a0a437dd03 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_copy_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/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index ec354102f87..372f19b16d5 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) { @@ -88,3 +89,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 21ed7c74409..5743530a3a5 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -8,12 +8,26 @@ #include #include +#include #include #include #include #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) { @@ -22,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[] = { @@ -80,3 +95,59 @@ 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_asserteq_mem("ABCD", hdr.signature, sizeof(hdr.signature)); + ut_asserteq(0x11, hdr.length); + ut_asserteq(0x22, hdr.revision); + ut_asserteq(0x33, hdr.checksum); + ut_asserteq_mem(OEM_ID, hdr.oem_id, sizeof(hdr.oem_id)); + ut_asserteq_mem(OEM_TABLE_ID, hdr.oem_table_id, + sizeof(hdr.oem_table_id)); + ut_asserteq(U_BOOT_BUILD_DATE, hdr.oem_revision); + ut_asserteq_mem(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); + +/* 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 Wed Apr 8 03:01: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: 1267721 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ena88PkP; 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 48xq1t0xK3z9sPF for ; Wed, 8 Apr 2020 13:06:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 827A081BC1; Wed, 8 Apr 2020 05:02:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ena88PkP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5163E819F3; Wed, 8 Apr 2020 05:02:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 DDCBC819DE for ; Wed, 8 Apr 2020 05:02:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id o127so5695844iof.0 for ; Tue, 07 Apr 2020 20:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GSLcBZhEAV4gpEjGfV85O0ajX0rtvLMVung777NmJys=; b=ena88PkPVHwH9TGZ9ZSxvTgEhbgv9z7ArYIXEsVn8xURau8tw11eMxx0cTfEAaEhiG b7bb6shwRTHmy8vP2vCqmZhFif+je8NxKrC7vPGv97I3iMd66Eg6d3Q9RQlwAaU9Crk+ 4dHUFPIXWy+Q1vxinM8BaN53wu0GFJsg6PhsA= 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=GSLcBZhEAV4gpEjGfV85O0ajX0rtvLMVung777NmJys=; b=Z/CnKIH8oLoEer9wDeLnwXJrYTGmzb57Wc8YbEWDlpkWs55Pm2uYIRs+c/UThAGXfz v+SSlF3haAeQ0U2vLti/zhOcd5ftm8AgmoF8qE1WP4V67+le9Z/Xbx6jOG6lkz9r/kAo Dd3Rd4CGqBn8iBZuf1xdzUNXhI3Zf/ZdB50bSyCQfpgvsyG/FgCKbNoL8Qtact5uo6Zo 3MNOYkCIDKtAal4VfR3J9FqHEHVprNMrBMcplnFfahjVVGjvfAxyVBQo6o8wXMwYhhJU BrukDaSlFBbg/xS+kzpil555/dlxFqc/JQpmdoZ7mbvDeb5x0mWnF8X+Ey8zLposDFeN BevQ== X-Gm-Message-State: AGi0PubY2Fl3E3NAmXBeRAJEDjiDY124X9p8okGcf5lImTdLP/uCUf8E 9Wl4WIRNfIp7XfSaEh7BcFJefttQ36DBSQ== X-Google-Smtp-Source: APiQypI3eC646rML1WmPfAE7/IO/v/KglRp8z8wzpaFxb0oDdvJ565gCIDrdBhCZ7nwz2xPrIBD2qg== X-Received: by 2002:a05:6638:ce:: with SMTP id w14mr5044779jao.5.1586314941335; Tue, 07 Apr 2020 20:02:21 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:21 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 25/31] acpi: Convert part of acpi_table to use acpi_ctx Date: Tue, 7 Apr 2020 21:01:01 -0600 Message-Id: <20200407210023.v4.25.I93e1e33891714417335e1dd517982b18bf9f882f@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: - Update comment in acpi_inc_align() to show the alignment Changes in v3: - Rename acpi_align_large() to acpi_align64() Changes in v2: None arch/x86/lib/acpi_table.c | 88 +++++++++++++++++++-------------------- include/acpi/acpi_table.h | 36 ++++++++++++++++ lib/acpi/acpi_table.c | 24 ++++++++++- test/dm/acpi.c | 28 +++++++++++++ 4 files changed, 130 insertions(+), 46 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 98f97208339..484cf66bf4e 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 @@ -469,9 +471,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; @@ -482,60 +484,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_align64(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; } } @@ -545,51 +548,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/acpi_table.h b/include/acpi/acpi_table.h index 7f44b0434b9..6cca092b965 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -23,6 +23,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 @@ -517,6 +519,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_align64() - Align the ACPI output pointer to a 64-byte boundary + * + * @ctx: ACPI context + */ +void acpi_align64(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 to a 16-byte boundary + * + * @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 372f19b16d5..07d9bbb0afa 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -6,10 +6,11 @@ */ #include -#include #include #include #include +#include +#include int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) { @@ -98,3 +99,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_align64(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 5743530a3a5..17e208ee80e 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -151,3 +151,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_align64(&ctx); + ut_asserteq_ptr((void *)64, ctx.current); + acpi_align64(&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 Wed Apr 8 03:01: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: 1267722 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=GYKuVq90; 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 48xq251MYsz9sPF for ; Wed, 8 Apr 2020 13:07:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E14ED819DB; Wed, 8 Apr 2020 05:02:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GYKuVq90"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD24E81A30; Wed, 8 Apr 2020 05:02:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 92E8F81A1A for ; Wed, 8 Apr 2020 05:02:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id e79so5657814iof.5 for ; Tue, 07 Apr 2020 20:02:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4vUiCOPLb4JdyKG30kRvk4XgYG6+SLjIEMXFMD98FJE=; b=GYKuVq90+f3Mp5iHpJUj7x5PeCmAGa+DEb729JdPpgC59OE1ftp0J0zJQXIhWNvnSE Q8BJk/kQV/cYGJphJHx9VGU+1jdZJo6WulT5dxniQ8K2VvtBJLlB2KGbUwfR6fLuMooj aqKVgk7cGcIF5SWO2j7RqsDScWieU1KZZeCAw= 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=4vUiCOPLb4JdyKG30kRvk4XgYG6+SLjIEMXFMD98FJE=; b=Keu6U/VZcP1MKL+hCadJwiKms2uzwJRUDI3IEQdAvqfaDiVVDTSaMPS+ayZKjhTQl4 q837rn3iq5sjFC3hwC7RP5R63bUnQ99kdeV7s9bJ9DVC8fwj0p4ZQxc/Za2j3DuKwLri tmGxM5eajHzMUyB/d1pRaUEVFikJ7LSSzDrQMFDbWBa7YkXjfoX3W0wtvPx1jCdx3Gpc veiXf6Ip+HF+7ofEoGDRC/qi460Box7hoUpb9U9cdeHCpsLM0BVNvFcGdGp2QPh5TWLX uSwUPAQk5pVdgn+e4htpo0rnJxUDU0RsxT97qXx0WtzpLFKYY1iGNz+CEVLWHHqIc/jG lDMg== X-Gm-Message-State: AGi0PuZgyExWDE7WArQDg7CSj51PyB8Nq4FdDffVqSnZDFWboYIsEwBS LN6HtaRB+NSTp8SJjuN6byd4POtcnxvRaw== X-Google-Smtp-Source: APiQypIIgREzRBX3WS0V8/Sn2ooP5d/FIrkpdbnFPUS6atXjuaZspTviiaSpJwTd48VtGDem/C7KtQ== X-Received: by 2002:a05:6602:13d4:: with SMTP id o20mr5099922iov.104.1586314952319; Tue, 07 Apr 2020 20:02:32 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 26/31] x86: Allow devices to write ACPI tables Date: Tue, 7 Apr 2020 21:01:02 -0600 Message-Id: <20200407210023.v4.26.I6f54ae1deb9a3f954441d072e5d591d7cdb4ed5d@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None 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 484cf66bf4e..99523473a17 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -581,6 +581,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 Wed Apr 8 03:01: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: 1267724 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=ftniBMo+; 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 48xq2Y4m9cz9sPF for ; Wed, 8 Apr 2020 13:07:33 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C2C981948; Wed, 8 Apr 2020 05:03:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ftniBMo+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0706981A1A; Wed, 8 Apr 2020 05:02:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 217D481A27 for ; Wed, 8 Apr 2020 05:02:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id n20so5657442ioa.4 for ; Tue, 07 Apr 2020 20:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lCA4jxG4TamBErSbE2jiAaBNkNjYK0QVzqCp7pWOe/A=; b=ftniBMo+JCcSaqySS8luQ40MiWHPxoyKRpKtL/6myXnMtlYLoySLHvdXzU5nOy/A49 0kuU3yQC0AsSbT4y/PQVtWexkkS4zHLXutIXQYWp84JVxUu10Ftr2WKqEG7NnWpmzfKv vPZi2uaUkWljHeqLeKXX2HTz6VqiBtN5rmy2k= 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=lCA4jxG4TamBErSbE2jiAaBNkNjYK0QVzqCp7pWOe/A=; b=ulyi5YNJJs/ys8qGp8lzAcDMnYL76VbjnUB1bFYKZHdNH4U7EgSKwfJaI2xHC+L6/y 0WXCfv40faP0MIBbbDR9V0whfGJjouLEvwQfSBqXdCE6Tt4KYs5S+LdgEQumtYr2bF6I 4TJaF949/uMxX/Vi7Pmh/4l8mqOP1FewIXrTVx5CENgkRW9WyAOpVhzN5FcFa/Zacn1F RYAvcip2kfsjBVekvyo34jIaLsdUnRvcjMdfi1Ppv2FMQ9PXDUdkoz49AjwHgUrFwR+C PVYSlbQ3JmcYVW2+Kx3UrsDd5TD7LiBcfTjAO+KKu37Wk8ggMyI6+4T0vGs5VHtwyDsB 4lOg== X-Gm-Message-State: AGi0PuYz5yE8Imw7pQZzSD6wKlhgTu4OHMWD4SfccuVAugkWr85kwmls 8BY9GdCMBkpfI8kaxtK8telQ8aXRKQhZkA== X-Google-Smtp-Source: APiQypJY9R7jfe0P1V1F7PlgM2NH/3QvOI9xyrJJup80ch1sm9NcCv7WvgIYOPkEzlRFCqz3D2eCcA== X-Received: by 2002:a02:966a:: with SMTP id c97mr5110376jai.106.1586314953933; Tue, 07 Apr 2020 20:02:33 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 27/31] acpi: Drop code for missing XSDT from acpi_write_rsdp() Date: Tue, 7 Apr 2020 21:01:03 -0600 Message-Id: <20200407210023.v4.27.I4566efe7db4c618499115f6973d851e0aa502da9@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None 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 99523473a17..e8f0bb18fc5 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 Wed Apr 8 03:01: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: 1267723 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=RI8Linii; 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 48xq2K2hDZz9sSX for ; Wed, 8 Apr 2020 13:07:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6046E81C49; Wed, 8 Apr 2020 05:02:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RI8Linii"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5BAC281A0D; Wed, 8 Apr 2020 05:02:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 EE66681A0A for ; Wed, 8 Apr 2020 05:02:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id b12so5626890ion.8 for ; Tue, 07 Apr 2020 20:02:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KE0rJU2LvfPINVyczRN3sand7iyRlH5Vp0NU/HfMjCQ=; b=RI8Linii/lWj75pC7E3+Fzt16pyb7/ShtZLMm6YPohl+h9iYP+hzDCjD2eYz1OE4D9 6onPRE0AWmwHLN+J89x5/KI6OWg0mxIbiVUlsLrnuZsmxFuNSfvgysrn3tukxHgO0GJM un0K0HYuOtwB9H8abJ6dcRa8o2g6UWGvIKDMs= 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=KE0rJU2LvfPINVyczRN3sand7iyRlH5Vp0NU/HfMjCQ=; b=qctjyNnaMy2PESMtGOLgAn7RfsSw2shfYfeMQKNfQtmf/UmwMxAdiBFlOwy+IJOVh/ JK0i75HWt1yqjv2wllfC35NLXfYLQ30XVzBHz3dqGF0qpvI2N77nrmJ2MWDLTLWtAL8K 2qA0GkfUsUzMjZNldUbhqlcsve+nFAyMsGfP/579P9kjPQkbM/t9oQ1tl+h1y2xcKted 3x1qYo0m9YX94hGObV0DxS4FyALJrs54ODHr35rJA/eotInqcc6ryN/iA/uln+pYHO3I SooEe3p/EMOzR5lQnOKsbOQIXOKZfZWoySy8wF5X+S7Iikqcv7vvA413aFz95XPy2BfX MboA== X-Gm-Message-State: AGi0PuboOxY2RwxrTXgPzIX/thHBYApFaJhR4xrQI673k9pivvWQ9sBw 6YGZ+v1vgI/pc1tzflwGnd8WoE4vp/13Pw== X-Google-Smtp-Source: APiQypL+jwcZTmEkHnuy8ZObmd5YICfw3Vmb+y0NkWqOhcsVjdTgfjsHkjdCPFtcmNOT/MWBBwy9tA== X-Received: by 2002:a05:6638:398:: with SMTP id y24mr5024855jap.125.1586314955439; Tue, 07 Apr 2020 20:02:35 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 28/31] acpi: Move acpi_add_table() to generic code Date: Tue, 7 Apr 2020 21:01:04 -0600 Message-Id: <20200407210023.v4.28.Ie9d79ce7293bd55022f7c6e940ce3583d38353da@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: - Fix 'RSDP' typo Changes in v2: None arch/x86/lib/acpi_table.c | 83 +++++---------------------------------- include/acpi/acpi_table.h | 9 +++++ include/dm/acpi.h | 5 +++ lib/acpi/acpi_table.c | 61 ++++++++++++++++++++++++++++ test/dm/acpi.c | 4 ++ 5 files changed, 89 insertions(+), 73 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index e8f0bb18fc5..d4af56eabf4 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -83,67 +83,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; - - /* The RSDT is mandatory while the XSDT is not */ - rsdt = (struct acpi_rsdt *)rsdp->rsdt_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); - - /* The RSDT is mandatory while the XSDT is not */ - if (!rsdp->xsdt_address) - return; - - /* - * 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 - */ - xsdt = (struct acpi_xsdt *)((u32)rsdp->xsdt_address); - - /* 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)); @@ -463,8 +402,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; @@ -486,9 +423,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)); @@ -501,8 +438,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"); @@ -544,38 +481,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/acpi_table.h b/include/acpi/acpi_table.h index 6cca092b965..6225a4c5ccb 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -553,6 +553,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 9a0a437dd03..ee6f7a63e79 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 RSDT 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 07d9bbb0afa..5311ae9368b 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -120,3 +122,62 @@ 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; + + /* The RSDT is mandatory while the XSDT is not */ + rsdt = ctx->rsdt; + + /* 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 + */ + xsdt = (struct acpi_xsdt *)((uintptr_t)ctx->rsdp->xsdt_address); + + /* 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 17e208ee80e..4dd4a540967 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 Wed Apr 8 03:01: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: 1267725 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MTTdMCSj; 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 48xq2n4RxCz9sPF for ; Wed, 8 Apr 2020 13:07:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 29A20819E7; Wed, 8 Apr 2020 05:03:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MTTdMCSj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15B0881A0D; Wed, 8 Apr 2020 05:02:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 38FD281A2F for ; Wed, 8 Apr 2020 05:02:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x143.google.com with SMTP id o11so1117292ilq.7 for ; Tue, 07 Apr 2020 20:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Epth2rlPMQvUSrsRKC50pvh1L3d+1Hn0IJlJAT1Ko8k=; b=MTTdMCSjlq6rlrq7fTIlIdD8855TATvv4GhwZseNEH64wUrjJB2ICbz9tOxrika2HQ TpybHyzfiQ8SiQAsfwSitwOHy2EGNLSV8K++Okq44eFjI1dAKrDQQAjhhazcJYY1GMQc Au75xTlhwVnENJ/fqxWHF0YKFKkQiEwsEIMB0= 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=Epth2rlPMQvUSrsRKC50pvh1L3d+1Hn0IJlJAT1Ko8k=; b=Orf6AQUnX8KIkRSoMcO3rtNuLLPmFqWXzW+sMIT6X2BkiOMKJEMn+7ylCkcR6d98TT uYAyqTnXtdIr2CTNZ8Uo4u77MgdEjLSKo1lYNKvLpkWQA+6KssXBWx+NjXnejFr9w6TA h3VHAQk5dF2O7VFXntgCA3Z/oHLlFlKajOZxmZi1AckMlfqW4SsouZi8K/blsY2RVSVC w8O/tTtWTpMNNhA2HvJCCCXe2RXf30Woof6t9AAKzrfvQSwnHxikPz/kzUbps08Kl3uD 8tsbZo0EO3/qG56r+d0VeBrpzqFSD2BAtx/Cg8tEZ583lin1QOO5RkqTNMzF+cnsZpC/ tnVw== X-Gm-Message-State: AGi0PuZDEuhDu0k3MYqQkBySTUsqCNxG9lKucO5KwCfu24k3tiXhR0T9 tuq8sj1HAvbXOlbltHB3pLrTPssDRAvFmg== X-Google-Smtp-Source: APiQypJkyukOuy8fRGinI48F70eOwvMvyMChuoi2KVjWiG766MmF5zMmpFLS+iekNz0Ql56ltmyNLw== X-Received: by 2002:a05:6e02:54e:: with SMTP id i14mr6083078ils.166.1586314957368; Tue, 07 Apr 2020 20:02:37 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 29/31] acpi: Put table-setup code in its own function Date: Tue, 7 Apr 2020 21:01:05 -0600 Message-Id: <20200407210023.v4.29.I34e9fcd28119cc2fcb87ad8679efb582a4c611df@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 --- Changes in v4: - Put back cast on table_compute_checksum() Changes in v3: - Fix 'XDST' typo - Move acpi_align_large() out of dm_test_acpi_setup_base_tables() - Beef up the comment explaining how the unaligned address is used Changes in v2: None arch/x86/lib/acpi_table.c | 72 +----------------------------------- include/acpi/acpi_table.h | 10 +++++ lib/acpi/acpi_table.c | 77 +++++++++++++++++++++++++++++++++++++++ test/dm/acpi.c | 58 ++++++++++++++++++++++++++++- 4 files changed, 144 insertions(+), 73 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index d4af56eabf4..4a7b0739394 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -31,58 +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)); -} - -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)); @@ -402,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; @@ -415,33 +362,16 @@ 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)); + acpi_setup_base_tables(ctx, start); /* * Per ACPI spec, the FACS table address must be aligned to a 64 byte * boundary (Windows checks this, but Linux does not). */ acpi_align64(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); - debug("ACPI: * FACS\n"); facs = ctx->current; acpi_inc_align(ctx, sizeof(struct acpi_facs)); diff --git a/include/acpi/acpi_table.h b/include/acpi/acpi_table.h index 6225a4c5ccb..48bf189c570 100644 --- a/include/acpi/acpi_table.h +++ b/include/acpi/acpi_table.h @@ -562,6 +562,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 XSDT + * + * 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 5311ae9368b..85193c49e45 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -181,3 +181,80 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table) 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)); + + /* 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 4dd4a540967..5d5e46e2944 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -8,6 +8,9 @@ #include #include +#include +#include +#include #include #include #include @@ -137,9 +140,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" @@ -152,6 +155,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); @@ -183,3 +191,49 @@ 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, by allocating an aligned + * address and then adding 4 to it + */ + 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 Wed Apr 8 03:01: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: 1267726 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HthV3LSz; 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 48xq3159q6z9sPF for ; Wed, 8 Apr 2020 13:07:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D673881C4F; Wed, 8 Apr 2020 05:03:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HthV3LSz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D938E81A1A; Wed, 8 Apr 2020 05:02:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 8490481A08 for ; Wed, 8 Apr 2020 05:02:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id w20so402352iob.2 for ; Tue, 07 Apr 2020 20:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wVW9LS2t0dQjl822wfqQOWhUtS3/40g9+Mu99VMJa48=; b=HthV3LSz79XO6870qQnBzo52CLrhx+AJIMXRrKGNv1Gr7C10PuIotfEZ3N9HDnuyqT zgYoi6JffUDXFSEn1UjWRI649B5Vc3wBJtRYR9l2iyZpHabxAQGOqUhCJ224vxcknB++ bn19C/ZJqrkIAJOre96a1QTEaOK80wQSnnkAw= 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=wVW9LS2t0dQjl822wfqQOWhUtS3/40g9+Mu99VMJa48=; b=ifOCIrfujxjaNgNXsCmo6rtL7uixO/tDI6L9IvcF+omgrd1LRIpbNTGghgtu/IWhra xJI/0lx16a3AYnj3O6p8HNv3y2rod70L70/EOKaD8752T8fnuBPor2oiZEsBmmK9G0nJ q1+I8bP425/ooJW4noOX/re+avMBKA5kTPo82T32+pk0dZb/TX5d3hvsf+PtZRzBYm0j 3eapSRpiXIl9zSg8n34CaKTIF0EbE8o4icvoQbBV/YaRko9h8ie3VUeYmFrQmnuwmn7o 3A9aErDeh8zfLKs4PhmmSjUuA36vljLy45vcKxR4qwugyhFgac8wrWzrq3afqSBBt0XG vszw== X-Gm-Message-State: AGi0Puaw8NlZKFuByCQcxvfwcgVWZ0/8foSRWoYE6E7XKYO8huqA7FnU pbDhbZ3niGqEs3tBHXJH8xMtLHWWK4RpGg== X-Google-Smtp-Source: APiQypJqioP+cdOjT+E4LMxYeuYqOpdejKpPld2ZYtYIgc/zBIxtkcALo8xSa5dTmFuE09ZknqVHKA== X-Received: by 2002:a02:a517:: with SMTP id e23mr4911189jam.56.1586314959270; Tue, 07 Apr 2020 20:02:39 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:39 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass Subject: [PATCH v4 30/31] acpi: Move the xsdt pointer to acpi_ctx Date: Tue, 7 Apr 2020 21:01:06 -0600 Message-Id: <20200407210023.v4.30.Ib392027f44b50a6cfdad4ce529b8479958cb302d@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean Put this in the context along with the other important pointers. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner --- Changes in v4: None Changes in v3: None Changes in v2: None include/dm/acpi.h | 2 ++ lib/acpi/acpi_table.c | 10 ++++------ test/dm/acpi.c | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/dm/acpi.h b/include/dm/acpi.h index ee6f7a63e79..288310b5128 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 RSDT 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 85193c49e45..9d2b49f8ba5 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -165,7 +165,7 @@ 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 */ - xsdt = (struct acpi_xsdt *)((uintptr_t)ctx->rsdp->xsdt_address); + xsdt = ctx->xsdt; /* Add table to the XSDT */ xsdt->entry[i] = map_to_sysmem(table); @@ -236,8 +236,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 */ @@ -248,13 +246,13 @@ 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)); /* 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 5d5e46e2944..8e160d2cf4e 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -160,6 +160,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); @@ -223,6 +227,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 Wed Apr 8 03:01: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: 1267727 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=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=lox5uhN+; 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 48xq3F4QJbz9sPF for ; Wed, 8 Apr 2020 13:08:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A500281C52; Wed, 8 Apr 2020 05:03:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lox5uhN+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B81781A30; Wed, 8 Apr 2020 05:02:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-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 5857081A0A for ; Wed, 8 Apr 2020 05:02:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id w1so59813iot.7 for ; Tue, 07 Apr 2020 20:02:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=99iwYF7jRZfqO24t+EEHcht/2qd6267RQiLrmiOD+8A=; b=lox5uhN+TIgFba4lzUudtMSvUlJymL6Fmg4u6Zv0c1d3rK2PDOQ+H5tMgufTaAX+RH nxiC4iyl7nqWWr96uTM0HRsfpIDWd5SowAKZC8NmNP/zXoRpRA14tHAYKCBKLrOOtbxa LCMxYwQI/Y96wU3/C2EDfBS/Obsk1YW21J4nk= 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=99iwYF7jRZfqO24t+EEHcht/2qd6267RQiLrmiOD+8A=; b=pGw74JHKWcBqtG+UxP61lrsCIauNpb49IEZ4suEamsRmUxAZajHWkmYshWX1KlhMeL 8kVfyNca1UTcR8PXjRVz0V2EPpNQXU9PF88QAq8qCvJfoFM6xSMo3CaU7JH+cHJk1l5/ xOkiRrf9ovKAeQPiSyTS4XoMqWdhxApXdH3T+ISTh7jIx4DPfIh4t3nRdtRfQdd9NU6s kyP1ee/U+/pivZ6vhwFeg2/dsx3mhOXkUmZe0MoJRguuHfr3Ot58oracf+5NInIGDBfq 50oh876TusSXJc3nP29yWie8UhsL7YM4kW4S1afBPf/982SPndRgZwYvrLRSGERN+moL gPhg== X-Gm-Message-State: AGi0PubTihwj/8eaH4pnUV4mKdulEGtSSSnsilKorhzP3X9dTWuZqPzZ YTF6FEO4157fJYdsJ8RwpoSI5+utD0dGIA== X-Google-Smtp-Source: APiQypKLMAX1b4TLFFanycHSBcJT5d1LStKXUJpXQ7BYzPL0C3pzL8w/J61PJ+661hNsq+DHQpJ5Ww== X-Received: by 2002:a05:6602:2242:: with SMTP id o2mr5152741ioo.22.1586314961813; Tue, 07 Apr 2020 20:02:41 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id l6sm7732310ilh.27.2020.04.07.20.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 20:02:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Wolfgang Wallner , Bin Meng , Andy Shevchenko , Leif Lindholm , Simon Glass , Andy Shevchenko , Anup Patel , Eugeniu Rosca , Faiz Abbas , Heinrich Schuchardt , Joel Johnson , Lukasz Majewski , Miquel Raynal , "Park, Aiden" , Patrice Chotard , Ramon Fried , Sam Protsenko , Simon Goldschmidt , Stefan Roese Subject: [PATCH v4 31/31] acpi: Add an acpi command Date: Tue, 7 Apr 2020 21:01:07 -0600 Message-Id: <20200407210023.v4.31.I5894252b8fe4522e409528c497d882226f34ab9b@changeid> X-Mailer: git-send-email 2.26.0.292.g33ef6b2f38-goog In-Reply-To: <20200408030107.168474-1-sjg@chromium.org> References: <20200408030107.168474-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 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 Reviewed-by: Wolfgang Wallner --- Changes in v4: - Rename list_fact() to list_fadt() - Add a comment to dump_hdr() Changes in v3: None Changes in v2: None 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 | 186 +++++++++++++++++++++++++ lib/acpi/acpi_table.c | 1 + test/dm/acpi.c | 73 ++++++++++ 7 files changed, 277 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 f4ce72d5660..f95ddb058a2 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 f4c1839104e..4aee2f3e8c4 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 6403bc45a5e..2d3bfe0ab91 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 f1dd513a4b4..15a9693ed0e 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 00000000000..203bd93bd5d --- /dev/null +++ b/cmd/acpi.c @@ -0,0 +1,186 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 Google LLC + * Written by Simon Glass + */ +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/** + * dump_hdr() - Dump an ACPI header + * + * If the header is for FACS then it shows the revision information as well + * + * @hdr: ACPI header to dump + */ +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_fadt(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_fadt((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 9d2b49f8ba5..5abf1cad50f 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -240,6 +240,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 8e160d2cf4e..4eabf53128a 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -7,9 +7,11 @@ */ #include +#include #include #include #include +#include #include #include #include @@ -212,6 +214,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); @@ -242,3 +245,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);