TianoCore EDK2 master
Loading...
Searching...
No Matches
SdDevice.c
Go to the documentation of this file.
1
10#include "SdMmcPciHcDxe.h"
11
27 IN UINT8 Slot
28 )
29{
30 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
31 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
33 EFI_STATUS Status;
34
35 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
36 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
37 ZeroMem (&Packet, sizeof (Packet));
38
39 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
40 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
41 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
42
43 SdMmcCmdBlk.CommandIndex = SD_GO_IDLE_STATE;
44 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBc;
45
46 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
47
48 return Status;
49}
50
69 IN UINT8 Slot,
70 IN UINT8 SupplyVoltage,
71 IN UINT8 CheckPattern
72 )
73{
74 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
75 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
77 EFI_STATUS Status;
78
79 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
80 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
81 ZeroMem (&Packet, sizeof (Packet));
82
83 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
84 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
85 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
86
87 SdMmcCmdBlk.CommandIndex = SD_SEND_IF_COND;
88 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
89 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR7;
90 SdMmcCmdBlk.CommandArgument = (SupplyVoltage << 8) | CheckPattern;
91
92 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
93
94 if (!EFI_ERROR (Status)) {
95 if (SdMmcStatusBlk.Resp0 != SdMmcCmdBlk.CommandArgument) {
96 return EFI_DEVICE_ERROR;
97 }
98 }
99
100 return Status;
101}
102
120 IN UINT8 Slot,
121 IN UINT32 VoltageWindow,
122 IN BOOLEAN S18R
123 )
124{
125 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
126 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
128 EFI_STATUS Status;
129 UINT32 Switch;
130
131 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
132 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
133 ZeroMem (&Packet, sizeof (Packet));
134
135 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
136 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
137 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
138
139 SdMmcCmdBlk.CommandIndex = SDIO_SEND_OP_COND;
140 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
141 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR4;
142
143 Switch = S18R ? BIT24 : 0;
144
145 SdMmcCmdBlk.CommandArgument = (VoltageWindow & 0xFFFFFF) | Switch;
146
147 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
148
149 return Status;
150}
151
173 IN UINT8 Slot,
174 IN UINT16 Rca,
175 IN UINT32 VoltageWindow,
176 IN BOOLEAN S18R,
177 IN BOOLEAN Xpc,
178 IN BOOLEAN Hcs,
179 OUT UINT32 *Ocr
180 )
181{
182 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
183 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
185 EFI_STATUS Status;
186 UINT32 Switch;
187 UINT32 MaxPower;
188 UINT32 HostCapacity;
189
190 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
191 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
192 ZeroMem (&Packet, sizeof (Packet));
193
194 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
195 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
196 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
197
198 SdMmcCmdBlk.CommandIndex = SD_APP_CMD;
199 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
200 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
201 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
202
203 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
204 if (EFI_ERROR (Status)) {
205 return Status;
206 }
207
208 SdMmcCmdBlk.CommandIndex = SD_SEND_OP_COND;
209 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
210 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR3;
211
212 Switch = S18R ? BIT24 : 0;
213 MaxPower = Xpc ? BIT28 : 0;
214 HostCapacity = Hcs ? BIT30 : 0;
215
216 SdMmcCmdBlk.CommandArgument = (VoltageWindow & 0xFFFFFF) | Switch | MaxPower | HostCapacity;
217
218 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
219 if (!EFI_ERROR (Status)) {
220 //
221 // For details, refer to SD Host Controller Simplified Spec 3.0 Table 2-12.
222 //
223 *Ocr = SdMmcStatusBlk.Resp0;
224 }
225
226 return Status;
227}
228
245 IN UINT8 Slot
246 )
247{
248 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
249 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
251 EFI_STATUS Status;
252
253 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
254 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
255 ZeroMem (&Packet, sizeof (Packet));
256
257 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
258 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
259 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
260
261 SdMmcCmdBlk.CommandIndex = SD_ALL_SEND_CID;
262 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
263 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
264
265 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
266
267 return Status;
268}
269
287 IN UINT8 Slot,
288 OUT UINT16 *Rca
289 )
290{
291 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
292 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
294 EFI_STATUS Status;
295
296 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
297 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
298 ZeroMem (&Packet, sizeof (Packet));
299
300 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
301 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
302 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
303
304 SdMmcCmdBlk.CommandIndex = SD_SET_RELATIVE_ADDR;
305 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
306 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR6;
307
308 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
309 if (!EFI_ERROR (Status)) {
310 *Rca = (UINT16)(SdMmcStatusBlk.Resp0 >> 16);
311 }
312
313 return Status;
314}
315
332 IN UINT8 Slot,
333 IN UINT16 Rca
334 )
335{
336 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
337 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
339 EFI_STATUS Status;
340
341 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
342 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
343 ZeroMem (&Packet, sizeof (Packet));
344
345 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
346 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
347 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
348
349 SdMmcCmdBlk.CommandIndex = SD_SELECT_DESELECT_CARD;
350 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
351 if (Rca != 0) {
352 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;
353 }
354
355 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
356
357 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
358
359 return Status;
360}
361
377 IN UINT8 Slot
378 )
379{
380 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
381 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
383 EFI_STATUS Status;
384
385 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
386 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
387 ZeroMem (&Packet, sizeof (Packet));
388
389 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
390 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
391 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
392
393 SdMmcCmdBlk.CommandIndex = SD_VOLTAGE_SWITCH;
394 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
395 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
396 SdMmcCmdBlk.CommandArgument = 0;
397
398 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
399
400 return Status;
401}
402
420 IN UINT8 Slot,
421 IN UINT16 Rca,
422 IN UINT8 BusWidth
423 )
424{
425 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
426 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
428 EFI_STATUS Status;
429 UINT8 Value;
430
431 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
432 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
433 ZeroMem (&Packet, sizeof (Packet));
434
435 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
436 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
437 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
438
439 SdMmcCmdBlk.CommandIndex = SD_APP_CMD;
440 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
441 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
442 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
443
444 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
445 if (EFI_ERROR (Status)) {
446 return Status;
447 }
448
449 SdMmcCmdBlk.CommandIndex = SD_SET_BUS_WIDTH;
450 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
451 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
452
453 if (BusWidth == 1) {
454 Value = 0;
455 } else if (BusWidth == 4) {
456 Value = 2;
457 } else {
458 return EFI_INVALID_PARAMETER;
459 }
460
461 SdMmcCmdBlk.CommandArgument = Value & 0x3;
462
463 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
464 return Status;
465}
466
488 IN UINT8 Slot,
489 IN SD_MMC_BUS_MODE BusTiming,
490 IN UINT8 CommandSystem,
491 IN SD_DRIVER_STRENGTH_TYPE DriverStrength,
492 IN UINT8 PowerLimit,
493 IN BOOLEAN Mode,
494 OUT UINT8 *SwitchResp
495 )
496{
497 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
498 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
500 EFI_STATUS Status;
501 UINT32 ModeValue;
502 UINT8 AccessMode;
503
504 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
505 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
506 ZeroMem (&Packet, sizeof (Packet));
507
508 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
509 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
510 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
511
512 SdMmcCmdBlk.CommandIndex = SD_SWITCH_FUNC;
513 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
514 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
515
516 ModeValue = Mode ? BIT31 : 0;
517
518 switch (BusTiming) {
519 case SdMmcUhsDdr50:
520 AccessMode = 0x4;
521 break;
522 case SdMmcUhsSdr104:
523 AccessMode = 0x3;
524 break;
525 case SdMmcUhsSdr50:
526 AccessMode = 0x2;
527 break;
528 case SdMmcUhsSdr25:
529 case SdMmcSdHs:
530 AccessMode = 0x1;
531 break;
532 case SdMmcUhsSdr12:
533 case SdMmcSdDs:
534 AccessMode = 0;
535 break;
536 default:
537 AccessMode = 0xF;
538 }
539
540 SdMmcCmdBlk.CommandArgument = (AccessMode & 0xF) | ((CommandSystem & 0xF) << 4) | \
541 ((DriverStrength & 0xF) << 8) | ((PowerLimit & 0xF) << 12) | \
542 ModeValue;
543
544 Packet.InDataBuffer = SwitchResp;
545 Packet.InTransferLength = 64;
546
547 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
548 if (EFI_ERROR (Status)) {
549 return Status;
550 }
551
552 if (Mode) {
553 if ((((AccessMode & 0xF) != 0xF) && ((SwitchResp[16] & 0xF) != AccessMode)) ||
554 (((CommandSystem & 0xF) != 0xF) && (((SwitchResp[16] >> 4) & 0xF) != CommandSystem)) ||
555 (((DriverStrength & 0xF) != 0xF) && ((SwitchResp[15] & 0xF) != DriverStrength)) ||
556 (((PowerLimit & 0xF) != 0xF) && (((SwitchResp[15] >> 4) & 0xF) != PowerLimit)))
557 {
558 return EFI_DEVICE_ERROR;
559 }
560 }
561
562 return Status;
563}
564
582 IN UINT8 Slot,
583 IN UINT16 Rca,
584 OUT UINT32 *DevStatus
585 )
586{
587 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
588 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
590 EFI_STATUS Status;
591
592 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
593 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
594 ZeroMem (&Packet, sizeof (Packet));
595
596 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
597 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
598 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
599
600 SdMmcCmdBlk.CommandIndex = SD_SEND_STATUS;
601 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
602 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
603 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
604
605 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
606 if (!EFI_ERROR (Status)) {
607 *DevStatus = SdMmcStatusBlk.Resp0;
608 }
609
610 return Status;
611}
612
631 IN UINT8 Slot
632 )
633{
634 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
635 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
637 EFI_STATUS Status;
638 UINT8 TuningBlock[64];
639
640 ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
641 ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
642 ZeroMem (&Packet, sizeof (Packet));
643
644 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
645 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
646 Packet.Timeout = SD_MMC_HC_GENERIC_TIMEOUT;
647
648 SdMmcCmdBlk.CommandIndex = SD_SEND_TUNING_BLOCK;
649 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
650 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
651 SdMmcCmdBlk.CommandArgument = 0;
652
653 Packet.InDataBuffer = TuningBlock;
654 Packet.InTransferLength = sizeof (TuningBlock);
655
656 Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
657
658 return Status;
659}
660
680 IN EFI_PCI_IO_PROTOCOL *PciIo,
682 IN UINT8 Slot
683 )
684{
685 EFI_STATUS Status;
686 UINT8 HostCtrl2;
687 UINT8 Retry;
688
689 //
690 // Notify the host that the sampling clock tuning procedure starts.
691 //
692 HostCtrl2 = BIT6;
693 Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
694 if (EFI_ERROR (Status)) {
695 return Status;
696 }
697
698 //
699 // Ask the device to send a sequence of tuning blocks till the tuning procedure is done.
700 //
701 Retry = 0;
702 do {
703 Status = SdCardSendTuningBlk (PassThru, Slot);
704 if (EFI_ERROR (Status)) {
705 DEBUG ((DEBUG_ERROR, "SdCardSendTuningBlk: Send tuning block fails with %r\n", Status));
706 return Status;
707 }
708
709 Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
710 if (EFI_ERROR (Status)) {
711 return Status;
712 }
713
714 if ((HostCtrl2 & (BIT6 | BIT7)) == 0) {
715 break;
716 }
717
718 if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
719 return EFI_SUCCESS;
720 }
721 } while (++Retry < 40);
722
723 DEBUG ((DEBUG_ERROR, "SdCardTuningClock: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));
724 //
725 // Abort the tuning procedure and reset the tuning circuit.
726 //
727 HostCtrl2 = (UINT8) ~(BIT6 | BIT7);
728 Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
729 if (EFI_ERROR (Status)) {
730 return Status;
731 }
732
733 return EFI_DEVICE_ERROR;
734}
735
754 IN EFI_PCI_IO_PROTOCOL *PciIo,
756 IN UINT8 Slot,
757 IN UINT16 Rca,
758 IN UINT8 BusWidth
759 )
760{
761 EFI_STATUS Status;
762 UINT32 DevStatus;
763
764 Status = SdCardSetBusWidth (PassThru, Slot, Rca, BusWidth);
765 if (EFI_ERROR (Status)) {
766 DEBUG ((DEBUG_ERROR, "SdCardSwitchBusWidth: Switch to bus width %d fails with %r\n", BusWidth, Status));
767 return Status;
768 }
769
770 Status = SdCardSendStatus (PassThru, Slot, Rca, &DevStatus);
771 if (EFI_ERROR (Status)) {
772 DEBUG ((DEBUG_ERROR, "SdCardSwitchBusWidth: Send status fails with %r\n", Status));
773 return Status;
774 }
775
776 //
777 // Check the switch operation is really successful or not.
778 //
779 if ((DevStatus >> 16) != 0) {
780 DEBUG ((DEBUG_ERROR, "SdCardSwitchBusWidth: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));
781 return EFI_DEVICE_ERROR;
782 }
783
784 Status = SdMmcHcSetBusWidth (PciIo, Slot, BusWidth);
785
786 return Status;
787}
788
800BOOLEAN
802 IN SD_MMC_HC_PRIVATE_DATA *Private,
803 IN UINT8 SlotIndex,
804 IN UINT8 CardSupportedBusTimings,
805 IN BOOLEAN IsInUhsI,
806 IN SD_MMC_BUS_MODE BusTiming
807 )
808{
809 SD_MMC_HC_SLOT_CAP *Capability;
810
811 Capability = &Private->Capability[SlotIndex];
812
813 if (IsInUhsI) {
814 switch (BusTiming) {
815 case SdMmcUhsSdr104:
816 if ((Capability->Sdr104 != 0) && ((CardSupportedBusTimings & BIT3) != 0)) {
817 return TRUE;
818 }
819
820 break;
821 case SdMmcUhsDdr50:
822 if ((Capability->Ddr50 != 0) && ((CardSupportedBusTimings & BIT4) != 0)) {
823 return TRUE;
824 }
825
826 break;
827 case SdMmcUhsSdr50:
828 if ((Capability->Sdr50 != 0) && ((CardSupportedBusTimings & BIT2) != 0)) {
829 return TRUE;
830 }
831
832 break;
833 case SdMmcUhsSdr25:
834 if ((CardSupportedBusTimings & BIT1) != 0) {
835 return TRUE;
836 }
837
838 break;
839 case SdMmcUhsSdr12:
840 if ((CardSupportedBusTimings & BIT0) != 0) {
841 return TRUE;
842 }
843
844 break;
845 default:
846 break;
847 }
848 } else {
849 switch (BusTiming) {
850 case SdMmcSdHs:
851 if ((Capability->HighSpeed != 0) && ((CardSupportedBusTimings & BIT1) != 0)) {
852 return TRUE;
853 }
854
855 break;
856 case SdMmcSdDs:
857 if ((CardSupportedBusTimings & BIT0) != 0) {
858 return TRUE;
859 }
860
861 break;
862 default:
863 break;
864 }
865 }
866
867 return FALSE;
868}
869
882SD_MMC_BUS_MODE
884 IN SD_MMC_HC_PRIVATE_DATA *Private,
885 IN UINT8 SlotIndex,
886 IN UINT8 CardSupportedBusTimings,
887 IN BOOLEAN IsInUhsI
888 )
889{
890 SD_MMC_BUS_MODE BusTiming;
891
892 if (IsInUhsI) {
893 BusTiming = SdMmcUhsSdr104;
894 } else {
895 BusTiming = SdMmcSdHs;
896 }
897
898 while (BusTiming > SdMmcSdDs) {
899 if (SdIsBusTimingSupported (Private, SlotIndex, CardSupportedBusTimings, IsInUhsI, BusTiming)) {
900 break;
901 }
902
903 BusTiming--;
904 }
905
906 return BusTiming;
907}
908
918UINT8
920 IN SD_MMC_HC_PRIVATE_DATA *Private,
921 IN UINT8 SlotIndex,
922 IN SD_MMC_BUS_MODE BusTiming
923 )
924{
925 UINT8 BusWidth;
926 UINT8 PreferredBusWidth;
927
928 PreferredBusWidth = Private->Slot[SlotIndex].OperatingParameters.BusWidth;
929
930 if ((BusTiming == SdMmcSdDs) || (BusTiming == SdMmcSdHs)) {
931 if ((PreferredBusWidth != EDKII_SD_MMC_BUS_WIDTH_IGNORE) &&
932 ((PreferredBusWidth == 1) || (PreferredBusWidth == 4)))
933 {
934 BusWidth = PreferredBusWidth;
935 } else {
936 BusWidth = 4;
937 }
938 } else {
939 //
940 // UHS-I modes support only 4-bit width.
941 // Switch to 4-bit has been done before calling this function anyway so
942 // this is purely informational.
943 //
944 BusWidth = 4;
945 }
946
947 return BusWidth;
948}
949
959UINT32
961 IN SD_MMC_HC_PRIVATE_DATA *Private,
962 IN UINT8 SlotIndex,
963 IN SD_MMC_BUS_MODE BusTiming
964 )
965{
966 UINT32 PreferredClockFreq;
967 UINT32 MaxClockFreq;
968
969 PreferredClockFreq = Private->Slot[SlotIndex].OperatingParameters.ClockFreq;
970
971 switch (BusTiming) {
972 case SdMmcUhsSdr104:
973 MaxClockFreq = 208;
974 break;
975 case SdMmcUhsSdr50:
976 MaxClockFreq = 100;
977 break;
978 case SdMmcUhsDdr50:
979 case SdMmcUhsSdr25:
980 case SdMmcSdHs:
981 MaxClockFreq = 50;
982 break;
983 case SdMmcUhsSdr12:
984 case SdMmcSdDs:
985 default:
986 MaxClockFreq = 25;
987 }
988
989 if ((PreferredClockFreq != EDKII_SD_MMC_CLOCK_FREQ_IGNORE) && (PreferredClockFreq < MaxClockFreq)) {
990 return PreferredClockFreq;
991 } else {
992 return MaxClockFreq;
993 }
994}
995
1008 IN SD_MMC_HC_PRIVATE_DATA *Private,
1009 IN UINT8 SlotIndex,
1010 IN UINT8 CardSupportedDriverStrengths,
1011 IN SD_MMC_BUS_MODE BusTiming
1012 )
1013{
1014 EDKII_SD_MMC_DRIVER_STRENGTH PreferredDriverStrength;
1015 EDKII_SD_MMC_DRIVER_STRENGTH DriverStrength;
1016
1017 if ((BusTiming == SdMmcSdDs) || (BusTiming == SdMmcSdHs)) {
1018 DriverStrength.Sd = SdDriverStrengthIgnore;
1019 return DriverStrength;
1020 }
1021
1022 PreferredDriverStrength = Private->Slot[SlotIndex].OperatingParameters.DriverStrength;
1023 DriverStrength.Sd = SdDriverStrengthTypeB;
1024
1025 if ((PreferredDriverStrength.Sd != EDKII_SD_MMC_DRIVER_STRENGTH_IGNORE) &&
1026 (CardSupportedDriverStrengths & (BIT0 << PreferredDriverStrength.Sd)))
1027 {
1028 if (((PreferredDriverStrength.Sd == SdDriverStrengthTypeA) &&
1029 (Private->Capability[SlotIndex].DriverTypeA != 0)) ||
1030 ((PreferredDriverStrength.Sd == SdDriverStrengthTypeC) &&
1031 (Private->Capability[SlotIndex].DriverTypeC != 0)) ||
1032 ((PreferredDriverStrength.Sd == SdDriverStrengthTypeD) &&
1033 (Private->Capability[SlotIndex].DriverTypeD != 0)))
1034 {
1035 DriverStrength.Sd = PreferredDriverStrength.Sd;
1036 }
1037 }
1038
1039 return DriverStrength;
1040}
1041
1051VOID
1053 IN SD_MMC_HC_PRIVATE_DATA *Private,
1054 IN UINT8 SlotIndex,
1055 IN UINT8 *SwitchQueryResp,
1056 IN BOOLEAN IsInUhsI,
1057 OUT SD_MMC_BUS_SETTINGS *BusMode
1058 )
1059{
1060 BusMode->BusTiming = SdGetTargetBusTiming (Private, SlotIndex, SwitchQueryResp[13], IsInUhsI);
1061 BusMode->BusWidth = SdGetTargetBusWidth (Private, SlotIndex, BusMode->BusTiming);
1062 BusMode->ClockFreq = SdGetTargetBusClockFreq (Private, SlotIndex, BusMode->BusTiming);
1063 BusMode->DriverStrength = SdGetTargetDriverStrength (Private, SlotIndex, SwitchQueryResp[9], BusMode->BusTiming);
1064}
1065
1085 IN EFI_PCI_IO_PROTOCOL *PciIo,
1087 IN UINT8 Slot,
1088 IN UINT16 Rca,
1089 IN BOOLEAN S18A,
1090 IN BOOLEAN SdVersion1
1091 )
1092{
1093 EFI_STATUS Status;
1094 SD_MMC_HC_SLOT_CAP *Capability;
1095 UINT8 HostCtrl1;
1096 UINT8 SwitchResp[64];
1097 SD_MMC_HC_PRIVATE_DATA *Private;
1098 SD_MMC_BUS_SETTINGS BusMode;
1099
1100 ZeroMem (SwitchResp, 64 * sizeof (UINT8));
1101
1102 Private = SD_MMC_HC_PRIVATE_FROM_THIS (PassThru);
1103
1104 Capability = &Private->Capability[Slot];
1105
1106 Status = SdCardSelect (PassThru, Slot, Rca);
1107 if (EFI_ERROR (Status)) {
1108 return Status;
1109 }
1110
1111 if (S18A) {
1112 //
1113 // For UHS-I speed modes 4-bit data bus is requiered so we
1114 // switch here irrespective of platform preference.
1115 //
1116 Status = SdCardSwitchBusWidth (PciIo, PassThru, Slot, Rca, 4);
1117 if (EFI_ERROR (Status)) {
1118 return Status;
1119 }
1120 }
1121
1122 //
1123 // Get the supported bus speed from SWITCH cmd return data group #1.
1124 // SdVersion1 don't support the SWITCH cmd
1125 //
1126 if (!SdVersion1) {
1127 Status = SdCardSwitch (PassThru, Slot, 0xFF, 0xF, SdDriverStrengthIgnore, 0xF, FALSE, SwitchResp);
1128 if (EFI_ERROR (Status)) {
1129 return Status;
1130 }
1131 }
1132
1133 SdGetTargetBusMode (Private, Slot, SwitchResp, S18A, &BusMode);
1134
1135 DEBUG ((
1136 DEBUG_INFO,
1137 "SdCardSetBusMode: Target bus mode: bus timing = %d, bus width = %d, clock freq[MHz] = %d, driver strength = %d\n",
1138 BusMode.BusTiming,
1139 BusMode.BusWidth,
1140 BusMode.ClockFreq,
1141 BusMode.DriverStrength.Sd
1142 ));
1143
1144 if (!S18A) {
1145 Status = SdCardSwitchBusWidth (PciIo, PassThru, Slot, Rca, BusMode.BusWidth);
1146 if (EFI_ERROR (Status)) {
1147 return Status;
1148 }
1149 }
1150
1151 //
1152 // SdVersion1 don't support the SWITCH cmd
1153 //
1154 if (!SdVersion1) {
1155 Status = SdCardSwitch (PassThru, Slot, BusMode.BusTiming, 0xF, BusMode.DriverStrength.Sd, 0xF, TRUE, SwitchResp);
1156 if (EFI_ERROR (Status)) {
1157 return Status;
1158 }
1159 }
1160
1161 Status = SdMmcSetDriverStrength (Private->PciIo, Slot, BusMode.DriverStrength.Sd);
1162 if (EFI_ERROR (Status)) {
1163 return Status;
1164 }
1165
1166 //
1167 // Set to High Speed timing
1168 //
1169 if (BusMode.BusTiming == SdMmcSdHs) {
1170 HostCtrl1 = BIT2;
1171 Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL1, sizeof (HostCtrl1), &HostCtrl1);
1172 if (EFI_ERROR (Status)) {
1173 return Status;
1174 }
1175 }
1176
1177 Status = SdMmcHcUhsSignaling (Private->ControllerHandle, PciIo, Slot, BusMode.BusTiming);
1178 if (EFI_ERROR (Status)) {
1179 return Status;
1180 }
1181
1182 Status = SdMmcHcClockSupply (Private, Slot, BusMode.BusTiming, FALSE, BusMode.ClockFreq * 1000);
1183 if (EFI_ERROR (Status)) {
1184 return Status;
1185 }
1186
1187 if ((BusMode.BusTiming == SdMmcUhsSdr104) || ((BusMode.BusTiming == SdMmcUhsSdr50) && (Capability->TuningSDR50 != 0))) {
1188 Status = SdCardTuningClock (PciIo, PassThru, Slot);
1189 if (EFI_ERROR (Status)) {
1190 return Status;
1191 }
1192 }
1193
1194 return Status;
1195}
1196
1211 IN SD_MMC_HC_PRIVATE_DATA *Private,
1212 IN UINT8 Slot
1213 )
1214{
1215 EFI_STATUS Status;
1216 EFI_PCI_IO_PROTOCOL *PciIo;
1218 UINT32 Ocr;
1219 UINT16 Rca;
1220 BOOLEAN Xpc;
1221 BOOLEAN S18r;
1222 UINT64 MaxCurrent;
1223 UINT16 ControllerVer;
1224 UINT8 PowerCtrl;
1225 UINT32 PresentState;
1226 UINT8 HostCtrl2;
1227 UINTN Retry;
1228 BOOLEAN ForceVoltage33;
1229 BOOLEAN SdVersion1;
1230
1231 ForceVoltage33 = FALSE;
1232 SdVersion1 = FALSE;
1233
1234 PciIo = Private->PciIo;
1235 PassThru = &Private->PassThru;
1236
1237Voltage33Retry:
1238 //
1239 // 1. Send Cmd0 to the device
1240 //
1241 Status = SdCardReset (PassThru, Slot);
1242 if (EFI_ERROR (Status)) {
1243 DEBUG ((DEBUG_INFO, "SdCardIdentification: Executing Cmd0 fails with %r\n", Status));
1244 return Status;
1245 }
1246
1247 //
1248 // 2. Send Cmd8 to the device, the command will fail for SdVersion1
1249 //
1250 Status = SdCardVoltageCheck (PassThru, Slot, 0x1, 0xFF);
1251 if (EFI_ERROR (Status)) {
1252 SdVersion1 = TRUE;
1253 DEBUG ((DEBUG_INFO, "SdCardIdentification: Executing Cmd8 fails with %r\n", Status));
1254 }
1255
1256 //
1257 // 3. Send SDIO Cmd5 to the device to the SDIO device OCR register.
1258 //
1259 Status = SdioSendOpCond (PassThru, Slot, 0, FALSE);
1260 if (!EFI_ERROR (Status)) {
1261 DEBUG ((DEBUG_INFO, "SdCardIdentification: Found SDIO device, ignore it as we don't support\n"));
1262 return EFI_DEVICE_ERROR;
1263 }
1264
1265 //
1266 // 4. Send Acmd41 with voltage window 0 to the device
1267 //
1268 Status = SdCardSendOpCond (PassThru, Slot, 0, 0, FALSE, FALSE, FALSE, &Ocr);
1269 if (EFI_ERROR (Status)) {
1270 DEBUG ((DEBUG_INFO, "SdCardIdentification: Executing SdCardSendOpCond fails with %r\n", Status));
1271 return EFI_DEVICE_ERROR;
1272 }
1273
1274 if (Private->Capability[Slot].Voltage33 != 0) {
1275 //
1276 // Support 3.3V
1277 //
1278 MaxCurrent = ((UINT32)Private->MaxCurrent[Slot] & 0xFF) * 4;
1279 } else if (Private->Capability[Slot].Voltage30 != 0) {
1280 //
1281 // Support 3.0V
1282 //
1283 MaxCurrent = (((UINT32)Private->MaxCurrent[Slot] >> 8) & 0xFF) * 4;
1284 } else if (Private->Capability[Slot].Voltage18 != 0) {
1285 //
1286 // Support 1.8V
1287 //
1288 MaxCurrent = (((UINT32)Private->MaxCurrent[Slot] >> 16) & 0xFF) * 4;
1289 } else {
1290 ASSERT (FALSE);
1291 return EFI_DEVICE_ERROR;
1292 }
1293
1294 if (MaxCurrent >= 150) {
1295 Xpc = TRUE;
1296 } else {
1297 Xpc = FALSE;
1298 }
1299
1300 Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CTRL_VER, TRUE, sizeof (ControllerVer), &ControllerVer);
1301 if (EFI_ERROR (Status)) {
1302 return Status;
1303 }
1304
1305 if (((ControllerVer & 0xFF) >= SD_MMC_HC_CTRL_VER_300) &&
1306 ((ControllerVer & 0xFF) <= SD_MMC_HC_CTRL_VER_420))
1307 {
1308 S18r = TRUE;
1309 } else if (((ControllerVer & 0xFF) == SD_MMC_HC_CTRL_VER_100) || ((ControllerVer & 0xFF) == SD_MMC_HC_CTRL_VER_200)) {
1310 S18r = FALSE;
1311 } else {
1312 ASSERT (FALSE);
1313 return EFI_UNSUPPORTED;
1314 }
1315
1316 //
1317 // 1.8V had failed in the previous run, forcing a retry with 3.3V instead
1318 //
1319 if (ForceVoltage33 == TRUE) {
1320 S18r = FALSE;
1321 }
1322
1323 //
1324 // 5. Repeatly send Acmd41 with supply voltage window to the device.
1325 // Note here we only support the cards complied with SD physical
1326 // layer simplified spec version 2.0 and version 3.0 and above.
1327 //
1328 Ocr = 0;
1329 Retry = 0;
1330 do {
1331 Status = SdCardSendOpCond (PassThru, Slot, 0, Ocr, S18r, Xpc, TRUE, &Ocr);
1332 if (EFI_ERROR (Status)) {
1333 DEBUG ((DEBUG_ERROR, "SdCardIdentification: SdCardSendOpCond fails with %r Ocr %x, S18r %x, Xpc %x\n", Status, Ocr, S18r, Xpc));
1334 return EFI_DEVICE_ERROR;
1335 }
1336
1337 if (Retry++ == 100) {
1338 DEBUG ((DEBUG_ERROR, "SdCardIdentification: SdCardSendOpCond fails too many times\n"));
1339 return EFI_DEVICE_ERROR;
1340 }
1341
1342 gBS->Stall (10 * 1000);
1343 } while ((Ocr & BIT31) == 0);
1344
1345 //
1346 // 6. If the S18A bit is set and the Host Controller supports 1.8V signaling
1347 // (One of support bits is set to 1: SDR50, SDR104 or DDR50 in the
1348 // Capabilities register), switch its voltage to 1.8V.
1349 //
1350 if (((Private->Capability[Slot].Sdr50 != 0) ||
1351 (Private->Capability[Slot].Sdr104 != 0) ||
1352 (Private->Capability[Slot].Ddr50 != 0)) &&
1353 ((Ocr & BIT24) != 0))
1354 {
1355 Status = SdCardVoltageSwitch (PassThru, Slot);
1356 if (EFI_ERROR (Status)) {
1357 DEBUG ((DEBUG_ERROR, "SdCardIdentification: Executing SdCardVoltageSwitch fails with %r\n", Status));
1358 Status = EFI_DEVICE_ERROR;
1359 goto Error;
1360 } else {
1361 Status = SdMmcHcStopClock (PciIo, Slot);
1362 if (EFI_ERROR (Status)) {
1363 Status = EFI_DEVICE_ERROR;
1364 goto Error;
1365 }
1366
1367 SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
1368 if (((PresentState >> 20) & 0xF) != 0) {
1369 DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with PresentState = 0x%x\n", PresentState));
1370 Status = EFI_DEVICE_ERROR;
1371 goto Error;
1372 }
1373
1374 HostCtrl2 = BIT3;
1375 SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
1376
1377 gBS->Stall (5000);
1378
1379 SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
1380 if ((HostCtrl2 & BIT3) == 0) {
1381 DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with HostCtrl2 = 0x%x\n", HostCtrl2));
1382 Status = EFI_DEVICE_ERROR;
1383 goto Error;
1384 }
1385
1386 Status = SdMmcHcStartSdClock (PciIo, Slot);
1387 if (EFI_ERROR (Status)) {
1388 goto Error;
1389 }
1390
1391 gBS->Stall (1000);
1392
1393 SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
1394 if (((PresentState >> 20) & 0xF) != 0xF) {
1395 //
1396 // Delay 50 milliseconds in order for clock to stabilize, retry reading the SD_MMC_HC_PRESENT_STATE
1397 //
1398 gBS->Stall (50000);
1399 SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState);
1400 if (((PresentState >> 20) & 0xF) != 0xF) {
1401 DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with PresentState = 0x%x, It should be 0xF\n", PresentState));
1402 //
1403 // Reset and reinitialize the slot before the 3.3V retry.
1404 //
1405 Status = SdMmcHcReset (Private, Slot);
1406 if (EFI_ERROR (Status)) {
1407 goto Error;
1408 }
1409
1410 Status = SdMmcHcInitHost (Private, Slot);
1411 if (EFI_ERROR (Status)) {
1412 goto Error;
1413 }
1414
1415 DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V failed, forcing a retry with 3.3V instead\n"));
1416 ForceVoltage33 = TRUE;
1417 goto Voltage33Retry;
1418 }
1419 }
1420 }
1421
1422 DEBUG ((DEBUG_INFO, "SdCardIdentification: Switch to 1.8v signal voltage success\n"));
1423 }
1424
1425 Status = SdCardAllSendCid (PassThru, Slot);
1426 if (EFI_ERROR (Status)) {
1427 DEBUG ((DEBUG_ERROR, "SdCardIdentification: Executing SdCardAllSendCid fails with %r\n", Status));
1428 return Status;
1429 }
1430
1431 Status = SdCardSetRca (PassThru, Slot, &Rca);
1432 if (EFI_ERROR (Status)) {
1433 DEBUG ((DEBUG_ERROR, "SdCardIdentification: Executing SdCardSetRca fails with %r\n", Status));
1434 return Status;
1435 }
1436
1437 //
1438 // Enter Data Tranfer Mode.
1439 //
1440 DEBUG ((DEBUG_INFO, "SdCardIdentification: Found a SD device at slot [%d]\n", Slot));
1441 Private->Slot[Slot].CardType = SdCardType;
1442
1443 Status = SdCardSetBusMode (PciIo, PassThru, Slot, Rca, ((Ocr & BIT24) != 0), SdVersion1);
1444
1445 return Status;
1446
1447Error:
1448 //
1449 // Set SD Bus Power = 0
1450 //
1451 PowerCtrl = (UINT8) ~BIT0;
1452 Status = SdMmcHcAndMmio (PciIo, Slot, SD_MMC_HC_POWER_CTRL, sizeof (PowerCtrl), &PowerCtrl);
1453 return EFI_DEVICE_ERROR;
1454}
UINT64 UINTN
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#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 OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
EDKII_SD_MMC_DRIVER_STRENGTH SdGetTargetDriverStrength(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 CardSupportedDriverStrengths, IN SD_MMC_BUS_MODE BusTiming)
Definition: SdDevice.c:1007
EFI_STATUS SdCardSwitch(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN SD_MMC_BUS_MODE BusTiming, IN UINT8 CommandSystem, IN SD_DRIVER_STRENGTH_TYPE DriverStrength, IN UINT8 PowerLimit, IN BOOLEAN Mode, OUT UINT8 *SwitchResp)
Definition: SdDevice.c:486
VOID SdGetTargetBusMode(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 *SwitchQueryResp, IN BOOLEAN IsInUhsI, OUT SD_MMC_BUS_SETTINGS *BusMode)
Definition: SdDevice.c:1052
BOOLEAN SdIsBusTimingSupported(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 CardSupportedBusTimings, IN BOOLEAN IsInUhsI, IN SD_MMC_BUS_MODE BusTiming)
Definition: SdDevice.c:801
EFI_STATUS SdCardSendTuningBlk(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: SdDevice.c:629
EFI_STATUS SdCardSendStatus(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: SdDevice.c:580
EFI_STATUS SdCardSendOpCond(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN UINT32 VoltageWindow, IN BOOLEAN S18R, IN BOOLEAN Xpc, IN BOOLEAN Hcs, OUT UINT32 *Ocr)
Definition: SdDevice.c:171
UINT8 SdGetTargetBusWidth(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming)
Definition: SdDevice.c:919
EFI_STATUS SdCardReset(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: SdDevice.c:25
SD_MMC_BUS_MODE SdGetTargetBusTiming(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN UINT8 CardSupportedBusTimings, IN BOOLEAN IsInUhsI)
Definition: SdDevice.c:883
EFI_STATUS SdCardSwitchBusWidth(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN UINT8 BusWidth)
Definition: SdDevice.c:753
EFI_STATUS SdioSendOpCond(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT32 VoltageWindow, IN BOOLEAN S18R)
Definition: SdDevice.c:118
EFI_STATUS SdCardSetRca(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, OUT UINT16 *Rca)
Definition: SdDevice.c:285
EFI_STATUS SdCardSetBusWidth(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN UINT8 BusWidth)
Definition: SdDevice.c:418
EFI_STATUS SdCardAllSendCid(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: SdDevice.c:243
EFI_STATUS SdCardSetBusMode(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, IN BOOLEAN S18A, IN BOOLEAN SdVersion1)
Definition: SdDevice.c:1084
UINT32 SdGetTargetBusClockFreq(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 SlotIndex, IN SD_MMC_BUS_MODE BusTiming)
Definition: SdDevice.c:960
EFI_STATUS SdCardTuningClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: SdDevice.c:679
EFI_STATUS SdCardVoltageCheck(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT8 SupplyVoltage, IN UINT8 CheckPattern)
Definition: SdDevice.c:67
EFI_STATUS SdCardSelect(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: SdDevice.c:330
EFI_STATUS SdCardIdentification(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
Definition: SdDevice.c:1210
EFI_STATUS SdCardVoltageSwitch(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: SdDevice.c:375
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 SdMmcHcReset(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
Definition: SdMmcPciHci.c:477
EFI_STATUS SdMmcHcInitHost(IN SD_MMC_HC_PRIVATE_DATA *Private, IN UINT8 Slot)
Definition: SdMmcPciHci.c:1213
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 SdMmcHcStartSdClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
Definition: SdMmcPciHci.c:785
EFI_STATUS SdMmcSetDriverStrength(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 SlotIndex, IN SD_DRIVER_STRENGTH_TYPE DriverStrength)
Definition: SdMmcPciHci.c:1399
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 SdMmcHcStopClock(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 Slot)
Definition: SdMmcPciHci.c:739
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