From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 20/28] x86: acpi: Add some generic ASL libraries
Date: Sat, 7 May 2016 07:46:29 -0700 [thread overview]
Message-ID: <1462632397-11224-21-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1462632397-11224-1-git-send-email-bmeng.cn@gmail.com>
This adds several generic ASL libraries that can be included by
other ASL files, which are:
- debug.asl: for debug output using POST I/O port and legacy serial port
- globutil.asl: for string compare routines
- statdef.asl: for _STA status values
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Tested-by: Stefan Roese <sr@denx.de>
---
Changes in v2: None
arch/x86/include/asm/acpi/debug.asl | 136 +++++++++++++++++++++++++++++++++
arch/x86/include/asm/acpi/globutil.asl | 113 +++++++++++++++++++++++++++
arch/x86/include/asm/acpi/statdef.asl | 82 ++++++++++++++++++++
3 files changed, 331 insertions(+)
create mode 100644 arch/x86/include/asm/acpi/debug.asl
create mode 100644 arch/x86/include/asm/acpi/globutil.asl
create mode 100644 arch/x86/include/asm/acpi/statdef.asl
diff --git a/arch/x86/include/asm/acpi/debug.asl b/arch/x86/include/asm/acpi/debug.asl
new file mode 100644
index 0000000..8e7b603
--- /dev/null
+++ b/arch/x86/include/asm/acpi/debug.asl
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
+ *
+ * Modified from coreboot src/arch/x86/acpi/debug.asl
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/* POST register region */
+OperationRegion(X80, SystemIO, 0x80, 1)
+Field(X80, ByteAcc, NoLock, Preserve)
+{
+ P80, 8
+}
+
+/* Legacy serial port register region */
+OperationRegion(CREG, SystemIO, 0x3F8, 8)
+Field(CREG, ByteAcc, NoLock, Preserve)
+{
+ CDAT, 8,
+ CDLM, 8,
+ , 8,
+ CLCR, 8,
+ CMCR, 8,
+ CLSR, 8
+}
+
+/* DINI - Initialize the serial port to 115200 8-N-1 */
+Method(DINI)
+{
+ Store(0x83, CLCR)
+ Store(0x01, CDAT) /* 115200 baud (low) */
+ Store(0x00, CDLM) /* 115200 baud (high) */
+ Store(0x03, CLCR) /* word=8 stop=1 parity=none */
+ Store(0x03, CMCR) /* DTR=1 RTS=1 out1/2=Off loop=Off */
+ Store(0x00, CDLM) /* turn off interrupts */
+}
+
+/* THRE - Wait for serial port transmitter holding register to go empty */
+Method(THRE)
+{
+ And(CLSR, 0x20, Local0)
+ While (LEqual(Local0, Zero)) {
+ And(CLSR, 0x20, Local0)
+ }
+}
+
+/* OUTX - Send a single raw character */
+Method(OUTX, 1)
+{
+ THRE()
+ Store(Arg0, CDAT)
+}
+
+/* OUTC - Send a single character, expanding LF into CR/LF */
+Method(OUTC, 1)
+{
+ If (LEqual(Arg0, 0x0a)) {
+ OUTX(0x0d)
+ }
+ OUTX(Arg0)
+}
+
+/* DBGN - Send a single hex nibble */
+Method(DBGN, 1)
+{
+ And(Arg0, 0x0f, Local0)
+ If (LLess(Local0, 10)) {
+ Add(Local0, 0x30, Local0)
+ } Else {
+ Add(Local0, 0x37, Local0)
+ }
+ OUTC(Local0)
+}
+
+/* DBGB - Send a hex byte */
+Method(DBGB, 1)
+{
+ ShiftRight(Arg0, 4, Local0)
+ DBGN(Local0)
+ DBGN(Arg0)
+}
+
+/* DBGW - Send a hex word */
+Method(DBGW, 1)
+{
+ ShiftRight(Arg0, 8, Local0)
+ DBGB(Local0)
+ DBGB(Arg0)
+}
+
+/* DBGD - Send a hex dword */
+Method(DBGD, 1)
+{
+ ShiftRight(Arg0, 16, Local0)
+ DBGW(Local0)
+ DBGW(Arg0)
+}
+
+/* Get a char from a string */
+Method(GETC, 2)
+{
+ CreateByteField(Arg0, Arg1, DBGC)
+ Return (DBGC)
+}
+
+/* DBGO - Send either a string or an integer */
+Method(DBGO, 1, Serialized)
+{
+ If (LEqual(ObjectType(Arg0), 1)) {
+ If (LGreater(Arg0, 0xffff)) {
+ DBGD(Arg0)
+ } Else {
+ If (LGreater(Arg0, 0xff)) {
+ DBGW(Arg0)
+ } Else {
+ DBGB(Arg0)
+ }
+ }
+ } Else {
+ Name(BDBG, Buffer(80) {})
+ Store(Arg0, BDBG)
+ Store(0, Local1)
+ While (One) {
+ Store(GETC(BDBG, Local1), Local0)
+ If (LEqual(Local0, 0)) {
+ Return (Zero)
+ }
+ OUTC(Local0)
+ Increment(Local1)
+ }
+ }
+
+ Return (Zero)
+}
diff --git a/arch/x86/include/asm/acpi/globutil.asl b/arch/x86/include/asm/acpi/globutil.asl
new file mode 100644
index 0000000..46381b6
--- /dev/null
+++ b/arch/x86/include/asm/acpi/globutil.asl
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
+ *
+ * Modified from coreboot src/arch/x86/acpi/globutil.asl
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+Method(MIN, 2)
+{
+ If (LLess(Arg0, Arg1)) {
+ Return (Arg0)
+ } Else {
+ Return (Arg1)
+ }
+}
+
+Method(SLEN, 1)
+{
+ Store(Arg0, Local0)
+ Return (Sizeof(Local0))
+}
+
+Method(S2BF, 1, Serialized)
+{
+ Add(SLEN(Arg0), One, Local0)
+ Name(BUFF, Buffer(Local0) {})
+ Store(Arg0, BUFF)
+ Return (BUFF)
+}
+
+/*
+ * SCMP - Strong string compare
+ *
+ * Checks both length and content
+ */
+Method(SCMP, 2)
+{
+ Store(S2BF(Arg0), Local0)
+ Store(S2BF(Arg1), Local1)
+ Store(Zero, Local4)
+ Store(SLEN(Arg0), Local5)
+ Store(SLEN(Arg1), Local6)
+ Store(MIN(Local5, Local6), Local7)
+
+ While (LLess(Local4, Local7)) {
+ Store(Derefof(Index(Local0, Local4)), Local2)
+ Store(Derefof(Index(Local1, Local4)), Local3)
+ If (LGreater(Local2, Local3)) {
+ Return (One)
+ } Else {
+ If (LLess(Local2, Local3)) {
+ Return (Ones)
+ }
+ }
+ Increment(Local4)
+ }
+
+ If (LLess(Local4, Local5)) {
+ Return (One)
+ } Else {
+ If (LLess(Local4, Local6)) {
+ Return (Ones)
+ } Else {
+ Return (Zero)
+ }
+ }
+}
+
+/*
+ * WCMP - Weak string compare
+ *
+ * Checks to find Arg1 at beginning of Arg0.
+ * Fails if length(Arg0) < length(Arg1).
+ * Returns 0 on fail, 1 on pass.
+ */
+Method(WCMP, 2)
+{
+ Store(S2BF(Arg0), Local0)
+ Store(S2BF(Arg1), Local1)
+ If (LLess(SLEN(Arg0), SLEN(Arg1))) {
+ Return (Zero)
+ }
+ Store(Zero, Local2)
+ Store(SLEN(Arg1), Local3)
+
+ While (LLess(Local2, Local3)) {
+ If (LNotEqual(Derefof(Index(Local0, Local2)),
+ Derefof(Index(Local1, Local2)))) {
+ Return (Zero)
+ }
+ Increment(Local2)
+ }
+
+ Return (One)
+}
+
+/*
+ * I2BM - Returns Bit Map
+ *
+ * Arg0 = IRQ Number (0-15)
+ */
+Method(I2BM, 1)
+{
+ Store(0, Local0)
+ If (LNotEqual(Arg0, 0)) {
+ Store(1, Local1)
+ ShiftLeft(Local1, Arg0, Local0)
+ }
+
+ Return (Local0)
+}
diff --git a/arch/x86/include/asm/acpi/statdef.asl b/arch/x86/include/asm/acpi/statdef.asl
new file mode 100644
index 0000000..e8cff10
--- /dev/null
+++ b/arch/x86/include/asm/acpi/statdef.asl
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2016 Bin Meng <bmeng.cn@gmail.com>
+ *
+ * Modified from coreboot src/arch/x86/acpi/statdef.asl
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/* Status and notification definitions */
+
+#define STA_MISSING 0x00
+#define STA_PRESENT 0x01
+#define STA_ENABLED 0x03
+#define STA_DISABLED 0x09
+#define STA_INVISIBLE 0x0b
+#define STA_UNAVAILABLE 0x0d
+#define STA_VISIBLE 0x0f
+
+/* SMBus status codes */
+#define SMB_OK 0x00
+#define SMB_UNKNOWN_FAIL 0x07
+#define SMB_DEV_ADDR_NAK 0x10
+#define SMB_DEVICE_ERROR 0x11
+#define SMB_DEV_CMD_DENIED 0x12
+#define SMB_UNKNOWN_ERR 0x13
+#define SMB_DEV_ACC_DENIED 0x17
+#define SMB_TIMEOUT 0x18
+#define SMB_HST_UNSUPP_PROTOCOL 0x19
+#define SMB_BUSY 0x1a
+#define SMB_PKT_CHK_ERROR 0x1f
+
+/* Device Object Notification Values */
+#define NOTIFY_BUS_CHECK 0x00
+#define NOTIFY_DEVICE_CHECK 0x01
+#define NOTIFY_DEVICE_WAKE 0x02
+#define NOTIFY_EJECT_REQUEST 0x03
+#define NOTIFY_DEVICE_CHECK_JR 0x04
+#define NOTIFY_FREQUENCY_ERROR 0x05
+#define NOTIFY_BUS_MODE 0x06
+#define NOTIFY_POWER_FAULT 0x07
+#define NOTIFY_CAPABILITIES 0x08
+#define NOTIFY_PLD_CHECK 0x09
+#define NOTIFY_SLIT_UPDATE 0x0b
+#define NOTIFY_SRA_UPDATE 0x0d
+
+/* Battery Device Notification Values */
+#define NOTIFY_BAT_STATUSCHG 0x80
+#define NOTIFY_BAT_INFOCHG 0x81
+#define NOTIFY_BAT_MAINTDATA 0x82
+
+/* Power Source Object Notification Values */
+#define NOTIFY_PWR_STATUSCHG 0x80
+#define NOTIFY_PWR_INFOCHG 0x81
+
+/* Thermal Zone Object Notification Values */
+#define NOTIFY_TZ_STATUSCHG 0x80
+#define NOTIFY_TZ_TRIPPTCHG 0x81
+#define NOTIFY_TZ_DEVLISTCHG 0x82
+#define NOTIFY_TZ_RELTBLCHG 0x83
+
+/* Power Button Notification Values */
+#define NOTIFY_POWER_BUTTON 0x80
+
+/* Sleep Button Notification Values */
+#define NOTIFY_SLEEP_BUTTON 0x80
+
+/* Lid Notification Values */
+#define NOTIFY_LID_STATUSCHG 0x80
+
+/* Processor Device Notification Values */
+#define NOTIFY_CPU_PPCCHG 0x80
+#define NOTIFY_CPU_CSTATECHG 0x81
+#define NOTIFY_CPU_THROTLCHG 0x82
+
+/* User Presence Device Notification Values */
+#define NOTIFY_USR_PRESNCECHG 0x80
+
+/* Ambient Light Sensor Notification Values */
+#define NOTIFY_ALS_ILLUMCHG 0x80
+#define NOTIFY_ALS_COLORTMPCHG 0x81
+#define NOTIFY_ALS_RESPCHG 0x82
--
1.8.2.1
next prev parent reply other threads:[~2016-05-07 14:46 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-07 14:46 [U-Boot] [PATCH v2 00/28] x86: Initial ACPI support for Intel BayTrail Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 01/28] x86: Drop asm/acpi.h Bin Meng
2016-05-07 18:45 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 02/28] x86: Fix build warning in tables.c when CONFIG_SEABIOS Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 03/28] x86: acpi: Fix compiler warnings in write_acpi_tables() Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 04/28] x86: irq: Reserve IRQ9 for ACPI in PIC mode Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 05/28] x86: irq: Enable SCI on IRQ9 Bin Meng
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 06/28] x86: dts: Update to include ACTL register details Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 07/28] acpi: Change build log for ASL files Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:17 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 08/28] acpi: Explicitly spell out dsdt.c in the make rule Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 09/28] acpi: Specify U-Boot include path for ASL files Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 10/28] acpi: Output all errors/warnings/remarks when compiling ASL Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 11/28] x86: acpi: Remove unused codes Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 12/28] x86: acpi: Various changes to acpi_table.h Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 13/28] x86: acpi: Reorder code in acpi_table.h Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 14/28] x86: acpi: Remove acpi_create_ssdt_generator() Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 15/28] x86: acpi: Change fill_header() Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 16/28] x86: acpi: Adjust order in acpi_table.c Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 17/28] x86: acpi: Use u32 in table write routines Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 4:26 ` Bin Meng
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 18/28] x86: acpi: Align FACS table to a 64 byte boundary Bin Meng
2016-05-07 18:46 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 19/28] x86: acpi: Clean up table header revisions Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` Bin Meng [this message]
2016-05-07 18:47 ` [U-Boot] [PATCH v2 20/28] x86: acpi: Add some generic ASL libraries Simon Glass
2016-05-08 8:18 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 21/28] x86: acpi: Return table length in acpi_create_madt_lapics() Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 22/28] x86: baytrail: Add platform ASL files Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 23/28] x86: baytrail: Generate ACPI FADT/MADT tables Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 24/28] x86: baytrail: Enable ACPI table generation for all boards Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 25/28] x86: baytrail: Add .gitignore for ACPI enabled boards Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 26/28] x86: Remove acpi=off boot parameter when ACPI is on Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 27/28] x86: doc: Minor update for accuracy Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 14:46 ` [U-Boot] [PATCH v2 28/28] x86: doc: Document ACPI support Bin Meng
2016-05-07 18:47 ` Simon Glass
2016-05-08 8:19 ` Bin Meng
2016-05-07 18:45 ` [U-Boot] [PATCH v2 00/28] x86: Initial ACPI support for Intel BayTrail Simon Glass
2016-05-08 1:27 ` Bin Meng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462632397-11224-21-git-send-email-bmeng.cn@gmail.com \
--to=bmeng.cn@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox