[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <459C1ABB.3090500@drzeus.cx>
Date: Wed, 03 Jan 2007 22:06:03 +0100
From: Pierre Ossman <drzeus-list@...eus.cx>
To: Philip Langdale <philipl@...rt.org>
CC: linux-kernel@...r.kernel.org, John Gilmore <gnu@...d.com>
Subject: Re: [PATCH 2.6.19] mmc: Add support for SDHC cards (Take 2)
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists