forked from len0rd/rockbox
jz4740: SD clock sequencing changes.
* Don't stop clock before switching speeds * Don't stop clock prior to transactions * Stop clock at the end of transactions Will result in slightly better performance and some power saving when we're not actively using the SD peripheral. Change-Id: I1c82476cad97137b1469900645ecf7bb0887119a
This commit is contained in:
parent
0aa2197d93
commit
6920c089af
1 changed files with 13 additions and 17 deletions
|
|
@ -172,7 +172,7 @@ struct sd_response_r1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sd_response_r3
|
struct sd_response_r3
|
||||||
{
|
{
|
||||||
unsigned int ocr;
|
unsigned int ocr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -335,10 +335,10 @@ static int jz_sd_check_status(struct sd_request *request)
|
||||||
{
|
{
|
||||||
DEBUG("SD CRC error, MSC_STAT 0x%x", status);
|
DEBUG("SD CRC error, MSC_STAT 0x%x", status);
|
||||||
return SD_ERROR_CRC;
|
return SD_ERROR_CRC;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Checking for FIFO empty */
|
/* Checking for FIFO empty */
|
||||||
/*if(status & MSC_STAT_DATA_FIFO_EMPTY && request->rtype != RESPONSE_NONE)
|
/*if(status & MSC_STAT_DATA_FIFO_EMPTY && request->rtype != RESPONSE_NONE)
|
||||||
{
|
{
|
||||||
|
|
@ -623,8 +623,6 @@ static void jz_sd_set_clock(unsigned int rate)
|
||||||
{
|
{
|
||||||
int clkrt;
|
int clkrt;
|
||||||
|
|
||||||
jz_sd_stop_clock();
|
|
||||||
|
|
||||||
/* select clock source from CPM */
|
/* select clock source from CPM */
|
||||||
cpm_select_msc_clk(rate);
|
cpm_select_msc_clk(rate);
|
||||||
|
|
||||||
|
|
@ -676,9 +674,6 @@ static int jz_sd_exec_cmd(struct sd_request *request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stop clock */
|
|
||||||
jz_sd_stop_clock();
|
|
||||||
|
|
||||||
/* mask all interrupts */
|
/* mask all interrupts */
|
||||||
//REG_MSC_IMASK = 0xffff;
|
//REG_MSC_IMASK = 0xffff;
|
||||||
/* clear status */
|
/* clear status */
|
||||||
|
|
@ -851,8 +846,8 @@ static int jz_sd_exec_cmd(struct sd_request *request)
|
||||||
{
|
{
|
||||||
if (request->cmd == SD_SEND_SCR)
|
if (request->cmd == SD_SEND_SCR)
|
||||||
{
|
{
|
||||||
/* SD card returns SCR register as data.
|
/* SD card returns SCR register as data.
|
||||||
SD core expect it in the response buffer,
|
SD core expect it in the response buffer,
|
||||||
after normal response. */
|
after normal response. */
|
||||||
request->buffer =
|
request->buffer =
|
||||||
(unsigned char *) ((unsigned int) request->response + 5);
|
(unsigned char *) ((unsigned int) request->response + 5);
|
||||||
|
|
@ -889,6 +884,7 @@ static int jz_sd_exec_cmd(struct sd_request *request)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Command completed */
|
/* Command completed */
|
||||||
|
jz_sd_stop_clock(); /* Stop SD clock since we're done */
|
||||||
|
|
||||||
return SD_NO_ERROR; /* return successfully */
|
return SD_NO_ERROR; /* return successfully */
|
||||||
}
|
}
|
||||||
|
|
@ -1026,7 +1022,7 @@ static int sd_init_card_state(struct sd_request *request)
|
||||||
retval = sd_unpack_r1(request, &r1);
|
retval = sd_unpack_r1(request, &r1);
|
||||||
if (retval & (limit_41 < 100))
|
if (retval & (limit_41 < 100))
|
||||||
{
|
{
|
||||||
DEBUG("sd_init_card_state: unable to SD_APP_CMD error=%d",
|
DEBUG("sd_init_card_state: unable to SD_APP_CMD error=%d",
|
||||||
retval);
|
retval);
|
||||||
limit_41++;
|
limit_41++;
|
||||||
sd_simple_cmd(request, SD_APP_OP_COND, ocr, RESPONSE_R3);
|
sd_simple_cmd(request, SD_APP_OP_COND, ocr, RESPONSE_R3);
|
||||||
|
|
@ -1064,7 +1060,7 @@ static int sd_init_card_state(struct sd_request *request)
|
||||||
|
|
||||||
case SD_ALL_SEND_CID:
|
case SD_ALL_SEND_CID:
|
||||||
for(i=0; i<4; i++)
|
for(i=0; i<4; i++)
|
||||||
card.cid[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) |
|
card.cid[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) |
|
||||||
(request->response[3+i*4]<< 8) | request->response[4+i*4]);
|
(request->response[3+i*4]<< 8) | request->response[4+i*4]);
|
||||||
|
|
||||||
logf("CID: %08lx%08lx%08lx%08lx", card.cid[0], card.cid[1], card.cid[2], card.cid[3]);
|
logf("CID: %08lx%08lx%08lx%08lx", card.cid[0], card.cid[1], card.cid[2], card.cid[3]);
|
||||||
|
|
@ -1072,11 +1068,11 @@ static int sd_init_card_state(struct sd_request *request)
|
||||||
break;
|
break;
|
||||||
case SD_SEND_RELATIVE_ADDR:
|
case SD_SEND_RELATIVE_ADDR:
|
||||||
retval = sd_unpack_r6(request, &r1, &card.rca);
|
retval = sd_unpack_r6(request, &r1, &card.rca);
|
||||||
card.rca = card.rca << 16;
|
card.rca = card.rca << 16;
|
||||||
DEBUG("sd_init_card_state: Get RCA from SD: 0x%04lx Status: %x", card.rca, r1.status);
|
DEBUG("sd_init_card_state: Get RCA from SD: 0x%04lx Status: %x", card.rca, r1.status);
|
||||||
if (retval)
|
if (retval)
|
||||||
{
|
{
|
||||||
DEBUG("sd_init_card_state: unable to SET_RELATIVE_ADDR error=%d",
|
DEBUG("sd_init_card_state: unable to SET_RELATIVE_ADDR error=%d",
|
||||||
retval);
|
retval);
|
||||||
return SD_INIT_FAILED;
|
return SD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
@ -1086,7 +1082,7 @@ static int sd_init_card_state(struct sd_request *request)
|
||||||
|
|
||||||
case SD_SEND_CSD:
|
case SD_SEND_CSD:
|
||||||
for(i=0; i<4; i++)
|
for(i=0; i<4; i++)
|
||||||
card.csd[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) |
|
card.csd[i] = ((request->response[1+i*4]<<24) | (request->response[2+i*4]<<16) |
|
||||||
(request->response[3+i*4]<< 8) | request->response[4+i*4]);
|
(request->response[3+i*4]<< 8) | request->response[4+i*4]);
|
||||||
|
|
||||||
sd_parse_csd(&card);
|
sd_parse_csd(&card);
|
||||||
|
|
@ -1132,7 +1128,7 @@ static int sd_read_switch(struct sd_request *request)
|
||||||
|
|
||||||
if (((unsigned char *)status)[13] & 0x02)
|
if (((unsigned char *)status)[13] & 0x02)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue