Date: Wed, 27 Sep 2006 19:28:55 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 106792 for review Message-ID: <200609271928.k8RJStr0027175@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=106792 Change 106792 by imp@imp_lighthouse on 2006/09/27 19:28:45 more Affected files ... .. //depot/projects/arm/src/sys/dev/mmc/mmc.c#6 edit .. //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#7 edit Differences ... ==== //depot/projects/arm/src/sys/dev/mmc/mmc.c#6 (text+ko) ==== @@ -46,6 +46,8 @@ struct intr_config_hook config_intrhook; }; +#define CMD_RETRIES 3 + /* bus entry points */ static int mmc_probe(device_t dev); static int mmc_attach(device_t dev); @@ -184,10 +186,12 @@ mmcbr_update_ios(dev); mmc_ms_delay(1); + memset(&cmd, 0, sizeof(cmd)); cmd.opcode = MMC_GO_IDLE_STATE; cmd.arg = 0; cmd.flags = MMC_RSP_NONE | MMC_CMD_BC; mmc_wait_for_cmd(sc, &cmd, 0); + printf("GO_IDLE returns %d\n", cmd.error); mmc_ms_delay(1); mmcbr_set_chip_select(dev, cs_dontcare); @@ -196,17 +200,53 @@ } static int -mmc_send_app_op_cond(struct mmc_softc *sc, uint32_t rca, uint32_t *ocr) +mmc_send_app_op_cond(struct mmc_softc *sc, uint32_t ocr, uint32_t *rocr) { - // XXX write me - return EIO; + struct mmc_command cmd; + int err = MMC_ERR_NONE, i; + + memset(&cmd, 0, sizeof(cmd)); + cmd.opcode = ACMD_SD_SEND_OP_COND; + cmd.arg = ocr; + cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR; + + for (i = 0; i < 100; i++) { + err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); + if (err != MMC_ERR_NONE) + break; + if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || ocr == 0) + break; + err = MMC_ERR_TIMEOUT; + mmc_ms_delay(10); + } + if (rocr && err == MMC_ERR_NONE) + *rocr = cmd.resp[0]; + return err; } static int -mmc_send_op_cond(struct mmc_softc *sc, uint32_t rca, uint32_t *ocr) +mmc_send_op_cond(struct mmc_softc *sc, uint32_t ocr, uint32_t *rocr) { - // XXX write me - return EIO; + struct mmc_command cmd; + int err = MMC_ERR_NONE, i; + + memset(&cmd, 0, sizeof(cmd)); + cmd.opcode = MMC_SEND_OP_COND; + cmd.arg = ocr; + cmd.flags = MMC_RSP_R3 | MMC_CMD_BCR; + + for (i = 0; i < 100; i++) { + err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); + if (err != MMC_ERR_NONE) + break; + if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || ocr == 0) + break; + err = MMC_ERR_TIMEOUT; + mmc_ms_delay(10); + } + if (rocr && err == MMC_ERR_NONE) + *rocr = cmd.resp[0]; + return err; } static void ==== //depot/projects/arm/src/sys/dev/mmc/mmcreg.h#7 (text+ko) ==== @@ -201,7 +201,9 @@ /* in SD 2.0 spec, bits 8-14 are now marked reserved */ /* Low voltage in SD2.0 spec is bit 7, TBD voltage */ /* Low voltage in MC 3.31 spec is bit 7, 1.65-1.95V */ -/* Linux has defines for lower bits down to 0, for reasons unknown */ +/* Linux has defines for lower bits down to 0, which were defined in prior */ +/* specs to MMC 3.31. 3.31 redefined them to be reserved and also said that */ +/* cards had to support the 2.7-3.6V. */ #define MMC_OCR_LOW_VOLTAGE (1u << 7) /* Low Voltage Range -- tbd */ #define MMC_OCR_200_210 (1U << 8) /* Vdd voltage 2.00 ~ 2.10 */ #define MMC_OCR_210_220 (1U << 9) /* Vdd voltage 2.10 ~ 2.20 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200609271928.k8RJStr0027175>