Timeout SD init after about a second

This commit is contained in:
angelsl 2017-11-05 01:13:21 +08:00 committed by d0k3
parent 12739c2a91
commit ee6482aa44

View File

@ -397,6 +397,7 @@ static int SD_Init()
u32 temp = (handleSD.error & 0x1) << 0x1E; u32 temp = (handleSD.error & 0x1) << 0x1E;
u32 temp2 = 0; u32 temp2 = 0;
s32 timeout = 0x80;
do do
{ {
do do
@ -404,10 +405,15 @@ static int SD_Init()
sdmmc_send_command(&handleSD, 0x10437, handleSD.initarg << 0x10); sdmmc_send_command(&handleSD, 0x10437, handleSD.initarg << 0x10);
sdmmc_send_command(&handleSD, 0x10769, 0x00FF8000 | temp); sdmmc_send_command(&handleSD, 0x10769, 0x00FF8000 | temp);
temp2 = 1; temp2 = 1;
timeout--;
} }
while(!(handleSD.error & 1)); while(!(handleSD.error & 1) && timeout > 0);
}
while((handleSD.ret[0] & 0x80000000) == 0 && timeout > 0);
if ((handleSD.ret[0] & 0x80000000) == 0) {
return 6;
} }
while((handleSD.ret[0] & 0x80000000) == 0);
if(!((handleSD.ret[0] >> 30) & 1) || !temp) if(!((handleSD.ret[0] >> 30) & 1) || !temp)
temp2 = 0; temp2 = 0;