int is_sd_accessible(void) { volatile unsigned int present_state; int timer=0; xil_printf("check SD card accessibility \n"); #if 0 IN8(XPAR_LOGISDHC_0_REGS_BASEADDR+0x2F) = 0x01; // Soft reset IN16(XPAR_LOGISDHC_0_REGS_BASEADDR+0x2C) = 0x205; // Clock ctrl reg; SD clock frequency = 50MHz/2, SD clk en, Internal clk en IN8(XPAR_LOGISDHC_0_REGS_BASEADDR+0x28) = 0x00; // Host ctrl reg; High speed disabled, Data trans width = 1, (0x06; Host ctrl reg; High speed enabled, Data trans width = 4) ; 0x04 High speed IN8(XPAR_LOGISDHC_0_REGS_BASEADDR+0x29) = 0x0F; // Power ctrl reg; SD Bus voltage select, SD Bus Power IN16(XPAR_LOGISDHC_0_REGS_BASEADDR+0x36) = 0xFFFF; // Error interrupt status en reg; Enable all IN16(XPAR_LOGISDHC_0_REGS_BASEADDR+0x34) = 0xFFFF; // Normal interrupt status en reg; Enable all IN16(XPAR_LOGISDHC_0_REGS_BASEADDR+0x38) = 0x0008; // Normal interrupt signal en reg; Enable all IN16(XPAR_LOGISDHC_0_REGS_BASEADDR+0x3A) = 0x0000; // Error interrupt signal en reg; dis Enable all #endif for(timer=0; timer < 100; timer++) { present_state = IN32(XPAR_LOGISDHC_0_REGS_BASEADDR+0x24+0); //Check Present state reg (bit 0 and 1) before doing anything if((present_state & 0x3) == 0) break; } present_state = IN32(XPAR_LOGISDHC_0_REGS_BASEADDR+0x24+0); //Check Present state reg (bit 0 and 1) before doing anything if((present_state & 0x3) != 0) return -1; // BAD, SD card is not accessible. return 0; // GOOD, SD card is accessible. }
GLOBAL VOID IN32 IFN2( IU32 *, pop1, /* pntr to dst operand */ IU32, op2 /* src(port nr.) operand */ ) { #ifndef PIG IU32 temp; #ifdef SFELLOW (*Ios_ind_function[Ios_in_adapter_table[(IO_ADDR)op2 & (PC_IO_MEM_SIZE-1)]]) ((IO_ADDR)op2, &temp); *pop1 = temp; #else IN16(&temp, op2); *pop1 = temp; IN16(&temp, op2 + 2); *pop1 += temp << 16; #endif #endif /* !PIG */ }