blob: 86d207620ab9425fb00da7e960edae148a5ee4ce [file] [log] [blame]
Angel Pons0612b272020-04-05 15:46:56 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Subrata Banikc1645fa2016-08-05 18:25:55 +05302
Julius Wernercd49cce2019-03-05 16:53:33 -08003#if CONFIG(ACPI_CONSOLE)
Subrata Banikc1645fa2016-08-05 18:25:55 +05304
5#include <soc/iomap.h>
6
Julius Wernercd49cce2019-03-05 16:53:33 -08007Name (UFLG, CONFIG(CONSOLE_SERIAL))
Subrata Banikc1645fa2016-08-05 18:25:55 +05308
9Method (LURT, 1, Serialized)
10{
Alexey Buyanov03248032020-06-01 21:41:14 -070011 If (Arg0 == 0) { /* 0 = 0x3f8 */
12 Local0 = 0x3f8
13 } ElseIf (Arg0 == 1) { /* 1 = 0x2f8 */
14 Local0 = 0x2f8
15 } ElseIf (Arg0 == 2) { /* 2 = 0x3e8 */
16 Local0 = 0x3e8
17 } ElseIf (Arg0 == 3) { /* 3 = 0x2e8 */
18 Local0 = 0x2e8
Subrata Banikc1645fa2016-08-05 18:25:55 +053019 }
20 Return (Local0)
21}
22
23Method (APRT, 1, Serialized)
24{
25 Name(OPDT, 0)
26 Name(INDX, 0)
27 Name(LENG, 0)
28 Name(ADBG, Buffer(256) {0})
29
Alexey Buyanov03248032020-06-01 21:41:14 -070030 If (ObjectType(Arg0) == 1) { /* Integer */
Subrata Banikf0c7be42017-06-02 10:18:09 +053031 ToHexString(Arg0, Local0)
Alexey Buyanov03248032020-06-01 21:41:14 -070032 ADBG = Local0
33 } ElseIf (ObjectType(Arg0) == 2) { /* String */
34 ADBG = Arg0
35 } ElseIf (ObjectType(Arg0) == 3) { /* Buffer */
Subrata Banikc1645fa2016-08-05 18:25:55 +053036 ToHexString(Arg0, ADBG)
37 } Else {
Alexey Buyanov03248032020-06-01 21:41:14 -070038 ADBG = "This type of object is not supported"
Subrata Banikc1645fa2016-08-05 18:25:55 +053039 }
40
Alexey Buyanov03248032020-06-01 21:41:14 -070041 While (DeRefOf(ADBG[INDX]) != 0)
Subrata Banikc1645fa2016-08-05 18:25:55 +053042 {
Alexey Buyanov03248032020-06-01 21:41:14 -070043 INDX++
Subrata Banikc1645fa2016-08-05 18:25:55 +053044 }
Alexey Buyanov03248032020-06-01 21:41:14 -070045 LENG = INDX /* Length of the String */
Subrata Banikc1645fa2016-08-05 18:25:55 +053046
Julius Wernercd49cce2019-03-05 16:53:33 -080047#if CONFIG(DRIVERS_UART_8250MEM_32)
V Sowmya3670cc12017-09-12 14:52:12 +053048 OperationRegion (UBAR, SystemMemory,
Nico Huber99954182019-05-29 23:33:06 +020049 CONFIG_CONSOLE_UART_BASE_ADDRESS, 24)
Subrata Banikc1645fa2016-08-05 18:25:55 +053050 Field (UBAR, AnyAcc, NoLock, Preserve)
51 {
Subrata Banikf0c7be42017-06-02 10:18:09 +053052 TDR, 8, /* Transmit Data Register BAR + 0x000 */
53 , 24,
54 IER, 8, /* Interrupt Enable Register BAR + 0x004 */
55 , 24,
56 IIR, 8, /* Interrupt Identification Register BAR + 0x008 */
57 , 24,
58 LCR, 8, /* Line Control Register BAR + 0x00C */
59 , 24,
60 MCR, 8, /* Modem Control Register BAR + 0x010 */
61 , 24,
62 LSR, 8, /* Line Status Register BAR + 0x014 */
63 , 24
Subrata Banikc1645fa2016-08-05 18:25:55 +053064 }
65#else
66 OperationRegion (UBAR, SystemIO, LURT (CONFIG_UART_FOR_CONSOLE), 6)
67 Field (UBAR, ByteAcc, NoLock, Preserve)
68 {
69 TDR, 8, /* Transmit Data Register IO Port + 0x0 */
70 IER, 8, /* Interrupt Enable Register IO Port + 0x1 */
71 IIR, 8, /* Interrupt Identification Register IO Port + 0x2 */
72 LCR, 8, /* Line Control Register IO Port + 0x3 */
73 MCR, 8, /* Modem Control Register IO Port + 0x4 */
74 LSR, 8 /* Line Status Register IO Port + 0x5 */
75 }
76#endif
77
Alexey Buyanov03248032020-06-01 21:41:14 -070078 If (UFLG == 0) {
Subrata Banikc1645fa2016-08-05 18:25:55 +053079 /* Enable Baud Rate Divisor Latch, Set Word length to 8 bit*/
Alexey Buyanov03248032020-06-01 21:41:14 -070080 LCR = 0x83
81 IIR = 0x01
82 MCR = 0x03
Subrata Banikc1645fa2016-08-05 18:25:55 +053083
84 /* Configure baud rate to 115200 */
Alexey Buyanov03248032020-06-01 21:41:14 -070085 TDR = 0x01
86 IER = 0x00
87 LCR = 0x03 /* Disable Baud Rate Divisor Latch */
Subrata Banikc1645fa2016-08-05 18:25:55 +053088
Alexey Buyanov03248032020-06-01 21:41:14 -070089 UFLG++
Subrata Banikc1645fa2016-08-05 18:25:55 +053090 }
Alexey Buyanov03248032020-06-01 21:41:14 -070091 INDX = 0x00
92 While (INDX < LENG)
Subrata Banikc1645fa2016-08-05 18:25:55 +053093 {
94 /* Wait for the transmitter t to be ready */
95 While (1)
96 {
Alexey Buyanov03248032020-06-01 21:41:14 -070097 OPDT = LSR & 0x20
98 If (OPDT != 0)
Subrata Banikc1645fa2016-08-05 18:25:55 +053099 {
100 Break
101 }
102 }
Alexey Buyanov03248032020-06-01 21:41:14 -0700103 TDR = DeRefOf (ADBG[INDX])
104 INDX++
Subrata Banikc1645fa2016-08-05 18:25:55 +0530105 }
106} /* End of APRT */
107
108#endif