Date: Sat, 9 Sep 2006 00:03:22 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 105864 for review Message-ID: <200609090003.k8903M76058138@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=105864 Change 105864 by imp@imp_lighthouse on 2006/09/09 00:03:09 Fix mmc support, to the extent that it compiles again. This costs 1100 bytes, so keep it disabled. Save a few bytes with better math. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#9 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/mci_device.c#9 (text+ko) ==== @@ -48,6 +48,8 @@ #include "lib.h" +#define MMC_SUPPORT 0 + //*---------------------------------------------------------------------------- //* \fn AT91F_MCI_SendCommand //* \brief Generic function to send a command to the MMC or SDCard @@ -71,8 +73,10 @@ // Test error ==> if crc error and response R3 ==> don't check error error = (AT91C_BASE_MCI->MCI_SR) & AT91C_MCI_SR_ERROR; if (error != 0 ) { - // if the command is SEND_OP_COND the CRC error flag is always present (cf : R3 response) - if ( (Cmd != AT91C_SDCARD_APP_OP_COND_CMD) && (Cmd != AT91C_MMC_SEND_OP_COND_CMD) ) + // if the command is SEND_OP_COND the CRC error flag is + // always present (cf : R3 response) + if ((Cmd != AT91C_SDCARD_APP_OP_COND_CMD) && + (Cmd != AT91C_MMC_SEND_OP_COND_CMD)) return ((AT91C_BASE_MCI->MCI_SR) & AT91C_MCI_SR_ERROR); if (error != AT91C_MCI_RCRCE) return ((AT91C_BASE_MCI->MCI_SR) & AT91C_MCI_SR_ERROR); @@ -175,8 +179,7 @@ if ((AT91F_MCI_GetStatus( - pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) != - AT91C_SR_READY_FOR_DATA) { + pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) == 0) { #if IMP_DEBUG printf("2\n"); #endif @@ -219,10 +222,7 @@ // Init Mode Register AT91C_BASE_MCI->MCI_MR |= ((sectorLength << 16) | AT91C_MCI_PDCMODE); - if (sizeToRead %4) - sizeToRead = (sizeToRead /4)+1; - else - sizeToRead = sizeToRead/4; + sizeToRead = (sizeToRead + 3) / 4; AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS); AT91C_BASE_PDC_MCI->PDC_RPR = (unsigned int)dataBuffer; @@ -242,7 +242,7 @@ return AT91C_READ_OK; } -#if 0 +#if MMC_SUPPORT //*---------------------------------------------------------------------------- //* \fn AT91F_MCI_WriteBlock //* \brief Write an ENTIRE block but not always PARTIAL block !!! @@ -254,14 +254,14 @@ unsigned int *dataBuffer, int sizeToWrite ) { - unsigned log2sl = MCI_Device.pMCI_DeviceFeatures->WRITE_BL_LEN; + unsigned log2sl = pMCI_Device->pMCI_DeviceFeatures->WRITE_BL_LEN; unsigned sectorLength = 1 << log2sl; /////////////////////////////////////////////////////////////////////// if( pMCI_Device->pMCI_DeviceDesc->state != AT91C_MCI_IDLE) return AT91C_WRITE_ERROR; - if( (AT91F_MCI_GetStatus(pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) != AT91C_SR_READY_FOR_DATA) + if( (AT91F_MCI_GetStatus(pMCI_Device->pMCI_DeviceFeatures->Relative_Card_Address) & AT91C_SR_READY_FOR_DATA) == 0) return AT91C_WRITE_ERROR; if ((dest + sizeToWrite) > pMCI_Device->pMCI_DeviceFeatures->Memory_Capacity) @@ -281,12 +281,9 @@ /////////////////////////////////////////////////////////////////////// // Init Mode Register - AT91C_BASE_MCI->MCI_MR |= ((pMCI_Device->pMCI_DeviceFeatures->Max_Write_DataBlock_Length << 16) | AT91C_MCI_PDCMODE); - - if (sizeToWrite %4) - sizeToWrite = (sizeToWrite /4)+1; - else - sizeToWrite = sizeToWrite/4; + AT91C_BASE_MCI->MCI_MR |= ((1 << pMCI_Device->pMCI_DeviceFeatures->WRITE_BL_LEN) << 16) | AT91C_MCI_PDCMODE; + + sizeToWrite = (sizeToWrite + 3) / 4; // Init PDC for write sequence AT91C_BASE_PDC_MCI->PDC_PTCR = (AT91C_PDC_TXTDIS | AT91C_PDC_RXTDIS); @@ -372,7 +369,7 @@ return( AT91F_MCI_SendCommand(AT91C_SET_BLOCKLEN_CMD, length) ); } -#if 0 +#if MMC_SUPPORT //*---------------------------------------------------------------------------- //* \fn AT91F_MCI_MMC_GetAllOCR //* \brief Asks to all cards to send their operations conditions @@ -456,25 +453,25 @@ continue; } printf("Response is %x %x %x %x\n", tab_response[0], - tab_response[1], tab_response[2], tab_response[3]) - f->READ_BL_LEN = ((tab_response[2] >> CSD__RD_B_LEN_S) & CSD__RD_B_LEN_M); - f->WRITE_BL_LEN = ((tab_response[3] >> CSD__WBLEN_S) & CSD__WBLEN_M ); - f->Sector_Size = 1 + ((tab_response[2] >> CSD__v22_SECT_SIZE_S) & CSD__v22_SECT_SIZE_M ); - f->Read_Partial = (tab_response[2] >> CSD__RD_B_PAR_S) & CSD__RD_B_PAR_M; - f->Write_Partial = (tab_response[3] >> CSD__WBLOCK_P_S) & CSD__WBLOCK_P_M; + tab_response[1], tab_response[2], tab_response[3]); + f->READ_BL_LEN = ((tab_response[1] >> CSD_1_RD_B_LEN_S) & CSD_1_RD_B_LEN_M); + f->WRITE_BL_LEN = ((tab_response[3] >> CSD_3_WBLEN_S) & CSD_3_WBLEN_M ); + f->Sector_Size = 1 + ((tab_response[2] >> CSD_2_v22_SECT_SIZE_S) & CSD_2_v22_SECT_SIZE_M ); + f->Read_Partial = (tab_response[1] >> CSD_1_RD_B_PAR_S) & CSD_1_RD_B_PAR_M; + f->Write_Partial = (tab_response[3] >> CSD_3_WBLOCK_P_S) & CSD_3_WBLOCK_P_M; // None in MMC specification version 2.2 f->Erase_Block_Enable = 0; - f->Read_Block_Misalignment = (tab_response[2] >> CSD__RD_B_MIS_S) & CSD__RD_B_MIS_M; - f->Write_Block_Misalignment = (tab_response[2] >> CSD__WR_B_MIS_S) & CSD__WR_B_MIS_M; + f->Read_Block_Misalignment = (tab_response[1] >> CSD_1_RD_B_MIS_S) & CSD_1_RD_B_MIS_M; + f->Write_Block_Misalignment = (tab_response[1] >> CSD_1_WR_B_MIS_S) & CSD_1_WR_B_MIS_M; //// Compute Memory Capacity // compute MULT - mult = 1 << ( ((tab_response[2] >> CSD__C_SIZE_M_S) & CSD__C_SIZE_M_M) + 2 ); + mult = 1 << ( ((tab_response[2] >> CSD_2_C_SIZE_M_S) & CSD_2_C_SIZE_M_M) + 2 ); // compute MSB of C_SIZE - blocknr = ((tab_response[1] >> CSD__CSIZE_H_S) & CSD__CSIZE_H_M) << 2; + blocknr = ((tab_response[1] >> CSD_1_CSIZE_H_S) & CSD_1_CSIZE_H_M) << 2; // compute MULT * (LSB of C-SIZE + MSB already computed + 1) = BLOCKNR - blocknr = mult * ( ( blocknr + ( (tab_response[2] >> CSD__CSIZE_L_S) & CSD__CSIZE_L_M) ) + 1 ); + blocknr = mult * ( ( blocknr + ( (tab_response[2] >> CSD_2_CSIZE_L_S) & CSD_2_CSIZE_L_M) ) + 1 ); f->Memory_Capacity = (1 << f->READ_BL_LEN) * blocknr; //// End of Compute Memory Capacity }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609090003.k8903M76058138>