Commit Graph

21 Commits

Author SHA1 Message Date
Luiz Otavio O Souza
d86f31b96b Remove stale comments about the issues with HS mode.
Remove a previous workaround to limit the minimum sdhci frequency that
isn't needed anymore.
2015-02-04 16:36:51 +00:00
Luiz Otavio O Souza
07c7a520f1 Remove some duplicate calls to bus_release_resource() and destroy the mutex
on error cases.

While here remove unnecessary includes.
2015-02-04 16:21:45 +00:00
Ian Lepore
86ee58d992 Save the command-and-flags value into the shadow register when it is written.
This doesn't actually change any behavior, because it just allows a 16-bit
read of the command register to return the correct value, and nothing
actually does a 16-bit read of that register.
2015-01-18 20:47:21 +00:00
Ian Lepore
bba987dc50 Add a new SDHCI quirk, SDHCI_QUIRK_DONT_SET_HISPD_BIT. Apparently some
sdhci controllers, such as the one on a Raspberry Pi, mishandle the signal
timing in high speed signaling mode, but run just fine in standard mode
with the bus running at frequencies between 25-50MHz (which shouldn't work).

This is the solution adopted by U-Boot and other OSes (linux and *BSD)
for the timeouts on Raspberry Pi boards with certain SD cards.  Some
research shows that this quirk is also used on a few other boards, so the
fix is a generic quirk instead of being in the RPi-specific driver code.

This change is based on information discovered by Michal Meloun.
2015-01-17 19:57:03 +00:00
Ian Lepore
244fe94f3b Handle dma mappings with more than one segment for rpi sdhci.
The driver inherently does dma in 512 byte chunks, but it's possible that
such a buffer can span two physically discontiguous pages (such as when
a userland program does IO on the raw /dev/mmcsdN devices).  Now the driver
can handle a buffer that's split across two pages.

It could in theory handle any number of segments now, but as long as IO is
being done in 512 byte blocks it will never need more than two.
2015-01-12 02:42:33 +00:00
Ian Lepore
bf160401a9 Check for and handle failures of bus_dmamap_load(). The driver currently
requires that each 512 byte IO be in a single contiguous buffer, but if a
buffer crosses a page boundary and the physical pages aren't contiguous
you can get an EFBIG failure (too many segments).

The driver really should handle multiple segment IO, but before adding that
I wanted to make sure that it's handling failure properly while the failure
is easily recreatable.
2015-01-11 21:27:46 +00:00
Ian Lepore
bffed0e9c8 Store the shadow command/mode register in the softc, not a local static var.
Submitted by:	Michal Meloun
2015-01-11 17:00:24 +00:00
Luiz Otavio O Souza
bea71143ed Since r273264 the SD card detection on Raspberry Pi is reliably working and
that expose new bugs with HS mode.

When the old code could not do the proper card detection it would boot with
lower defaults (and no HS mode) and this makes some HS cards boots.

Now, with the card always identified as HS capable, the sdhci controller
tries to run the card at HS speeds and makes the boot always fail.

Disable the HS mode for now (which still can be enabled with the tunable)
until it is properly fixed.

MFC with:	r273264
Requested by:	many
2014-11-11 23:55:37 +00:00
Luiz Otavio O Souza
7c26b0a7c8 Add a workaround needed to fix a bug of Arasan Host Controller where it may
lose the contents of consecutive writes (that happens within two SD card
clock cycles).

This fixes the causes of instability during the SD card detection and
identification on Raspberry Pi (which happens at 400 kHz and so was much
more vulnerable to this issue).

Remove the previous workaround which clearly can't provide the same effect.

MFC after:	1 week
Relnotes:	yes
2014-10-18 19:01:07 +00:00
Ian Lepore
8c8f31e7b2 sdhci.h has grown a dependency on sysctl.h, include the latter where needed. 2014-09-01 19:20:34 +00:00
Ian Lepore
add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Ian Lepore
6489412064 Remove #include <machine/frame.h> from all the arm code that doesn't
really need it.  That would be almost everywhere it was included.  Add
it in a couple files that really do need it and were previously getting
it by accident via another header.
2013-10-27 01:34:10 +00:00
Rui Paulo
623b72a733 Disable debugging. 2013-07-01 06:32:56 +00:00
Ian Lepore
b479b38c0a Eliminate an intermediate buffer and some memcpy() operations, and do
DMA directly to/from the buffers passed in from higher layer drivers.

Reviewed by:	gonzo
2013-03-17 16:31:09 +00:00
Ian Lepore
33ff10ea55 Add a macro that gets the physical address of a memory mapped device
register from a bus space resource.

Note that this macro is just for ARM, and is intended to have a short
lifespan.  The DMA engines in some SoCs need the physical address of a
memory-mapped device register as one of the arguments for the transfer.
Several scattered ad-hoc solutions have been converted to use this macro,
which now also serves to mark the places where a more complete fix needs
to be applied (after that fix has been designed).
2013-03-17 03:04:43 +00:00
Oleksandr Tymoshenko
adc99a8aa6 Add platform DMA support to SDHCI driver for BCM2835
Submitted by:	Daisuke Aoyama <aoyama at peach.ne.jp>
Reviewed by:	ian@
2013-02-28 19:51:30 +00:00
Oleksandr Tymoshenko
8635d479c2 Spelling fixes
Spotted by:	N. J. Mann
2013-02-19 21:24:52 +00:00
Oleksandr Tymoshenko
f91360b174 Roll back change of frequency for initialization sequence since it
seems to cause more problems then previous behavior: it either breaks
initilization sequence in other places or uncovers problems with
high-speed mode timing for SDHCI 3.0
2013-02-19 20:33:55 +00:00
Oleksandr Tymoshenko
d3d7f709ce - Add hw.bcm2835.sdhci.hs tunable to enable/disable highspeed mode in
SDHCI driver
  Suggested by: Daisuke Aoyama

- Set initilization sequence frequency to 8MHz. It should fix Data CRC
    errors. Standard requires initialization sequence to be executed
    at 400KHz but on this hardware low frequncies seems to cause
    Data CRC errors.

    Value was derived from analyzing hardware signals after
    Raspberry Pi is powered up. Before any data is read though DATA line
    adapter's clock frequency is changed to 8MHz.

    Modern cards should function fine at 8MHz but for older MMC cards it
    can be overriden by setting hw.bcm2835.sdhci.min_freq tunable.
2013-02-17 00:23:42 +00:00
Oleksandr Tymoshenko
3b37b3c221 Get frequency from "clock-frequency" property of "/axi/sdhci" FDT node 2012-11-30 02:32:37 +00:00
Oleksandr Tymoshenko
a9387eb1df Add BCM2835 SDHCI driver and enable it in Raspberry Pi config 2012-10-29 17:23:45 +00:00