public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus-list@drzeus.cx>
To: Philip Langdale <philipl@overt.org>
Cc: linux-kernel@vger.kernel.org, John Gilmore <gnu@toad.com>
Subject: Re: [PATCH 2.6.19] mmc: Add support for SDHC cards (Take 2)
Date: Wed, 03 Jan 2007 22:06:03 +0100	[thread overview]
Message-ID: <459C1ABB.3090500@drzeus.cx> (raw)
In-Reply-To: <459928F3.9010804@overt.org>

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


  reply	other threads:[~2007-01-03 21:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-01 15:29 [PATCH 2.6.19] mmc: Add support for SDHC cards (Take 2) Philip Langdale
2007-01-03 21:06 ` Pierre Ossman [this message]
2007-01-03 23:06 ` Andrew Morton
2007-01-04  5:24   ` Philip Langdale
2007-01-04  5:59     ` Pierre Ossman
2007-01-04  6:35       ` Philip Langdale
2007-01-04  7:32         ` Pierre Ossman
2007-01-04 12:50     ` Alex Dubov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=459C1ABB.3090500@drzeus.cx \
    --to=drzeus-list@drzeus.cx \
    --cc=gnu@toad.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipl@overt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox