TianoCore EDK2 master
Loading...
Searching...
No Matches
EmmcDevice.c
Go to the documentation of this file.
1
10#include "SdMmcPciHcDxe.h"
11
28 IN UINT8 Slot
29 )
30{
31 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
32 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
34 EFI_STATUS Status;
35
36 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
37 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
38 ZeroMem (&Packet, sizeof (Packet));
39
40 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
41 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
42 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
43
44 SdMmcCmdBlk.CommandIndex = EMMC_GO_IDLE_STATE;
45 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBc;
46 SdMmcCmdBlk.ResponseType = 0;
47 SdMmcCmdBlk.CommandArgument = 0;
48
49 gBS->Stall (1000);
50
51 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
52
53 return Status;
54}
55
73 IN UINT8 Slot,
74 IN OUT UINT32 *Argument
75 )
76{
77 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
78 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
80 EFI_STATUS Status;
81
82 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
83 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
84 ZeroMem (&Packet, sizeof (Packet));
85
86 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
87 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
88 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
89
90 SdMmcCmdBlk.CommandIndex = EMMC_SEND_OP_COND;
91 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
92 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR3;
93 SdMmcCmdBlk.CommandArgument = *Argument;
94
95 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
96 if (!EFI_ERROR (Status)) {
97 //
98 // For details, refer to SD Host Controller Simplified Spec 3.0 Table 2-12.
99 //
100 *Argument = SdMmcStatusBlk.Resp0;
101 }
102
103 return Status;
104}
105
122 IN UINT8 Slot
123 )
124{
125 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
126 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
128 EFI_STATUS Status;
129
130 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
131 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
132 ZeroMem (&Packet, sizeof (Packet));
133
134 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
135 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
136 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
137
138 SdMmcCmdBlk.CommandIndex = EMMC_ALL_SEND_CID;
139 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
140 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
141 SdMmcCmdBlk.CommandArgument = 0;
142
143 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
144
145 return Status;
146}
147
165 IN UINT8 Slot,
166 IN UINT16 Rca
167 )
168{
169 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
170 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
172 EFI_STATUS Status;
173
174 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
175 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
176 ZeroMem (&Packet, sizeof (Packet));
177
178 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
179 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
180 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
181
182 SdMmcCmdBlk.CommandIndex = EMMC_SET_RELATIVE_ADDR;
183 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
184 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
185 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
186
187 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
188
189 return Status;
190}
191
212 IN UINT8 Slot,
213 IN UINT16 Rca,
214 OUT EMMC_CSD *Csd
215 )
216{
217 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
218 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
220 EFI_STATUS Status;
221
222 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
223 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
224 ZeroMem (&Packet, sizeof (Packet));
225
226 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
227 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
228 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
229
230 SdMmcCmdBlk.CommandIndex = EMMC_SEND_CSD;
231 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
232 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
233 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
234
235 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
236 if (!EFI_ERROR (Status)) {
237 //
238 // For details, refer to SD Host Controller Simplified Spec 3.0 Table 2-12.
239 //
240 CopyMem (((UINT8 *)Csd) + 1, &SdMmcStatusBlk.Resp0, sizeof (EMMC_CSD) - 1);
241 }
242
243 return Status;
244}
245
262 IN UINT8 Slot,
263 IN UINT16 Rca
264 )
265{
266 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
267 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
269 EFI_STATUS Status;
270
271 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
272 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
273 ZeroMem (&Packet, sizeof (Packet));
274
275 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
276 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
277 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
278
279 SdMmcCmdBlk.CommandIndex = EMMC_SELECT_DESELECT_CARD;
280 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
281 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
282 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
283
284 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
285
286 return Status;
287}
288
305 IN UINT8 Slot,
306 OUT EMMC_EXT_CSD *ExtCsd
307 )
308{
309 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
310 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
312 EFI_STATUS Status;
313
314 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
315 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
316 ZeroMem (&Packet, sizeof (Packet));
317
318 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
319 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
320 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
321
322 SdMmcCmdBlk.CommandIndex = EMMC_SEND_EXT_CSD;
323 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
324 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
325 SdMmcCmdBlk.CommandArgument = 0x00000000;
326
327 Packet.InDataBuffer = ExtCsd;
328 Packet.InTransferLength = sizeof (EMMC_EXT_CSD);
329
330 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
331 return Status;
332}
333
354 IN UINT8 Slot,
355 IN UINT8 Access,
356 IN UINT8 Index,
357 IN UINT8 Value,
358 IN UINT8 CmdSet
359 )
360{
361 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
362 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
364 EFI_STATUS Status;
365
366 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
367 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
368 ZeroMem (&Packet, sizeof (Packet));
369
370 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
371 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
372 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
373
374 SdMmcCmdBlk.CommandIndex = EMMC_SWITCH;
375 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
376 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;
377 SdMmcCmdBlk.CommandArgument = (Access << 24) | (Index << 16) | (Value << 8) | CmdSet;
378
379 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
380
381 return Status;
382}
383
401 IN UINT8 Slot,
402 IN UINT16 Rca,
403 OUT UINT32 *DevStatus
404 )
405{
406 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
407 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
409 EFI_STATUS Status;
410
411 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
412 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
413 ZeroMem (&Packet, sizeof (Packet));
414
415 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
416 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
417 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
418
419 SdMmcCmdBlk.CommandIndex = EMMC_SEND_STATUS;
420 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
421 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
422 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
423
424 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
425 if (!EFI_ERROR (Status)) {
426 *DevStatus = SdMmcStatusBlk.Resp0;
427 }
428
429 return Status;
430}
431
451 IN UINT8 Slot,
452 IN UINT8 BusWidth
453 )
454{
455 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
456 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
458 EFI_STATUS Status;
459 UINT8 TuningBlock[128];
460
461 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
462 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
463 ZeroMem (&Packet, sizeof (Packet));
464
465 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
466 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
467 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
468
469 SdMmcCmdBlk.CommandIndex = EMMC_SEND_TUNING_BLOCK;
470 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
471 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
472 SdMmcCmdBlk.CommandArgument = 0;
473
474 Packet.InDataBuffer = TuningBlock;
475 if (BusWidth == 8) {
476 Packet.InTransferLength = sizeof (TuningBlock);
477 } else {
478 Packet.InTransferLength = 64;
479 }
480
481 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
482
483 return Status;
484}
485
506 IN EFI_PCI_IO_PROTOCOL *PciIo,
508 IN UINT8 Slot,
509 IN UINT8 BusWidth
510 )
511{
512 EFI_STATUS Status;
513 UINT8 HostCtrl2;
514 UINT8 Retry;
515
516 //
517 // Notify the host that the sampling clock tuning procedure starts.
518 //
519 HostCtrl2 = BIT6;
520 Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
521 if (EFI_ERROR (Status)) {
522 return Status;
523 }
524
525 //
526 // Ask the device to send a sequence of tuning blocks till the tuning procedure is done.
527 //
528 Retry = 0;
529 do {
530 Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
531 if (EFI_ERROR (Status)) {
532 DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
533 return Status;
534 }
535
536 Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
537 if (EFI_ERROR (Status)) {
538 return Status;
539 }
540
541 if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
542 break;
543 }
544
545 if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
546 return EFI_SUCCESS;
547 }
548 } while (++Retry < 40);
549
550 DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
551 //
552 // Abort the tuning procedure and reset the tuning circuit.
553 //
554 HostCtrl2 = (UINT8) ~(BIT6 | BIT7);
555 Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
556 if (EFI_ERROR (Status)) {
557 return Status;
558 }
559
560 return EFI_DEVICE_ERROR;
561}
562
576 IN UINT8 Slot,
577 IN UINT16 Rca
578 )
579{
580 EFI_STATUS Status;
581 UINT32 DevStatus;
582
583 Status = EmmcSendStatus (PassThru, Slot, Rca, &DevStatus);
584 if (EFI_ERROR (Status)) {
585 DEBUG ((DEBUG_ERROR, "EmmcCheckSwitchStatus: Send status fails with %r\n", Status));
586 return Status;
587 }
588
589 //
590 // Check the switch operation is really successful or not.
591 //
592 if ((DevStatus & BIT7) != 0) {
593 DEBUG ((DEBUG_ERROR, "EmmcCheckSwitchStatus: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));
594 return EFI_DEVICE_ERROR;
595 }
596
597 return EFI_SUCCESS;
598}
599
620 IN EFI_PCI_IO_PROTOCOL *PciIo,
622 IN UINT8 Slot,
623 IN UINT16 Rca,
624 IN BOOLEAN IsDdr,
625 IN UINT8 BusWidth
626 )
627{
628 EFI_STATUS Status;
629 UINT8 Access;
630 UINT8 Index;
631 UINT8 Value;
632 UINT8 CmdSet;
633
634 //
635 // Write Byte, the Value field is written into the byte pointed by Index.
636 //
637 Access = 0x03;
638 Index = OFFSET_OF (EMMC_EXT_CSD, BusWidth);
639 if (BusWidth == 4) {
640 Value = 1;
641 } else if (BusWidth == 8) {
642 Value = 2;
643 } else {
644 return EFI_INVALID_PARAMETER;
645 }
646
647 if (IsDdr) {
648 Value += 4;
649 }
650
651 CmdSet = 0;
652 Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
653 if (EFI_ERROR (Status)) {
654 DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails with %r\n", BusWidth, Status));
655 return Status;
656 }
657
658 Status = EmmcCheckSwitchStatus (PassThru, Slot, Rca);
659 if (EFI_ERROR (Status)) {
660 return Status;
661 }
662
663 Status = SdMmcHcSetBusWidth (PciIo, Slot, BusWidth);
664
665 return Status;
666}
667
688 IN EFI_PCI_IO_PROTOCOL *PciIo,
690 IN UINT8 Slot,
691 IN UINT16 Rca,
692 IN EDKII_SD_MMC_DRIVER_STRENGTH DriverStrength,
693 IN SD_MMC_BUS_MODE BusTiming,
694 IN UINT32 ClockFreq
695 )
696{
697 EFI_STATUS Status;
698 UINT8 Access;
699 UINT8 Index;
700 UINT8 Value;
701 UINT8 CmdSet;
702 SD_MMC_HC_PRIVATE_DATA *Private;
703 UINT8 HostCtrl1;
704 BOOLEAN DelaySendStatus;
705
706 Private = SD_MMC_HC_PRIVATE_FROM_THIS (PassThru);
707 //
708 // Write Byte, the Value field is written into the byte pointed by Index.
709 //
710 Access = 0x03;
711 Index = OFFSET_OF (EMMC_EXT_CSD, HsTiming);
712 CmdSet = 0;
713 switch (BusTiming) {
714 case SdMmcMmcHs400:
715 Value = (UINT8)((DriverStrength.Emmc << 4) | 3);
716 break;
717 case SdMmcMmcHs200:
718 Value = (UINT8)((DriverStrength.Emmc << 4) | 2);
719 break;
720 case SdMmcMmcHsSdr:
721 case SdMmcMmcHsDdr:
722 Value = 1;
723 break;
724 case SdMmcMmcLegacy:
725 Value = 0;
726 break;
727 default:
728 DEBUG ((DEBUG_ERROR, "EmmcSwitchBusTiming: Unsupported BusTiming(%d)\n", BusTiming));
729 return EFI_INVALID_PARAMETER;
730 }
731
732 Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
733 if (EFI_ERROR (Status)) {
734 DEBUG ((DEBUG_ERROR, "EmmcSwitchBusTiming: Switch to bus timing %d fails with %r\n", BusTiming, Status));
735 return Status;
736 }
737
738 if ((BusTiming == SdMmcMmcHsSdr) || (BusTiming == SdMmcMmcHsDdr)) {
739 HostCtrl1 = BIT2;
740 Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (HostCtrl1), &HostCtrl1);
741 if (EFI_ERROR (Status)) {
742 return Status;
743 }
744 } else {
745 HostCtrl1 = (UINT8) ~BIT2;
746 Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (HostCtrl1), &HostCtrl1);
747 if (EFI_ERROR (Status)) {
748 return Status;
749 }
750 }
751
752 Status = SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, BusTiming);
753 if (EFI_ERROR (Status)) {
754 return Status;
755 }
756
757 //
758 // For cases when we switch bus timing to higher mode from current we want to
759 // send SEND_STATUS at current, lower, frequency then the target frequency to avoid
760 // stability issues. It has been observed that some designs are unable to process the
761 // SEND_STATUS at higher frequency during switch to HS200 @200MHz irrespective of the number of retries
762 // and only running the clock tuning is able to make them work at target frequency.
763 //
764 // For cases when we are downgrading the frequency and current high frequency is invalid
765 // we have to first change the frequency to target frequency and then send the SEND_STATUS.
766 //
767 if (Private->Slot[Slot].CurrentFreq < (ClockFreq * 1000)) {
768 Status = EmmcCheckSwitchStatus (PassThru, Slot, Rca);
769 if (EFI_ERROR (Status)) {
770 return Status;
771 }
772
773 DelaySendStatus = FALSE;
774 } else {
775 DelaySendStatus = TRUE;
776 }
777
778 //
779 // Convert the clock freq unit from MHz to KHz.
780 //
781 Status = SdMmcHcClockSupply (Private, Slot, BusTiming, FALSE, ClockFreq * 1000);
782 if (EFI_ERROR (Status)) {
783 return Status;
784 }
785
786 if (DelaySendStatus) {
787 Status = EmmcCheckSwitchStatus (PassThru, Slot, Rca);
788 if (EFI_ERROR (Status)) {
789 return Status;
790 }
791 }
792
793 return Status;
794}
795
814 IN EFI_PCI_IO_PROTOCOL *PciIo,
816 IN UINT8 Slot,
817 IN UINT16 Rca,
818 IN SD_MMC_BUS_SETTINGS *BusMode
819 )
820{
821 EFI_STATUS Status;
822 BOOLEAN IsDdr;
823
824 if (((BusMode->BusTiming != SdMmcMmcHsSdr) && (BusMode->BusTiming != SdMmcMmcHsDdr) && (BusMode->BusTiming != SdMmcMmcLegacy)) ||
825 (BusMode->ClockFreq > 52))
826 {
827 return EFI_INVALID_PARAMETER;
828 }
829
830 if (BusMode->BusTiming == SdMmcMmcHsDdr) {
831 IsDdr = TRUE;
832 } else {
833 IsDdr = FALSE;
834 }
835
836 Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, IsDdr, BusMode->BusWidth);
837 if (EFI_ERROR (Status)) {
838 return Status;
839 }
840
841 return EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, BusMode->BusTiming, BusMode->ClockFreq);
842}
843
862 IN EFI_PCI_IO_PROTOCOL *PciIo,
864 IN UINT8 Slot,
865 IN UINT16 Rca,
866 IN SD_MMC_BUS_SETTINGS *BusMode
867 )
868{
869 EFI_STATUS Status;
870
871 if ((BusMode->BusTiming != SdMmcMmcHs200) ||
872 ((BusMode->BusWidth != 4) && (BusMode->BusWidth != 8)))
873 {
874 return EFI_INVALID_PARAMETER;
875 }
876
877 Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, FALSE, BusMode->BusWidth);
878 if (EFI_ERROR (Status)) {
879 return Status;
880 }
881
882 Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, BusMode->BusTiming, BusMode->ClockFreq);
883 if (EFI_ERROR (Status)) {
884 return Status;
885 }
886
887 Status = EmmcTuningClkForHs200 (PciIo, PassThru, Slot, BusMode->BusWidth);
888
889 return Status;
890}
891
910 IN EFI_PCI_IO_PROTOCOL *PciIo,
912 IN UINT8 Slot,
913 IN UINT16 Rca,
914 IN SD_MMC_BUS_SETTINGS *BusMode
915 )
916{
917 EFI_STATUS Status;
918 SD_MMC_BUS_SETTINGS Hs200BusMode;
919 UINT32 HsFreq;
920
921 if ((BusMode->BusTiming != SdMmcMmcHs400) ||
922 (BusMode->BusWidth != 8))
923 {
924 return EFI_INVALID_PARAMETER;
925 }
926
927 Hs200BusMode.BusTiming = SdMmcMmcHs200;
928 Hs200BusMode.BusWidth = BusMode->BusWidth;
929 Hs200BusMode.ClockFreq = BusMode->ClockFreq;
930 Hs200BusMode.DriverStrength = BusMode->DriverStrength;
931
932 Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, &Hs200BusMode);
933 if (EFI_ERROR (Status)) {
934 return Status;
935 }
936
937 //
938 // Set to High Speed timing and set the clock frequency to a value less than or equal to 52MHz.
939 // This step is necessary to be able to switch Bus into 8 bit DDR mode which is unsupported in HS200.
940 //
941 HsFreq = BusMode->ClockFreq < 52 ? BusMode->ClockFreq : 52;
942 Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, SdMmcMmcHsSdr, HsFreq);
943 if (EFI_ERROR (Status)) {
944 return Status;
945 }
946
947 Status = EmmcSwitchBusWidth (PciIo, PassThru, Slot, Rca, TRUE, BusMode->BusWidth);
948 if (EFI_ERROR (Status)) {
949 return Status;
950 }
951
952 return EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, BusMode->BusTiming, BusMode->ClockFreq);
953}
954
966BOOLEAN
968 IN SD_MMC_HC_PRIVATE_DATA *Private,
969 IN UINT8 SlotIndex,
970 IN EMMC_EXT_CSD *ExtCsd,
971 IN SD_MMC_BUS_MODE BusTiming
972 )
973{
974 BOOLEAN Supported;
975 SD_MMC_HC_SLOT_CAP *Capabilities;
976
977 Capabilities = &Private->Capability[SlotIndex];
978
979 Supported = FALSE;
980 switch (BusTiming) {
981 case SdMmcMmcHs400:
982 if ((((ExtCsd->DeviceType & (BIT6 | BIT7)) != 0) && (Capabilities->Hs400 != 0)) && (Capabilities->BusWidth8 != 0)) {
983 Supported = TRUE;
984 }
985
986 break;
987 case SdMmcMmcHs200:
988 if ((((ExtCsd->DeviceType & (BIT4 | BIT5)) != 0) && (Capabilities->Sdr104 != 0))) {
989 Supported = TRUE;
990 }
991
992 break;
993 case SdMmcMmcHsDdr:
994 if ((((ExtCsd->DeviceType & (BIT2 | BIT3)) != 0) && (Capabilities->Ddr50 != 0))) {
995 Supported = TRUE;
996 }
997
998 break;
999 case SdMmcMmcHsSdr:
1000 if ((((ExtCsd->DeviceType & BIT1) != 0) && (Capabilities->HighSpeed != 0))) {
1001 Supported = TRUE;
1002 }
1003
1004 break;
1005 case SdMmcMmcLegacy:
1006 if ((ExtCsd->DeviceType & BIT0) != 0) {
1007 Supported = TRUE;
1008 }
1009
1010 break;
1011 default:
1012 ASSERT (FALSE);
1013 }
1014
1015 return Supported;
1016}
1017
1029SD_MMC_BUS_MODE
1031 IN SD_MMC_HC_PRIVATE_DATA *Private,
1032 IN UINT8 SlotIndex,
1033 IN EMMC_EXT_CSD *ExtCsd
1034 )
1035{
1036 SD_MMC_BUS_MODE BusTiming;
1037
1038 //
1039 // We start with highest bus timing that this driver currently supports and
1040 // return as soon as we find supported timing.
1041 //
1042 BusTiming = SdMmcMmcHs400;
1043 while (BusTiming > SdMmcMmcLegacy) {
1044 if (EmmcIsBusTimingSupported (Private, SlotIndex, ExtCsd, BusTiming)) {
1045 break;
1046 }
1047
1048 BusTiming--;
1049 }
1050
1051 return BusTiming;
1052}
1053
1065BOOLEAN
1067 IN SD_MMC_HC_PRIVATE_DATA *Private,
1068 IN UINT8 SlotIndex,
1069 IN SD_MMC_BUS_MODE BusTiming,
1070 IN UINT16 BusWidth
1071 )
1072{
1073 if ((BusWidth == 8) && (Private->Capability[SlotIndex].BusWidth8 != 0)) {
1074 return TRUE;
1075 } else if ((BusWidth == 4) && (BusTiming != SdMmcMmcHs400)) {
1076 return TRUE;
1077 } else if ((BusWidth == 1) && ((BusTiming == SdMmcMmcHsSdr) || (BusTiming == SdMmcMmcLegacy))) {
1078 return TRUE;
1079 }
1080
1081 return FALSE;
1082}
1083
1094UINT8
1096 IN SD_MMC_HC_PRIVATE_DATA *Private,
1097 IN UINT8 SlotIndex,
1098 IN EMMC_EXT_CSD *ExtCsd,
1099 IN SD_MMC_BUS_MODE BusTiming
1100 )
1101{
1102 UINT8 BusWidth;
1103 UINT8 PreferredBusWidth;
1104
1105 PreferredBusWidth = Private->Slot[SlotIndex].OperatingParameters.BusWidth;
1106
1107 if ((PreferredBusWidth != EDKII_SD_MMC_BUS_WIDTH_IGNORE) &&
1108 EmmcIsBusWidthSupported (Private, SlotIndex, BusTiming, PreferredBusWidth))
1109 {
1110 BusWidth = PreferredBusWidth;
1111 } else if (EmmcIsBusWidthSupported (Private, SlotIndex, BusTiming, 8)) {
1112 BusWidth = 8;
1113 } else if (EmmcIsBusWidthSupported (Private, SlotIndex, BusTiming, 4)) {
1114 BusWidth = 4;
1115 } else {
1116 BusWidth = 1;
1117 }
1118
1119 return BusWidth;
1120}
1121
1132UINT32
1134 IN SD_MMC_HC_PRIVATE_DATA *Private,
1135 IN UINT8 SlotIndex,
1136 IN EMMC_EXT_CSD *ExtCsd,
1137 IN SD_MMC_BUS_MODE BusTiming
1138 )
1139{
1140 UINT32 PreferredClockFreq;
1141 UINT32 MaxClockFreq;
1142
1143 PreferredClockFreq = Private->Slot[SlotIndex].OperatingParameters.ClockFreq;
1144
1145 switch (BusTiming) {
1146 case SdMmcMmcHs400:
1147 case SdMmcMmcHs200:
1148 MaxClockFreq = 200;
1149 break;
1150 case SdMmcMmcHsSdr:
1151 case SdMmcMmcHsDdr:
1152 MaxClockFreq = 52;
1153 break;
1154 default:
1155 MaxClockFreq = 26;
1156 break;
1157 }
1158
1159 if ((PreferredClockFreq != EDKII_SD_MMC_CLOCK_FREQ_IGNORE) && (PreferredClockFreq < MaxClockFreq)) {
1160 return PreferredClockFreq;
1161 } else {
1162 return MaxClockFreq;
1163 }
1164}
1165
1178 IN SD_MMC_HC_PRIVATE_DATA *Private,
1179 IN UINT8 SlotIndex,
1180 IN EMMC_EXT_CSD *ExtCsd,
1181 IN SD_MMC_BUS_MODE BusTiming
1182 )
1183{
1184 EDKII_SD_MMC_DRIVER_STRENGTH PreferredDriverStrength;
1185 EDKII_SD_MMC_DRIVER_STRENGTH DriverStrength;
1186
1187 PreferredDriverStrength = Private->Slot[SlotIndex].OperatingParameters.DriverStrength;
1188 DriverStrength.Emmc = EmmcDriverStrengthType0;
1189
1190 if ((PreferredDriverStrength.Emmc != EDKII_SD_MMC_DRIVER_STRENGTH_IGNORE) &&
1191 (ExtCsd->DriverStrength & (BIT0 << PreferredDriverStrength.Emmc)))
1192 {
1193 DriverStrength.Emmc = PreferredDriverStrength.Emmc;
1194 }
1195
1196 return DriverStrength;
1197}
1198
1207VOID
1209 IN SD_MMC_HC_PRIVATE_DATA *Private,
1210 IN UINT8 SlotIndex,
1211 IN EMMC_EXT_CSD *ExtCsd,
1212 OUT SD_MMC_BUS_SETTINGS *BusMode
1213 )
1214{
1215 BusMode->BusTiming = EmmcGetTargetBusTiming (Private, SlotIndex, ExtCsd);
1216 BusMode->BusWidth = EmmcGetTargetBusWidth (Private, SlotIndex, ExtCsd, BusMode->BusTiming);
1217 BusMode->ClockFreq = EmmcGetTargetClockFreq (Private, SlotIndex, ExtCsd, BusMode->BusTiming);
1218 BusMode->DriverStrength = EmmcGetTargetDriverStrength (Private, SlotIndex, ExtCsd, BusMode->BusTiming);
1219}
1220
1238 IN EFI_PCI_IO_PROTOCOL *PciIo,
1240 IN UINT8 Slot,
1241 IN UINT16 Rca
1242 )
1243{
1244 EFI_STATUS Status;
1245 EMMC_CSD Csd;
1246 EMMC_EXT_CSD ExtCsd;
1247 SD_MMC_BUS_SETTINGS BusMode;
1248 SD_MMC_HC_PRIVATE_DATA *Private;
1249
1250 Private = SD_MMC_HC_PRIVATE_FROM_THIS (PassThru);
1251
1252 Status = EmmcGetCsd (PassThru, Slot, Rca, &Csd);
1253 if (EFI_ERROR (Status)) {
1254 DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));
1255 return Status;
1256 }
1257
1258 Status = EmmcSelect (PassThru, Slot, Rca);
1259 if (EFI_ERROR (Status)) {
1260 DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));
1261 return Status;
1262 }
1263
1264 ASSERT (Private->BaseClkFreq[Slot] != 0);
1265
1266 //
1267 // Get Device_Type from EXT_CSD register.
1268 //
1269 Status = EmmcGetExtCsd (PassThru, Slot, &ExtCsd);
1270 if (EFI_ERROR (Status)) {
1271 DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetExtCsd fails with %r\n", Status));
1272 return Status;
1273 }
1274
1275 EmmcGetTargetBusMode (Private, Slot, &ExtCsd, &BusMode);
1276
1277 DEBUG ((
1278 DEBUG_INFO,
1279 "EmmcSetBusMode: Target bus mode: timing = %d, width = %d, clock freq = %d, driver strength = %d\n",
1280 BusMode.BusTiming,
1281 BusMode.BusWidth,
1282 BusMode.ClockFreq,
1283 BusMode.DriverStrength.Emmc
1284 ));
1285
1286 if (BusMode.BusTiming == SdMmcMmcHs400) {
1287 Status = EmmcSwitchToHS400 (PciIo, PassThru, Slot, Rca, &BusMode);
1288 } else if (BusMode.BusTiming == SdMmcMmcHs200) {
1289 Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, &BusMode);
1290 } else {
1291 //
1292 // Note that EmmcSwitchToHighSpeed is also called for SdMmcMmcLegacy
1293 // bus timing. This is because even though we might not want to
1294 // change the timing itself we still want to allow customization of
1295 // bus parameters such as clock frequency and bus width.
1296 //
1297 Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, &BusMode);
1298 }
1299
1300 DEBUG ((DEBUG_INFO, "EmmcSetBusMode: Switch to %a %r\n", (BusMode.BusTiming == SdMmcMmcHs400) ? "HS400" : ((BusMode.BusTiming == SdMmcMmcHs200) ? "HS200" : "HighSpeed"), Status));
1301
1302 return Status;
1303}
1304
1319 IN SD_MMC_HC_PRIVATE_DATA *Private,
1320 IN UINT8 Slot
1321 )
1322{
1323 EFI_STATUS Status;
1324 EFI_PCI_IO_PROTOCOL *PciIo;
1326 UINT32 Ocr;
1327 UINT16 Rca;
1328 UINTN Retry;
1329
1330 PciIo = Private->PciIo;
1331 PassThru = &Private->PassThru;
1332
1333 Status = EmmcReset (PassThru, Slot);
1334 if (EFI_ERROR (Status)) {
1335 DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd0 fails with %r\n", Status));
1336 return Status;
1337 }
1338
1339 Ocr = 0;
1340 Retry = 0;
1341 do {
1342 Status = EmmcGetOcr (PassThru, Slot, &Ocr);
1343 if (EFI_ERROR (Status)) {
1344 DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails with %r\n", Status));
1345 return Status;
1346 }
1347
1348 Ocr |= BIT30;
1349
1350 if (Retry++ == 100) {
1351 DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails too many times\n"));
1352 return EFI_DEVICE_ERROR;
1353 }
1354
1355 gBS->Stall (10 * 1000);
1356 } while ((Ocr & BIT31) == 0);
1357
1358 Status = EmmcGetAllCid (PassThru, Slot);
1359 if (EFI_ERROR (Status)) {
1360 DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd2 fails with %r\n", Status));
1361 return Status;
1362 }
1363
1364 //
1365 // Slot starts from 0 and valid RCA starts from 1.
1366 // Here we takes a simple formula to calculate the RCA.
1367 // Don't support multiple devices on the slot, that is
1368 // shared bus slot feature.
1369 //
1370 Rca = Slot + 1;
1371 Status = EmmcSetRca (PassThru, Slot, Rca);
1372 if (EFI_ERROR (Status)) {
1373 DEBUG ((DEBUG_ERROR, "EmmcIdentification: Executing Cmd3 fails with %r\n", Status));
1374 return Status;
1375 }
1376
1377 //
1378 // Enter Data Tranfer Mode.
1379 //
1380 DEBUG ((DEBUG_INFO, "EmmcIdentification: Found a EMMC device at slot [%d], RCA [%d]\n", Slot, Rca));
1381 Private->Slot[Slot].CardType = EmmcCardType;
1382
1383 Status = EmmcSetBusMode (PciIo, PassThru, Slot, Rca);
1384
1385 return Status;
1386}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EmmcSwitchBusWidth(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN BOOLEAN IsDdr, IN UINT8 BusWidth)
Definition: EmmcDevice.c:619
BOOLEAN EmmcIsBusTimingSupported(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
Definition: EmmcDevice.c:967
EFI_STATUS EmmcSendStatus(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: EmmcDevice.c:399
EFI_STATUS EmmcCheckSwitchStatus(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: EmmcDevice.c:574
EFI_STATUS EmmcSetBusMode(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: EmmcDevice.c:1237
EFI_STATUS EmmcSwitchToHS200(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN SD_MMC_BUS_SETTINGS *BusMode)
Definition: EmmcDevice.c:861
EFI_STATUS EmmcGetExtCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, OUT EMMC_EXT_CSD *ExtCsd)
Definition: EmmcDevice.c:303
EFI_STATUS EmmcSwitchToHighSpeed(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN SD_MMC_BUS_SETTINGS *BusMode)
Definition: EmmcDevice.c:813
EFI_STATUS EmmcSetRca(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: EmmcDevice.c:163
EDKII_SD_MMC_DRIVER_STRENGTH EmmcGetTargetDriverStrength(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
Definition: EmmcDevice.c:1177
EFI_STATUS EmmcGetOcr(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN OUT UINT32 *Argument)
Definition: EmmcDevice.c:71
UINT32 EmmcGetTargetClockFreq(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
Definition: EmmcDevice.c:1133
EFI_STATUS EmmcSendTuningBlk(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT8 BusWidth)
Definition: EmmcDevice.c:449
UINT8 EmmcGetTargetBusWidth(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, IN SD_MMC_BUS_MODE BusTiming)
Definition: EmmcDevice.c:1095
BOOLEAN EmmcIsBusWidthSupported(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming, IN UINT16 BusWidth)
Definition: EmmcDevice.c:1066
EFI_STATUS EmmcGetAllCid(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: EmmcDevice.c:120
EFI_STATUS EmmcIdentification(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
Definition: EmmcDevice.c:1318
EFI_STATUS EmmcSelect(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: EmmcDevice.c:260
EFI_STATUS EmmcReset(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: EmmcDevice.c:26
SD_MMC_BUS_MODE EmmcGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd)
Definition: EmmcDevice.c:1030
EFI_STATUS EmmcSwitch(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT8 Access, IN UINT8 Index, IN UINT8 Value, IN UINT8 CmdSet)
Definition: EmmcDevice.c:352
EFI_STATUS EmmcTuningClkForHs200(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT8 BusWidth)
Definition: EmmcDevice.c:505
EFI_STATUS EmmcSwitchToHS400(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN SD_MMC_BUS_SETTINGS *BusMode)
Definition: EmmcDevice.c:909
EFI_STATUS EmmcSwitchBusTiming(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN EDKII_SD_MMC_DRIVER_STRENGTH DriverStrength, IN SD_MMC_BUS_MODE BusTiming, IN UINT32 ClockFreq)
Definition: EmmcDevice.c:687
VOID EmmcGetTargetBusMode(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN EMMC_EXT_CSD *ExtCsd, OUT SD_MMC_BUS_SETTINGS *BusMode)
Definition: EmmcDevice.c:1208
EFI_STATUS EmmcGetCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT EMMC_CSD *Csd)
Definition: EmmcDevice.c:210
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OFFSET_OF(TYPE, Field)
Definition: Base.h:758
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI SdMmcPassThruPassThru(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *This, IN UINT8 Slot, IN OUT EFI_SD_MMC_PASS_THRU_COMMAND_PACKET *Packet, IN EFI_EVENT Event OPTIONAL)
EFI_STATUS SdMmcHcClockSupply(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot, IN SD_MMC_BUS_MODE BusTiming, IN BOOLEAN FirstTimeSetup, IN UINT64 ClockFreq)
Definition: SdMmcPciHci.c:815
EFI_STATUS EFIAPI SdMmcHcRwMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN BOOLEAN Read, IN UINT8 Count, IN OUT VOID *Data)
Definition: SdMmcPciHci.c:143
EFI_STATUS SdMmcHcUhsSignaling(IN EFI_HANDLE ControllerHandle, IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN SD_MMC_BUS_MODE Timing)
Definition: SdMmcPciHci.c:1310
EFI_STATUS EFIAPI SdMmcHcAndMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *AndData)
Definition: SdMmcPciHci.c:283
EFI_STATUS SdMmcHcSetBusWidth(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot, IN UINT16 BusWidth)
Definition: SdMmcPciHci.c:1011
EFI_STATUS EFIAPI SdMmcHcOrMmio(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, IN UINT32 Offset, IN UINT8 Count, IN VOID *OrData)
Definition: SdMmcPciHci.c:225
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
Definition: Emmc.h:84