VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Include/Protocol/SpiHc.h

最後變更 在這個檔案是 105670,由 vboxsync 提交於 7 月 前

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 7.6 KB
 
1/** @file
2 This file defines the SPI Host Controller Protocol.
3
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 @par Revision Reference:
9 This Protocol was introduced in UEFI PI Specification 1.8 A.
10
11**/
12
13#ifndef __SPI_HC_PROTOCOL_H__
14#define __SPI_HC_PROTOCOL_H__
15
16#include <Protocol/SpiConfiguration.h>
17#include <Protocol/SpiIo.h>
18
19///
20/// Global ID for the SPI Host Controller Protocol
21///
22#define EFI_SPI_HOST_GUID \
23 { 0xc74e5db2, 0xfa96, 0x4ae2, \
24 { 0xb3, 0x99, 0x15, 0x97, 0x7f, 0xe3, 0x0, 0x2d }}
25
26///
27/// EDK2-style name
28///
29#define EFI_SPI_HC_PROTOCOL_GUID EFI_SPI_HOST_GUID
30
31typedef struct _EFI_SPI_HC_PROTOCOL EFI_SPI_HC_PROTOCOL;
32
33/**
34 Assert or deassert the SPI chip select.
35
36 This routine is called at TPL_NOTIFY.
37 Update the value of the chip select line for a SPI peripheral. The SPI bus
38 layer calls this routine either in the board layer or in the SPI controller
39 to manipulate the chip select pin at the start and end of a SPI transaction.
40
41 @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure.
42 @param[in] SpiPeripheral The address of an EFI_SPI_PERIPHERAL data structure
43 describing the SPI peripheral whose chip select pin
44 is to be manipulated. The routine may access the
45 ChipSelectParameter field to gain sufficient
46 context to complete the operati on.
47 @param[in] PinValue The value to be applied to the chip select line of
48 the SPI peripheral.
49
50 @retval EFI_SUCCESS The chip select was set as requested
51 @retval EFI_NOT_READY Support for the chip select is not properly
52 initialized
53 @retval EFI_INVALID_PARAMETER The ChipSeLect value or its contents are
54 invalid
55
56**/
57typedef EFI_STATUS
58(EFIAPI *EFI_SPI_HC_PROTOCOL_CHIP_SELECT)(
59 IN CONST EFI_SPI_HC_PROTOCOL *This,
60 IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral,
61 IN BOOLEAN PinValue
62 );
63
64/**
65 Set up the clock generator to produce the correct clock frequency, phase and
66 polarity for a SPI chip.
67
68 This routine is called at TPL_NOTIFY.
69 This routine updates the clock generator to generate the correct frequency
70 and polarity for the SPI clock.
71
72 @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure.
73 @param[in] SpiPeripheral Pointer to a EFI_SPI_PERIPHERAL data structure from
74 which the routine can access the ClockParameter,
75 ClockPhase and ClockPolarity fields. The routine
76 also has access to the names for the SPI bus and
77 chip which can be used during debugging.
78 @param[in] ClockHz Pointer to the requested clock frequency. The SPI
79 host controller will choose a supported clock
80 frequency which is less then or equal to this
81 value. Specify zero to turn the clock generator
82 off. The actual clock frequency supported by the
83 SPI host controller will be returned.
84
85 @retval EFI_SUCCESS The clock was set up successfully
86 @retval EFI_UNSUPPORTED The SPI controller was not able to support the
87 frequency requested by ClockHz
88
89**/
90typedef EFI_STATUS
91(EFIAPI *EFI_SPI_HC_PROTOCOL_CLOCK)(
92 IN CONST EFI_SPI_HC_PROTOCOL *This,
93 IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral,
94 IN UINT32 *ClockHz
95 );
96
97/**
98 Perform the SPI transaction on the SPI peripheral using the SPI host
99 controller.
100
101 This routine is called at TPL_NOTIFY.
102 This routine synchronously returns EFI_SUCCESS indicating that the
103 asynchronous SPI transaction was started. The routine then waits for
104 completion of the SPI transaction prior to returning the final transaction
105 status.
106
107 @param[in] This Pointer to an EFI_SPI_HC_PROTOCOL structure.
108 @param[in] BusTransaction Pointer to a EFI_SPI_BUS_ TRANSACTION containing
109 the description of the SPI transaction to perform.
110
111 @retval EFI_SUCCESS The transaction completed successfully
112 @retval EFI_BAD_BUFFER_SIZE The BusTransaction->WriteBytes value is invalid,
113 or the BusTransaction->ReadinBytes value is
114 invalid
115 @retval EFI_UNSUPPORTED The BusTransaction-> Transaction Type is
116 unsupported
117
118**/
119typedef EFI_STATUS
120(EFIAPI *EFI_SPI_HC_PROTOCOL_TRANSACTION)(
121 IN CONST EFI_SPI_HC_PROTOCOL *This,
122 IN EFI_SPI_BUS_TRANSACTION *BusTransaction
123 );
124
125///
126/// Definitions of SPI Host Controller Attributes.
127///
128#define HC_SUPPORTS_WRITE_ONLY_OPERATIONS BIT0
129#define HC_SUPPORTS_READ_ONLY_OPERATIONS BIT1
130#define HC_SUPPORTS_WRITE_THEN_READ_OPERATIONS BIT2
131#define HC_TX_FRAME_IN_MOST_SIGNIFICANT_BITS BIT3
132#define HC_RX_FRAME_IN_MOST_SIGNIFICANT_BITS BIT4
133#define HC_SUPPORTS_2_BIT_DATA_BUS_WIDTH BIT5
134#define HC_SUPPORTS_4_BIT_DATA_BUS_WIDTH BIT6
135#define HC_SUPPORTS_8_BIT_DATA_BUS_WIDTH BIT7
136#define HC_TRANSFER_SIZE_INCLUDES_OPCODE BIT8
137#define HC_TRANSFER_SIZE_INCLUDES_ADDRESS BIT9
138///
139/// Support a SPI data transaction between the SPI controller and a SPI chip.
140///
141struct _EFI_SPI_HC_PROTOCOL {
142 ///
143 /// Host control attributes, may have zero or more of the following set:
144 /// * HC_SUPPORTS_WRITE_ONLY_OPERATIONS
145 /// * HC_SUPPORTS_READ_ONLY_OPERATIONS
146 /// * HC_SUPPORTS_WRITE_THEN_READ_OPERATIONS
147 /// * HC_TX_FRAME_IN_MOST_SIGNIFICANT_BITS
148 /// - The SPI host controller requires the transmit frame to be in most
149 /// significant bits instead of least significant bits.The host driver
150 /// will adjust the frames if necessary.
151 /// * HC_RX_FRAME_IN_MOST_SIGNIFICANT_BITS
152 /// - The SPI host controller places the receive frame to be in most
153 /// significant bits instead of least significant bits.The host driver
154 /// will adjust the frames to be in the least significant bits if
155 /// necessary.
156 /// * HC_SUPPORTS_2_BIT_DATA_BUS_W1DTH
157 /// - The SPI controller supports a 2 - bit data bus
158 /// * HC_SUPPORTS_4_B1T_DATA_BUS_WIDTH
159 /// - The SPI controller supports a 4 - bit data bus
160 /// * HC_TRANSFER_SIZE_INCLUDES_OPCODE
161 /// - Transfer size includes the opcode byte
162 /// * HC_TRANSFER_SIZE_INCLUDES_ADDRESS
163 /// - Transfer size includes the 3 address bytes
164 /// The SPI host controller must support full - duplex (receive while
165 /// sending) operation.The SPI host controller must support a 1 - bit bus
166 /// width.
167 ///
168 UINT32 Attributes;
169
170 ///
171 /// Mask of frame sizes which the SPI host controller supports. Frame size of
172 /// N-bits is supported when bit N-1 is set. The host controller must support
173 /// a frame size of 8-bits.
174 ///
175 UINT32 FrameSizeSupportMask;
176
177 ///
178 /// Maximum transfer size in bytes: 1 - Oxffffffff
179 ///
180 UINT32 MaximumTransferBytes;
181
182 ///
183 /// Assert or deassert the SPI chip select.
184 ///
185 EFI_SPI_HC_PROTOCOL_CHIP_SELECT ChipSelect;
186
187 ///
188 /// Set up the clock generator to produce the correct clock frequency, phase
189 /// and polarity for a SPI chip.
190 ///
191 EFI_SPI_HC_PROTOCOL_CLOCK Clock;
192
193 ///
194 /// Perform the SPI transaction on the SPI peripheral using the SPI host
195 /// controller.
196 ///
197 EFI_SPI_HC_PROTOCOL_TRANSACTION Transaction;
198};
199
200extern EFI_GUID gEfiSpiHcProtocolGuid;
201
202#endif // __SPI_HC_PROTOCOL_H__
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette