1 /** @file 2 3 Provides some data structure definitions used by the Designware SD/MMC 4 host controller driver. 5 6 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> 7 Copyright (C) 2017, Linaro Ltd. All rigths reserved.<BR> 8 9 This program and the accompanying materials 10 are licensed and made available under the terms and conditions of the BSD License 11 which accompanies this distribution. The full text of the license may be found at 12 http://opensource.org/licenses/bsd-license.php 13 14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 16 17 **/ 18 19 #ifndef _DW_MMC_HC_DXE_H_ 20 #define _DW_MMC_HC_DXE_H_ 21 22 #include <Uefi.h> 23 24 #include <IndustryStandard/Emmc.h> 25 #include <IndustryStandard/Pci.h> 26 #include <IndustryStandard/Sd.h> 27 28 #include <Library/ArmLib.h> 29 #include <Library/BaseMemoryLib.h> 30 #include <Library/DebugLib.h> 31 #include <Library/DevicePathLib.h> 32 #include <Library/MemoryAllocationLib.h> 33 #include <Library/UefiBootServicesTableLib.h> 34 #include <Library/UefiDriverEntryPoint.h> 35 #include <Library/UefiLib.h> 36 37 #include <Protocol/ComponentName.h> 38 #include <Protocol/ComponentName2.h> 39 #include <Protocol/DevicePath.h> 40 #include <Protocol/DriverBinding.h> 41 #include <Protocol/PciIo.h> 42 #include <Protocol/PlatformDwMmc.h> 43 #include <Protocol/SdMmcPassThru.h> 44 45 #include "DwMmcHci.h" 46 47 extern EFI_COMPONENT_NAME_PROTOCOL gDwMmcHcComponentName; 48 extern EFI_COMPONENT_NAME2_PROTOCOL gDwMmcHcComponentName2; 49 extern EFI_DRIVER_BINDING_PROTOCOL gDwMmcHcDriverBinding; 50 51 #define DW_MMC_HC_PRIVATE_SIGNATURE SIGNATURE_32 ('d', 'w', 's', 'd') 52 53 #define DW_MMC_HC_PRIVATE_FROM_THIS(a) \ 54 CR(a, DW_MMC_HC_PRIVATE_DATA, PassThru, DW_MMC_HC_PRIVATE_SIGNATURE) 55 56 // 57 // Generic time out value, 1 microsecond as unit. 58 // 59 #define DW_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000 60 61 // 62 // SD/MMC async transfer timer interval, set by experience. 63 // The unit is 100us, takes 1ms as interval. 64 // 65 #define DW_MMC_HC_ASYNC_TIMER EFI_TIMER_PERIOD_MILLISECONDS(1) 66 // 67 // SD/MMC removable device enumeration timer interval, set by experience. 68 // The unit is 100us, takes 100ms as interval. 69 // 70 #define DW_MMC_HC_ENUM_TIMER EFI_TIMER_PERIOD_MILLISECONDS(100) 71 72 typedef struct { 73 BOOLEAN Enable; 74 EFI_SD_MMC_SLOT_TYPE SlotType; 75 BOOLEAN MediaPresent; 76 BOOLEAN Initialized; 77 SD_MMC_CARD_TYPE CardType; 78 } DW_MMC_HC_SLOT; 79 80 typedef struct { 81 UINTN Signature; 82 83 EFI_HANDLE ControllerHandle; 84 EFI_PCI_IO_PROTOCOL *PciIo; 85 86 EFI_SD_MMC_PASS_THRU_PROTOCOL PassThru; 87 88 PLATFORM_DW_MMC_PROTOCOL *PlatformDwMmc; 89 90 UINT64 PciAttributes; 91 // 92 // The field is used to record the previous slot in GetNextSlot(). 93 // 94 UINT8 PreviousSlot; 95 // 96 // For Non-blocking operation. 97 // 98 EFI_EVENT TimerEvent; 99 // 100 // For Sd removable device enumeration. 101 // 102 EFI_EVENT ConnectEvent; 103 LIST_ENTRY Queue; 104 105 DW_MMC_HC_SLOT Slot[DW_MMC_HC_MAX_SLOT]; 106 DW_MMC_HC_SLOT_CAP Capability[DW_MMC_HC_MAX_SLOT]; 107 UINT64 MaxCurrent[DW_MMC_HC_MAX_SLOT]; 108 109 UINT32 ControllerVersion; 110 } DW_MMC_HC_PRIVATE_DATA; 111 112 #define DW_MMC_HC_TRB_SIG SIGNATURE_32 ('D', 'T', 'R', 'B') 113 114 // 115 // TRB (Transfer Request Block) contains information for the cmd request. 116 // 117 typedef struct { 118 UINT32 Signature; 119 LIST_ENTRY TrbList; 120 121 UINT8 Slot; 122 UINT16 BlockSize; 123 124 EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; 125 VOID *Data; 126 UINT32 DataLen; 127 BOOLEAN Read; 128 EFI_PHYSICAL_ADDRESS DataPhy; 129 VOID *DataMap; 130 DW_MMC_HC_TRANSFER_MODE Mode; 131 132 EFI_EVENT Event; 133 BOOLEAN Started; 134 UINT64 Timeout; 135 136 DW_MMC_HC_DMA_DESC_LINE *DmaDesc; 137 EFI_PHYSICAL_ADDRESS DmaDescPhy; 138 UINT32 DmaDescPages; 139 VOID *DmaMap; 140 141 BOOLEAN UseFifo; 142 BOOLEAN UseBE; // Big-endian 143 144 DW_MMC_HC_PRIVATE_DATA *Private; 145 } DW_MMC_HC_TRB; 146 147 #define DW_MMC_HC_TRB_FROM_THIS(a) \ 148 CR(a, DW_MMC_HC_TRB, TrbList, DW_MMC_HC_TRB_SIG) 149 150 // 151 // Task for Non-blocking mode. 152 // 153 typedef struct { 154 UINT32 Signature; 155 LIST_ENTRY Link; 156 157 UINT8 Slot; 158 EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet; 159 BOOLEAN IsStart; 160 EFI_EVENT Event; 161 UINT64 RetryTimes; 162 BOOLEAN InfiniteWait; 163 VOID *Map; 164 VOID *MapAddress; 165 } DW_MMC_HC_QUEUE; 166 167 // 168 // Prototypes 169 // 170 /** 171 Execute card identification procedure. 172 173 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 174 @param[in] Slot The slot number of the SD card to send the command to. 175 176 @retval EFI_SUCCESS The card is identified correctly. 177 @retval Others The card can't be identified. 178 179 **/ 180 typedef 181 EFI_STATUS 182 (*CARD_TYPE_DETECT_ROUTINE) ( 183 IN DW_MMC_HC_PRIVATE_DATA *Private, 184 IN UINT8 Slot 185 ); 186 187 /** 188 Sends SD command to an SD card that is attached to the SD controller. 189 190 The PassThru() function sends the SD command specified by Packet to the SD card 191 specified by Slot. 192 193 If Packet is successfully sent to the SD card, then EFI_SUCCESS is returned. 194 195 If a device error occurs while sending the Packet, then EFI_DEVICE_ERROR is returned. 196 197 If Slot is not in a valid range for the SD controller, then EFI_INVALID_PARAMETER 198 is returned. 199 200 If Packet defines a data command but both InDataBuffer and OutDataBuffer are NULL, 201 EFI_INVALID_PARAMETER is returned. 202 203 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. 204 @param[in] Slot The slot number of the SD card to send the command to. 205 @param[in,out] Packet A pointer to the SD command data structure. 206 @param[in] Event If Event is NULL, blocking I/O is performed. If Event is 207 not NULL, then nonblocking I/O is performed, and Event 208 will be signaled when the Packet completes. 209 210 @retval EFI_SUCCESS The SD Command Packet was sent by the host. 211 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the SD 212 command Packet. 213 @retval EFI_INVALID_PARAMETER Packet, Slot, or the contents of the Packet is invalid. 214 @retval EFI_INVALID_PARAMETER Packet defines a data command but both InDataBuffer and 215 OutDataBuffer are NULL. 216 @retval EFI_NO_MEDIA SD Device not present in the Slot. 217 @retval EFI_UNSUPPORTED The command described by the SD Command Packet is not 218 supported by the host controller. 219 @retval EFI_BAD_BUFFER_SIZE The InTransferLength or OutTransferLength exceeds the 220 limit supported by SD card ( i.e. if the number of bytes 221 exceed the Last LBA). 222 223 **/ 224 EFI_STATUS 225 EFIAPI 226 DwMmcPassThruPassThru ( 227 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, 228 IN UINT8 Slot, 229 IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet, 230 IN EFI_EVENT Event OPTIONAL 231 ); 232 233 /** 234 Used to retrieve next slot numbers supported by the SD controller. The function 235 returns information about all available slots (populated or not-populated). 236 237 The GetNextSlot() function retrieves the next slot number on an SD controller. 238 If on input Slot is 0xFF, then the slot number of the first slot on the SD controller 239 is returned. 240 241 If Slot is a slot number that was returned on a previous call to GetNextSlot(), then 242 the slot number of the next slot on the SD controller is returned. 243 244 If Slot is not 0xFF and Slot was not returned on a previous call to GetNextSlot(), 245 EFI_INVALID_PARAMETER is returned. 246 247 If Slot is the slot number of the last slot on the SD controller, then EFI_NOT_FOUND 248 is returned. 249 250 @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance. 251 @param[in,out] Slot On input, a pointer to a slot number on the SD controller. 252 On output, a pointer to the next slot number on the SD controller. 253 An input value of 0xFF retrieves the first slot number on the SD 254 controller. 255 256 @retval EFI_SUCCESS The next slot number on the SD controller was returned in Slot. 257 @retval EFI_NOT_FOUND There are no more slots on this SD controller. 258 @retval EFI_INVALID_PARAMETER Slot is not 0xFF and Slot was not returned on a previous call 259 to GetNextSlot(). 260 261 **/ 262 EFI_STATUS 263 EFIAPI 264 DwMmcPassThruGetNextSlot ( 265 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, 266 IN OUT UINT8 *Slot 267 ); 268 269 /** 270 Used to allocate and build a device path node for an SD card on the SD controller. 271 272 The BuildDevicePath() function allocates and builds a single device node for the SD 273 card specified by Slot. 274 275 If the SD card specified by Slot is not present on the SD controller, then EFI_NOT_FOUND 276 is returned. 277 278 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. 279 280 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES 281 is returned. 282 283 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of 284 DevicePath are initialized to describe the SD card specified by Slot, and EFI_SUCCESS is 285 returned. 286 287 @param[in] This A pointer to the EFI_SD_MMMC_PASS_THRU_PROTOCOL instance. 288 @param[in] Slot Specifies the slot number of the SD card for which a device 289 path node is to be allocated and built. 290 @param[in,out] DevicePath A pointer to a single device path node that describes the SD 291 card specified by Slot. This function is responsible for 292 allocating the buffer DevicePath with the boot service 293 AllocatePool(). It is the caller's responsibility to free 294 DevicePath when the caller is finished with DevicePath. 295 296 @retval EFI_SUCCESS The device path node that describes the SD card specified by 297 Slot was allocated and returned in DevicePath. 298 @retval EFI_NOT_FOUND The SD card specified by Slot does not exist on the SD controller. 299 @retval EFI_INVALID_PARAMETER DevicePath is NULL. 300 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate DevicePath. 301 302 **/ 303 EFI_STATUS 304 EFIAPI 305 DwMmcPassThruBuildDevicePath ( 306 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, 307 IN UINT8 Slot, 308 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath 309 ); 310 311 /** 312 This function retrieves an SD card slot number based on the input device path. 313 314 The GetSlotNumber() function retrieves slot number for the SD card specified by 315 the DevicePath node. If DevicePath is NULL, EFI_INVALID_PARAMETER is returned. 316 317 If DevicePath is not a device path node type that the SD Pass Thru driver supports, 318 EFI_UNSUPPORTED is returned. 319 320 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. 321 @param[in] DevicePath A pointer to the device path node that describes a SD 322 card on the SD controller. 323 @param[out] Slot On return, points to the slot number of an SD card on 324 the SD controller. 325 326 @retval EFI_SUCCESS SD card slot number is returned in Slot. 327 @retval EFI_INVALID_PARAMETER Slot or DevicePath is NULL. 328 @retval EFI_UNSUPPORTED DevicePath is not a device path node type that the SD 329 Pass Thru driver supports. 330 331 **/ 332 EFI_STATUS 333 EFIAPI 334 DwMmcPassThruGetSlotNumber ( 335 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, 336 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, 337 OUT UINT8 *Slot 338 ); 339 340 /** 341 Resets an SD card that is connected to the SD controller. 342 343 The ResetDevice() function resets the SD card specified by Slot. 344 345 If this SD controller does not support a device reset operation, EFI_UNSUPPORTED is 346 returned. 347 348 If Slot is not in a valid slot number for this SD controller, EFI_INVALID_PARAMETER 349 is returned. 350 351 If the device reset operation is completed, EFI_SUCCESS is returned. 352 353 @param[in] This A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance. 354 @param[in] Slot Specifies the slot number of the SD card to be reset. 355 356 @retval EFI_SUCCESS The SD card specified by Slot was reset. 357 @retval EFI_UNSUPPORTED The SD controller does not support a device reset operation. 358 @retval EFI_INVALID_PARAMETER Slot number is invalid. 359 @retval EFI_NO_MEDIA SD Device not present in the Slot. 360 @retval EFI_DEVICE_ERROR The reset command failed due to a device error 361 362 **/ 363 EFI_STATUS 364 EFIAPI 365 DwMmcPassThruResetDevice ( 366 IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, 367 IN UINT8 Slot 368 ); 369 370 // 371 // Driver model protocol interfaces 372 // 373 /** 374 Tests to see if this driver supports a given controller. If a child device is provided, 375 it further tests to see if this driver supports creating a handle for the specified child device. 376 377 This function checks to see if the driver specified by This supports the device specified by 378 ControllerHandle. Drivers will typically use the device path attached to 379 ControllerHandle and/or the services from the bus I/O abstraction attached to 380 ControllerHandle to determine if the driver supports ControllerHandle. This function 381 may be called many times during platform initialization. In order to reduce boot times, the tests 382 performed by this function must be very small, and take as little time as possible to execute. This 383 function must not change the state of any hardware devices, and this function must be aware that the 384 device specified by ControllerHandle may already be managed by the same driver or a 385 different driver. This function must match its calls to AllocatePages() with FreePages(), 386 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). 387 Since ControllerHandle may have been previously started by the same driver, if a protocol is 388 already in the opened state, then it must not be closed with CloseProtocol(). This is required 389 to guarantee the state of ControllerHandle is not modified by this function. 390 391 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. 392 @param[in] ControllerHandle The handle of the controller to test. This handle 393 must support a protocol interface that supplies 394 an I/O abstraction to the driver. 395 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This 396 parameter is ignored by device drivers, and is optional for bus 397 drivers. For bus drivers, if this parameter is not NULL, then 398 the bus driver must determine if the bus controller specified 399 by ControllerHandle and the child controller specified 400 by RemainingDevicePath are both supported by this 401 bus driver. 402 403 @retval EFI_SUCCESS The device specified by ControllerHandle and 404 RemainingDevicePath is supported by the driver specified by This. 405 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and 406 RemainingDevicePath is already being managed by the driver 407 specified by This. 408 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and 409 RemainingDevicePath is already being managed by a different 410 driver or an application that requires exclusive access. 411 Currently not implemented. 412 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and 413 RemainingDevicePath is not supported by the driver specified by This. 414 **/ 415 EFI_STATUS 416 EFIAPI 417 DwMmcHcDriverBindingSupported ( 418 IN EFI_DRIVER_BINDING_PROTOCOL *This, 419 IN EFI_HANDLE Controller, 420 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath 421 ); 422 423 /** 424 Starts a device controller or a bus controller. 425 426 The Start() function is designed to be invoked from the EFI boot service ConnectController(). 427 As a result, much of the error checking on the parameters to Start() has been moved into this 428 common boot service. It is legal to call Start() from other locations, 429 but the following calling restrictions must be followed or the system behavior will not be deterministic. 430 1. ControllerHandle must be a valid EFI_HANDLE. 431 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned 432 EFI_DEVICE_PATH_PROTOCOL. 433 3. Prior to calling Start(), the Supported() function for the driver specified by This must 434 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. 435 436 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. 437 @param[in] ControllerHandle The handle of the controller to start. This handle 438 must support a protocol interface that supplies 439 an I/O abstraction to the driver. 440 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This 441 parameter is ignored by device drivers, and is optional for bus 442 drivers. For a bus driver, if this parameter is NULL, then handles 443 for all the children of Controller are created by this driver. 444 If this parameter is not NULL and the first Device Path Node is 445 not the End of Device Path Node, then only the handle for the 446 child device specified by the first Device Path Node of 447 RemainingDevicePath is created by this driver. 448 If the first Device Path Node of RemainingDevicePath is 449 the End of Device Path Node, no child handle is created by this 450 driver. 451 452 @retval EFI_SUCCESS The device was started. 453 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. 454 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. 455 @retval Others The driver failded to start the device. 456 457 **/ 458 EFI_STATUS 459 EFIAPI 460 DwMmcHcDriverBindingStart ( 461 IN EFI_DRIVER_BINDING_PROTOCOL *This, 462 IN EFI_HANDLE Controller, 463 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath 464 ); 465 466 /** 467 Stops a device controller or a bus controller. 468 469 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). 470 As a result, much of the error checking on the parameters to Stop() has been moved 471 into this common boot service. It is legal to call Stop() from other locations, 472 but the following calling restrictions must be followed or the system behavior will not be deterministic. 473 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this 474 same driver's Start() function. 475 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid 476 EFI_HANDLE. In addition, all of these handles must have been created in this driver's 477 Start() function, and the Start() function must have called OpenProtocol() on 478 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. 479 480 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. 481 @param[in] ControllerHandle A handle to the device being stopped. The handle must 482 support a bus specific I/O protocol for the driver 483 to use to stop the device. 484 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. 485 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL 486 if NumberOfChildren is 0. 487 488 @retval EFI_SUCCESS The device was stopped. 489 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. 490 491 **/ 492 EFI_STATUS 493 EFIAPI 494 DwMmcHcDriverBindingStop ( 495 IN EFI_DRIVER_BINDING_PROTOCOL *This, 496 IN EFI_HANDLE Controller, 497 IN UINTN NumberOfChildren, 498 IN EFI_HANDLE *ChildHandleBuffer 499 ); 500 501 // 502 // EFI Component Name Functions 503 // 504 /** 505 Retrieves a Unicode string that is the user readable name of the driver. 506 507 This function retrieves the user readable name of a driver in the form of a 508 Unicode string. If the driver specified by This has a user readable name in 509 the language specified by Language, then a pointer to the driver name is 510 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified 511 by This does not support the language specified by Language, 512 then EFI_UNSUPPORTED is returned. 513 514 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 515 EFI_COMPONENT_NAME_PROTOCOL instance. 516 517 @param Language[in] A pointer to a Null-terminated ASCII string 518 array indicating the language. This is the 519 language of the driver name that the caller is 520 requesting, and it must match one of the 521 languages specified in SupportedLanguages. The 522 number of languages supported by a driver is up 523 to the driver writer. Language is specified 524 in RFC 4646 or ISO 639-2 language code format. 525 526 @param DriverName[out] A pointer to the Unicode string to return. 527 This Unicode string is the name of the 528 driver specified by This in the language 529 specified by Language. 530 531 @retval EFI_SUCCESS The Unicode string for the Driver specified by 532 This and the language specified by Language was 533 returned in DriverName. 534 535 @retval EFI_INVALID_PARAMETER Language is NULL. 536 537 @retval EFI_INVALID_PARAMETER DriverName is NULL. 538 539 @retval EFI_UNSUPPORTED The driver specified by This does not support 540 the language specified by Language. 541 542 **/ 543 EFI_STATUS 544 EFIAPI 545 DwMmcHcComponentNameGetDriverName ( 546 IN EFI_COMPONENT_NAME_PROTOCOL *This, 547 IN CHAR8 *Language, 548 OUT CHAR16 **DriverName 549 ); 550 551 /** 552 Retrieves a Unicode string that is the user readable name of the controller 553 that is being managed by a driver. 554 555 This function retrieves the user readable name of the controller specified by 556 ControllerHandle and ChildHandle in the form of a Unicode string. If the 557 driver specified by This has a user readable name in the language specified by 558 Language, then a pointer to the controller name is returned in ControllerName, 559 and EFI_SUCCESS is returned. If the driver specified by This is not currently 560 managing the controller specified by ControllerHandle and ChildHandle, 561 then EFI_UNSUPPORTED is returned. If the driver specified by This does not 562 support the language specified by Language, then EFI_UNSUPPORTED is returned. 563 564 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or 565 EFI_COMPONENT_NAME_PROTOCOL instance. 566 567 @param ControllerHandle[in] The handle of a controller that the driver 568 specified by This is managing. This handle 569 specifies the controller whose name is to be 570 returned. 571 572 @param ChildHandle[in] The handle of the child controller to retrieve 573 the name of. This is an optional parameter that 574 may be NULL. It will be NULL for device 575 drivers. It will also be NULL for a bus drivers 576 that wish to retrieve the name of the bus 577 controller. It will not be NULL for a bus 578 driver that wishes to retrieve the name of a 579 child controller. 580 581 @param Language[in] A pointer to a Null-terminated ASCII string 582 array indicating the language. This is the 583 language of the driver name that the caller is 584 requesting, and it must match one of the 585 languages specified in SupportedLanguages. The 586 number of languages supported by a driver is up 587 to the driver writer. Language is specified in 588 RFC 4646 or ISO 639-2 language code format. 589 590 @param ControllerName[out] A pointer to the Unicode string to return. 591 This Unicode string is the name of the 592 controller specified by ControllerHandle and 593 ChildHandle in the language specified by 594 Language from the point of view of the driver 595 specified by This. 596 597 @retval EFI_SUCCESS The Unicode string for the user readable name in 598 the language specified by Language for the 599 driver specified by This was returned in 600 DriverName. 601 602 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. 603 604 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid 605 EFI_HANDLE. 606 607 @retval EFI_INVALID_PARAMETER Language is NULL. 608 609 @retval EFI_INVALID_PARAMETER ControllerName is NULL. 610 611 @retval EFI_UNSUPPORTED The driver specified by This is not currently 612 managing the controller specified by 613 ControllerHandle and ChildHandle. 614 615 @retval EFI_UNSUPPORTED The driver specified by This does not support 616 the language specified by Language. 617 618 **/ 619 EFI_STATUS 620 EFIAPI 621 DwMmcHcComponentNameGetControllerName ( 622 IN EFI_COMPONENT_NAME_PROTOCOL *This, 623 IN EFI_HANDLE ControllerHandle, 624 IN EFI_HANDLE ChildHandle, OPTIONAL 625 IN CHAR8 *Language, 626 OUT CHAR16 **ControllerName 627 ); 628 629 /** 630 Create a new TRB for the SD/MMC cmd request. 631 632 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 633 @param[in] Slot The slot number of the SD card to send the command to. 634 @param[in] Packet A pointer to the SD command data structure. 635 @param[in] Event If Event is NULL, blocking I/O is performed. If Event is 636 not NULL, then nonblocking I/O is performed, and Event 637 will be signaled when the Packet completes. 638 639 @return Created Trb or NULL. 640 641 **/ 642 DW_MMC_HC_TRB * 643 DwMmcCreateTrb ( 644 IN DW_MMC_HC_PRIVATE_DATA *Private, 645 IN UINT8 Slot, 646 IN EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet, 647 IN EFI_EVENT Event 648 ); 649 650 /** 651 Free the resource used by the TRB. 652 653 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 654 655 **/ 656 VOID 657 DwMmcFreeTrb ( 658 IN DW_MMC_HC_TRB *Trb 659 ); 660 661 /** 662 Check if the env is ready for execute specified TRB. 663 664 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 665 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 666 667 @retval EFI_SUCCESS The env is ready for TRB execution. 668 @retval EFI_NOT_READY The env is not ready for TRB execution. 669 @retval Others Some erros happen. 670 671 **/ 672 EFI_STATUS 673 DwMmcCheckTrbEnv ( 674 IN DW_MMC_HC_PRIVATE_DATA *Private, 675 IN DW_MMC_HC_TRB *Trb 676 ); 677 678 /** 679 Wait for the env to be ready for execute specified TRB. 680 681 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 682 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 683 684 @retval EFI_SUCCESS The env is ready for TRB execution. 685 @retval EFI_TIMEOUT The env is not ready for TRB execution in time. 686 @retval Others Some erros happen. 687 688 **/ 689 EFI_STATUS 690 DwMmcWaitTrbEnv ( 691 IN DW_MMC_HC_PRIVATE_DATA *Private, 692 IN DW_MMC_HC_TRB *Trb 693 ); 694 695 /** 696 Execute the specified TRB. 697 698 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 699 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 700 701 @retval EFI_SUCCESS The TRB is sent to host controller successfully. 702 @retval Others Some erros happen when sending this request to the host controller. 703 704 **/ 705 EFI_STATUS 706 DwMmcExecTrb ( 707 IN DW_MMC_HC_PRIVATE_DATA *Private, 708 IN DW_MMC_HC_TRB *Trb 709 ); 710 711 /** 712 Check the TRB execution result. 713 714 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 715 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 716 717 @retval EFI_SUCCESS The TRB is executed successfully. 718 @retval EFI_NOT_READY The TRB is not completed for execution. 719 @retval Others Some erros happen when executing this request. 720 721 **/ 722 EFI_STATUS 723 DwMmcCheckTrbResult ( 724 IN DW_MMC_HC_PRIVATE_DATA *Private, 725 IN DW_MMC_HC_TRB *Trb 726 ); 727 728 /** 729 Wait for the TRB execution result. 730 731 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 732 @param[in] Trb The pointer to the DW_MMC_HC_TRB instance. 733 734 @retval EFI_SUCCESS The TRB is executed successfully. 735 @retval Others Some erros happen when executing this request. 736 737 **/ 738 EFI_STATUS 739 DwMmcWaitTrbResult ( 740 IN DW_MMC_HC_PRIVATE_DATA *Private, 741 IN DW_MMC_HC_TRB *Trb 742 ); 743 744 /** 745 Execute EMMC device identification procedure. 746 747 Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details. 748 749 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 750 @param[in] Slot The slot number of the SD card to send the command to. 751 752 @retval EFI_SUCCESS There is a EMMC card. 753 @retval Others There is not a EMMC card. 754 755 **/ 756 EFI_STATUS 757 EmmcIdentification ( 758 IN DW_MMC_HC_PRIVATE_DATA *Private, 759 IN UINT8 Slot 760 ); 761 762 /** 763 Execute EMMC device identification procedure. 764 765 Refer to EMMC Electrical Standard Spec 5.1 Section 6.4 for details. 766 767 @param[in] Private A pointer to the DW_MMC_HC_PRIVATE_DATA instance. 768 @param[in] Slot The slot number of the SD card to send the command to. 769 770 @retval EFI_SUCCESS There is a EMMC card. 771 @retval Others There is not a EMMC card. 772 773 **/ 774 EFI_STATUS 775 SdCardIdentification ( 776 IN DW_MMC_HC_PRIVATE_DATA *Private, 777 IN UINT8 Slot 778 ); 779 780 #endif 781