MMC-over-SPI
Subsystems (3)
cover MMC-over-SPI
Here's an updated version of the MMC-over-SPI patches, reworked to address most of Pierre's issues (moving even more code into the MMC core) and to clean up the I/O paths.
To build/run these, you'll need the CRC7 patch from recent MM trees.
- headers learn about SPI
- mmc_block learns about SPI
- mmc core updates
- mmc_spi host driver
The bits related to card lock/unlock aren't included here, since those didn't go upstream yet.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707141504.51950.david-b-yBeKhBN/[email protected]
PATCH 1/4 MMC headers learn about SPI
Teach the MMC/SD/SDIO system headers that some hosts use SPI mode
- New host capabilities and status bits
* MMC_CAP_SPI, with mmc_host_is_spi() test
* mmc_host.use_spi-crc flag
- SPI-specific declarations:
* Response types, MMC_RSP_SPI_R*
* Two SPI-only commands
* Status bits used native to SPI: R1_SPI_*, R2_SPI_*
- Fix a few (unrelated) whitespace bugs in the headers.
- Reorder a few mmc_host fields, removing several bytes of padding
None of these changes affect current code.
--- include/linux/mmc/core.h | 23 ++++++++++++++++++++-- include/linux/mmc/host.h | 9 ++++++-- include/linux/mmc/mmc.h | 48 ++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 69 insertions(+), 11 deletions(-)
include/linux/mmc/host.h +7 -2
@@ -90,6 +90,7 @@ struct mmc_host {#define MMC_CAP_BYTEBLOCK (1 << 2)/* Can do non-log2 block sizes */ #define MMC_CAP_MMC_HIGHSPEED (1 << 3)/* Can do MMC high-speed timing */ #define MMC_CAP_SD_HIGHSPEED (1 << 4)/* Can do SD high-speed timing */ +#define MMC_CAP_SPI (1 << 5)/* Talks only SPI protocols */ /* host specific block data */ unsigned int max_seg_size;/* see blk_queue_max_segment_size */
@@ -115,14 +116,16 @@ struct mmc_host {wait_queue_head_t wq; unsigned int claimed:1; /* host exclusively claimed */ -struct delayed_work detect; + unsigned int use_spi_crc:1; +#ifdef CONFIG_MMC_DEBUG unsigned int removed:1; /* host is being removed */#endif + unsigned int bus_dead:1; /* bus has been released */ +struct delayed_work detect;const struct mmc_bus_ops *bus_ops;/* current bus driver */ unsigned int bus_refs;/* reference counter */ - unsigned int bus_dead:1; /* bus has been released */unsigned long private[0 ]____cacheline_aligned ; };
@@ -137,6 +140,8 @@ static inline void *mmc_priv(struct mmc_return (void *)host->private; } +#define mmc_host_is_spi (host) ((host)->caps & MMC_CAP_SPI) +#define mmc_dev (x) ((x)->parent)#define mmc_classdev (x) (&(x)->class_dev)#define mmc_hostname (x) ((x)->class_dev.bus_id)
include/linux/mmc/core.h +21 -2
@@ -25,14 +25,19 @@ struct mmc_command {#define MMC_RSP_CRC (1 << 2)/* expect valid crc */ #define MMC_RSP_BUSY (1 << 3)/* card may send busy */ #define MMC_RSP_OPCODE (1 << 4)/* response contains opcode */ -#define MMC_CMD_MASK (3 << 5)/* command type */ + +#define MMC_CMD_MASK (3 << 5)/* non-SPI command type */ #define MMC_CMD_AC (0 << 5)#define MMC_CMD_ADTC (1 << 5)#define MMC_CMD_BC (2 << 5)#define MMC_CMD_BCR (3 << 5) +#define MMC_RSP_SPI_S1 (1 << 7)/* one status byte */ +#define MMC_RSP_SPI_S2 (1 << 8)/* second status byte */ +#define MMC_RSP_SPI_B4 (1 << 9)/* four data bytes */ +/* -* These are the response types, and correspond to valid bit +* These are the native response types, and correspond to valid bit * patterns of the above flags. One additional valid pattern * is all zeros, which means we don't expect a response. */
@@ -47,6 +52,20 @@ struct mmc_command {#define mmc_resp_type (cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))/* +* These are the SPI response types for MMC and SD cards (not SDIO). +* Commands return R1, with maybe more info. Zero is an error type; +* callers must always provide the appropriate MMC_RSP_SPI_Rx flags. +*/ +#define MMC_RSP_SPI_R1 (MMC_RSP_SPI_S1) +#define MMC_RSP_SPI_R1B (MMC_RSP_SPI_S1|MMC_RSP_BUSY) +#define MMC_RSP_SPI_R2 (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2) +#define MMC_RSP_SPI_R3 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) +#define MMC_RSP_SPI_R7 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) + +#define mmc_spi_resp_type (cmd) ((cmd)->flags & \ + (MMC_RSP_SPI_S1|MMC_RSP_BUSY|MMC_RSP_SPI_S2|MMC_RSP_SPI_B4)) + +/* * These are the command types. */ #define mmc_cmd_type (cmd) ((cmd)->flags & MMC_CMD_MASK)
include/linux/mmc/mmc.h +41 -6
87 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707141506.00262.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 1/4] MMC headers learn about SPI
Quoted 9 lines · On Sat, 14 Jul 2007 15:05:59 -0700 David Brownell…
include/linux/mmc/host.h +2
-1@@ -115,14 +116,16 @@ struct mmc_host {wait_queue_head_t wq; unsigned int claimed:1; /* host exclusively claimed */ -struct delayed_work detect; + unsigned int use_spi_crc:1; +#ifdef CONFIG_MMC_DEBUG unsigned int removed:1; /* host is being removed */
include/linux/mmc/host.h struct mmc_host { · line 131
Quoted 10 lines
include/linux/mmc/host.h +2
-1#endif + unsigned int bus_dead:1; /* bus has been released */ +struct delayed_work detect;const struct mmc_bus_ops *bus_ops;/* current bus driver */ unsigned int bus_refs;/* reference counter */ - unsigned int bus_dead:1; /* bus has been released */unsigned long private[0 ]____cacheline_aligned ; };
Some needless shuffling of existing members here.
include/linux/mmc/core.h struct mmc_command { · line 60
Quoted 10 lines
include/linux/mmc/core.h +6
-0@@ -47,6 +52,20 @@ struct mmc_command {#define mmc_resp_type (cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))/* +* These are the SPI response types for MMC and SD cards (not SDIO). +* Commands return R1, with maybe more info. Zero is an error type; +* callers must always provide the appropriate MMC_RSP_SPI_Rx flags. +*/ +#define MMC_RSP_SPI_R1 (MMC_RSP_SPI_S1) +#define MMC_RSP_SPI_R1B (MMC_RSP_SPI_S1|MMC_RSP_BUSY)
I think it's probably safe to keep the two response types separate, even though it is very unlikely that we'll have a command that only uses busy signalling in one of the modes.
Other than that, it looks fine.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726183150.024930aa-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 1/4] MMC headers learn about SPI
Quoted 16 lines · Pierre Ossman
Quoted 13 lines · On Sat, 14 Jul 2007 15:05:59 -0700 David Brownell…
include/linux/mmc/host.h +4
-1@@ -115,14 +116,16 @@ struct mmc_host {wait_queue_head_t wq; unsigned int claimed:1; /* host exclusively claimed */ -struct delayed_work detect; + unsigned int use_spi_crc:1; +#ifdef CONFIG_MMC_DEBUG unsigned int removed:1; /* host is being removed */#endif + unsigned int bus_dead:1; /* bus has been released */ +struct delayed_work detect;
Quoted 8 lines
include/linux/mmc/host.h struct mmc_host { · line 131
Quoted 6 lines
include/linux/mmc/host.h +0
-1const struct mmc_bus_ops *bus_ops;/* current bus driver */ unsigned int bus_refs;/* reference counter */ - unsigned int bus_dead:1; /* bus has been released */unsigned long private[0 ]____cacheline_aligned ; };Some needless shuffling of existing members here.
As explained in the comment: this reduces the padding. The previous way needed one word per bitfield; this way they all fit into the same word...
Quoted 14 lines
include/linux/mmc/core.h struct mmc_command { · line 60
Quoted 10 lines
include/linux/mmc/core.h +6
-0@@ -47,6 +52,20 @@ struct mmc_command {#define mmc_resp_type (cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))/* +* These are the SPI response types for MMC and SD cards (not SDIO). +* Commands return R1, with maybe more info. Zero is an error type; +* callers must always provide the appropriate MMC_RSP_SPI_Rx flags. +*/ +#define MMC_RSP_SPI_R1 (MMC_RSP_SPI_S1) +#define MMC_RSP_SPI_R1B (MMC_RSP_SPI_S1|MMC_RSP_BUSY)I think it's probably safe to keep the two response types separate, even though it is very unlikely that we'll have a command that only uses busy signalling in one of the modes.
That bothered me a smidgeon ...
Quoted 1 line
Other than that, it looks fine.
I'm not sure what you mean here, but then my first cup of coffee is still trying to do its work. Are you saying you want me to
- increase the padding again?
- define an MMC_RSP_SPI_BUSY, and use that?
The former would bother me a bit, but I could understand if you wanted it to be in a different patch. The latter is no problem at all.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200707260955.22967.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 1/4] MMC headers learn about SPI
Quoted 5 lines · On Thu, 26 Jul 2007 09:55:22 -0700 David Brownell…
As explained in the comment: this reduces the padding. The previous way needed one word per bitfield; this way they all fit into the same word...
Ah, didn't realize that. I blame the effect two weeks of vacation has on the brain. :)
Perhaps shuffling them all to the end (before private) so that it is more clear that they are grouped because of padding issues?
Quoted 10 lines
I'm not sure what you mean here, but then my first cup of coffee is still trying to do its work. Are you saying you want me to
- increase the padding again?
- define anMMC_RSP_SPI_BUSY, and use that?The former would bother me a bit, but I could understand if you wanted it to be in a different patch. The latter is no problem at all.
Well, both initially. But padding is a relevant concern, so I'm content with the latter.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726200525.6a5b7d72-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 1/4] MMC headers learn about SPI
Quoted 9 lines · Pierre Ossman
Quoted 5 lines · On Thu, 26 Jul 2007 09:55:22 -0700 David Brownell…
As explained in the comment: this reduces the padding. The previous way needed one word per bitfield; this way they all fit into the same word...
Quoted 5 lines
Ah, didn't realize that. I blame the effect two weeks of vacation has on the brain. :)
Perhaps shuffling them all to the end (before private) so that it is more clear that they are grouped because of padding issues?
What I did was add a comment about the padding, then grouped them all after the 'u32 ocr' to save a smidgeon more padding (on 64bit machines). Overall, there's more padding to remove.
Quoted 6 lines
Quoted 6 lines
I'm not sure what you mean here, but then my first cup of coffee is still trying to do its work. Are you saying you want me to
- increase the padding again?
- define anMMC_RSP_SPI_BUSY, and use that?
Quoted 6 lines
Quoted 3 lines
The former would bother me a bit, but I could understand if you wanted it to be in a different patch. The latter is no problem at all.
Well, both initially. But padding is a relevant concern, so I'm content with the latter.
Did both. See the appended patch.
- Dave
========== CUT HERE
Teach the MMC/SD/SDIO system headers that some hosts use SPI mode
- New host capabilities and status bits
* MMC_CAP_SPI, with mmc_host_is_spi() test
* mmc_host.use_spi_crc flag
- SPI-specific declarations:
* Response types, MMC_RSP_SPI_R*
* Two SPI-only commands
* Status bits used native to SPI: R1_SPI_*, R2_SPI_*
- Fix a few (unrelated) whitespace bugs in the headers.
- Reorder a few mmc_host fields, removing several bytes of padding
None of these changes affect current code.
--- include/linux/mmc/core.h | 24 ++++++++++++++++++++++-- include/linux/mmc/host.h | 16 +++++++++++----- include/linux/mmc/mmc.h | 47 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 74 insertions(+), 13 deletions(-)
include/linux/mmc/host.h +11 -5
@@ -90,6 +90,7 @@ struct mmc_host {#define MMC_CAP_BYTEBLOCK (1 << 2)/* Can do non-log2 block sizes */ #define MMC_CAP_MMC_HIGHSPEED (1 << 3)/* Can do MMC high-speed timing */ #define MMC_CAP_SD_HIGHSPEED (1 << 4)/* Can do SD high-speed timing */ +#define MMC_CAP_SPI (1 << 5)/* Talks only SPI protocols */ /* host specific block data */ unsigned int max_seg_size;/* see blk_queue_max_segment_size */
@@ -106,6 +107,14 @@ struct mmc_host {struct mmc_ios ios;/* current io bus settings */ u32 ocr;/* the current OCR setting */ +/* group bitfields together to minimize padding */ + unsigned int use_spi_crc:1; + unsigned int claimed:1; /* host exclusively claimed */ + unsigned int bus_dead:1; /* bus has been released */ +#ifdef CONFIG_MMC_DEBUG + unsigned int removed:1; /* host is being removed */ +#endif +unsigned int mode;/* current card mode of host */ #define MMC_MODE_MMC 0#define MMC_MODE_SD 1
@@ -113,16 +122,11 @@ struct mmc_host {struct mmc_card *card;/* device attached to this host */ wait_queue_head_t wq; - unsigned int claimed:1; /* host exclusively claimed */struct delayed_work detect; -#ifdef CONFIG_MMC_DEBUG - unsigned int removed:1; /* host is being removed */ -#endif const struct mmc_bus_ops *bus_ops;/* current bus driver */ unsigned int bus_refs;/* reference counter */ - unsigned int bus_dead:1; /* bus has been released */unsigned long private[0 ]____cacheline_aligned ; };
@@ -137,6 +141,8 @@ static inline void *mmc_priv(struct mmc_return (void *)host->private; } +#define mmc_host_is_spi (host) ((host)->caps & MMC_CAP_SPI) +#define mmc_dev (x) ((x)->parent)#define mmc_classdev (x) (&(x)->class_dev)#define mmc_hostname (x) ((x)->class_dev.bus_id)
include/linux/mmc/core.h +22 -2
@@ -25,14 +25,20 @@ struct mmc_command {#define MMC_RSP_CRC (1 << 2)/* expect valid crc */ #define MMC_RSP_BUSY (1 << 3)/* card may send busy */ #define MMC_RSP_OPCODE (1 << 4)/* response contains opcode */ -#define MMC_CMD_MASK (3 << 5)/* command type */ + +#define MMC_CMD_MASK (3 << 5)/* non-SPI command type */ #define MMC_CMD_AC (0 << 5)#define MMC_CMD_ADTC (1 << 5)#define MMC_CMD_BC (2 << 5)#define MMC_CMD_BCR (3 << 5) +#define MMC_RSP_SPI_S1 (1 << 7)/* one status byte */ +#define MMC_RSP_SPI_S2 (1 << 8)/* second status byte */ +#define MMC_RSP_SPI_B4 (1 << 9)/* four data bytes */ +#define MMC_RSP_SPI_BUSY (1 << 10)/* card may send busy */ +/* -* These are the response types, and correspond to valid bit +* These are the native response types, and correspond to valid bit * patterns of the above flags. One additional valid pattern * is all zeros, which means we don't expect a response. */
@@ -47,6 +53,20 @@ struct mmc_command {#define mmc_resp_type (cmd) ((cmd)->flags & (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY|MMC_RSP_OPCODE))/* +* These are the SPI response types for MMC and SD cards (not SDIO). +* Commands return R1, with maybe more info. Zero is an error type; +* callers must always provide the appropriate MMC_RSP_SPI_Rx flags. +*/ +#define MMC_RSP_SPI_R1 (MMC_RSP_SPI_S1) +#define MMC_RSP_SPI_R1B (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY) +#define MMC_RSP_SPI_R2 (MMC_RSP_SPI_S1|MMC_RSP_SPI_S2) +#define MMC_RSP_SPI_R3 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) +#define MMC_RSP_SPI_R7 (MMC_RSP_SPI_S1|MMC_RSP_SPI_B4) + +#define mmc_spi_resp_type (cmd) ((cmd)->flags & \ + (MMC_RSP_SPI_S1|MMC_RSP_SPI_BUSY|MMC_RSP_SPI_S2|MMC_RSP_SPI_B4)) + +/* * These are the command types. */ #define mmc_cmd_type (cmd) ((cmd)->flags & MMC_CMD_MASK)
include/linux/mmc/mmc.h +41 -6
87 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
PATCH 2/4 MMC block learns about SPI
In reply to a message not in the archiveTeaching the MMC/SD block card driver about SPI.
- Provide the SPI response type flags with each request issued. The model is that if no such flags are provided, it will be rejected by the MMC-over-SPI host.
- Understand that multiblock SPI writes don't use STOP_TRANSMISSION.
- Correct check for APP_CMD failure.
--- drivers/mmc/card/block.c | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-)
drivers/mmc/card/block.c +17 -9
@@ -151,17 +151,19 @@ static u32 mmc_sd_num_wr_blocks(struct m cmd.opcode =MMC_APP_CMD ; cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,0 ); -if ((err !=MMC_ERR_NONE ) || !(cmd.resp[0 ] &R1_APP_CMD )) +if (err !=MMC_ERR_NONE ) +return (u32)-1 ; +if (!mmc_host_is_spi (card->host) && !(cmd.resp[0 ] &R1_APP_CMD ))return (u32)-1 ;memset (&cmd,0 ,sizeof (struct mmc_command )); cmd.opcode =SD_APP_SEND_NUM_WR_BLKS ; cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ;memset (&data,0 ,sizeof (struct mmc_data ));
@@ -220,11 +222,11 @@ static int mmc_blk_issue_rq(struct mmc_q brq.cmd.arg = req->sector;if (!mmc_card_blockaddr (card)) brq.cmd.arg <<=9 ; - brq.cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + brq.cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; brq.data.blksz =1 << md->block_bits; brq.stop.opcode =MMC_STOP_TRANSMISSION ; brq.stop.arg =0 ; - brq.stop.flags =MMC_RSP_R1B |MMC_CMD_AC ; + brq.stop.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; brq.data.blocks = req->nr_sectors >> (md->block_bits -9 );if (brq.data.blocks > card->host->max_blk_count) brq.data.blocks = card->host->max_blk_count;
@@ -244,7 +246,12 @@ static int mmc_blk_issue_rq(struct mmc_qif (brq.data.blocks >1 ) { brq.data.flags |=MMC_DATA_MULTI ; - brq.mrq.stop = &brq.stop; +/* SPI multiblock writes terminate using a special +* token, not a STOP_TRANSMISSION request. +*/ +if (!mmc_host_is_spi (card->host) + ||rq_data_dir (req) ==READ ) + brq.mrq.stop = &brq.stop; readcmd =MMC_READ_MULTIPLE_BLOCK ; writecmd =MMC_WRITE_MULTIPLE_BLOCK ; }else {
@@ -302,13 +309,14 @@ static int mmc_blk_issue_rq(struct mmc_q goto cmd_err; } - if (rq_data_dir(req) != READ) { + if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { do { int err; cmd.opcode = MMC_SEND_STATUS; cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 + | MMC_CMD_AC; err = mmc_wait_for_cmd(card->host, &cmd, 5); if (err) { printk(KERN_ERR "%s: error %d requesting status\n",
@@ -511,7 +519,7 @@ mmc_blk_set_blksize(struct mmc_blk_datammc_claim_host (card->host); cmd.opcode =MMC_SET_BLOCKLEN ; cmd.arg =1 << md->block_bits; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,5 );mmc_release_host (card->host);
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707141506.42880.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 2/4] MMC block learns about SPI
Quoted 7 lines · On Sat, 14 Jul 2007 15:06:42 -0700 David Brownell…
drivers/mmc/card/block.c +1
-1@@ -302,13 +309,14 @@ static int mmc_blk_issue_rq(struct mmc_q goto cmd_err; } -if (rq_data_dir (req) !=READ ) { +if (!mmc_host_is_spi (card->host) &&rq_data_dir (req) !=READ ) { do {
drivers/mmc/card/block.c static int mmc_blk_issue_rq(struct mmc_q · line 322
Quoted 10 lines
drivers/mmc/card/block.c +2
-1int err; cmd.opcode =MMC_SEND_STATUS ; cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R2 |MMC_RSP_R1 + |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,5 );if (err) { printk(KERN_ERR "%s: error %d requesting status\n",
Nitpicking, but if this code isn't executed on a SPI host then a SPI response type is hardly needed. :)
Otherwise ok.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726183339.6631243f-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 2/4] MMC block learns about SPI
Quoted 12 lines · Pierre Ossman
Quoted 9 lines · On Sat, 14 Jul 2007 15:06:42 -0700 David Brownell…
drivers/mmc/card/block.c +1
-1@@ -302,13 +309,14 @@ static int mmc_blk_issue_rq(struct mmc_q goto cmd_err; } -if (rq_data_dir (req) !=READ ) { +if (!mmc_host_is_spi (card->host) &&rq_data_dir (req) !=READ ) { do { int err;
Quoted 11 lines
drivers/mmc/card/block.c static int mmc_blk_issue_rq(struct mmc_q · line 322
Quoted 8 lines
drivers/mmc/card/block.c +2
-1cmd.opcode =MMC_SEND_STATUS ; cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R2 |MMC_RSP_R1 + |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,5 );if (err) { printk(KERN_ERR "%s: error %d requesting status\n",Nitpicking, but if this code isn't executed on a SPI host then a SPI response type is hardly needed. :)
But then it can't hurt either, and will be safer to cut'n'paste. :)
Andrew Morton regularly gives feedback which amounts to "that's correct in this context, but please adopt this always-safe idiom" on the grounds that a *LOT* of Linux code is developed by cloning. It's hard for me to disagree with that... especially when I see my code showing up in some rather strange contexts!
Quoted 1 line
Otherwise ok.
So -- should I change that?
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200707261000.17339.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 2/4] MMC block learns about SPI
Quoted 9 lines · On Thu, 26 Jul 2007 10:00:16 -0700 David Brownell…
But then it can't hurt either, and will be safer to cut'n'paste. :)
Andrew Morton regularly gives feedback which amounts to "that's correct in this context, but please adopt this always-safe idiom" on the grounds that a *LOT* of Linux code is developed by cloning. It's hard for me to disagree with that... especially when I see my code showing up in some rather strange contexts!
Fair enough. But then you'd probably also need to have a look at the clause terminating that while loop. I believe it is specific to the native protocol.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726200639.06242858-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 2/4] MMC block learns about SPI
Quoted 13 lines · Pierre Ossman
Quoted 9 lines · On Thu, 26 Jul 2007 10:00:16 -0700 David Brownell…
But then it can't hurt either, and will be safer to cut'n'paste. :)
Andrew Morton regularly gives feedback which amounts to "that's correct in this context, but please adopt this always-safe idiom" on the grounds that a *LOT* of Linux code is developed by cloning. It's hard for me to disagree with that... especially when I see my code showing up in some rather strange contexts!
Quoted 3 lines
Fair enough. But then you'd probably also need to have a look at the clause terminating that while loop. I believe it is specific to the native protocol.
Sigh; yes it is. In this case, the code won't be cut/pastable. ;)
Updated patch appended. (BTW these refreshes are against current GIT.)
======== CUT HERE
Teaching the MMC/SD block card driver about SPI.
- Provide the SPI response type flags with each request issued. The model is that if no such flags are provided, it will be rejected by the MMC-over-SPI host.
- Understand that multiblock SPI writes don't use STOP_TRANSMISSION.
- Correct check for APP_CMD failure.
--- drivers/mmc/card/block.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mmc/card/block.c +15 -8
@@ -151,17 +151,19 @@ static u32 mmc_sd_num_wr_blocks(struct m cmd.opcode =MMC_APP_CMD ; cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,0 ); -if ((err !=MMC_ERR_NONE ) || !(cmd.resp[0 ] &R1_APP_CMD )) +if (err !=MMC_ERR_NONE ) +return (u32)-1 ; +if (!mmc_host_is_spi (card->host) && !(cmd.resp[0 ] &R1_APP_CMD ))return (u32)-1 ;memset (&cmd,0 ,sizeof (struct mmc_command )); cmd.opcode =SD_APP_SEND_NUM_WR_BLKS ; cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ;memset (&data,0 ,sizeof (struct mmc_data ));
@@ -220,11 +222,11 @@ static int mmc_blk_issue_rq(struct mmc_q brq.cmd.arg = req->sector;if (!mmc_card_blockaddr (card)) brq.cmd.arg <<=9 ; - brq.cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + brq.cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; brq.data.blksz =1 << md->block_bits; brq.stop.opcode =MMC_STOP_TRANSMISSION ; brq.stop.arg =0 ; - brq.stop.flags =MMC_RSP_R1B |MMC_CMD_AC ; + brq.stop.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; brq.data.blocks = req->nr_sectors >> (md->block_bits -9 );if (brq.data.blocks > card->host->max_blk_count) brq.data.blocks = card->host->max_blk_count;
@@ -244,7 +246,12 @@ static int mmc_blk_issue_rq(struct mmc_qif (brq.data.blocks >1 ) { brq.data.flags |=MMC_DATA_MULTI ; - brq.mrq.stop = &brq.stop; +/* SPI multiblock writes terminate using a special +* token, not a STOP_TRANSMISSION request. +*/ +if (!mmc_host_is_spi (card->host) + ||rq_data_dir (req) ==READ ) + brq.mrq.stop = &brq.stop; readcmd =MMC_READ_MULTIPLE_BLOCK ; writecmd =MMC_WRITE_MULTIPLE_BLOCK ; }else {
@@ -302,7 +309,7 @@ static int mmc_blk_issue_rq(struct mmc_q goto cmd_err; } -if (rq_data_dir (req) !=READ ) { +if (!mmc_host_is_spi (card->host) &&rq_data_dir (req) !=READ ) { do { int err;
@@ -510,7 +517,7 @@ mmc_blk_set_blksize(struct mmc_blk_datammc_claim_host (card->host); cmd.opcode =MMC_SET_BLOCKLEN ; cmd.arg =1 << md->block_bits; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; err =mmc_wait_for_cmd (card->host, &cmd,5 );mmc_release_host (card->host);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
PATCH 3/4 MMC core learns about SPI
In reply to a message not in the archiveTeach the MMC/SD/SDIO core about using SPI mode.
- Use mmc_host_is_spi() so enumeration works through SPI signaling, and protocols, not just the native versions.
- Provide the SPI response type flags with each request issued, including requests from the new lock/unlock code.
- Understand that some commands act a bit differently ... notably:
* OP_COND command reports busy status differently
* OP_COND command doesn't return the OCR
* APP_CMD status doesn't have an R1_APP_CMD analogue
- Understand that cmd->resp[0] and mmc_get_status() results for SPI return different values than for "native" MMC/SD protocol; this affects checking card lock status, and some others.
Those changes required some new and updated primitives:
- Provide utilities to access two SPI-only requests, and one request that wasn't previously needed:
* mmc_spi_read_ocr() ... SPI only
* mmc_spi_set_crc() ... SPI only (override by module parm)
* mmc_spi_send_cid() ... works without broadcast mode
- Updated internal routines:
* Previous mmc_send_csd() modified into mmc_send_cxd_native(); it uses native "R2" responses, which include 16 bytes of data.
* Previous mmc_send_ext_csd() becomes new mmc_send_cxd_data() helper for command-and-data access
* Bugfix to that mmc_send_cxd_data() code: dma-to-stack is unsafe/nonportable, so kmalloc a bounce buffer instead.
- Modified mmc_send_ext_csd() now uses mmc_send_cxd_data() helper
- Modified mmc_send_csd(), and new mmc_spi_send_cid(), routines use those helper routines based on whether they're native or SPI
The SPI support hasn't been tested on the new MMC4 cards (they're not widely available); likewise SD cards with 4GB and up may have surprises lurking.
--- drivers/mmc/core/core.c | 24 +++++- drivers/mmc/core/mmc.c | 33 ++++++--- drivers/mmc/core/mmc_ops.c | 158 ++++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc_ops.h | 4 + drivers/mmc/core/sd.c | 31 +++++--- drivers/mmc/core/sd_ops.c | 32 ++++++--- 6 files changed, 215 insertions(+), 67 deletions(-)
drivers/mmc/core/mmc_ops.h +4 -0
@@ -23,5 +23,9 @@ int mmc_send_ext_csd(struct mmc_card *caint mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status); +int mmc_spi_send_cid (struct mmc_host *host,u32 *cid); +int mmc_spi_read_ocr (struct mmc_host *host,u32 *ocrp); +int mmc_spi_set_crc (struct mmc_host *host); +#endif
drivers/mmc/core/core.c +18 -6
@@ -404,8 +404,13 @@ static void mmc_power_up(struct mmc_hostint bit =fls (host->ocr_avail) -1 ; host->ios.vdd = bit; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (mmc_host_is_spi (host)) { + host->ios.chip_select =MMC_CS_HIGH ; + host->ios.bus_mode =MMC_BUSMODE_PUSHPULL ; + }else { + host->ios.chip_select =MMC_CS_DONTCARE ; + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + } host->ios.power_mode =MMC_POWER_UP ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -424,8 +429,10 @@ static void mmc_power_off(struct mmc_hos { host->ios.clock =0 ; host->ios.vdd =0 ; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (!mmc_host_is_spi (host)) { + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + host->ios.chip_select =MMC_CS_DONTCARE ; + } host->ios.power_mode =MMC_POWER_OFF ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -541,7 +548,9 @@ void mmc_rescan(struct work_struct *work err =mmc_send_app_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_sd (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE ||mmc_attach_sd (host, ocr))mmc_power_off (host); }else {/*
@@ -550,7 +559,10 @@ void mmc_rescan(struct work_struct *work*/ err =mmc_send_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_mmc (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE + ||mmc_attach_mmc (host, ocr))mmc_power_off (host); }else {mmc_power_off (host);
drivers/mmc/core/mmc_ops.c +127 -31
258 lines not on this page · raw message
drivers/mmc/core/mmc.c +22 -11
@@ -264,7 +264,13 @@ static int mmc_init_card(struct mmc_host/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + err =mmc_spi_send_cid (host, cid); + }else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -287,13 +293,15 @@ static int mmc_init_card(struct mmc_host }/* -* Set card RCA. +* For native busses: set card RCA and leave open drain mode. */ - err =mmc_set_relative_addr (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_set_relative_addr (card); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -314,13 +322,15 @@ static int mmc_init_card(struct mmc_host/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/* -* Fetch and process extened CSD. +* Fetch and process extended CSD. */ err =mmc_read_ext_csd (card);if (err !=MMC_ERR_NONE )
@@ -480,7 +490,8 @@ static void mmc_suspend(struct mmc_hostBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd.c +21 -10
@@ -321,7 +321,13 @@ static int mmc_sd_init_card(struct mmc_h/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + err =mmc_spi_send_cid (host, cid); + }else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -343,13 +349,15 @@ static int mmc_sd_init_card(struct mmc_h }/* -* Set card RCA. +* For native busses: get card RCA and leave open drain mode. */ - err =mmc_send_relative_addr (host, &card->rca); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_send_relative_addr (host, &card->rca); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -369,9 +377,11 @@ static int mmc_sd_init_card(struct mmc_h/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/*
@@ -554,7 +564,8 @@ static void mmc_sd_suspend(struct mmc_hoBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd_ops.c +23 -9
@@ -70,6 +70,12 @@ int mmc_wait_for_app_cmd(struct mmc_host err = cmd->error;if (cmd->error ==MMC_ERR_NONE )break ; + +/* no point in retrying illegal commands! */ +if (mmc_host_is_spi (host)) { +if (cmd->resp[0 ] &R1_SPI_ILLEGAL_COMMAND ) +break ; + } }return err;
@@ -89,10 +95,10 @@ int mmc_app_cmd(struct mmc_host *host, sif (card) { cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; }else { cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_BCR ; } err =mmc_wait_for_cmd (host, &cmd,0 );
@@ -100,8 +106,8 @@ int mmc_app_cmd(struct mmc_host *host, sreturn err;/* Check that card supported application commands */ -if (!(cmd.resp[0 ] &R1_APP_CMD )) -return MMC_ERR_FAILED ; +if (!mmc_host_is_spi (host) && !(cmd.resp[0 ] &R1_APP_CMD )) +return (u32)-1 ;return MMC_ERR_NONE ; }
@@ -148,14 +154,18 @@ int mmc_send_app_op_cond(struct mmc_host cmd.opcode =SD_APP_OP_COND ; cmd.arg = ocr; - cmd.flags =MMC_RSP_R3 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R3 |MMC_CMD_BCR ;for (i =100 ; i; i--) { err =mmc_wait_for_app_cmd (host,NULL , &cmd,MMC_CMD_RETRIES );if (err !=MMC_ERR_NONE )break ; -if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 ) +if (mmc_host_is_spi (host)) { +/* wait until reset completes */ +if (!(cmd.resp[0 ] &R1_SPI_IDLE )) +break ; + }else if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 )break ; err =MMC_ERR_TIMEOUT ;
@@ -182,7 +192,7 @@ int mmc_send_if_cond(struct mmc_host *ho*/ cmd.opcode =SD_SEND_IF_COND ; cmd.arg = ((ocr &0xFF8000 ) !=0 ) <<8 | test_pattern; - cmd.flags =MMC_RSP_R7 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R7 |MMC_RSP_R7 |MMC_CMD_BCR ; err =mmc_wait_for_cmd (host, &cmd,0 );if (err !=MMC_ERR_NONE )
@@ -229,6 +239,8 @@ int mmc_app_send_scr(struct mmc_card *caBUG_ON (!card->host);BUG_ON (!scr); +/* NOTE: caller guarantees scr is heap-allocated */ + err =mmc_app_cmd (card->host, card);if (err !=MMC_ERR_NONE )return err;
@@ -242,7 +254,7 @@ int mmc_app_send_scr(struct mmc_card *ca cmd.opcode =SD_APP_SEND_SCR ; cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =8 ; data.blocks =1 ;
@@ -278,6 +290,8 @@ int mmc_sd_switch(struct mmc_card *card,BUG_ON (!card);BUG_ON (!card->host); +/* NOTE: caller guarantees resp is heap-allocated */ + mode = !!mode; value &=0xF ;
@@ -292,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, cmd.arg = mode <<31 |0x00FFFFFF ; cmd.arg &= ~(0xF << (group *4 )); cmd.arg |= value << (group *4 ); - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =64 ; data.blocks =1 ;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707141507.17484.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
drivers/mmc/core/core.c void mmc_rescan(struct work_struct *work · line 556
Quoted 11 lines · On Sat, 14 Jul 2007 15:07:16 -0700 David Brownell…
drivers/mmc/core/core.c +3
-1@@ -541,7 +548,9 @@ void mmc_rescan(struct work_struct *work err =mmc_send_app_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_sd (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE ||mmc_attach_sd (host, ocr))mmc_power_off (host); }else {/*
Getting the OCR is not vital to determine if it's SD or MMC, so we can move that into mmc.c and sd.c, reducing the code in here.
drivers/mmc/core/core.c void mmc_rescan(struct work_struct *work · line 568
Quoted 12 lines
drivers/mmc/core/core.c +4
-1@@ -550,7 +559,10 @@ void mmc_rescan(struct work_struct *work*/ err =mmc_send_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_mmc (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE + ||mmc_attach_mmc (host, ocr))mmc_power_off (host); }else {mmc_power_off (host);
This will fail to initialise a high capacity MMC card. From the MMC spec:
"Without the CMD58 with bits [30:29] set as "10b" in prior to the CMD1 a higher than 2GB of density of memory will remain in Idle state forever."
drivers/mmc/core/mmc_ops.c int mmc_send_op_cond(struct mmc_host *ho · line 108
Quoted 4 lines
drivers/mmc/core/mmc_ops.c +0
-0@@ -95,14 +106,18 @@ int mmc_send_op_cond(struct mmc_host *ho cmd.opcode =MMC_SEND_OP_COND ; cmd.arg = ocr;
Argument is "None", not "Ignored", so this should be 0 for SPI.
drivers/mmc/core/mmc_ops.c int mmc_send_ext_csd(struct mmc_card *ca · line 246
Quoted 6 lines
drivers/mmc/core/mmc_ops.c +3
-1-mmc_set_data_timeout (&data, card,0 ); +/* Note that for MMC_SEND_EXT_CSD we could set the timeout; but +* not for the other requests. But host->card isn't set yet! +*/
This will break on native hosts as a timeout of 0 means exactly that.
drivers/mmc/core/mmc_ops.c int mmc_send_ext_csd(struct mmc_card *ca · line 276
Quoted 9 lines
drivers/mmc/core/mmc_ops.c +9
-0+ +int mmc_spi_send_cid (struct mmc_host *host,u32 *cid) +{ +if (!mmc_host_is_spi (host)) +return mmc_send_cxd_native (host,0 , cid,MMC_SEND_CID ); + +return mmc_send_cxd_data (host,MMC_SEND_CID , cid,16 ); +} +
As this is not SPI specific (except for its current use), why not mmc_send_cid() ?
And the argument for it is the RCA (in native mode).
drivers/mmc/core/mmc_ops.c int mmc_send_ext_csd(struct mmc_card *ca · line 303
Quoted 7 lines
drivers/mmc/core/mmc_ops.c +7
-0+ +/* Enabling software CRCs can be a significant (30%) performance cost, +* and for other reasons isn't always desired; so it can be disabled. +*/ +static int use_spi_crc =1 ; +module_param (use_spi_crc, bool,0 ); +
The *_ops.c only contain function wrappers of protocol commands, not policy. So I think this is better placed where mmc_spi_set_crc() is called.
Quoted 7 lines
drivers/mmc/core/mmc.c +0
-1@@ -264,7 +264,13 @@ static int mmc_init_card(struct mmc_host/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid);
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 276
Quoted 10 lines
drivers/mmc/core/mmc.c +7
-0+if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + err =mmc_spi_send_cid (host, cid); + }else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
A matter of taste, but wouldn't it be clearer if you separated out the crc bit and did that earlier, before the above comment?
Quoted 7 lines
drivers/mmc/core/sd.c +0
-1@@ -321,7 +321,13 @@ static int mmc_sd_init_card(struct mmc_h/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid);
drivers/mmc/core/sd.c static int mmc_sd_init_card(struct mmc_h · line 333
Quoted 10 lines
drivers/mmc/core/sd.c +7
-0+if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + err =mmc_spi_send_cid (host, cid); + }else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
Ditto.
Quoted 5 lines
drivers/mmc/core/sd_ops.c +0
-0@@ -70,6 +70,12 @@ int mmc_wait_for_app_cmd(struct mmc_host err = cmd->error;if (cmd->error ==MMC_ERR_NONE )
drivers/mmc/core/sd_ops.c int mmc_wait_for_app_cmd(struct mmc_host · line 81
Quoted 10 lines
drivers/mmc/core/sd_ops.c +6
-0break ; + +/* no point in retrying illegal commands! */ +if (mmc_host_is_spi (host)) { +if (cmd->resp[0 ] &R1_SPI_ILLEGAL_COMMAND ) +break ; + } }return err;
"Illegal command" refers to the previous command sent (and failed). So this can give false negatives.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726191824.569542fd-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
Quoted 5 lines · Pierre Ossman
Quoted 2 lines · On Sat, 14 Jul 2007 15:07:16 -0700 David Brownell <[email protected]> wrote:
(quoted diff) +0
-0@@ -541,7 +548,9 @@ void mmc_rescan(struct work_struct *work
Quoted 12 lines
Review void mmc_rescan(struct work_struct *work · line 556
Quoted 9 lines
(quoted diff) +3
-1err = mmc_send_app_op_cond(host, 0, &ocr); if (err == MMC_ERR_NONE) { - if (mmc_attach_sd(host, ocr)) + if (mmc_host_is_spi(host)) + err = mmc_spi_read_ocr(host, &ocr); + if (err != MMC_ERR_NONE || mmc_attach_sd(host, ocr)) mmc_power_off(host); } else { /*Getting the OCR is not vital to determine if it's SD or MMC, so we can move that into
mmc.candsd.c, reducing the code in here.
Yes we could ... but this way is IMO simpler, since it retains a simple invariant: that the OCR parameter to attach() methods is always valid. As one would expect! Which gives another
advantage: no surprises.
Quoted 15 lines
Review void mmc_rescan(struct work_struct *work · line 568
Quoted 12 lines
(quoted diff) +4
-1@@ -550,7 +559,10 @@ void mmc_rescan(struct work_struct *work */ err = mmc_send_op_cond(host, 0, &ocr); if (err == MMC_ERR_NONE) { - if (mmc_attach_mmc(host, ocr)) + if (mmc_host_is_spi(host)) + err = mmc_spi_read_ocr(host, &ocr); + if (err != MMC_ERR_NONE + || mmc_attach_mmc(host, ocr)) mmc_power_off(host); } else { mmc_power_off(host);This will fail to initialise a high capacity MMC card. From the MMC spec:
Quoted 2 lines
"Without the CMD58 with bits [30:29] set as "10b" in prior to the CMD1 a higher than 2GB of density of memory will remain in Idle state forever."
The first thing mmc_attach_mmc() does is reset the card...
Are you sure that "forever" means that reset will fail? That would be a very foolish thing to specify. And while I've seen strange things in specs, that would be one of the worst that's not a vendor-specific part of a papering over errata ...
I'd be inclined to leave this alone unless someone gets such a card and notices that it doesn't work. After all, lack of testing on those new (and-I-still-can't-find-one) cards is a general disclaimer.
Quoted 6 lines
Review int mmc_send_op_cond(struct mmc_host *ho · line 108
Quoted 4 lines
(quoted diff) +0
-0@@ -95,14 +106,18 @@ int mmc_send_op_cond(struct mmc_host *ho cmd.opcode = MMC_SEND_OP_COND; cmd.arg = ocr;Argument is "None", not "Ignored", so this should be 0 for SPI.
Indeed. The specs would make more sense if they said "zero" in such cases, so the language isn't in conflict with the day-to-day/commonsense uses of those words!
Quoted 7 lines
Review int mmc_send_op_cond(struct mmc_host *ho · line 112
Quoted 5 lines
(quoted diff) +3
-1- mmc_set_data_timeout(&data, card, 0); + /* Note that for MMC_SEND_EXT_CSD we could set the timeout; but + * not for the other requests. But host->card isn't set yet! + */This will break on native hosts as a timeout of 0 means exactly that.
Urgh. OK; I just grew the parameter list by one more member, which is NULL before there's a card. (You might consider setting host->card earlier...)
Quoted 12 lines
Review int mmc_send_op_cond(struct mmc_host *ho · line 121
Quoted 9 lines
(quoted diff) +9
-0+ +int mmc_spi_send_cid(struct mmc_host *host, u32 *cid) +{ + if (!mmc_host_is_spi(host)) + return mmc_send_cxd_native(host, 0, cid, MMC_SEND_CID); + + return mmc_send_cxd_data(host, MMC_SEND_CID, cid, 16); +} +As this is not SPI specific (except for its current use), why not
mmc_send_cid()?
Quoted 1 line
And the argument for it is the RCA (in native mode).
OK ... renamed, and passed "rca << 16". At least, if host->card has been set, which only happens *after* the enumeration sequence needs to fetch the CID ... which is done before it knows whether to create a card struct or not. (The SEND_ALL_CID request is used for non-SPI hosts.)
Quoted 10 lines
Review int mmc_send_op_cond(struct mmc_host *ho
Quoted 7 lines
(quoted diff) +7
-0+ +/* Enabling software CRCs can be a significant (30%) performance cost, + * and for other reasons isn't always desired; so it can be disabled. + */ +static int use_spi_crc = 1; +module_param(use_spi_crc, bool, 0); +The *_ops.c only contain function wrappers of protocol commands, not policy. So I think this is better placed where
mmc_spi_set_crc()is called.
You mean, have separate module params for SD and for MMC? It seems cleaner this way...
Quoted 13 lines
Quoted 13 lines
drivers/mmc/core/mmc.c +6
-1@@ -264,7 +264,13 @@ static int mmc_init_card(struct mmc_host/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + err =mmc_spi_send_cid (host, cid); + }else
Quoted 8 lines
drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 276
Quoted 4 lines
drivers/mmc/core/mmc.c +1
-0+ err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;A matter of taste, but wouldn't it be clearer if you separated out the crc bit and did that earlier, before the above comment?
[ ditto for SD ]
OK. The comment probably should have been updated, but I'd expect GCC will merge the two adjacent "if (it's spi)" blocks which will be the result.
Quoted 14 lines
Quoted 14 lines
drivers/mmc/core/sd_ops.c +6
-0@@ -70,6 +70,12 @@ int mmc_wait_for_app_cmd(struct mmc_host err = cmd->error;if (cmd->error ==MMC_ERR_NONE )break ; + +/* no point in retrying illegal commands! */ +if (mmc_host_is_spi (host)) { +if (cmd->resp[0 ] &R1_SPI_ILLEGAL_COMMAND ) +break ; + } }
Quoted 4 lines
drivers/mmc/core/sd_ops.c int mmc_wait_for_app_cmd(struct mmc_host · line 81
Quoted 1 line
drivers/mmc/core/sd_ops.c +0
-0return err;"Illegal command" refers to the previous command sent (and failed). So this can give false negatives.
The immediately preceding command would be MMC_APP_CMD ... ? I didn't see any language in the specs which could let me interpret this as anything other than APP_CMD failure:
When an error bit is detected in “R” mode the card will report the error in the response to the command that raised the exception. The command will not be executed and the associated state transition will not take place.
What this does is to quickly abort retries of SD card ops that were sent to MMC cards, and which always fail with ILLEGAL_COMMAND.
- Dave
======== CUT HERE
Teach the MMC/SD/SDIO core about using SPI mode.
- Use mmc_host_is_spi() so enumeration works through SPI signaling and protocols, not just the native versions.
- Provide the SPI response type flags with each request issued, including requests from the new lock/unlock code.
- Understand that some commands act a bit differently ... notably:
* OP_COND command reports busy status differently
* OP_COND command doesn't return the OCR
* APP_CMD status doesn't have an R1_APP_CMD analogue
- Understand that cmd->resp[0] and mmc_get_status() results for SPI return different values than for "native" MMC/SD protocol; this affects checking card lock status, and some others.
Those changes required some new and updated primitives:
- Provide utilities to access two SPI-only requests, and one request that wasn't previously needed:
* mmc_spi_read_ocr() ... SPI only
* mmc_spi_set_crc() ... SPI only (override by module parm)
* mmc_spi_send_cid() ... works without broadcast mode
- Updated internal routines:
* Previous mmc_send_csd() modified into mmc_send_cxd_native(); it uses native "R2" responses, which include 16 bytes of data.
* Previous mmc_send_ext_csd() becomes new mmc_send_cxd_data() helper for command-and-data access
* Bugfix to that mmc_send_cxd_data() code: dma-to-stack is unsafe/nonportable, so kmalloc a bounce buffer instead.
- Modified mmc_send_ext_csd() now uses mmc_send_cxd_data() helper
- Modified mmc_send_csd(), and new mmc_spi_send_cid(), routines use those helper routines based on whether they're native or SPI
The SPI support hasn't been tested on the new MMC4 cards (they're not widely available); likewise SD cards with 4GB and up may have surprises lurking.
--- drivers/mmc/core/core.c | 24 ++++-- drivers/mmc/core/mmc.c | 39 +++++++--- drivers/mmc/core/mmc_ops.c | 165 ++++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc_ops.h | 3 drivers/mmc/core/sd.c | 37 +++++++--- drivers/mmc/core/sd_ops.c | 32 ++++++-- 6 files changed, 232 insertions(+), 68 deletions(-)
drivers/mmc/core/mmc_ops.h +3 -0
@@ -22,6 +22,9 @@ int mmc_send_csd(struct mmc_card *card,int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd);int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status); +int mmc_send_cid (struct mmc_host *host,u32 *cid); +int mmc_spi_read_ocr (struct mmc_host *host,u32 *ocrp); +int mmc_spi_set_crc (struct mmc_host *host);#endif
drivers/mmc/core/core.c +18 -6
@@ -404,8 +404,13 @@ static void mmc_power_up(struct mmc_hostint bit =fls (host->ocr_avail) -1 ; host->ios.vdd = bit; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (mmc_host_is_spi (host)) { + host->ios.chip_select =MMC_CS_HIGH ; + host->ios.bus_mode =MMC_BUSMODE_PUSHPULL ; + }else { + host->ios.chip_select =MMC_CS_DONTCARE ; + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + } host->ios.power_mode =MMC_POWER_UP ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -424,8 +429,10 @@ static void mmc_power_off(struct mmc_hos { host->ios.clock =0 ; host->ios.vdd =0 ; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (!mmc_host_is_spi (host)) { + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + host->ios.chip_select =MMC_CS_DONTCARE ; + } host->ios.power_mode =MMC_POWER_OFF ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -541,7 +548,9 @@ void mmc_rescan(struct work_struct *work err =mmc_send_app_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_sd (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE ||mmc_attach_sd (host, ocr))mmc_power_off (host); }else {/*
@@ -550,7 +559,10 @@ void mmc_rescan(struct work_struct *work*/ err =mmc_send_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_mmc (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE + ||mmc_attach_mmc (host, ocr))mmc_power_off (host); }else {mmc_power_off (host);
drivers/mmc/core/mmc_ops.c +133 -32
265 lines not on this page · raw message
drivers/mmc/core/mmc.c +28 -11
@@ -262,9 +262,21 @@ static int mmc_init_card(struct mmc_host goto err;/* +* For SPI, enable CRC as appropriate. +*/ +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + } + +/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) + err =mmc_send_cid (host, cid); +else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -287,13 +299,15 @@ static int mmc_init_card(struct mmc_host }/* -* Set card RCA. +* For native busses: set card RCA and leave open drain mode. */ - err =mmc_set_relative_addr (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_set_relative_addr (card); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -314,13 +328,15 @@ static int mmc_init_card(struct mmc_host/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/* -* Fetch and process extened CSD. +* Fetch and process extended CSD. */ err =mmc_read_ext_csd (card);if (err !=MMC_ERR_NONE )
@@ -480,7 +496,8 @@ static void mmc_suspend(struct mmc_hostBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd.c +27 -10
@@ -319,9 +319,21 @@ static int mmc_sd_init_card(struct mmc_h goto err;/* +* For SPI, enable CRC as appropriate. +*/ +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + } + +/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) + err =mmc_send_cid (host, cid); +else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -343,13 +355,15 @@ static int mmc_sd_init_card(struct mmc_h }/* -* Set card RCA. +* For native busses: get card RCA and leave open drain mode. */ - err =mmc_send_relative_addr (host, &card->rca); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_send_relative_addr (host, &card->rca); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -369,9 +383,11 @@ static int mmc_sd_init_card(struct mmc_h/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/*
@@ -554,7 +570,8 @@ static void mmc_sd_suspend(struct mmc_hoBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd_ops.c +23 -9
@@ -70,6 +70,12 @@ int mmc_wait_for_app_cmd(struct mmc_host err = cmd->error;if (cmd->error ==MMC_ERR_NONE )break ; + +/* no point in retrying illegal commands! */ +if (mmc_host_is_spi (host)) { +if (cmd->resp[0 ] &R1_SPI_ILLEGAL_COMMAND ) +break ; + } }return err;
@@ -89,10 +95,10 @@ int mmc_app_cmd(struct mmc_host *host, sif (card) { cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; }else { cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_BCR ; } err =mmc_wait_for_cmd (host, &cmd,0 );
@@ -100,8 +106,8 @@ int mmc_app_cmd(struct mmc_host *host, sreturn err;/* Check that card supported application commands */ -if (!(cmd.resp[0 ] &R1_APP_CMD )) -return MMC_ERR_FAILED ; +if (!mmc_host_is_spi (host) && !(cmd.resp[0 ] &R1_APP_CMD )) +return (u32)-1 ;return MMC_ERR_NONE ; }
@@ -148,14 +154,18 @@ int mmc_send_app_op_cond(struct mmc_host cmd.opcode =SD_APP_OP_COND ; cmd.arg = ocr; - cmd.flags =MMC_RSP_R3 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R3 |MMC_CMD_BCR ;for (i =100 ; i; i--) { err =mmc_wait_for_app_cmd (host,NULL , &cmd,MMC_CMD_RETRIES );if (err !=MMC_ERR_NONE )break ; -if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 ) +if (mmc_host_is_spi (host)) { +/* wait until reset completes */ +if (!(cmd.resp[0 ] &R1_SPI_IDLE )) +break ; + }else if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 )break ; err =MMC_ERR_TIMEOUT ;
@@ -182,7 +192,7 @@ int mmc_send_if_cond(struct mmc_host *ho*/ cmd.opcode =SD_SEND_IF_COND ; cmd.arg = ((ocr &0xFF8000 ) !=0 ) <<8 | test_pattern; - cmd.flags =MMC_RSP_R7 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R7 |MMC_RSP_R7 |MMC_CMD_BCR ; err =mmc_wait_for_cmd (host, &cmd,0 );if (err !=MMC_ERR_NONE )
@@ -229,6 +239,8 @@ int mmc_app_send_scr(struct mmc_card *caBUG_ON (!card->host);BUG_ON (!scr); +/* NOTE: caller guarantees scr is heap-allocated */ + err =mmc_app_cmd (card->host, card);if (err !=MMC_ERR_NONE )return err;
@@ -242,7 +254,7 @@ int mmc_app_send_scr(struct mmc_card *ca cmd.opcode =SD_APP_SEND_SCR ; cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =8 ; data.blocks =1 ;
@@ -278,6 +290,8 @@ int mmc_sd_switch(struct mmc_card *card,BUG_ON (!card);BUG_ON (!card->host); +/* NOTE: caller guarantees resp is heap-allocated */ + mode = !!mode; value &=0xF ;
@@ -292,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, cmd.arg = mode <<31 |0x00FFFFFF ; cmd.arg &= ~(0xF << (group *4 )); cmd.arg |= value << (group *4 ); - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =64 ; data.blocks =1 ;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
spi-devel-general mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 200707261458.55558.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
Grr ... sent wrong version. This passes "host" not "host->card" in one place (GCC would warn, and is otherwise the same.
====== CUT HERE
Teach the MMC/SD/SDIO core about using SPI mode.
- Use mmc_host_is_spi() so enumeration works through SPI signaling and protocols, not just the native versions.
- Provide the SPI response type flags with each request issued, including requests from the new lock/unlock code.
- Understand that some commands act a bit differently ... notably:
* OP_COND command reports busy status differently
* OP_COND command doesn't return the OCR
* APP_CMD status doesn't have an R1_APP_CMD analogue
- Understand that cmd->resp[0] and mmc_get_status() results for SPI return different values than for "native" MMC/SD protocol; this affects checking card lock status, and some others.
Those changes required some new and updated primitives:
- Provide utilities to access two SPI-only requests, and one request that wasn't previously needed:
* mmc_spi_read_ocr() ... SPI only
* mmc_spi_set_crc() ... SPI only (override by module parm)
* mmc_spi_send_cid() ... works without broadcast mode
- Updated internal routines:
* Previous mmc_send_csd() modified into mmc_send_cxd_native(); it uses native "R2" responses, which include 16 bytes of data.
* Previous mmc_send_ext_csd() becomes new mmc_send_cxd_data() helper for command-and-data access
* Bugfix to that mmc_send_cxd_data() code: dma-to-stack is unsafe/nonportable, so kmalloc a bounce buffer instead.
- Modified mmc_send_ext_csd() now uses mmc_send_cxd_data() helper
- Modified mmc_send_csd(), and new mmc_spi_send_cid(), routines use those helper routines based on whether they're native or SPI
The SPI support hasn't been tested on the new MMC4 cards (they're not widely available); likewise SD cards with 4GB and up may have surprises lurking.
--- drivers/mmc/core/core.c | 24 ++++-- drivers/mmc/core/mmc.c | 39 +++++++--- drivers/mmc/core/mmc_ops.c | 165 ++++++++++++++++++++++++++++++++++++--------- drivers/mmc/core/mmc_ops.h | 3 drivers/mmc/core/sd.c | 37 +++++++--- drivers/mmc/core/sd_ops.c | 32 ++++++-- 6 files changed, 232 insertions(+), 68 deletions(-)
drivers/mmc/core/mmc_ops.h +3 -0
@@ -22,6 +22,9 @@ int mmc_send_csd(struct mmc_card *card,int mmc_send_ext_csd (struct mmc_card *card,u8 *ext_csd);int mmc_switch (struct mmc_card *card,u8 set,u8 index,u8 value);int mmc_send_status (struct mmc_card *card,u32 *status); +int mmc_send_cid (struct mmc_host *host,u32 *cid); +int mmc_spi_read_ocr (struct mmc_host *host,u32 *ocrp); +int mmc_spi_set_crc (struct mmc_host *host);#endif
drivers/mmc/core/core.c +18 -6
@@ -404,8 +404,13 @@ static void mmc_power_up(struct mmc_hostint bit =fls (host->ocr_avail) -1 ; host->ios.vdd = bit; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (mmc_host_is_spi (host)) { + host->ios.chip_select =MMC_CS_HIGH ; + host->ios.bus_mode =MMC_BUSMODE_PUSHPULL ; + }else { + host->ios.chip_select =MMC_CS_DONTCARE ; + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + } host->ios.power_mode =MMC_POWER_UP ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -424,8 +429,10 @@ static void mmc_power_off(struct mmc_hos { host->ios.clock =0 ; host->ios.vdd =0 ; - host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; - host->ios.chip_select =MMC_CS_DONTCARE ; +if (!mmc_host_is_spi (host)) { + host->ios.bus_mode =MMC_BUSMODE_OPENDRAIN ; + host->ios.chip_select =MMC_CS_DONTCARE ; + } host->ios.power_mode =MMC_POWER_OFF ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ;
@@ -541,7 +548,9 @@ void mmc_rescan(struct work_struct *work err =mmc_send_app_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_sd (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE ||mmc_attach_sd (host, ocr))mmc_power_off (host); }else {/*
@@ -550,7 +559,10 @@ void mmc_rescan(struct work_struct *work*/ err =mmc_send_op_cond (host,0 , &ocr);if (err ==MMC_ERR_NONE ) { -if (mmc_attach_mmc (host, ocr)) +if (mmc_host_is_spi (host)) + err =mmc_spi_read_ocr (host, &ocr); +if (err !=MMC_ERR_NONE + ||mmc_attach_mmc (host, ocr))mmc_power_off (host); }else {mmc_power_off (host);
drivers/mmc/core/mmc_ops.c +133 -32
265 lines not on this page · raw message
drivers/mmc/core/mmc.c +28 -11
@@ -262,9 +262,21 @@ static int mmc_init_card(struct mmc_host goto err;/* +* For SPI, enable CRC as appropriate. +*/ +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + } + +/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) + err =mmc_send_cid (host, cid); +else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -287,13 +299,15 @@ static int mmc_init_card(struct mmc_host }/* -* Set card RCA. +* For native busses: set card RCA and leave open drain mode. */ - err =mmc_set_relative_addr (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_set_relative_addr (card); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -314,13 +328,15 @@ static int mmc_init_card(struct mmc_host/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/* -* Fetch and process extened CSD. +* Fetch and process extended CSD. */ err =mmc_read_ext_csd (card);if (err !=MMC_ERR_NONE )
@@ -480,7 +496,8 @@ static void mmc_suspend(struct mmc_hostBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd.c +27 -10
@@ -319,9 +319,21 @@ static int mmc_sd_init_card(struct mmc_h goto err;/* +* For SPI, enable CRC as appropriate. +*/ +if (mmc_host_is_spi (host)) { + err =mmc_spi_set_crc (host); +if (err !=MMC_ERR_NONE ) + goto err; + } + +/* * Fetch CID from card. */ - err =mmc_all_send_cid (host, cid); +if (mmc_host_is_spi (host)) + err =mmc_send_cid (host, cid); +else + err =mmc_all_send_cid (host, cid);if (err !=MMC_ERR_NONE ) goto err;
@@ -343,13 +355,15 @@ static int mmc_sd_init_card(struct mmc_h }/* -* Set card RCA. +* For native busses: get card RCA and leave open drain mode. */ - err =mmc_send_relative_addr (host, &card->rca); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_send_relative_addr (host, &card->rca); +if (err !=MMC_ERR_NONE ) + goto free_card; -mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); +mmc_set_bus_mode (host,MMC_BUSMODE_PUSHPULL ); + }if (!oldcard) {/*
@@ -369,9 +383,11 @@ static int mmc_sd_init_card(struct mmc_h/* * Select card, as all following commands rely on that. */ - err =mmc_select_card (card); -if (err !=MMC_ERR_NONE ) - goto free_card; +if (!mmc_host_is_spi (host)) { + err =mmc_select_card (card); +if (err !=MMC_ERR_NONE ) + goto free_card; + }if (!oldcard) {/*
@@ -554,7 +570,8 @@ static void mmc_sd_suspend(struct mmc_hoBUG_ON (!host->card);mmc_claim_host (host); -mmc_deselect_cards (host); +if (!mmc_host_is_spi (host)) +mmc_deselect_cards (host); host->card->state &= ~MMC_STATE_HIGHSPEED ;mmc_release_host (host); }
drivers/mmc/core/sd_ops.c +23 -9
@@ -70,6 +70,12 @@ int mmc_wait_for_app_cmd(struct mmc_host err = cmd->error;if (cmd->error ==MMC_ERR_NONE )break ; + +/* no point in retrying illegal commands! */ +if (mmc_host_is_spi (host)) { +if (cmd->resp[0 ] &R1_SPI_ILLEGAL_COMMAND ) +break ; + } }return err;
@@ -89,10 +95,10 @@ int mmc_app_cmd(struct mmc_host *host, sif (card) { cmd.arg = card->rca <<16 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_AC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; }else { cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_BCR ; } err =mmc_wait_for_cmd (host, &cmd,0 );
@@ -100,8 +106,8 @@ int mmc_app_cmd(struct mmc_host *host, sreturn err;/* Check that card supported application commands */ -if (!(cmd.resp[0 ] &R1_APP_CMD )) -return MMC_ERR_FAILED ; +if (!mmc_host_is_spi (host) && !(cmd.resp[0 ] &R1_APP_CMD )) +return (u32)-1 ;return MMC_ERR_NONE ; }
@@ -148,14 +154,18 @@ int mmc_send_app_op_cond(struct mmc_host cmd.opcode =SD_APP_OP_COND ; cmd.arg = ocr; - cmd.flags =MMC_RSP_R3 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R3 |MMC_CMD_BCR ;for (i =100 ; i; i--) { err =mmc_wait_for_app_cmd (host,NULL , &cmd,MMC_CMD_RETRIES );if (err !=MMC_ERR_NONE )break ; -if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 ) +if (mmc_host_is_spi (host)) { +/* wait until reset completes */ +if (!(cmd.resp[0 ] &R1_SPI_IDLE )) +break ; + }else if (cmd.resp[0 ] &MMC_CARD_BUSY || ocr ==0 )break ; err =MMC_ERR_TIMEOUT ;
@@ -182,7 +192,7 @@ int mmc_send_if_cond(struct mmc_host *ho*/ cmd.opcode =SD_SEND_IF_COND ; cmd.arg = ((ocr &0xFF8000 ) !=0 ) <<8 | test_pattern; - cmd.flags =MMC_RSP_R7 |MMC_CMD_BCR ; + cmd.flags =MMC_RSP_SPI_R7 |MMC_RSP_R7 |MMC_CMD_BCR ; err =mmc_wait_for_cmd (host, &cmd,0 );if (err !=MMC_ERR_NONE )
@@ -229,6 +239,8 @@ int mmc_app_send_scr(struct mmc_card *caBUG_ON (!card->host);BUG_ON (!scr); +/* NOTE: caller guarantees scr is heap-allocated */ + err =mmc_app_cmd (card->host, card);if (err !=MMC_ERR_NONE )return err;
@@ -242,7 +254,7 @@ int mmc_app_send_scr(struct mmc_card *ca cmd.opcode =SD_APP_SEND_SCR ; cmd.arg =0 ; - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =8 ; data.blocks =1 ;
@@ -278,6 +290,8 @@ int mmc_sd_switch(struct mmc_card *card,BUG_ON (!card);BUG_ON (!card->host); +/* NOTE: caller guarantees resp is heap-allocated */ + mode = !!mode; value &=0xF ;
@@ -292,7 +306,7 @@ int mmc_sd_switch(struct mmc_card *card, cmd.arg = mode <<31 |0x00FFFFFF ; cmd.arg &= ~(0xF << (group *4 )); cmd.arg |= value << (group *4 ); - cmd.flags =MMC_RSP_R1 |MMC_CMD_ADTC ; + cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; data.blksz =64 ; data.blocks =1 ;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
In reply to a message not in the archiveQuoted 6 lines · On Thu, 26 Jul 2007 14:58:54 -0700 David Brownell <[email protected]> wrote:
Yes we could ... but this way is IMO simpler, since it retains a simple invariant: that the OCR parameter to
attach()methods is always valid. As one would expect! Which gives another
advantage: no surprises.
Fair enough. I'm not that attached to it.
Quoted 8 lines
Quoted 7 lines
This will fail to initialise a high capacity MMC card. From the MMC spec:
"Without the CMD58 with bits [30:29] set as "10b" in prior to the CMD1 a higher than 2GB of density of memory will remain in Idle state forever."
Quoted 8 lines
The first thing
mmc_attach_mmc()does is reset the card...Are you sure that "forever" means that reset will fail? That would be a very foolish thing to specify. And while I've seen strange things in specs, that would be one of the worst that's not a vendor-specific part of a papering over errata ...
Well, it's rather straight-forward if you think about it. As they've changed the addressing scheme, but retain the original commands, a host that does not understand the new scheme would utterly destroy the data. So the card refuses to init unless the host can present some evidence that it understands the new scheme.
Quoted 5 lines
I'd be inclined to leave this alone unless someone gets such a card and notices that it doesn't work. After all, lack of testing on those new (and-I-still-can't-find-one) cards is a general disclaimer.
Too bad I have no SPI setup here. :(
Please add a comment that we know that MMC 4.2 is broken and can be fixed once someone is able to test.
Quoted 8 lines
Quoted 4 lines
The *_ops.c only contain function wrappers of protocol commands, not policy. So I think this is better placed where
mmc_spi_set_crc()is called.You mean, have separate module params for SD and for MMC? It seems cleaner this way...
No, that would be silly. You'd probably have to stick it in core.c and reference it from mmc.c and sd.c.
The reason I complain is that seeing mmc_spi_set_crc() will look like it always activates CRC, as all other functions in *_ops.c are simple wrappers around protocol ops.
Quoted 8 lines
Quoted 3 lines
"Illegal command" refers to the previous command sent (and failed). So this can give false negatives.
The immediately preceding command would be
MMC_APP_CMD... ? I didn't see any language in the specs which could let me interpret this as anything other thanAPP_CMDfailure:
Quoted 9 lines
When an error bit is detected in “R” mode the card will report the error in the response to the command that raised the exception. The command will not be executed and the associated state transition will not take place.
What this does is to quickly abort retries of SD card ops that were sent to MMC cards, and which always fail with
ILLEGAL_COMMAND.
I hate this part of the spec. The SD spec also claims:
"Clear condition B: Always related to the previous command"
But in the SPI section, they back out of that claim. So for SPI, things seems somewhat sane.
(The MMC spec is even more hilarious. I lists clear condition A and B, but never explains what they mean. And looking at some older card specs, it seems that the MMC spec had the same conditions and definitions as SD *sigh*)
We can proceed with your code, although I'm still a bit nervous about sticking that parsing in there.
Rgds
Signature · 15 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 20070801170220.3c5ccff6-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
Quoted 19 lines · Pierre Ossman
Quoted 7 lines · On Thu, 26 Jul 2007 14:58:54 -0700 David Brownell <[email protected]> wrote:
Quoted 6 lines
This will fail to initialise a high capacity MMC card. From the MMC spec:
"Without the CMD58 with bits [30:29] set as "10b" in prior to the CMD1 a higher than 2GB of density of memory will remain in Idle state forever."
Quoted 8 lines
The first thing
mmc_attach_mmc()does is reset the card...Are you sure that "forever" means that reset will fail? That would be a very foolish thing to specify. And while I've seen strange things in specs, that would be one of the worst that's not a vendor-specific part of a papering over errata ...
Quoted 2 lines
Well, it's rather straight-forward if you think about it. As they've changed the addressing scheme,
Since I've not seen the MMC4 spec, I couldn't know. :)
And the nearest approximation of MMC4 I've got (an early Samsung spec) says CMD58 has argument "none" (== 0) ... while one of the cards I've got rejected CMD58 before CMD1. So "straightforward" is not a word I could apply here...
Quoted 4 lines
but retain the original commands, a host
that does not understand the new scheme would utterly destroy the data. So the card refuses to init unless the host can present some evidence that it understands the new scheme.
Right, but that doesn't answer my question: whether the card is specified to lock up "forever", or whether (as I'd expect) reinitialization (starting with reset) works the normal way.
Quoted 7 lines
Quoted 5 lines
I'd be inclined to leave this alone unless someone gets such a card and notices that it doesn't work. After all, lack of testing on those new (and-I-still-can't-find-one) cards is a general disclaimer.
Too bad I have no SPI setup here. :(
My current setup uses a breadboard, so it can hook up to the real SPI hardware ... I started out using bitbanged SPI to a card which normally muxed to a "native" controller. Maybe one of those could work for you.
Quoted 2 lines
Please add a comment that we know that MMC 4.2 is broken and can be fixed once someone is able to test.
Doesn't the general disclaimer that MMC4 cards haven't been tested already cover that part? If you like, just tweak the patch comments to clarify.
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
The *_ops.c only contain function wrappers of protocol commands, not policy. So I think this is better placed where
mmc_spi_set_crc()is called.You mean, have separate module params for SD and for MMC? It seems cleaner this way...
Quoted 6 lines
No, that would be silly. You'd probably have to stick it in
core.cand reference it frommmc.candsd.c.The reason I complain is that seeing
mmc_spi_set_crc()will look like it always activates CRC, as all other functions in *_ops.c are simple wrappers around protocol ops.
So, move the param and mmc_spi_set_crc() into core.c then, and leave the calls where they are?
Can we do that as a separate patch? You said below we can proceed, which suggests to me that now's the time to convert to incrmentals. I don't mind a few more update patches, but it'd be easier to do them against say a git-mmc patch against 2.6.23-rc2 ...
Quoted 17 lines
Quoted 7 lines
Quoted 2 lines
"Illegal command" refers to the previous command sent (and failed). So this can give false negatives.
The immediately preceding command would be
MMC_APP_CMD... ? I didn't see any language in the specs which could let me interpret this as anything other thanAPP_CMDfailure:Quoted 9 lines
When an error bit is detected in “R” mode the card will report the error in the response to the command that raised the exception. The command will not be executed and the associated state transition will not take place.
What this does is to quickly abort retries of SD card ops that were sent to MMC cards, and which always fail with
ILLEGAL_COMMAND.
Quoted 6 lines
I hate this part of the spec. The SD spec also claims:
"Clear condition B: Always related to the previous command"
But in the SPI section, they back out of that claim. So for SPI, things seems somewhat sane.
I don't have either of those specs. "Previous command" isn't particularly clear, though maybe in context it could be ... it might mean the immediately preceding command, or the one before that, depending on usage.
Quoted 4 lines
(The MMC spec is even more hilarious. I lists clear condition A and B, but never explains what they mean. And looking at some older card specs, it seems that the MMC spec had the same conditions and definitions as SD *sigh*)
Yeech!
Quoted 2 lines
We can proceed with your code, although I'm still a bit nervous about sticking that parsing in there.
I don't think you need to be nervous about that. It clearly works, and to those of us who've worked this driver and had to become one with the docs we have, this hasn't raised flags.
It is however *much* better not to need to map the SPI status codes into the "native" ones. As you implicitly noted above, expecting them to behave the same doesn't seem like a good idea!
- Dave
Quoted 8 lines
Rgds
Signature · 5 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
spi-devel-general mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 200708011002.28801.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
Quoted 7 lines · On Wed, 1 Aug 2007 10:02:28 -0700 David Brownell…
Quoted 3 lines · Pierre Ossman
Well, it's rather straight-forward if you think about it. As they've changed the addressing scheme,
Since I've not seen the MMC4 spec, I couldn't know. :)
You can see the same thing in SD with the if cond thingy.
Quoted 5 lines
And the nearest approximation of MMC4 I've got (an early Samsung spec) says CMD58 has argument "none" (== 0) ... while one of the cards I've got rejected CMD58 before CMD1. So "straightforward" is not a word I could apply here...
We can just code it so that failure is acceptable for that initial CMD58.
Quoted 10 lines
Quoted 5 lines
but retain the original commands, a host
that does not understand the new scheme would utterly destroy the data. So the card refuses to init unless the host can present some evidence that it understands the new scheme.Right, but that doesn't answer my question: whether the card is specified to lock up "forever", or whether (as I'd expect) reinitialization (starting with reset) works the normal way.
Like SDHC, it never goes out of idle mode.
Quoted 6 lines
My current setup uses a breadboard, so it can hook up to the real SPI hardware ... I started out using bitbanged SPI to a card which normally muxed to a "native" controller. Maybe one of those could work for you.
Well, I'd need something to do the banging.
Quoted 8 lines
Quoted 3 lines
Please add a comment that we know that MMC 4.2 is broken and can be fixed once someone is able to test.
Doesn't the general disclaimer that MMC4 cards haven't been tested already cover that part? If you like, just tweak the patch comments to clarify.
The disclaimer is in the commit message. And people rarely go digging into the history for documentation.
I'll add the comment before committing.
Quoted 4 lines
So, move the param and
mmc_spi_set_crc()intocore.cthen, and leave the calls where they are?
mmc_spi_set_crc() fits quite nicely into mmc_ops.c, so no need for moving that. I was thinking more along the lines of:
extern int mmc_spi_crc_enabled;
mmc_spi_set_crc(host, mmc_spi_crc_enabled);
Quoted 5 lines
Can we do that as a separate patch? You said below we can proceed, which suggests to me that now's the time to convert to incrmentals. I don't mind a few more update patches, but it'd be easier to do them against say a git-mmc patch against 2.6.23-rc2 ...
Sure.
Quoted 5 lines
Quoted 5 lines
I hate this part of the spec. The SD spec also claims:
"Clear condition B: Always related to the previous command"
Quoted 8 lines
Quoted 2 lines
But in the SPI section, they back out of that claim. So for SPI, things seems somewhat sane.
I don't have either of those specs. "Previous command" isn't particularly clear, though maybe in context it could be ... it might mean the immediately preceding command, or the one before that, depending on usage.
That's from the public SD physical spec. And the wording doesn't get much clearer. Sometimes they also talk about the "last" command, which is equally ambiguous.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070802145445.1118d1e7-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 3/4] MMC core learns about SPI
Quoted 11 lines · Pierre Ossman
Quoted 4 lines
So, move the param and
mmc_spi_set_crc()intocore.cthen, and leave the calls where they are?
mmc_spi_set_crc()fits quite nicely intommc_ops.c, so no need for moving that. I was thinking more along the lines of:extern int
mmc_spi_crc_enabled;
mmc_spi_set_crc(host, mmc_spi_crc_enabled);
OK.
Quoted 8 lines
Quoted 5 lines
Can we do that as a separate patch? You said below we can proceed, which suggests to me that now's the time to convert to incrmentals. I don't mind a few more update patches, but it'd be easier to do them against say a git-mmc patch against 2.6.23-rc2 ...
Sure.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
PATCH 4/4 mmc_spi host driver
In reply to a message not in the archiveThis is the latest version of the MMC-over-SPI support. It works on 2.6.22-git5, along with the preceding patches which teach the rest of the MMC stack about SPI so that this host driver can focus on doing only lowlevel SPI-specific stuff.
It's been lightly tested on MMC and SD cards, reading and writing ext3 filesystems (including fsck). This includes CRC mode, which is now enabled by default.
The main issue of note is that sometimes cards need to be power cycled to recover after certain faults. In some cases, it may be necessary to disable CRCs. ("modprobe mmc_core use_spi_crc=n")
Changes from previous versions include more code shrinkage and cleanup, reducing the number of I/O requests needed per operation, and moving even more nuances into the MMC core code.
--- drivers/mmc/host/Kconfig | 13 drivers/mmc/host/Makefile | 1 drivers/mmc/host/mmc_spi.c | 1416 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/spi/mmc_spi.h | 33 + 4 files changed, 1463 insertions(+)
drivers/mmc/host/Kconfig +13 -0
@@ -100,3 +100,16 @@ config MMC_TIFM_SD To compile this driver as a module, choose M here: the module will be called tifm_sd. +config MMC_SPI + tristate "MMC/SD over SPI" + depends on MMC && SPI_MASTER && !HIGHMEM && EXPERIMENTAL + select CRC7 + select CRC_ITU_T + help + Some systems accss MMC/SD cards using a SPI controller instead of + using a "native" MMC/SD controller. This has a disadvantage of + being relatively high overhead, but a compensating advantage of + working on many systems without dedicated MMC/SD controllers. + + If unsure, or if your system has no SPI master driver, say N. +
drivers/mmc/host/Makefile +1 -0
@@ -15,4 +15,5 @@ obj-$(CONFIG_MMC_AU1X) += au1xmmc.o obj-$(CONFIG_MMC_OMAP) += omap.o obj-$(CONFIG_MMC_AT91) += at91_mci.o obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o +obj-$(CONFIG_MMC_SPI) += mmc_spi.o
include/linux/spi/mmc_spi.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef __LINUX_SPI_MMC_SPI_H +#define __LINUX_SPI_MMC_SPI_H + +struct device ; +struct mmc_host ; + +/* Put this in platform_data of a device being used to manage an MMC/SD +* card slot. (Modeled after PXA mmc glue; see that for usage examples.) +* +* REVISIT This is not a spi-specific notion. Any card slot should be +* able to handle it. If the MMC core doesn't adopt this kind of notion, +* switch the "struct device *" parameters over to "struct spi_device *". +*/ +struct mmc_spi_platform_data { +/* driver activation and (optional) card detect irq hookup */ +int (*init)(struct device *, +irqreturn_t (*)(int ,void *), +void *); +void (*exit)(struct device *,void *); + +/* sense switch on sd cards */ +int (*get_ro)(struct device *); + +/* how long to debounce card detect, in msecs */ +u16 detect_delay; + +/* power management */ +u16 powerup_msecs;/* delay of up to 250 msec */ +u32 ocr_mask;/* available voltages */ +void (*setpower)(struct device *,unsigned int maskval); +}; + +#endif /* __LINUX_SPI_MMC_SPI_H */
drivers/mmc/host/mmc_spi.c new file +1416 -0
1,416 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707141508.07555.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 9 lines · On Sat, 14 Jul 2007 15:08:06 -0700 David Brownell…
drivers/mmc/host/Kconfig +3
-0@@ -100,3 +100,16 @@ config MMC_TIFM_SD To compile this driver as a module, choose M here: the module will be called tifm_sd. +config MMC_SPI + tristate "MMC/SD over SPI" + depends on MMC && SPI_MASTER && !HIGHMEM && EXPERIMENTAL
drivers/mmc/host/Kconfig config MMC_TIFM_SD · line 115
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+ select CRC7 + select CRC_ITU_T + help + Some systems accss MMC/SD cards using a SPI controller instead of + using a "native" MMC/SD controller. This has a disadvantage of + being relatively high overhead, but a compensating advantage of + working on many systems without dedicated MMC/SD controllers. + + If unsure, or if your system has no SPI master driver, say N. +
It is customary to have "(Experimental)" in the description aswell.
drivers/mmc/host/Kconfig
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+ +static int +mmc_spi_readbytes(struct mmc_spi_host *host, unsigned len) +{ + int status; + + if (len > sizeof *host->data) { + WARN_ON(1); + return -EIO; + }
sizeof without parenthesis? Heathen!
Quoted 11 lines
drivers/mmc/host/Kconfig +11
-0+ +/* + * Note that for SPI, cmd->resp[0] is not the same data as "native" protocol + * hosts return! The low byte holds R1_SPI bits. The next byte may hold + * R2_SPI bits ... for SEND_STATUS, or after data read errors. + * + * cmd->resp[1] holds any four-byte response, for R3 (READ_OCR) and on + * newer cards R7 (IF_COND). + */ + +static char *maptype(struct mmc_command *cmd)
drivers/mmc/host/Kconfig
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+{ + switch (mmc_spi_resp_type(cmd)) { + case MMC_RSP_SPI_R1: return "R1"; + case MMC_RSP_SPI_R1B: return "R1B"; + case MMC_RSP_SPI_R2: return "R2"; + case MMC_RSP_SPI_R3: return "R3/R7"; + default: return "?"; + } +} +
I'm trying to move all generic debugging code into the core, so I would prefer if you would have a look at extending that to fit your needs. That way everyone wins.
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+ + /* Status byte: the entire seven-bit R1 response. */ + if (cmd->resp[0] != 0) { + if (R1_SPI_COM_CRC & cmd->resp[0]) { + cmd->error = MMC_ERR_BADCRC; + value = -EILSEQ; + } else if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS + | R1_SPI_ILLEGAL_COMMAND) + & cmd->resp[0]) { + cmd->error = MMC_ERR_INVALID;
drivers/mmc/host/Kconfig
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+ value = -EINVAL; + } else if ((R1_SPI_ERASE_SEQ | R1_SPI_ERASE_RESET) + & cmd->resp[0]) { + cmd->error = MMC_ERR_FAILED; + value = -EINVAL; + } /* else R1_SPI_IDLE, "it's resetting" */ + + if (value < 0) + goto fail; + }
I'd still preferred that you'd didn't try to decode this here. And your code demostrates why; CRC error and illegal command both signal problems with the previous command, not the current one, so this code would be failing the wrong request.
drivers/mmc/host/Kconfig
Quoted 7 lines
drivers/mmc/host/Kconfig +7
-0+ + switch (mmc_spi_resp_type(cmd)) { + + /* SPI R1B == R1 + busy; STOP_TRANSMISSION (for multiblock reads) + * and less-common stuff like various erase operations. + */ + case MMC_RSP_SPI_R1B:
for (i = 0;i < mmc_spi_resp_size(cmd);i++)
cmd->resp[i/4] |= *cp++ << (24 - (i % 4) * 8);
if (cmd->flags & MMC_SPI_RSP_BUSY)
mmc_spi_wait_unbusy();
That's the whole point of hacking up the response types into components, so that the host driver doesn't have to care.
You can keep your design if you'd like, but I really think this is cleaner and more layered.
drivers/mmc/host/Kconfig
Quoted 11 lines
drivers/mmc/host/Kconfig +11
-0+ + /* We can handle most commands (except block reads) in one full + * duplex I/O operation before either starting the next transfer + * (data block or command) or else deselecting the card. + * + * First, write 7 bytes: + * - an all-ones byte to ensure the card is ready + * - opcode byte (plus start and transmission bits) + * - four bytes of big-endian argument + * - crc7 (plus end bit) ... always computed, it's cheap + *
I thought your argument against always using crc7 was that it wasn't cheap? Colour me confused.
drivers/mmc/host/Kconfig
Quoted 10 lines
drivers/mmc/host/Kconfig +10
-0+ if (status == -EILSEQ) + data->error = MMC_ERR_BADCRC; + else if (status == -ETIMEDOUT) + data->error = MMC_ERR_TIMEOUT; + else if (status == -EINVAL) + data->error = MMC_ERR_INVALID; + else if (data->error == MMC_ERR_NONE) + data->error = MMC_ERR_FAILED; + break; + }
At least we agree on error codes. This is precisely the change I have pending in my patch set to remove the MMC_ERR_* mess. :)
There are a few outstanding issues, but they are really minor so this could very soon get into my -mm branch. I need a MAINTAINERS entry aswell.
I'd like to see those REVISIT things attended to before I push the stuff to Linus though.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070726200202.5e5dcf62-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 9 lines · Pierre Ossman
Quoted 6 lines · On Sat, 14 Jul 2007 15:08:06 -0700 David Brownell <[email protected]> wrote:
drivers/mmc/host/Kconfig +0
-0@@ -100,3 +100,16 @@ config MMC_TIFM_SD To compile this driver as a module, choose M here: the module will be called tifm_sd.
Quoted 6 lines
drivers/mmc/host/Kconfig config MMC_TIFM_SD · line 105
Quoted 4 lines
drivers/mmc/host/Kconfig +3
-0+config MMC_SPI + tristate "MMC/SD over SPI" + depends on MMC && SPI_MASTER && !HIGHMEM && EXPERIMENTALIt is customary to have "(Experimental)" in the description aswell.
OK ... actually "(EXPERIMENTAL)" shouting it to the rooftops.
Quoted 11 lines
drivers/mmc/host/Kconfig
Quoted 9 lines
drivers/mmc/host/Kconfig +9
-0+static int +mmc_spi_readbytes(struct mmc_spi_host *host, unsigned len) +{ + int status; + + if (len > sizeof *host->data) { + WARN_ON(1); + return -EIO; + }sizeof without parenthesis? Heathen!
Most style guides I've used say to do it that way; it's not a function call! It should now meet your pagan mores.
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/Kconfig +7
-0+static char *maptype(struct mmc_command *cmd) +{ + switch (mmc_spi_resp_type(cmd)) { + case MMC_RSP_SPI_R1: return "R1"; + case MMC_RSP_SPI_R1B: return "R1B"; + case MMC_RSP_SPI_R2: return "R2"; + case MMC_RSP_SPI_R3: return "R3/R7";
Quoted 8 lines
drivers/mmc/host/Kconfig
Quoted 4 lines
drivers/mmc/host/Kconfig +4
-0+ default: return "?"; + } +} +I'm trying to move all generic debugging code into the core, so I would prefer if you would have a look at extending that to fit your needs. That way everyone wins.
That's not generic, it's driver-specific. :)
If anything comes to mind, I'll see about doing that. In that case I'd as soon have the thing compile itself completely out of the picture on non-debug builds...
Quoted 14 lines
Quoted 14 lines
drivers/mmc/host/Kconfig +14
-0+ + /* Status byte: the entire seven-bit R1 response. */ + if (cmd->resp[0] != 0) { + if (R1_SPI_COM_CRC & cmd->resp[0]) { + cmd->error = MMC_ERR_BADCRC; + value = -EILSEQ; + } else if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS + | R1_SPI_ILLEGAL_COMMAND) + & cmd->resp[0]) { + cmd->error = MMC_ERR_INVALID; + value = -EINVAL; + } else if ((R1_SPI_ERASE_SEQ | R1_SPI_ERASE_RESET) + & cmd->resp[0]) { + cmd->error = MMC_ERR_FAILED;
Quoted 8 lines
drivers/mmc/host/Kconfig
Quoted 6 lines
drivers/mmc/host/Kconfig +6
-0+ value = -EINVAL; + } /* else R1_SPI_IDLE, "it's resetting" */ + + if (value < 0) + goto fail; + }I'd still preferred that you'd didn't try to decode this here.
You said you weren't going to update the MMC core to check the status bits after every request, and I'm certainly not about to change *EVERY MMC/SD REQUEST* to adopt a radically different callling convention either!!
Which leaves us needing a solution that actually works, and this seems to be the only option: continue to use the current calling convention, ->error fields report the failures.
Quoted 3 lines
And your code demostrates why; CRC error and illegal command both signal problems with the previous command, not the current one, so this code would be failing the wrong request.
Not according to any docs I've got. Both of those are 'R' mode fault reports. My previous reply quoted the relevant text:
When an error bit is detected in “R” mode the card will report the error in the response to the command that raised the exception. The command will not be executed and the associated state transition will not take place.
Note: ** "in the response to the command that raised the exception" ** ... no mention of any delay. You're talking as if these were type "X" instead!
Quoted 11 lines
drivers/mmc/host/Kconfig
Quoted 8 lines
drivers/mmc/host/Kconfig +7
-0+ + switch (mmc_spi_resp_type(cmd)) { + + /* SPI R1B == R1 + busy; STOP_TRANSMISSION (for multiblock reads) + * and less-common stuff like various erase operations. + */ + case MMC_RSP_SPI_R1B:for (i = 0;i < mmc_spi_resp_size(cmd);i++)
cmd->resp[i/4] |= *cp++ << (24 - (i % 4) * 8);
The test for the new MMC_SPI_RSP_BUSY could be done; I won't do it for now since it'd just take more time to finish this stuff.
Quoted 2 lines
if (
cmd->flags&MMC_SPI_RSP_BUSY)mmc_spi_wait_unbusy();
However, that bit looks deeply messy. You'd be splitting the OCR (and other SPI four byte responses) into two different words, for example!
Or to put it differently, this way the structure that's passed up to the core is actually meaningful: one word of status, and maybe another word of data. And *never* any mixed status/data words that'd need disentangling.
After all, if you really wanted to provide raw protocol data to the mmc core, cmd->resp[] would be bytes, not 32-bit words in cpu-order.
Quoted 5 lines
That's the whole point of hacking up the response types into components, so that the host driver doesn't have to care.
You can keep your design if you'd like, but I really think this is cleaner and more layered.
I guess we'll have to disagree on this for now. If it matters, it can be changed later; but I certainly couldn't call mixing data and status as an improvement!!
Quoted 6 lines
Quoted 6 lines
drivers/mmc/host/Kconfig +6
-0+ + /* We can handle most commands (except block reads) in one full + * duplex I/O operation before either starting the next transfer + * (data block or command) or else deselecting the card. + * + * First, write 7 bytes:
Quoted 8 lines
drivers/mmc/host/Kconfig
Quoted 5 lines
drivers/mmc/host/Kconfig +5
-0+ * - an all-ones byte to ensure the card is ready + * - opcode byte (plus start and transmission bits) + * - four bytes of big-endian argument + * - crc7 (plus end bit) ... always computed, it's cheap + *I thought your argument against always using crc7 was that it wasn't cheap? Colour me confused.
The data block CRC is quite expensive, yes. The CRC7 isn't; and in any case, you had pretty much demanded that it always be computed (to eliminate the #define for the crc needed in the card reset command) ...
Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/Kconfig +5
-0+ if (status == -EILSEQ) + data->error = MMC_ERR_BADCRC; + else if (status == -ETIMEDOUT) + data->error = MMC_ERR_TIMEOUT; + else if (status == -EINVAL)
Quoted 8 lines
drivers/mmc/host/Kconfig
Quoted 5 lines
drivers/mmc/host/Kconfig +5
-0+ data->error = MMC_ERR_INVALID; + else if (data->error == MMC_ERR_NONE) + data->error = MMC_ERR_FAILED; + break; + }At least we agree on error codes. This is precisely the change I have pending in my patch set to remove the MMC_ERR_* mess. :)
I had to pick something. ;)
Quoted 2 lines
There are a few outstanding issues, but they are really minor so this could very soon get into my -mm branch.
Appended is a version of the mmc_spi patch with most of the issues above addressed.
I'll be glad to see this get into your MM branch ... that'll mean it can more easily get to the people who will use it, and who will start shaking out the next set of issues.
Quoted 1 line
I need a
MAINTAINERSentry aswell.
I was hoping someone would sign up for that, so I don't have to stick myself there with "Odd fixes" status...
Quoted 2 lines
I'd like to see those REVISIT things attended to before I push the stuff to Linus though.
In this driver? They're mostly performance tuning issues, which are normally best left till later:
- Using msleep -- usleep? -- to avoid some busy-waiting. That's got to be done with caution, since it can slow things down and since card timings are all over the map. Given working HRT this should be practical.
- Eliminating byte-at-a-time reads on the RX block paths, probably using some kind of bounce buffer scheme. Needs some investigation; maybe your new bouncebuffer stuff ought to help out...
- Double checking that another device doesn't get added to the bus ... that's easy enough to do. (Lurking there is the need for a new SPI primitive, too.)
- dma_map_single() operations could theoretically fail. Not that it'd be likely on hardware that uses this driver; but that's simple error path cleanup.
More significant are the two FIXMEs related to card reset. One will require someone with relevant hardware (Jan?), the other still needs investigation.
- Dave
============== CUT HERE
This is the latest version of the MMC-over-SPI support. It works on 2.6.23-rc1-git, along with the preceding patches which teach the rest of the MMC stack about SPI so that this host driver can focus on doing only lowlevel SPI-specific stuff, and add CRC7 support.
It's been lightly tested on MMC and SD cards, reading and writing ext3 filesystems (including fsck). This includes CRC mode, which is now enabled by default.
The main issue of note is that sometimes cards need to be power cycled to recover after certain faults. In some cases, it may be necessary to disable CRCs. ("modprobe mmc_core use_spi_crc=n")
Changes from previous versions include more code shrinkage and cleanup, reducing the number of I/O requests needed per operation, and moving even more nuances into the MMC core code.
--- drivers/mmc/host/Kconfig | 13 drivers/mmc/host/Makefile | 1 drivers/mmc/host/mmc_spi.c | 1416 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/spi/mmc_spi.h | 33 + 4 files changed, 1463 insertions(+)
drivers/mmc/host/Kconfig +13 -0
@@ -100,3 +100,16 @@ config MMC_TIFM_SD To compile this driver as a module, choose M here: the module will be called tifm_sd. +config MMC_SPI + tristate "MMC/SD over SPI (EXPERIMENTAL)" + depends on MMC && SPI_MASTER && !HIGHMEM && EXPERIMENTAL + select CRC7 + select CRC_ITU_T + help + Some systems accss MMC/SD cards using a SPI controller instead of + using a "native" MMC/SD controller. This has a disadvantage of + being relatively high overhead, but a compensating advantage of + working on many systems without dedicated MMC/SD controllers. + + If unsure, or if your system has no SPI master driver, say N. +
drivers/mmc/host/Makefile +1 -0
@@ -15,4 +15,5 @@ obj-$(CONFIG_MMC_AU1X) += au1xmmc.o obj-$(CONFIG_MMC_OMAP) += omap.o obj-$(CONFIG_MMC_AT91) += at91_mci.o obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o +obj-$(CONFIG_MMC_SPI) += mmc_spi.o
include/linux/spi/mmc_spi.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef __LINUX_SPI_MMC_SPI_H +#define __LINUX_SPI_MMC_SPI_H + +struct device ; +struct mmc_host ; + +/* Put this in platform_data of a device being used to manage an MMC/SD +* card slot. (Modeled after PXA mmc glue; see that for usage examples.) +* +* REVISIT This is not a spi-specific notion. Any card slot should be +* able to handle it. If the MMC core doesn't adopt this kind of notion, +* switch the "struct device *" parameters over to "struct spi_device *". +*/ +struct mmc_spi_platform_data { +/* driver activation and (optional) card detect irq hookup */ +int (*init)(struct device *, +irqreturn_t (*)(int ,void *), +void *); +void (*exit)(struct device *,void *); + +/* sense switch on sd cards */ +int (*get_ro)(struct device *); + +/* how long to debounce card detect, in msecs */ +u16 detect_delay; + +/* power management */ +u16 powerup_msecs;/* delay of up to 250 msec */ +u32 ocr_mask;/* available voltages */ +void (*setpower)(struct device *,unsigned int maskval); +}; + +#endif /* __LINUX_SPI_MMC_SPI_H */
drivers/mmc/host/mmc_spi.c new file +1416 -0
1,416 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
spi-devel-general mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 200707261632.37011.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 10 lines · On Thu, 26 Jul 2007 16:32:36 -0700 David Brownell…
You said you weren't going to update the MMC core to check the status bits after every request, and I'm certainly not about to change *EVERY MMC/SD REQUEST* to adopt a radically different callling convention either!!
Which leaves us needing a solution that actually works, and this seems to be the only option: continue to use the current calling convention, ->error fields report the failures.
I'm more concerned with where you check this, rather than how. If you want to apply it broadly, the request handling functions in core.c would seem more sane.
Quoted 5 lines
However, that bit looks deeply messy. You'd be splitting the OCR (and other SPI four byte responses) into two different words, for example!
Quoted 9 lines
Or to put it differently, this way the structure that's passed up to the core is actually meaningful: one word of status, and maybe another word of data. And *never* any mixed status/data words that'd need disentangling.
After all, if you really wanted to provide raw protocol data to the mmc core, cmd->resp[] would be bytes, not 32-bit words in cpu-order.
It should, as that's how it's used everywhere. And I'd gladly accept a patch that fixes this.
Quoted 6 lines
I guess we'll have to disagree on this for now. If it matters, it can be changed later; but I certainly couldn't call mixing data and status as an improvement!!
Quoted 8 lines
From my point of view, it's all data. :)
The data block CRC is quite expensive, yes. The CRC7 isn't; and in any case, you had pretty much demanded that it always be computed (to eliminate the #define for the crc needed in the card reset command) ...
Ah, didn't think of that distinction. Carry on.
Quoted 6 lines
Quoted 3 lines
At least we agree on error codes. This is precisely the change I have pending in my patch set to remove the MMC_ERR_* mess. :)
I had to pick something. ;)
I have committed that to -mm now. Could I bother you with an update of your patch to remove all MMC_ERR_ stuff? :)
Quoted 6 lines
Quoted 2 lines
I need a
MAINTAINERSentry aswell.I was hoping someone would sign up for that, so I don't have to stick myself there with "Odd fixes" status...
Have you poked someone? I don't even have any SPI hardware, so I'm definitely the wrong person.
Quoted 11 lines
Quoted 3 lines
I'd like to see those REVISIT things attended to before I push the stuff to Linus though.
In this driver? They're mostly performance tuning issues, which are normally best left till later:
-
dma_map_single()operations could theoretically fail. Not that it'd be likely on hardware that uses this driver; but that's simple error path cleanup.
This is the one I'm mostly concerned with. Dangling error paths give me the willies.
Quoted 4 lines
More significant are the two FIXMEs related to card reset. One will require someone with relevant hardware (Jan?), the other still needs investigation.
Ok.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070801171217.1478267b-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 9 lines · Pierre Ossman
Quoted 6 lines · On Thu, 26 Jul 2007 16:32:36 -0700 David Brownell…
You said you weren't going to update the MMC core to check the status bits after every request, and I'm certainly not about to change *EVERY MMC/SD REQUEST* to adopt a radically different callling convention either!!
Quoted 8 lines
Quoted 4 lines
Which leaves us needing a solution that actually works, and this seems to be the only option: continue to use the current calling convention, ->error fields report the failures.
I'm more concerned with where you check this, rather than how. If you want to apply it broadly, the request handling functions in
core.cwould seem more sane.
That's not how any other host controller driver works though...
I'm concerned with not becoming a guinea pig for experimenting with deep MMC stack changes which are not directly related to the SPI support.
Quoted 9 lines
Quoted 9 lines
However, that bit looks deeply messy. You'd be splitting the OCR (and other SPI four byte responses) into two different words, for example!
Or to put it differently, this way the structure that's passed up to the core is actually meaningful: one word of status, and maybe another word of data. And *never* any mixed status/data words that'd need disentangling.
Quoted 7 lines
Quoted 4 lines
After all, if you really wanted to provide raw protocol data to the mmc core, cmd->resp[] would be bytes, not 32-bit words in cpu-order.
It should, as that's how it's used everywhere. And I'd gladly accept a patch that fixes this.
Erm, I don't follow. It *is* used as 32-bit words everywhere I've had occasion to check.
Quoted 6 lines
Quoted 4 lines
I guess we'll have to disagree on this for now. If it matters, it can be changed later; but I certainly couldn't call mixing data and status as an improvement!!
From my point of view, it's all data. :)
Which of your points of view, though? Clearly at some point the MMC stack recognizes the different semantics associated with for example OCR vs the command response codes. Data isn't necessarily opaque ...
Quoted 9 lines
Quoted 5 lines
The data block CRC is quite expensive, yes. The CRC7 isn't; and in any case, you had pretty much demanded that it always be computed (to eliminate the #define for the crc needed in the card reset command) ...
Ah, didn't think of that distinction. Carry on.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
At least we agree on error codes. This is precisely the change I have pending in my patch set to remove the MMC_ERR_* mess. :)
I had to pick something. ;)
I have committed that to -mm now. Could I bother you with an update of your patch to remove all
MMC_ERR_stuff? :)
You mean, git-mmc.patch from 2.6.23-rc1-mm2 which I see has just come out?
It really would have been easier all around if you had made those changes *after* merging at least the core parts of the SPI support. It looks like most of the SPI patches won't even apply any more, so I'm "gifted" with a needless quantity of make-work. The kind of stuff I've been trying to avoid by submitting the SPI stuff *before* any of those newer patches which jumped ahead of it in the queue ... :(
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
I'd like to see those REVISIT things attended to before I push the stuff to Linus though.
In this driver? They're mostly performance tuning issues, which are normally best left till later:
Quoted 7 lines
Quoted 4 lines
-
dma_map_single()operations could theoretically fail. Not that it'd be likely on hardware that uses this driver; but that's simple error path cleanup.This is the one I'm mostly concerned with. Dangling error paths give me the willies.
That will be a trivial incremental patch. You are aware that almost all DMA mapping calls in the kernel don't check for errors, right? Because the ability to return errors is quite new ... and last I checked, not even documented.
So while I'm glad that the DMA API finally changed (I recall pointing out that gaping hole almost four years ago by now), this particular issue shouldn't worry much at all.
Quoted 6 lines
Quoted 4 lines
More significant are the two FIXMEs related to card reset. One will require someone with relevant hardware (Jan?), the other still needs investigation.
Ok.
I can't see those getting investigated before these patches merge.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200708011117.24664.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 8 lines · On Wed, 1 Aug 2007 11:17:24 -0700 David Brownell…
Quoted 4 lines · Pierre Ossman
I'm more concerned with where you check this, rather than how. If you want to apply it broadly, the request handling functions in
core.cwould seem more sane.That's not how any other host controller driver works though...
Other controllers don't care at all about status bits. Except for omap, which caused it to break in fun and interesting ways.
Quoted 4 lines
I'm concerned with not becoming a guinea pig for experimenting with deep MMC stack changes which are not directly related to the SPI support.
You're the one who started poking the error handling bear ;)
But we can ignore it for now.
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
After all, if you really wanted to provide raw protocol data to the mmc core, cmd->resp[] would be bytes, not 32-bit words in cpu-order.
It should, as that's how it's used everywhere. And I'd gladly accept a patch that fixes this.
Erm, I don't follow. It *is* used as 32-bit words everywhere I've had occasion to check.
The only place it is used as that is when checking status bits (in the app cmd handling). In all other places it is treated as a data buffer. Just look at the UNSTUFF_BITS macro in mmc.c and sd.c.
Quoted 8 lines
Quoted 2 lines
From my point of view, it's all data. :)
Which of your points of view, though? Clearly at some point the MMC stack recognizes the different semantics associated with for example OCR vs the command response codes. Data isn't necessarily opaque ...
Right. I'm talking about the layer the host driver handles. There things should be:
<header> <payload> <tail>
Quoted 7 lines
Quoted 3 lines
I have committed that to -mm now. Could I bother you with an update of your patch to remove all
MMC_ERR_stuff? :)You mean, git-mmc.patch from 2.6.23-rc1-mm2 which I see has just come out?
Unfortunately I have little insight into Andrew's schedule for producing new -mm. I push stuff to my "for-andrew" branch and he eventually pulls from that.
Quoted 8 lines
It really would have been easier all around if you had made those changes *after* merging at least the core parts of the SPI support. It looks like most of the SPI patches won't even apply any more, so I'm "gifted" with a needless quantity of make-work. The kind of stuff I've been trying to avoid by submitting the SPI stuff *before* any of those newer patches which jumped ahead of it in the queue ... :(
I don't see how it would have been easier. The only difference is that I'd get a merge problem when I applied the new stuff. So the difference is really whose lap it would have fallen in.
I can fix your patches if you'd like, but you'd probably have better insight into selecting relevant error codes now that the entire errno is available.
Quoted 6 lines
That will be a trivial incremental patch. You are aware that almost all DMA mapping calls in the kernel don't check for errors, right? Because the ability to return errors is quite new ... and last I checked, not even documented.
Somehow, that doesn't make me feel any better.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
More significant are the two FIXMEs related to card reset. One will require someone with relevant hardware (Jan?), the other still needs investigation.
Ok.
I can't see those getting investigated before these patches merge.
Sure, that's fine.
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070802150615.36e073c6-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 5 lines · Pierre Ossman
Quoted 2 lines · On Wed, 1 Aug 2007 11:17:24 -0700 David Brownell…
Quoted 1 line · Pierre Ossman
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I'm more concerned with where you check this, rather than how. If you want to apply it broadly, the request handling functions in
core.cwould seem more sane.That's not how any other host controller driver works though...
Other controllers don't care at all about status bits.
Maybe not, but they *do* report failures. And in this case there's no other way to report failures ... since SPI doesn't have any integral error checks whatsoever. The only way to detect errors is to look at those bits after each transaction.
(Without hardware feedback, you can't even tell if there's a device present on any given chipselect. The SPI host can fling bits out, and read back pulled-up/down bits in any quantity, without error.)
Quoted 2 lines
Except for omap,
which caused it to break in fun and interesting ways.
I think the only time I touched that code was to teach it how to do SD ... 4wire support, writeprotect sensing, and funky block sizes.
The intended design of an MMC/SD host driver has never been all that clear. It's becoming more clear with your recent work ... but it's not there yet, and there aren't even test scripts or suites for de-facto requirements (and to facilitate regression testing).
Quoted 6 lines
Quoted 4 lines
I'm concerned with not becoming a guinea pig for experimenting with deep MMC stack changes which are not directly related to the SPI support.
You're the one who started poking the error handling bear ;)
Was I? Didn't think so. How was I to know that whiteboard scribbles would animate themselves? :)
Quoted 10 lines
But we can ignore it for now.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
After all, if you really wanted to provide raw protocol data to the mmc core, cmd->resp[] would be bytes, not 32-bit words in cpu-order.
It should, as that's how it's used everywhere. And I'd gladly accept a patch that fixes this.
Quoted 7 lines
Quoted 3 lines
Erm, I don't follow. It *is* used as 32-bit words everywhere I've had occasion to check.
The only place it is used as that is when checking status bits (in the app cmd handling). In all other places it is treated as a data buffer. Just look at the
UNSTUFF_BITSmacro inmmc.candsd.c.
And it all but ignores those status bits too, which seems kind of problematic. (Relies on controller hardware to mirror protocol faults by hardware faults of some kind...) But I see what you mean about UNSTUFF_BITS.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
From my point of view, it's all data. :)
Which of your points of view, though? Clearly at some point the MMC stack recognizes the different semantics associated with for example OCR vs the command response codes. Data isn't necessarily opaque ...
Quoted 4 lines
Right. I'm talking about the layer the host driver handles. There things should be:
<header> <payload> <tail>
Fault handling being orthogonal to that. And at this time, like it or (clearly!) not, the mmc core does virtually no fault checking ... it relies on reports from host drivers.
You're probably on to something with the notion that the I/O wrappers should check the status codes. But that's a substantial change from how the stack has worked, ever since it was written.
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
I have committed that to -mm now. Could I bother you with an update of your patch to remove all
MMC_ERR_stuff? :)You mean, git-mmc.patch from 2.6.23-rc1-mm2 which I see has just come out?
Unfortunately I have little insight into Andrew's schedule for producing new -mm. I push stuff to my "for-andrew" branch and he eventually pulls from that.
That's no problem.
Quoted 9 lines
Quoted 8 lines
It really would have been easier all around if you had made those changes *after* merging at least the core parts of the SPI support. It looks like most of the SPI patches won't even apply any more, so I'm "gifted" with a needless quantity of make-work. The kind of stuff I've been trying to avoid by submitting the SPI stuff *before* any of those newer patches which jumped ahead of it in the queue ... :(
Quoted 3 lines
I don't see how it would have been easier. The only difference is that I'd get a merge problem when I applied the new stuff. So the difference is really whose lap it would have fallen in.
Not exactly ... you'd have been developing that new stuff against current GIT, which would already have had some of those patches, so there wouldn't even *be* a merge problem for that stuff.
Quoted 3 lines
I can fix your patches if you'd like, but you'd probably have better insight into selecting relevant error codes now that the entire errno is available.
Patches #1 and #2 were easy fixes; about 2/3 of #3 is rejected, and I've not yet looked at the details ... that's all the core changes, which haven't previously cared about much more than success-or-fault. #4 should be easy to cope with.
Quoted 7 lines
Quoted 5 lines
That will be a trivial incremental patch. You are aware that almost all DMA mapping calls in the kernel don't check for errors, right? Because the ability to return errors is quite new ... and last I checked, not even documented.
Somehow, that doesn't make me feel any better.
It's just an indication of how seldom DMA mapping errors have ever made problems.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
More significant are the two FIXMEs related to card reset. One will require someone with relevant hardware (Jan?), the other still needs investigation.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Ok.
I can't see those getting investigated before these patches merge.
Sure, that's fine.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200708021334.50670.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 7 lines · On Thu, 2 Aug 2007 13:34:49 -0700 David Brownell…
Quoted 2 lines
Except for omap,
which caused it to break in fun and interesting ways.I think the only time I touched that code was to teach it how to do SD ... 4wire support, writeprotect sensing, and funky block sizes.
Quoted 6 lines
The intended design of an MMC/SD host driver has never been all that clear. It's becoming more clear with your recent work ... but it's not there yet, and there aren't even test scripts or suites for de-facto requirements (and to facilitate regression testing).
I agree. There are still a bunch of corner cases that are fuzzy at best. Unfortunately, all difficult cases usually involve error conditions. So I haven't been able to come up with a way to test things without having a custom card that can fail requests in different exotic ways.
Quoted 10 lines
Fault handling being orthogonal to that. And at this time, like it or (clearly!) not, the mmc core does virtually no fault checking ... it relies on reports from host drivers.
You're probably on to something with the notion that the I/O wrappers should check the status codes. But that's a substantial change from how the stack has worked, ever since it was written.
Indeed. The core lacks proper error checking on that level because those errors are so extremely rare. People are lazy and "good enough" goes a long way. I'd love to see better error handling, but with these low odds, other things get prioritized.
Quoted 9 lines
Quoted 4 lines
I don't see how it would have been easier. The only difference is that I'd get a merge problem when I applied the new stuff. So the difference is really whose lap it would have fallen in.
Not exactly ... you'd have been developing that new stuff against current GIT, which would already have had some of those patches, so there wouldn't even *be* a merge problem for that stuff.
I'm afraid my development is far from serial. All code that needs further testing gets its own branch, as there is still some uncertainty as to when it will be pushed upstream.
Quoted 6 lines
Patches #1 and #2 were easy fixes; about 2/3 of #3 is rejected, and I've not yet looked at the details ... that's all the core changes, which haven't previously cared about much more than success-or-fault. #4 should be easy to cope with.
It should just be a matter of replacing MMC_ERR_ codes with -Esomething.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 20070804151452.0efaa5a9-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 9 lines · Pierre Ossman
Quoted 5 lines · On Thu, 2 Aug 2007 13:34:49 -0700 David Brownell…
The intended design of an MMC/SD host driver has never been all that clear. It's becoming more clear with your recent work ... but it's not there yet, and there aren't even test scripts or suites for de-facto requirements (and to facilitate regression testing).
Quoted 5 lines
I agree. There are still a bunch of corner cases that are fuzzy at best. Unfortunately, all difficult cases usually involve error conditions. So I haven't been able to come up with a way to test things without having a custom card that can fail requests in different exotic ways.
There's always writing negative tests ... i.e. issue requests that will fail, and make sure they fail "correctly". One of those might be an alternative to the current block driver.
One expects that code developed outside any test framework will have fair coverage for success paths (e.g. whatever is needed to make MMC and SD memory cards work), and the most common fault paths (e.g. what's triggered during enumeration). But beyond that ... passing illegal params, reading past end of card, "unusual" write sizes, and other things are unlikely to behave consistently between drivers.
Quoted 6 lines
Quoted 4 lines
Patches #1 and #2 were easy fixes; about 2/3 of #3 is rejected, and I've not yet looked at the details ... that's all the core changes, which haven't previously cared about much more than success-or-fault. #4 should be easy to cope with.
It should just be a matter of replacing
MMC_ERR_codes with -Esomething.
Or MMC_ERR_NONE with zero. Almost ... thing is, the new SDIO stuff seems to bork things in some cases, more with SD cards than MMC.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200708041032.10001.david-b-yBeKhBN/[email protected]
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
Quoted 5 lines · On Sat, 4 Aug 2007 10:32:09 -0700 David Brownell…
There's always writing negative tests ... i.e. issue requests that will fail, and make sure they fail "correctly". One of those might be an alternative to the current block driver.
I've thought about it, and the interesting cases are difficult to achieve with a standard card. If you have some ideas, I'd love to hear them.
Also, a common problem is drivers that break layering. So my number one wanted test is to issue a command opcode that doesn't match what the spec says in terms of response and semantics.
Quoted 8 lines
One expects that code developed outside any test framework will have fair coverage for success paths (e.g. whatever is needed to make MMC and SD memory cards work), and the most common fault paths (e.g. what's triggered during enumeration). But beyond that ... passing illegal params, reading past end of card, "unusual" write sizes, and other things are unlikely to behave consistently between drivers.
Now if only there was time. :)
Quoted 7 lines
Quoted 3 lines
It should just be a matter of replacing
MMC_ERR_codes with -Esomething.Or
MMC_ERR_NONEwith zero. Almost ... thing is, the new SDIO stuff seems to bork things in some cases, more with SD cards than MMC.
Well, the sdio code so far hasn't paid any attention to sdio. Perhaps it's best to just avoid that detection on a spi host for now.
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
In reply to a message not in the archiveQuoted 7 lines · On Thu, 2 Aug 2007 13:34:49 -0700 David Brownell…
The intended design of an MMC/SD host driver has never been all that clear. It's becoming more clear with your recent work ... but it's not there yet, and there aren't even test scripts or suites for de-facto requirements (and to facilitate regression testing).
I got annoyed by the olpc xo and wrote some tests. Enjoy.
(Not SPI enabled, but I'm sure you can make some additions ;))
Signature · 5 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org
commit e966ae990cd2ef3be48ece8cde0f97f04a0d6024
Author: Pierre Ossman <[email protected]> Date: Tue Aug 7 14:27:17 2007 +0200
mmc: mmc host test driver
A dummy driver that performs a series of requests that are often mis- handled by host drivers.
drivers/mmc/card/Kconfig +6 -0
@@ -32,6 +32,12 @@ config MMC_BLOCK_BOUNCE If unsure, say Y here. +config MMC_TEST + tristate "MMC host test driver" + default n + help + Dummy driver that tests that a host performs as it should. + config SDIO_UART tristate "SDIO UART/GPS class support" depends on MMC
drivers/mmc/card/Makefile +1 -0
@@ -9,5 +9,6 @@ endif obj-$(CONFIG_MMC_BLOCK) += mmc_block.o mmc_block-objs := block.o queue.o +obj-$(CONFIG_MMC_TEST) += mmc_test.o obj-$(CONFIG_SDIO_UART) += sdio_uart.o
drivers/mmc/card/mmc_test.c new file +520 -0
520 lines not on this page · raw message
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general
Re: [patch 2.6.22-git5 4/4] mmc_spi host driver
In reply to a message not in the archiveQuoted 9 lines · Pierre Ossman
Quoted 6 lines
Quoted 2 lines
I need a
MAINTAINERSentry aswell.I was hoping someone would sign up for that, so I don't have to stick myself there with "Odd fixes" status...
Have you poked someone? I don't even have any SPI hardware, so I'm definitely the wrong person.
Well, I certainly asked for a volunteer with one of the earlier patchsets I posted ... as I started cleaning this up so that it could be merged.
Mike, Hans-Peter, Jan ... you've all got platforms that need this driver. At least two of you even shipped products using earlier versions. Would one of you want to sign up as the maintainer for the mmc_spi host?
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Hello David,
Quoted 8 lines · David Brownell
Here's an updated version of the MMC-over-SPI patches, reworked to address most of Pierre's issues (moving even more code into the MMC core) and to clean up the I/O paths.
To build/run these, you'll need the CRC7 patch from recent MM trees.
- headers learn about SPI
Quoted 8 lines
-
mmc_blocklearns about SPI- mmc core updates
-
mmc_spihost driverThe bits related to card lock/unlock aren't included here, since those didn't go upstream yet.
Much thanks for the patches!
Though, I still have some troubles with getting MMC(SD)-over-SPI to work.
I'm using slightly patched spi_mpc83xx.c driver + these four mmc patches.
spi_mpc83xx.c tested only in loopback mode and using oscilloscope. It _seem_ to work fine, but as I didn't tested it on real hardware (other than MMC/SD), I can't say if it's fault of spi_mpc83xx or mmc_spi.
David, can you see anything helpful in these debug messages?
- - - -
mmc_spi spi1.0: ASSUMING unshared SPI bus! mmc_spi spi1.0: ASSUMING 3.2-3.4 V slot power mmc0: clock 0Hz busmode 0 powermode 0 cs 0 Vdd 0 width 0 timing 0 mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff mmc0: clock 0Hz busmode 2 powermode 1 cs 1 Vdd 21 width 0 timing 0 mmc_spi spi1.0: mmc_spi: power up (21) mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0 mmc_spi spi1.0: mmc_spi: power on (21) mmc_spi spi1.0: mmc_spi: clock to 400000 Hz, 0 mmc0: starting CMD0 arg 00000000 flags 000000c0 mmc_spi spi1.0: mmc_spi: CMD0, MMC_SPI_R1 mmc0: req done (CMD0): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD8 arg 000001aa flags 000002f5 mmc_spi spi1.0: mmc_spi: CMD8, MMC_SPI_R3/R7 mmc_spi spi1.0: ... CMD8 response SPI_R3/R7: resp 0005 00000000 mmc0: req done (CMD8): 5/0/0: 00000005 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000000 00000000 00000000 00000000 mmc0: starting CMD58 arg 00000000 flags 00000280 mmc_spi spi1.0: mmc_spi: CMD58, MMC_SPI_R3/R7 mmc0: req done (CMD58): 0/0/0: 00000000 80ff8000 00000000 00000000 mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 20 width 0 timing 0 mmc0: starting CMD0 arg 00000000 flags 000000c0 mmc_spi spi1.0: mmc_spi: CMD0, MMC_SPI_R1 mmc0: req done (CMD0): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD8 arg 000001aa flags 000002f5 mmc_spi spi1.0: mmc_spi: CMD8, MMC_SPI_R3/R7 mmc_spi spi1.0: ... CMD8 response SPI_R3/R7: resp 0005 00000000 mmc0: req done (CMD8): 5/0/0: 00000005 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000000 00000000 00000000 00000000 mmc0: starting CMD59 arg 00000001 flags 00000080 mmc_spi spi1.0: mmc_spi: CMD59, MMC_SPI_R1 mmc0: req done (CMD59): 0/0/0: 00000000 00000000 00000000 00000000 mmc0: starting CMD10 arg 00000000 flags 000000b5 mmc_spi spi1.0: mmc_spi: CMD10, MMC_SPI_R1 mmc_spi spi1.0: mmc_spi: read block, 16 bytes mmc_spi spi1.0: read error f8 (248) mmc_spi spi1.0: read status -5 mmc0: req done (CMD10): 0/4/0: 00000001 00000000 00000000 00000000 mmc0: clock 0Hz busmode 2 powermode 0 cs 1 Vdd 0 width 0 timing 0 mmc_spi spi1.0: mmc_spi: power off (0)
- - - -
SD card is Kingston 1GB, 3.3V.
Thanks!
p.s. I've sent subscription request to this list, but SF still processing it. So please Cc me, just to be sure I'll not miss something.
Signature · 14 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 20070716164837.GA18707-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Quoted 14 lines · Anton Vorontsov
Hello David,
Quoted 5 lines · David Brownell
Here's an updated version of the MMC-over-SPI patches, reworked to address most of Pierre's issues (moving even more code into the MMC core) and to clean up the I/O paths.
...
Much thanks for the patches!
Though, I still have some troubles with getting MMC(SD)-over-SPI to work.
Quoted 7 lines
I'm using slightly patched
spi_mpc83xx.cdriver + these four mmc patches.
spi_mpc83xx.ctested only in loopback mode and using oscilloscope. It _seem_ to work fine, but as I didn't tested it on real hardware (other than MMC/SD), I can't say if it's fault ofspi_mpc83xxormmc_spi.
I can't say either, but my first thought is that it might be a card-specific quirk. I already found one in that particular place, and the messages below look fine until the very end.
Quoted 5 lines
David, can you see anything helpful in these debug messages?
- - - -
mmc_spispi1.0: ASSUMING unshared SPI bus!mmc_spispi1.0: ASSUMING 3.2-3.4 V slot power
You should provide an ocr_mask in your platform data, saying what voltage range you can supply ... even if it's only 3V3 !!
Quoted 10 lines
mmc0: clock 0Hz busmode 0 powermode 0 cs 0 Vdd 0 width 0 timing 0
mmc_spispi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmc0: clock 0Hz busmode 2 powermode 1 cs 1 Vdd 21 width 0 timing 0mmc_spispi1.0:mmc_spi: power up (21)
mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0mmc_spispi1.0:mmc_spi: power on (21)mmc_spispi1.0:mmc_spi: clock to 400000 Hz, 0
mmc0: starting CMD0 arg 00000000 flags000000c0mmc_spispi1.0:mmc_spi: CMD0,MMC_SPI_R1
mmc0: req done (CMD0): 0/0/0: 00000001 00000000 00000000 00000000
Looks fine: reset card, R1_SPI_IDLE status is set in the status word (00000001) ... it'll be resetting for some time.
Quoted 4 lines
mmc0: starting CMD8 arg 000001aa flags 000002f5 mmc_spi spi1.0: mmc_spi: CMD8, MMC_SPI_R3/R7 mmc_spi spi1.0: ... CMD8 response SPI_R3/R7: resp 0005 00000000 mmc0: req done (CMD8): 5/0/0: 00000005 00000000 00000000 00000000
OK, it doesn't handle SEND_EXT_CSD at all (status R1_SPI_ILLEGAL_COMMAND in addition to the idle status), so it comes as MMC_ERR_INVALID. (Or SEND_IF_COND, if this were an SD 2.0+ card...)
Quoted 6 lines
mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000
ACMD41 == SD_SEND_OP_COND, it's still resetting. Repeats..
Quoted 84 lines
mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000
Quoted 6 lines
mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00000000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000000 00000000 00000000 00000000
Finally the reset completed, R1_SPI_IDLE bit clears.
Quoted 3 lines
mmc0: starting CMD58 arg 00000000 flags 00000280
mmc_spispi1.0:mmc_spi: CMD58, MMC_SPI_R3/R7
mmc0: req done (CMD58): 0/0/0: 0000000080ff800000000000 00000000
Reads the OCR, fine.
Quoted 4 lines
mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 20 width 0 timing 0
mmc0: starting CMD0 arg 00000000 flags000000c0mmc_spispi1.0:mmc_spi: CMD0,MMC_SPI_R1
mmc0: req done (CMD0): 0/0/0: 00000001 00000000 00000000 00000000
Restarts the enumeration, now knowing it's an SD card.
Quoted 4 lines
mmc0: starting CMD8 arg 000001aa flags 000002f5 mmc_spi spi1.0: mmc_spi: CMD8, MMC_SPI_R3/R7 mmc_spi spi1.0: ... CMD8 response SPI_R3/R7: resp 0005 00000000 mmc0: req done (CMD8): 5/0/0: 00000005 00000000 00000000 00000000
... so here it's trying SEND_IF_COND (still failing) ...
Quoted 98 lines
mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000001 00000000 00000000 00000000
Quoted 6 lines
mmc0: starting CMD55 arg 00000000 flags 000000f5 mmc_spi spi1.0: mmc_spi: CMD55, MMC_SPI_R1 mmc0: req done (CMD55): 0/0/0: 00000001 00000000 00000000 00000000 mmc0: starting CMD41 arg 00300000 flags 000000e1 mmc_spi spi1.0: mmc_spi: CMD41, MMC_SPI_R1 mmc0: req done (CMD41): 0/0/0: 00000000 00000000 00000000 00000000
Reset finished, IDLE status is no longer set ...
Quoted 3 lines
mmc0: starting CMD59 arg 00000001 flags 00000080
mmc_spispi1.0:mmc_spi: CMD59,MMC_SPI_R1
mmc0: req done (CMD59): 0/0/0: 00000000 00000000 00000000 00000000
Enables CRC mode (arg == 1).
Quoted 4 lines
mmc0: starting CMD10 arg 00000000 flags 000000b5 mmc_spi spi1.0: mmc_spi: CMD10, MMC_SPI_R1 mmc_spi spi1.0: mmc_spi: read block, 16 bytes mmc_spi spi1.0: read error f8 (248)
Hmm, the data block in the MMC_SEND_CID command didn't start with a valid token ... it saw 0xf8, not 0xfe, which is a lowlevel protocol error.
Maybe your scope can show whether or not this was the actual data sent by the card... or you can otherwise verify that the input data (from start of CMD10) was a bunch of 0xff values then an 0xf8...
Quoted 4 lines
mmc_spispi1.0: read status -5
mmc0: req done (CMD10): 0/4/0: 00000001 00000000 00000000 00000000
mmc0: clock 0Hz busmode 2 powermode 0 cs 1 Vdd 0 width 0 timing 0mmc_spispi1.0:mmc_spi: power off (0)
Rather than retrying that command, everything shuts down. Which is annoying, but seems to be the intended behavior; if that's bug, it's not a bug in the SPI support.
Quoted 4 lines
- - - -
SD card is Kingston 1GB, 3.3V.
I didn't try Kingston cards. Since everything worked fine until that last command, maybe a different card will behave better.
The driver does handle one protocol quirk. A SanDisk SD card would issue an 0x00 byte right after issuing the command, in that SEND_CID case as well as the SEND_CSD case. That should be an 0xff byte ... depending on exactly where that 0xf8 showed up, maybe the mmc_spi_readblock() code should be changed to skip not just 0x00 but *ANY* non-{0xff,0xfe} byte in that slot.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707161154.54728.david-b-yBeKhBN/[email protected]
Quoted 18 lines · David Brownell
Quoted 17 lines · Anton Vorontsov
Hello David,
Quoted 5 lines · David Brownell
Here's an updated version of the MMC-over-SPI patches, reworked to address most of Pierre's issues (moving even more code into the MMC core) and to clean up the I/O paths.
...
Much thanks for the patches!
Though, I still have some troubles with getting MMC(SD)-over-SPI to work.
I'm using slightly patched
spi_mpc83xx.cdriver + these four mmc patches.
Quoted 8 lines
Quoted 4 lines
spi_mpc83xx.ctested only in loopback mode and using oscilloscope. It _seem_ to work fine, but as I didn't tested it on real hardware (other than MMC/SD), I can't say if it's fault ofspi_mpc83xxormmc_spi.I can't say either, but my first thought is that it might be a card-specific quirk. I already found one in that particular place, and the messages below look fine until the very end.
Uhh.. can you believe?
mmc_spi spi1.0: ASSUMING unshared SPI bus!mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmcblk0: mmc0:0000 SD01G 1006080KiB
mmcblk0: p1
root-/FxswC0nw/[email protected]:~# mount /dev/mmcblk0p1 /mnt/ EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended root-/FxswC0nw/[email protected]:~# ls /mnt/ bin etc include lib libexec lost+found man sbin share var root-/FxswC0nw/[email protected]:~#
Yup, I've turned debugging off, it's plainly working.
The only change I've made is:
drivers/mmc/host/mmc_spi.c +1 -1
@@ -1184,7 +1184,7 @@ static int mmc_spi_probe(struct spi_device *spi)* Docs are very explicit that sampling is on the rising edge, so * SPI_MODE_0 and SPI_MODE_3 having different CPOL may not matter. */ - spi->mode |=SPI_CPOL |SPI_CPHA ; + spi->mode =0 ; spi->bits_per_word =8 ; status =spi_setup (spi);
Am I understanding correctly that SPI_CPOL is:
~~~| |~~| |~~~~
| | | |
0 |_| |_|(does not work for me)
While !SPI_CPOL is:
|~| |~|
| | | |
0 ___| |__| |____(works great for me)
Is that correct? Not vice versa?
At least that is what I'm observing on oscilloscope. Maybe it's something still messed in mpc83xx_spi.c (I've already fixed a lot), or maybe something else. So, if mmc_spi modes are correct, then mpc83xx_spi having inversed values, and should be fixed.
With only SPI_CPHA that thing does not work also.
Today I've tested it on bunch of cards, MMC Transcend 64MB, MMC SanDisk 16MB, SD Kingston 128MB and 1GB. All of them work.
Thus, despite minor issues, mmc_spi works great, much thanks!
Signature · 10 lines
Anton Vorontsov email: cbou-JGs/[email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 20070717151350.GA3752-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Quoted 11 lines · Anton Vorontsov
Uhh.. can you believe?
mmc_spispi1.0: ASSUMING unshared SPI bus!mmc_spispi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmcblk0: mmc0:0000 SD01G 1006080KiB
mmcblk0: p1root-/FxswC0nw/[email protected]:~# mount /dev/mmcblk0p1 /mnt/ EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended root-/FxswC0nw/[email protected]:~# ls /mnt/ bin etc include lib libexec lost+found man sbin share var root-/FxswC0nw/[email protected]:~#
Good!
Quoted 1 line
Yup, I've turned debugging off, it's plainly working.
And presumably it works with debugging enabled, too ...
drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1190
Quoted 13 lines
The only change I've made is:
drivers/mmc/host/mmc_spi.c +1
-1@@ -1184,7 +1184,7 @@ static int mmc_spi_probe(struct spi_device *spi)* Docs are very explicit that sampling is on the rising edge, so * SPI_MODE_0 and SPI_MODE_3 having different CPOL may not matter. */ - spi->mode |=SPI_CPOL |SPI_CPHA ; + spi->mode =0 ; spi->bits_per_word =8 ; status =spi_setup (spi);
Curious. I think it was Jan Nikitenko who reported mode 0 not working for SD, while mode 3 did work. All my recent testing used mode 3, but I started with mode 0...
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
Quoted 7 lines
Am I understanding correctly that
SPI_CPOLis:~~~| |~~| |~~~~ | | | | 0 |_| |_|(does not work for me)
Quoted 8 lines
While !SPI_CPOL is:
|~| |~| | | | | 0 ___| |__| |____(works great for me)
Is that correct? Not vice versa?
That's for the clock, I take it ... yes. There's a pretty good timing diagram at Wikipedia, which should make the two bits (CPOL, CPHA) clear:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
CPOL=0 means the clock starts at idle=low (vs high if CPOL=1). CPHA=0 means capture on leading clock edge (vs trailing if CPHA=1).
Quoted 2 lines
At least that is what I'm observing on oscilloscope. Maybe it's something still messed in
mpc83xx_spi.c(I've already fixed a lot),
Could you post your changes to that driver?
Quoted 4 lines
or maybe something else. So, if
mmc_spimodes are correct, thenmpc83xx_spihaving inversed values, and should be fixed.With only
SPI_CPHAthat thing does not work also.
Later today two patches to mpc83xx_spi should merge into the kernel.org GIT tree but they don't look like they'd relate to this SPI mode issue. (And the CRC7 patch should also be merging...)
It's not inconceivable that the SPI controller driver is a bit confused with respect to interpreting the mode bits. We've seen that problem before.
Quoted 2 lines
Today I've tested it on bunch of cards, MMC Transcend 64MB, MMC SanDisk 16MB, SD Kingston 128MB and 1GB. All of them work.
Presumably you tested all of them with mode 0 ... which of them work with mode 3? Does it work better in mode 3 if you use a lower clock speed ceiling in the spi board info for that card slot?
Quoted 1 line
Thus, despite minor issues,
mmc_spiworks great, much thanks!
Glad to hear it! Now, to sort out why mode 3 fails for you ...
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707170911.16715.david-b-yBeKhBN/[email protected]
Quoted 14 lines · David Brownell
Quoted 11 lines · Anton Vorontsov
Uhh.. can you believe?
mmc_spispi1.0: ASSUMING unshared SPI bus!mmc_spispi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmcblk0: mmc0:0000 SD01G 1006080KiB
mmcblk0: p1root-/FxswC0nw/[email protected]:~# mount /dev/mmcblk0p1 /mnt/ EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended root-/FxswC0nw/[email protected]:~# ls /mnt/ bin etc include lib libexec lost+found man sbin share var root-/FxswC0nw/[email protected]:~#
Quoted 6 lines
Good!
Quoted 1 line
Yup, I've turned debugging off, it's plainly working.
And presumably it works with debugging enabled, too ...
I had the same issues with debugging on in the past, mainly if it went directly to serial console - could it be the changed timing?
Quoted 14 lines
Quoted 14 lines
The only change I've made is:
drivers/mmc/host/mmc_spi.c +1
-1@@ -1184,7 +1184,7 @@ static int mmc_spi_probe(struct spi_device *spi)* Docs are very explicit that sampling is on the rising edge, so * SPI_MODE_0 and SPI_MODE_3 having different CPOL may not matter. */ - spi->mode |=SPI_CPOL |SPI_CPHA ; + spi->mode =0 ; spi->bits_per_word =8 ;
Quoted 5 lines
drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1190
Quoted 1 line
drivers/mmc/host/mmc_spi.c +0
-0status =spi_setup (spi);Curious. I think it was Jan Nikitenko who reported mode 0 not working for SD, while mode 3 did work. All my recent testing used mode 3, but I started with mode 0...
I do not recall anything about that, I had mode 3 there since the very first version of mmc-spi patch posted by David here:
http://www.google.com/search?q=cache%3Awww.gossamer-threads.com%2Flists%2Flinux%2Fkernel%2F671939#671939
Just tried mode 0 today, and it seems to work as well, if I did not overlook something (talking about some old version of mmc-spi, could not get to test the latest releases yet, sorry)
Quoted 4 lines
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
Someone with access to full mmc and sd specs told me, that the timing diagrams there do not show needed spi mode, because the diagrams there are like in a table form, with only CS, DataIN and DataOut signals (no clock signal at all).
Jan
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Jan Nikitenko
Quoted 3 lines · David Brownell
Curious. I think it was Jan Nikitenko who reported mode 0 not working for SD, while mode 3 did work. All my recent testing used mode 3, but I started with mode 0...
I do not recall anything about that, I had mode 3 there since the very first version of mmc-spi patch posted by David ...
Well then it was somebody else. Doesn't much matter though. :)
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Quoted 14 lines · David Brownell
Quoted 11 lines · Anton Vorontsov
Uhh.. can you believe?
mmc_spispi1.0: ASSUMING unshared SPI bus!mmc_spispi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
mmcblk0: mmc0:0000 SD01G 1006080KiB
mmcblk0: p1root-/FxswC0nw/[email protected]:~# mount /dev/mmcblk0p1 /mnt/ EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended root-/FxswC0nw/[email protected]:~# ls /mnt/ bin etc include lib libexec lost+found man sbin share var root-/FxswC0nw/[email protected]:~#
Quoted 6 lines
Good!
Quoted 1 line
Yup, I've turned debugging off, it's plainly working.
And presumably it works with debugging enabled, too ...
Yes, sure. I've just forgot to insert "because"; "I've turned debugging off, because it's plainly working now". Sorry for the confusion. Debugging isn't culprit. ;-)
Quoted 39 lines
drivers/mmc/host/mmc_spi.c static int mmc_spi_probe(struct spi_device *spi) · line 1190
Quoted 13 lines
The only change I've made is:
drivers/mmc/host/mmc_spi.c +1
-1@@ -1184,7 +1184,7 @@ static int mmc_spi_probe(struct spi_device *spi)* Docs are very explicit that sampling is on the rising edge, so * SPI_MODE_0 and SPI_MODE_3 having different CPOL may not matter. */ - spi->mode |=SPI_CPOL |SPI_CPHA ; + spi->mode =0 ; spi->bits_per_word =8 ; status =spi_setup (spi);Curious. I think it was Jan Nikitenko who reported mode 0 not working for SD, while mode 3 did work. All my recent testing used mode 3, but I started with mode 0...
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
Quoted 7 lines
Am I understanding correctly that
SPI_CPOLis:~~~| |~~| |~~~~ | | | | 0 |_| |_|(does not work for me)
Quoted 8 lines
While !SPI_CPOL is:
|~| |~| | | | | 0 ___| |__| |____(works great for me)
Is that correct? Not vice versa?
Quoted 8 lines
That's for the clock, I take it ... yes. There's a pretty good timing diagram at Wikipedia, which should make the two bits (CPOL, CPHA) clear:
http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
CPOL=0 means the clock starts at idle=low (vs high if CPOL=1). CPHA=0 means capture on leading clock edge (vs trailing if CPHA=1).
Ok, just as I thought. That means that mpc83xx_spi.c is correct in that regard.
Quoted 4 lines
Quoted 2 lines
At least that is what I'm observing on oscilloscope. Maybe it's something still messed in
mpc83xx_spi.c(I've already fixed a lot),Could you post your changes to that driver?
Sure, you'll see them shortly. Just need a bit of time.
Quoted 15 lines
Quoted 4 lines
or maybe something else. So, if
mmc_spimodes are correct, thenmpc83xx_spihaving inversed values, and should be fixed.With only
SPI_CPHAthat thing does not work also.Later today two patches to
mpc83xx_spishould merge into the kernel.org GIT tree but they don't look like they'd relate to this SPI mode issue. (And the CRC7 patch should also be merging...)It's not inconceivable that the SPI controller driver is a bit confused with respect to interpreting the mode bits. We've seen that problem before.
Quoted 5 lines
Quoted 2 lines
Today I've tested it on bunch of cards, MMC Transcend 64MB, MMC SanDisk 16MB, SD Kingston 128MB and 1GB. All of them work.
Presumably you tested all of them with mode 0 ... which of them work with mode 3?
None.
Quoted 3 lines
Does it work better in mode 3 if you use
a lower clock speed ceiling in the spi board info for that card slot?
Nope.
Quoted 5 lines
Quoted 1 line
Thus, despite minor issues,
mmc_spiworks great, much thanks!Glad to hear it! Now, to sort out why mode 3 fails for you ...
- Dave
Much thanks,
Signature · 10 lines
Anton Vorontsov email: cbou-JGs/[email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 20070718100047.GA9544-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Quoted 4 lines · Anton Vorontsov
Quoted 4 lines
Later today two patches to
mpc83xx_spishould merge into the kernel.org GIT tree but they don't look like they'd relate to this SPI mode issue. (And the CRC7 patch should also be merging...)
[...]
Quoted 3 lines
Quoted 1 line
Could you post your changes to that driver?
Sure, you'll see them shortly. Just need a bit of time.
Dammit. I've done git pull from Linus' tree, and this commit already fixes most of things (major ones).
- - -
commit f29ba280ecb46331c1f6842b094808af01131422
Author: Joakim Tjernlund <[email protected]> Date: Tue Jul 17 04:04:12 2007 -0700
spi_mpc83xx.c: support QE enabled 83xx CPU's like mpc832x
Quicc Engine enabled mpc83xx CPU's has a somewhat different HW interface to the SPI controller. This patch adds a qe_mode knob that sees to that needed adaptions are performed.
- - -
I'm working on mpc832x too. Heh.. much time wasted... It haven't been in -mm. :-(
Signature · 10 lines
Anton Vorontsov email: cbou-JGs/[email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
Quoted 9 lines · On Tue, 17 Jul 2007 09:11:15 -0700 David Brownell…
Curious. I think it was Jan Nikitenko who reported mode 0 not working for SD, while mode 3 did work. All my recent testing used mode 3, but I started with mode 0...
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
I can probably help out there.
According to the specs, both mode 0 and mode 3 are valid. The idle polarity simply isn't specified, only that data shall be sampled on rising edge. Hence mode 0 or 3.
Rgds
Signature · 11 lines
-- Pierre Ossman Linux kernel, MMC maintainer http://www.kernel.org PulseAudio, core developer http://pulseaudio.org rdesktop, core developer http://www.rdesktop.org ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 20070718164409.56ca0019-mgABNEgzgxm+PRNnhPf8W5YgPPQkE1Si@public.gmane.org
Quoted 8 lines · Pierre Ossman
Quoted 4 lines · On Tue, 17 Jul 2007 09:11:15 -0700 David Brownell…
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
Quoted 5 lines
I can probably help out there.
According to the specs, both mode 0 and mode 3 are valid. The idle polarity simply isn't specified, only that data shall be sampled on rising edge. Hence mode 0 or 3.
Thanks. In that case, I'm thinking there *IS* a bug of some kind in the controller driver Anton is using, else mode 3 would work for him like it (evidently) works for everyone else.
I'll see about making time to see if mode 0 works for me too; but even if it does, I'd prefer to leave the driver the way it is now instead of changing it to cover up for that mpc83xx bug ... plus, I just like CPHA=1 modes better because they don't need to start with that strange half-clock. ;)
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
A message that is not in the archive (sent off-list or not yet received): 200707181027.17819.david-b-yBeKhBN/[email protected]
Quoted 11 lines · David Brownell
Quoted 10 lines · Pierre Ossman
Quoted 4 lines · On Tue, 17 Jul 2007 09:11:15 -0700 David Brownell…
Ideally, someone with access to full MMC and SD specs can see what they say about the SPI clocking. The simplified SD specs omit the timing diagrams.
I can probably help out there.
Quoted 7 lines
Quoted 3 lines
According to the specs, both mode 0 and mode 3 are valid. The idle polarity simply isn't specified, only that data shall be sampled on rising edge. Hence mode 0 or 3.
Thanks. In that case, I'm thinking there *IS* a bug of some kind in the controller driver Anton is using, else mode 3 would work for him like it (evidently) works for everyone else.
I've checked with MPC8323E reference manual, and according to it spi_mpc83xx is doing right thing.
Quoted 5 lines
I'll see about making time to see if mode 0 works for me too; but even if it does, I'd prefer to leave the driver the way it is now instead of changing it to cover up for that mpc83xx bug ... plus, I just like CPHA=1 modes better because they don't need to start with that strange half-clock. ;)
Well. As Pierre Ossman told, it should work at any mode. That also proves that it's not mpc83xx's bug (because even if it would be a bug, and spi_mpc83xx having inversed values, it's still should work).
So, it's likely depends on spi controller, maybe some timing issues or signal shapes, which distracts SD/MMC... Not sure.
But then, may I ask for "alt_mode" (bool) platform data variable?
Thanks!
Signature · 9 lines
Anton Vorontsov email: cbou-JGs/[email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): 20070719161553.GA15756-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Quoted 7 lines · Anton Vorontsov
Quoted 4 lines
Thanks. In that case, I'm thinking there *IS* a bug of some kind in the controller driver Anton is using, else mode 3 would work for him like it (evidently) works for everyone else.
I've checked with MPC8323E reference manual, and according to it
spi_mpc83xxis doing right thing.
I notice that driver disregards the cs_change instructions in the messages ... I could imagine how that could make a big difference.
If that hardware were doing the right thing, then it would work reliably! Since it's not reliable, it's doing something wrong. You seem to think it's not a hardware issue; that may be true.
Recall that the first dozen or so commands worked just fine. The issue was that some byte that should have been all-ones or 0xfe reported instead an 0xf8. That's not the kind of error that can be explained by clock skew; it covers at least two bits.
Quoted 7 lines
Quoted 5 lines
I'll see about making time to see if mode 0 works for me too; but even if it does, I'd prefer to leave the driver the way it is now instead of changing it to cover up for that mpc83xx bug ... plus, I just like CPHA=1 modes better because they don't need to start with that strange half-clock. ;)
Well. As Pierre Ossman told, it should work at any mode.
Well, either mode 0 or mode 3. And since it doesn't work in both modes, clearly something in your test system is buggy.
Quoted 3 lines
That also
proves that it's not mpc83xx's bug (because even if it would be a bug, andspi_mpc83xxhaving inversed values, it's still should work).
No way could it "prove" that!!
How could it ever be possible that your system not work in mode 3, and yet that not be a bug in your test system???
The only thing "proven" is that the mmc_spi code is basically correct; otherwise neither clock mode could cause the right data transfers. (And otherewise other folk wouldn't have seen it work...)
The problem is in a lower level ... maybe the SPI controller driver, or the silicon, or the board wiring.
Quoted 2 lines
So, it's likely depends on spi controller, maybe some timing issues or signal shapes, which distracts SD/MMC... Not sure.
What does your oscilloscope show is going on when this error triggers?
Right now I'd most suspect the lack of cs_change support in that controller driver.
Quoted 1 line
But then, may I ask for "
alt_mode" (bool) platform data variable?
Well, as already said: (a) we know mode 3 is required to work,
(b) we know that on your test system it doesn't, so accordingly
(c) we know there's a bug in your test system.
The only reason to add such a flag would be to paper over that bug.
The idea with bugs is to *FIX* them, not paper them over so they'll never get fixed. Especially if you've got a lab setup with even basic hardware debug tools, like your oscilloscope, which make it so easy to verify that the right signals are going down the wires.
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
A message that is not in the archive (sent off-list or not yet received): 200707191328.18846.david-b-yBeKhBN/[email protected]
Quoted 12 lines · David Brownell
Quoted 7 lines · Anton Vorontsov
Quoted 4 lines
Thanks. In that case, I'm thinking there *IS* a bug of some kind in the controller driver Anton is using, else mode 3 would work for him like it (evidently) works for everyone else.
I've checked with MPC8323E reference manual, and according to it
spi_mpc83xxis doing right thing.I notice that driver disregards the
cs_changeinstructions in the messages ... I could imagine how that could make a big difference.
Quoted 8 lines
If that hardware were doing the right thing, then it would work reliably! Since it's not reliable, it's doing something wrong. You seem to think it's not a hardware issue; that may be true.
Recall that the first dozen or so commands worked just fine. The issue was that some byte that should have been all-ones or
0xfereported instead an0xf8. That's not the kind of error that can be explained by clock skew; it covers at least two bits.
Yup, I've either noticed that 0xf8 and 0xfe differs by only two bits (and by three if comparing to 0xff). But I can't really explain it yet.
Quoted 25 lines
Quoted 7 lines
Quoted 5 lines
I'll see about making time to see if mode 0 works for me too; but even if it does, I'd prefer to leave the driver the way it is now instead of changing it to cover up for that mpc83xx bug ... plus, I just like CPHA=1 modes better because they don't need to start with that strange half-clock. ;)
Well. As Pierre Ossman told, it should work at any mode.
Well, either mode 0 or mode 3. And since it doesn't work in both modes, clearly something in your test system is buggy.
Quoted 3 lines
That also
proves that it's not mpc83xx's bug (because even if it would be a bug, andspi_mpc83xxhaving inversed values, it's still should work).No way could it "prove" that!!
How could it ever be possible that your system not work in mode 3, and yet that not be a bug in your test system???
The only thing "proven" is that the
mmc_spicode is basically correct; otherwise neither clock mode could cause the right data transfers. (And otherewise other folk wouldn't have seen it work...)
Quoted 8 lines
The problem is in a lower level ... maybe the SPI controller driver, or the silicon, or the board wiring.
Quoted 2 lines
So, it's likely depends on spi controller, maybe some timing issues or signal shapes, which distracts SD/MMC... Not sure.
What does your oscilloscope show is going on when this error triggers?
Well, it's not handy to catch particular bit using my oscilloscope. It's unable to scroll in time. But as failing bits are in the last spi message, maybe I could do something.
Quoted 2 lines
Right now I'd most suspect the lack of
cs_changesupport in that controller driver.
I see. Thanks for the pointer.
Quoted 6 lines
Quoted 1 line
But then, may I ask for "
alt_mode" (bool) platform data variable?Well, as already said: (a) we know mode 3 is required to work,
(b) we know that on your test system it doesn't, so accordingly
(c) we know there's a bug in your test system.
Quoted 6 lines
The only reason to add such a flag would be to paper over that bug.
The idea with bugs is to *FIX* them, not paper them over so they'll never get fixed. Especially if you've got a lab setup with even basic hardware debug tools, like your oscilloscope, which make it so easy to verify that the right signals are going down the wires.
Yeah, you're right. And your whole reply makes a lot of sense, much thanks for explanations and ideas.
Signature · 14 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
A message that is not in the archive (sent off-list or not yet received): 20070723142923.GA28979-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]
Quoted 4 lines · Anton Vorontsov
Quoted 2 lines · David Brownell
I notice that driver disregards the
cs_changeinstructions in the messages ... I could imagine how that could make a big difference.
For example, the extra flapping on the chipselect changes timings...
Quoted 4 lines
Quoted 4 lines
If that hardware were doing the right thing, then it would work reliably! Since it's not reliable, it's doing something wrong. You seem to think it's not a hardware issue; that may be true.
Quoted 8 lines
Quoted 4 lines
Recall that the first dozen or so commands worked just fine. The issue was that some byte that should have been all-ones or
0xfereported instead an0xf8. That's not the kind of error that can be explained by clock skew; it covers at least two bits.Yup, I've either noticed that
0xf8and0xfediffers by only two bits (and by three if comparing to0xff). But I can't really explain it yet.
See if fixing the cs_change handling -- so that chipselect never goes inactive except between MMC requests -- helps. Minimally, you'll notice that mode 0 adds extra delays (albeit only 1/2 clock) before the clock starts toggling; and that deslecting cards except between requests or while the card issues BUSY, falls into the "undefined behavior" category. So while that might not be able to trigger certain perversions, dropping a few clocks in some odd cases would not seem to violate the spec...
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
A message that is not in the archive (sent off-list or not yet received): 200707231033.31717.david-b-yBeKhBN/[email protected]
Quoted 18 lines · David Brownell
Quoted 4 lines · Anton Vorontsov
Quoted 2 lines · David Brownell
I notice that driver disregards the
cs_changeinstructions in the messages ... I could imagine how that could make a big difference.For example, the extra flapping on the chipselect changes timings...
Quoted 9 lines
Quoted 8 lines
If that hardware were doing the right thing, then it would work reliably! Since it's not reliable, it's doing something wrong. You seem to think it's not a hardware issue; that may be true.
Recall that the first dozen or so commands worked just fine. The issue was that some byte that should have been all-ones or
0xfereported instead an0xf8. That's not the kind of error that can be explained by clock skew; it covers at least two bits.
Quoted 6 lines
Quoted 3 lines
Yup, I've either noticed that
0xf8and0xfediffers by only two bits (and by three if comparing to0xff). But I can't really explain it yet.See if fixing the
cs_changehandling -- so that chipselect never goes inactive except between MMC requests -- helps.
Okay.. I've looked into cs_change for spi_mpc83xx, and it seems bitbang framework (which is used by spi_mpc83xx driver) handle cs_change by itself.
At least bitbang_work() doing very similar things done by other drivers not using bitbang library.
Quoted 9 lines
Minimally,
you'll notice that mode 0 adds extra delays (albeit only 1/2 clock) before the clock starts toggling; and that deslecting cards except between requests or while the card issues BUSY, falls into the "undefined behavior" category. So while that might not be able to trigger certain perversions, dropping a few clocks in some odd cases would not seem to violate the spec...- Dave
Thanks,
Signature · 10 lines
Anton Vorontsov email: cbou-JGs/[email protected] backup email: [email protected] irc://irc.freenode.net/bd2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
Quoted 4 lines · David Brownell
Quoted 4 lines
Quoted 4 lines
If that hardware were doing the right thing, then it would work reliably! Since it's not reliable, it's doing something wrong. You seem to think it's not a hardware issue; that may be true.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Recall that the first dozen or so commands worked just fine. The issue was that some byte that should have been all-ones or
0xfereported instead an0xf8. That's not the kind of error that can be explained by clock skew; it covers at least two bits.Yup, I've either noticed that
0xf8and0xfediffers by only two bits (and by three if comparing to0xff). But I can't really explain it yet.
Just for the record -- on my test rig, SPI mode 3 stopped working entirely ... I'd get one-bit errors, so that CMD0 status would be "0x03" instead of "0x01" (indicating CRC error plus still-resetting). Switching to SPI mode 0 made it all work again; masking out the 0x02 bit made everything time out. So I'm thinking that *was* somehow a shift of one bit.
I think this was caused by removing wires for one SPI device from that breadboard ... but it's hard to say for sure. For a while it seemed like MMC cards worked OK but not SD cards! I'm working on a more permanent rig. But I think when I send the next revision to Pierre, it'll be using SPI_MODE_0. :)
I thought you might be amused, given the strange behavior you saw!
- Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/