public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: SPCR: Support Precise Baud Rate filed
@ 2025-09-12 12:25 cp0613
  2025-09-12 14:02 ` Rafael J. Wysocki
  2025-09-13  5:24 ` [PATCH v2] " Guo Ren
  0 siblings, 2 replies; 8+ messages in thread
From: cp0613 @ 2025-09-12 12:25 UTC (permalink / raw)
  To: rafael, lenb, guoren, jeeheng.sia; +Cc: linux-acpi, linux-kernel, Chen Pei

From: Chen Pei <cp0613@linux.alibaba.com>

The Microsoft Serial Port Console Redirection (SPCR) specification
revision 1.09 comprises additional field: Precise Baud Rate [1].

It is used to describe non-traditional baud rates (such as those
used by high-speed UARTs).

It contains a specific non-zero baud rate which overrides the value
of the Configured Baud Rate field. If this field is zero or not
present, Configured Baud Rate is used.

Link: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table # 1

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
---
 drivers/acpi/spcr.c | 54 ++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 23 deletions(-)

diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
index cd36a97b0ea2..a97b02ee5538 100644
--- a/drivers/acpi/spcr.c
+++ b/drivers/acpi/spcr.c
@@ -146,29 +146,37 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 		goto done;
 	}
 
-	switch (table->baud_rate) {
-	case 0:
-		/*
-		 * SPCR 1.04 defines 0 as a preconfigured state of UART.
-		 * Assume firmware or bootloader configures console correctly.
-		 */
-		baud_rate = 0;
-		break;
-	case 3:
-		baud_rate = 9600;
-		break;
-	case 4:
-		baud_rate = 19200;
-		break;
-	case 6:
-		baud_rate = 57600;
-		break;
-	case 7:
-		baud_rate = 115200;
-		break;
-	default:
-		err = -ENOENT;
-		goto done;
+	/*
+	 * SPCR 1.09 defines Precise Baud Rate Filed contains a specific
+	 * non-zero baud rate which overrides the value of the Configured
+	 * Baud Rate field. If this field is zero or not present, Configured
+	 * Baud Rate is used.
+	 */
+	if (table->precise_baudrate)
+		baud_rate = table->precise_baudrate;
+	else switch (table->baud_rate) {
+		case 0:
+			/*
+			 * SPCR 1.04 defines 0 as a preconfigured state of UART.
+			 * Assume firmware or bootloader configures console correctly.
+			 */
+			baud_rate = 0;
+			break;
+		case 3:
+			baud_rate = 9600;
+			break;
+		case 4:
+			baud_rate = 19200;
+			break;
+		case 6:
+			baud_rate = 57600;
+			break;
+		case 7:
+			baud_rate = 115200;
+			break;
+		default:
+			err = -ENOENT;
+			goto done;
 	}
 
 	/*
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] ACPI: SPCR: Support Precise Baud Rate filed
@ 2025-09-12  8:57 cp0613
  2025-09-12  9:29 ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: cp0613 @ 2025-09-12  8:57 UTC (permalink / raw)
  To: rafael, lenb, guoren, jeeheng.sia; +Cc: linux-acpi, linux-kernel, Chen Pei

From: Chen Pei <cp0613@linux.alibaba.com>

The Microsoft Serial Port Console Redirection (SPCR) specification
revision 1.09 comprises additional field: Precise Baud Rate [1].

It is used to describe non-traditional baud rates (such as those
used by high-speed UARTs).

It contains a specific non-zero baud rate which overrides the value
of the Configured Baud Rate field. If this field is zero or not
present, Configured Baud Rate is used.

Link: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table # 1

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
---
 drivers/acpi/spcr.c | 56 ++++++++++++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 23 deletions(-)

diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
index cd36a97b0ea2..69142c2ac4b3 100644
--- a/drivers/acpi/spcr.c
+++ b/drivers/acpi/spcr.c
@@ -146,29 +146,39 @@ int __init acpi_parse_spcr(bool enable_earlycon, bool enable_console)
 		goto done;
 	}
 
-	switch (table->baud_rate) {
-	case 0:
-		/*
-		 * SPCR 1.04 defines 0 as a preconfigured state of UART.
-		 * Assume firmware or bootloader configures console correctly.
-		 */
-		baud_rate = 0;
-		break;
-	case 3:
-		baud_rate = 9600;
-		break;
-	case 4:
-		baud_rate = 19200;
-		break;
-	case 6:
-		baud_rate = 57600;
-		break;
-	case 7:
-		baud_rate = 115200;
-		break;
-	default:
-		err = -ENOENT;
-		goto done;
+	/*
+	 * SPCR 1.09 defines Precise Baud Rate Filed contains a specific
+	 * non-zero baud rate which overrides the value of the Configured
+	 * Baud Rate field. If this field is zero or not present, Configured
+	 * Baud Rate is used.
+	 */
+	if (table->precise_baudrate)
+		baud_rate = table->precise_baudrate;
+	else {
+		switch (table->baud_rate) {
+		case 0:
+			/*
+			 * SPCR 1.04 defines 0 as a preconfigured state of UART.
+			 * Assume firmware or bootloader configures console correctly.
+			 */
+			baud_rate = 0;
+			break;
+		case 3:
+			baud_rate = 9600;
+			break;
+		case 4:
+			baud_rate = 19200;
+			break;
+		case 6:
+			baud_rate = 57600;
+			break;
+		case 7:
+			baud_rate = 115200;
+			break;
+		default:
+			err = -ENOENT;
+			goto done;
+		}
 	}
 
 	/*
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-09-13  7:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 12:25 [PATCH v2] ACPI: SPCR: Support Precise Baud Rate filed cp0613
2025-09-12 14:02 ` Rafael J. Wysocki
2025-09-13  7:07   ` [PATCH] " cp0613
2025-09-13  5:24 ` [PATCH v2] " Guo Ren
2025-09-13  7:06   ` [PATCH] " cp0613
  -- strict thread matches above, loose matches on Subject: below --
2025-09-12  8:57 cp0613
2025-09-12  9:29 ` Rafael J. Wysocki
2025-09-12 12:23   ` cp0613

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox