Switch to Normmatt's iodelay

Seems to be more reliable in all conditions
This commit is contained in:
Aurora 2016-03-16 04:01:38 +01:00
parent e9410c86b1
commit 8ce395caa5
6 changed files with 38 additions and 24 deletions

View File

@ -6,4 +6,4 @@
#include "common.h" #include "common.h"
void waitcycles(u32 us); void ioDelay(u32 us);

View File

@ -1,10 +1,17 @@
.arm // Copyright 2014 Normmatt
.global waitcycles // Licensed under GPLv2 or any later version
.type waitcycles STT_FUNC // Refer to the license.txt file included.
@waitcycles ( u32 us ) .arm
waitcycles: .global ioDelay
waitcycles_loop: .type ioDelay STT_FUNC
@ioDelay ( u32 us )
ioDelay:
ldr r1, =0x18000000 @ VRAM
1:
@ Loop doing uncached reads from VRAM to make loop timing more reliable
ldr r2, [r1]
subs r0, #1 subs r0, #1
bgt waitcycles_loop bgt 1b
bx lr bx lr

View File

@ -286,7 +286,7 @@ static void InitSD()
static int Nand_Init() static int Nand_Init()
{ {
inittarget(&handleNAND); inittarget(&handleNAND);
waitcycles(0xF000); ioDelay(0xF000);
sdmmc_send_command(&handleNAND,0,0); sdmmc_send_command(&handleNAND,0,0);
@ -337,7 +337,7 @@ static int SD_Init()
{ {
inittarget(&handleSD); inittarget(&handleSD);
waitcycles(1u << 18); //Card needs a little bit of time to be detected, it seems ioDelay(1u << 18); //Card needs a little bit of time to be detected, it seems
//If not inserted //If not inserted
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1; if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;

View File

@ -6,4 +6,4 @@
#include "common.h" #include "common.h"
void waitcycles(u32 us); void ioDelay(u32 us);

View File

@ -1,10 +1,17 @@
.arm // Copyright 2014 Normmatt
.global waitcycles // Licensed under GPLv2 or any later version
.type waitcycles STT_FUNC // Refer to the license.txt file included.
@waitcycles ( u32 us ) .arm
waitcycles: .global ioDelay
waitcycles_loop: .type ioDelay STT_FUNC
@ioDelay ( u32 us )
ioDelay:
ldr r1, =0x18000000 @ VRAM
1:
@ Loop doing uncached reads from VRAM to make loop timing more reliable
ldr r2, [r1]
subs r0, #1 subs r0, #1
bgt waitcycles_loop bgt 1b
bx lr bx lr

View File

@ -286,7 +286,7 @@ static void InitSD()
static int Nand_Init() static int Nand_Init()
{ {
inittarget(&handleNAND); inittarget(&handleNAND);
waitcycles(0xF000); ioDelay(0xF000);
sdmmc_send_command(&handleNAND,0,0); sdmmc_send_command(&handleNAND,0,0);
@ -337,7 +337,7 @@ static int SD_Init()
{ {
inittarget(&handleSD); inittarget(&handleSD);
waitcycles(1u << 18); //Card needs a little bit of time to be detected, it seems ioDelay(1u << 18); //Card needs a little bit of time to be detected, it seems
//If not inserted //If not inserted
if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1; if (!(*((vu16*)0x1000601c) & TMIO_STAT0_SIGSTATE)) return -1;