Commit Graph

47 Commits

Author SHA1 Message Date
Alexander Motin
a1fda318a8 Add kernel dumping support. Works fine with sdhci controller driver. 2009-02-17 19:17:25 +00:00
Warner Losh
711873d44f o Define some symbols for a few items that are bare constants in the
code.
o Use NULL in preference to 0 for a few pointers.
o default to bus timing normal, like we default to bus_width_1.
2009-02-03 04:28:45 +00:00
Alexander Motin
64e4196db9 Add one more debug level. 2009-01-28 23:18:21 +00:00
Alexander Motin
ed01be88f7 Improve mmc driver verbose logging.
Make requests logging controllable by hw.mmc.debug sysctl.
2009-01-28 22:09:00 +00:00
Warner Losh
b63865c6bf Default to normal bus timing mode on SD cards. In practice, most
cards people have today support high speed mode, so the timing field
would be initialized to bus_timing_hs, but there are some slow
cards...
2009-01-21 17:49:23 +00:00
Warner Losh
38d1bc2312 Fix minor style nit for file consistency. 2009-01-21 17:34:14 +00:00
Warner Losh
3cb54b06bc Make the command reporting be under boot verbose.
Also, report a few other things under boot verbose.
Small style nit to make new code look like old code in this file.
2009-01-21 17:28:24 +00:00
Alexander Motin
1e9d4974c1 Fix copy/paste mistake in variable name. This could lead to using incorrect
bus frequency.
2009-01-21 14:22:06 +00:00
Alexander Motin
eb67f31a1b Implement suspend/resume for mmc and mmcsd drivers.
Now it is possible to suspend/resume with inserted and active card.

To reinitialize card on resume and to detect card change while suspended,
implement bus rescan routines. It can also be used by controllers without
card presence detection signals or with multiple cards per slot support.

While there, cleanup msleep() usage. We have no any rights to exit without
"request done" signal from driver as it could lead to modify after free.
2008-12-06 21:41:27 +00:00
Alexander Motin
2262a5197a Report card erase sector size as disk stripe size. 2008-11-23 14:32:40 +00:00
Alexander Motin
249b0e8586 Improve detach handling: close races, flush queue. 2008-11-23 14:02:06 +00:00
Alexander Motin
3a4a255741 Allow card reader bridge driver to report maximum supported transfer size.
sdhci supports up to 65535 blocks transfers, at91_mci - one block.

Enable multiblock operations disabled before to follow at91_mci driver
limitations.

Reviewed by:	imp@
2008-10-29 20:01:26 +00:00
Alexander Motin
a7cf627487 Coalesce sequentional BIO_DELETE requests to slightly relax size and alignment
constraints required by the card.
2008-10-18 22:22:25 +00:00
Alexander Motin
3906d42d63 Implement BIO_DELETE command with MMC and SD erase commands.
Erase operation gives card's logic information about unused areas to help it
implement wear-leveling with lower overhead comparing to usual writing.
Erase is much faster then write and does not depends on data bus speed.
Also as result of hitting in-card write logic optimizations I have measured
up to 50% performance boost on writing undersized blocks into preerased areas.

At the same time there are strict limitations on size and allignment of erase
operations. We can erase only blocks aligned to the erase sector size and
with size multiple of it. Different cards has different erase sector size
which usually varies from 64KB to 4MB. SD cards actually allow to erase
smaller blocks, but it is much more expensive as it is implemented via
read-erase-write sequence and so not sutable for the BIO_DELETE purposes.

Reviewed by:	imp@
2008-10-18 16:17:04 +00:00
Alexander Motin
58bb626051 Use GB suffix only from 10GB instead of 1GB.
There are lot of cards with uneven sizes and too strong rounding
will lead to very significant rounding errors.

Reviewed by:	imp@
2008-10-12 19:19:26 +00:00
Warner Losh
b231f5d9b1 style(9): spaces around operators. 2008-10-12 07:30:05 +00:00
Warner Losh
a0075e5860 Print the cards natural size.
Move nested tertiary operator expressions into their own function.
Remove extra blank line.
cache sd->disk in 'd' to make the code easier to read.
2008-10-12 07:24:31 +00:00
Alexander Motin
eecec5bd59 SELECT_CARD command with zero RCA deselects all cards and so has no reply. 2008-10-11 17:30:02 +00:00
Alexander Motin
67d752c3d4 Give mmcsd driver a bit more information about card. It allows to reorganize
log message in a way a bit more common for disk devices. Also it will allow
mmcsd driver to use MMC/SD specific commands when needed.
2008-10-11 13:05:13 +00:00
Alexander Motin
fa5f41d31c Add high capacity MMC cards support. 2008-10-09 20:09:56 +00:00
Warner Losh
4871891e2c o Use seprate routines to decode cid and csd for sd and mmc cards. All they
have in common right now is a memset.  This saves a parameter to
  these routines, as well as a level of indentation.
o Make mmc_get_bits a little clearer...  It really only works on 128-bit
  registers right now.
2008-10-09 19:47:28 +00:00
Alexander Motin
49dd20d149 Only voltage bits should be zero in send_op_cond argument to ignore busy. 2008-10-08 21:10:55 +00:00
Alexander Motin
8d66abb099 Generic SD Host Controller driver going to be named sdhci. 2008-10-08 20:00:51 +00:00
Alexander Motin
07492efe64 Fix bit offset in mmc_sd_switch(). 2008-10-08 18:13:14 +00:00
Alexander Motin
c18f1e2627 Set of mmc layer improvements:
- add MMC support.
 - add SDHC support.
 - add 4 and 8 bit bus width support.
 - add High Speed bus timing support.
2008-10-08 17:35:41 +00:00
Warner Losh
38c51cbe85 Define and use MMC_SECTOR_SIZE.
Make mmc_get_media_size now return an off_t and remove now useless cast.
2008-10-02 07:06:59 +00:00
Warner Losh
a84f3c7af9 MAXPHYS seems more stable on the AT91RM9200 boards that I have. We
may need to ask the host controller for the right number to use
here...
2008-10-02 07:00:31 +00:00
Warner Losh
0c0903b1e1 Improve support for multiple block read/write. This code is currently
disabled by default because there's problems with it on AT91RM9200,
currently the only host controller in the tree.  I've not had time to
track those problems to ground.  I'm committing because this is
important for other host controllers that are in the pipeline.

Submitted by:	mav@
2008-09-30 02:34:45 +00:00
Warner Losh
051bc8ead2 Make the media size return the block rather than the bytes on the device. 2008-09-29 18:55:45 +00:00
Warner Losh
4e0efe35fa Explicitly set data to NULL rather than relying mmc_wait_for_cmd() to
do it for us.  There may be commands we have to wait for that need to
set data.

Submitted by:	mav@
2008-09-29 18:33:08 +00:00
Warner Losh
dece39ab88 Minor style fixes from mav@ (with similar problems fixed where I noticed
them):
	#define<tab>
	zero memory when we allocate it
	Put device name in error message.

Submitted by:	mav@
2008-09-29 18:17:23 +00:00
Warner Losh
128d0ff2c4 Conform to style(9) for return (foo); The files were a mix before.
Submitted by:	mav@
2008-09-29 18:05:26 +00:00
Warner Losh
6fdacf52be Convert all C++ comments to C style. There's lots of folks that don't
like them and they don't add enough to be worth standing out.
2008-09-29 01:32:21 +00:00
Warner Losh
e9bb9da34d The parameters to the MMCBR_ACQUIRE_HOST and MMCBR_RELEAES_HOST were
the device in question, rather than the bus doing the requesting.  Fix
it so that it is the bus.

Submitted by:	mav@
2008-09-29 01:28:30 +00:00
Warner Losh
bd2bbf2483 Add "caps" word to host bridge. 2008-09-28 23:37:06 +00:00
Warner Losh
5d2f651035 Implement power down, and power down the bus on detach.
Submitted by:	mav@
2008-09-28 23:24:52 +00:00
Warner Losh
08eb9a9be8 When a device is read only, fail all non-read BIO requests.
Submitted by:	mav@
2008-09-28 22:42:29 +00:00
Warner Losh
40fab6e7c7 Propigate read-only status of cards. Right now it is read only at
device attach time.  We may need to read this more often in the
future, but for now simplicity of implementation wins.

Submitted by:	mav@
2008-09-28 22:40:11 +00:00
Warner Losh
8aaa15e202 The OCR register defines both acceptable voltage bits, as well as bits
for other things.  Mask out the voltage only bits when returning the
Vdd mask for voltage computation.

Submitted by:	mav@
2008-09-28 22:27:29 +00:00
Warner Losh
2703cdbb1b Other busses on the system use the official capitalization for the
technology.  Make mmc conform to that.

Submitted by:	mav@
2008-09-28 22:23:06 +00:00
Warner Losh
752fe3b39e Fix line continuation whitespace.
Submitted by:	mav@
2008-09-28 22:21:53 +00:00
Julian Elischer
3745c395ec Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0  so that we can eventually MFC the
new kthread_xxx() calls.
2007-10-20 23:23:23 +00:00
Warner Losh
6634080bee MFp4: When querying the operating condition of SD cards (using the
application specific SEND_OP_COND (CMD55 + ACMD41), go ahead and allow
100 tries.  This gives a timeout of a second rather than the ~100ms
the old style produces.

I've had one old 16MB SD card which needs the extra time.  I've now
had reports from the field that other cards need this too.

Originally done at BSDcan 2007 while waiting to give my embedding
madness minitalk.
2007-06-05 17:04:44 +00:00
Warner Losh
14eced725c A careful reading of the disclaimer that is required to download the
SD Simplified specification, as well as other SD and SDIO
implemenations I've examined, suggest this disclaimer may be required.
It is unclear to me exactly what the license would be for, or why it
might be required.  Err on the side of caution and include this
disclaimer so anybody deploying this code can judge for themselves.  I
have no further unformation about the details.
2007-05-26 05:23:36 +00:00
Warner Losh
0e1466ac89 First cut at making detach work. also add sdh as a possible mmc bridge.
Submitted by: Andrea Bittau
(Andrea may have updated patches, but I've tested these)
2007-05-15 05:49:14 +00:00
Warner Losh
78f8edfb44 Don't need mmc_mode ivar 2007-05-15 05:46:58 +00:00
Warner Losh
114b4164dd Preliminary MMC stack. This stack supports SD 1.0 cards only, but
should be easily adapted to SD 2.0 (aka SDHC), SDIO, MMC and MMCplus
cards.  At the present time, there's only one bridge driver for the
ARM9 based Atmel AT91RM9200.
2006-10-20 06:39:59 +00:00