]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Include/Library/PL011UartLib.h
ArmPlatformPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / ArmPlatformPkg / Include / Library / PL011UartLib.h
CommitLineData
12156134
AB
1/** @file\r
2*\r
3* Copyright (c) 2011-2016, ARM Limited. All rights reserved.\r
4*\r
f4dfad05 5* SPDX-License-Identifier: BSD-2-Clause-Patent\r
12156134
AB
6*\r
7**/\r
8\r
9#ifndef __PL011_UART_LIB_H__\r
10#define __PL011_UART_LIB_H__\r
11\r
12#include <Uefi/UefiBaseType.h>\r
13\r
14#include <Protocol/SerialIo.h>\r
15\r
16/**\r
17\r
18 Initialise the serial port to the specified settings.\r
19 All unspecified settings will be set to the default values.\r
20\r
21 @param[in] UartBase The base address of the serial device.\r
22 @param[in] UartClkInHz The clock in Hz for the serial device.\r
23 Ignored if the PCD PL011UartInteger is not 0\r
24 @param[in out] BaudRate The baud rate of the serial device. If the\r
25 baud rate is not supported, the speed will be\r
26 reduced to the nearest supported one and the\r
27 variable's value will be updated accordingly.\r
28 @param[in out] ReceiveFifoDepth The number of characters the device will\r
29 buffer on input. Value of 0 will use the\r
30 device's default FIFO depth.\r
31 @param[in out] Parity If applicable, this is the EFI_PARITY_TYPE\r
32 that is computed or checked as each character\r
33 is transmitted or received. If the device\r
34 does not support parity, the value is the\r
35 default parity value.\r
36 @param[in out] DataBits The number of data bits in each character.\r
37 @param[in out] StopBits If applicable, the EFI_STOP_BITS_TYPE number\r
38 of stop bits per character.\r
39 If the device does not support stop bits, the\r
40 value is the default stop bit value.\r
41\r
42 @retval RETURN_SUCCESS All attributes were set correctly on the\r
43 serial device.\r
44 @retval RETURN_INVALID_PARAMETER One or more of the attributes has an\r
45 unsupported value.\r
46\r
47**/\r
48RETURN_STATUS\r
49EFIAPI\r
50PL011UartInitializePort (\r
51 IN UINTN UartBase,\r
52 IN UINT32 UartClkInHz,\r
53 IN OUT UINT64 *BaudRate,\r
54 IN OUT UINT32 *ReceiveFifoDepth,\r
55 IN OUT EFI_PARITY_TYPE *Parity,\r
56 IN OUT UINT8 *DataBits,\r
57 IN OUT EFI_STOP_BITS_TYPE *StopBits\r
58 );\r
59\r
60/**\r
61\r
62 Assert or deassert the control signals on a serial port.\r
63 The following control signals are set according their bit settings :\r
64 . Request to Send\r
65 . Data Terminal Ready\r
66\r
67 @param[in] UartBase UART registers base address\r
68 @param[in] Control The following bits are taken into account :\r
69 . EFI_SERIAL_REQUEST_TO_SEND : assert/deassert the\r
70 "Request To Send" control signal if this bit is\r
71 equal to one/zero.\r
72 . EFI_SERIAL_DATA_TERMINAL_READY : assert/deassert\r
73 the "Data Terminal Ready" control signal if this\r
74 bit is equal to one/zero.\r
75 . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : enable/disable\r
76 the hardware loopback if this bit is equal to\r
77 one/zero.\r
78 . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : not supported.\r
79 . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : enable/\r
80 disable the hardware flow control based on CTS (Clear\r
81 To Send) and RTS (Ready To Send) control signals.\r
82\r
83 @retval RETURN_SUCCESS The new control bits were set on the device.\r
84 @retval RETURN_UNSUPPORTED The device does not support this operation.\r
85\r
86**/\r
87RETURN_STATUS\r
88EFIAPI\r
89PL011UartSetControl (\r
90 IN UINTN UartBase,\r
91 IN UINT32 Control\r
92 );\r
93\r
94/**\r
95\r
96 Retrieve the status of the control bits on a serial device.\r
97\r
98 @param[in] UartBase UART registers base address\r
99 @param[out] Control Status of the control bits on a serial device :\r
100\r
101 . EFI_SERIAL_DATA_CLEAR_TO_SEND,\r
102 EFI_SERIAL_DATA_SET_READY,\r
103 EFI_SERIAL_RING_INDICATE,\r
104 EFI_SERIAL_CARRIER_DETECT,\r
105 EFI_SERIAL_REQUEST_TO_SEND,\r
106 EFI_SERIAL_DATA_TERMINAL_READY\r
107 are all related to the DTE (Data Terminal Equipment)\r
108 and DCE (Data Communication Equipment) modes of\r
109 operation of the serial device.\r
110 . EFI_SERIAL_INPUT_BUFFER_EMPTY : equal to one if the\r
111 receive buffer is empty, 0 otherwise.\r
112 . EFI_SERIAL_OUTPUT_BUFFER_EMPTY : equal to one if the\r
113 transmit buffer is empty, 0 otherwise.\r
114 . EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE : equal to one if\r
115 the hardware loopback is enabled (the ouput feeds the\r
116 receive buffer), 0 otherwise.\r
117 . EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE : equal to one if\r
118 a loopback is accomplished by software, 0 otherwise.\r
119 . EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE : equal to\r
120 one if the hardware flow control based on CTS (Clear\r
121 To Send) and RTS (Ready To Send) control signals is\r
122 enabled, 0 otherwise.\r
123\r
124 @retval RETURN_SUCCESS The control bits were read from the serial device.\r
125\r
126**/\r
127RETURN_STATUS\r
128EFIAPI\r
129PL011UartGetControl (\r
130 IN UINTN UartBase,\r
131 OUT UINT32 *Control\r
132 );\r
133\r
134/**\r
135 Write data to serial device.\r
136\r
137 @param Buffer Point of data buffer which need to be written.\r
138 @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
139\r
140 @retval 0 Write data failed.\r
141 @retval !0 Actual number of bytes written to serial device.\r
142\r
143**/\r
144UINTN\r
145EFIAPI\r
146PL011UartWrite (\r
147 IN UINTN UartBase,\r
148 IN UINT8 *Buffer,\r
149 IN UINTN NumberOfBytes\r
150 );\r
151\r
152/**\r
153 Read data from serial device and save the data in buffer.\r
154\r
155 @param Buffer Point of data buffer which need to be written.\r
156 @param NumberOfBytes Number of output bytes which are cached in Buffer.\r
157\r
158 @retval 0 Read data failed.\r
159 @retval !0 Actual number of bytes read from serial device.\r
160\r
161**/\r
162UINTN\r
163EFIAPI\r
164PL011UartRead (\r
165 IN UINTN UartBase,\r
166 OUT UINT8 *Buffer,\r
167 IN UINTN NumberOfBytes\r
168 );\r
169\r
170/**\r
171 Check to see if any data is available to be read from the debug device.\r
172\r
173 @retval TRUE At least one byte of data is available to be read\r
174 @retval FALSE No data is available to be read\r
175\r
176**/\r
177BOOLEAN\r
178EFIAPI\r
179PL011UartPoll (\r
180 IN UINTN UartBase\r
181 );\r
182\r
183#endif\r