Date: Wed, 13 Sep 2006 06:45:19 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 106045 for review Message-ID: <200609130645.k8D6jJkV054553@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=106045 Change 106045 by imp@imp_lighthouse on 2006/09/13 06:45:09 checkpoint Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91_qdmmc.c#6 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91_qdmmc.c#6 (text+ko) ==== @@ -160,11 +160,88 @@ return (0); } +#if 0 +static int +at91_qdmmc_SDCard_GetOCR(device_t dev) +{ + struct at91_qdmmc_softc *sc = device_get_softc(dev); + uint32_t response = 0; + + // The RCA to be used for CMD55 in Idle state shall be the card's + // default RCA=0x0000. + sc->cards[0].rca = 0; + while(!(response & AT91C_CARD_POWER_UP_BUSY)) { + response = at91_qdmmc_SDCard_SendAppCommand(dev, + SDCARD_APP_OP_COND_CMD, AT91C_MMC_HOST_VOLTAGE_RANGE); + if (response != 0) + return (-1); + response = RD4(sc, MCI_RSPR); + } + + return (response); +} +#endif + static int at91_qdmmc_sdcard_init(device_t dev) { - printf("No SD cards found\n"); +#if 0 + struct at91_qdmmc_softc *sc = device_get_softc(dev); + unsigned int tab_response[4]; + unsigned int mult,blocknr; + + at91_qdmmc_SendCommand(dev, GO_IDLE_STATE_CMD, AT91C_NO_ARGUMENT); + + if (at91_qdmmc_SDCard_GetOCR(dev) == -1) + return ENXIO; + + f = pMCI_Device->pMCI_DeviceFeatures; + if (at91_qdmmc_SDCard_GetCID(tab_response) != 0) + return AT91C_INIT_ERROR; + f->Card_Inserted = AT91C_SD_CARD_INSERTED; + if (at91_qdmmc_SendCommand(SET_RELATIVE_ADDR_CMD, 0) != 0) + return AT91C_INIT_ERROR; + f->Relative_Card_Address = (AT91C_BASE_MCI->MCI_RSPR[0] >> 16); + if (at91_qdmmc_GetCSD(f->Relative_Card_Address,tab_response) + != AT91C_CMD_SEND_OK) + return AT91C_INIT_ERROR; + 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_v21_SECT_SIZE_S) & + CSD_2_v21_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; + f->Erase_Block_Enable = (tab_response[2] >> CSD_2_v21_ER_BLEN_EN_S) & + CSD_2_v21_ER_BLEN_EN_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_2_C_SIZE_M_S) & + CSD_2_C_SIZE_M_M) + 2 ); + // compute MSB of C_SIZE + 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_2_CSIZE_L_S) & + CSD_2_CSIZE_L_M)) + 1); + f->Memory_Capacity = (1 << f->READ_BL_LEN) * blocknr; + //// End of Compute Memory Capacity + if (at91_qdmmc_SDCard_SetBusWidth(pMCI_Device) != AT91C_CMD_SEND_OK) + return AT91C_INIT_ERROR; + if (at91_qdmmc_SetBlocklength(1 << f->READ_BL_LEN) != AT91C_CMD_SEND_OK) + return AT91C_INIT_ERROR; + printf("Found SD card %u bytes\n", f->Memory_Capacity); + return (0); +#else return (ENXIO); +#endif } static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609130645.k8D6jJkV054553>