Re: [PATCH 2.6.19] mmc: Add support for SDHC cards (Take 2)

From: Pierre Ossman
Date: Wed Jan 03 2007 - 16:06:31 EST


Philip Langdale wrote:
> @@ -1386,10 +1420,37 @@
> * all get the idea that they should be ready for CMD2.
> * (My SanDisk card seems to need this.)
> */
> - if (host->mode == MMC_MODE_SD)
> - mmc_send_app_op_cond(host, host->ocr, NULL);
> - else
> + if (host->mode == MMC_MODE_SD) {
> + struct mmc_command cmd;
> + int err, ocr = host->ocr;
> + static const u8 test_pattern = 0xAA;
> +
> + /*
> + * To support SD 2.0 cards, we must always invoke SD_SEND_IF_COND
> + * before SD_APP_OP_COND. This command will harmlessly fail for
> + * SD 1.0 cards.
> + */
> + cmd.opcode = SD_SEND_IF_COND;
> + cmd.arg = ((host->ocr & 0xFF8000) != 0) << 8 | test_pattern;
> + cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR;
> +
> + err = mmc_wait_for_cmd(host, &cmd, 0);
> + if (err != MMC_ERR_NONE ||
> + (cmd.resp[0] & 0xFF) == test_pattern) {
> + if (err == MMC_ERR_NONE) {
> + /*
> + * If SD_SEND_IF_COND succeeded, we are dealing
> + * with an SD 2.0 compliant card and we should
> + * set bit 30 of the ocr to indicate that we
> + * can handle block-addressed SDHC cards.
> + */
> + ocr |= 1 << 30;
> + }
> + mmc_send_app_op_cond(host, ocr, NULL);
> + }
> + } else {
> mmc_send_op_cond(host, host->ocr, NULL);
> + }
>
> mmc_discover_cards(host);
>
>

Nah... I think a mmc_send_if_cond() would be cleaner. The setup routine
should contain the sequence of events needed, while we abstract the
really low level grunt work into functions.

(more on that subject as soon as kernel.org has finished mirroring ;))

Rgds

--
-- Pierre Ossman

Linux kernel, MMC maintainer http://www.kernel.org
PulseAudio, core developer http://pulseaudio.org
rdesktop, core developer http://www.rdesktop.org

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/