summaryrefslogtreecommitdiffstats
path: root/sys/dev/sdhci/sdhci.h
Commit message (Collapse)AuthorAgeFilesLines
* Add a new SDHCI quirk, SDHCI_QUIRK_BROKEN_AUTO_STOP, to workaroundloos2017-09-061-0/+2
| | | | | | | | | | | | controllers that do not support or have broken ACMD12 implementations. Reviewed by: jmcneill Obtained from: NetBSD MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D10602 (cherry picked from commit e0630b81d4e24fd0b8b4e35aa67b3d6ed715cbb5)
* MFC: r315598marius2017-05-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Add support for eMMC DDR bus speed mode up to 52 MHz to sdhci(4) and mmc(4). Given that support for DDR52 is not denoted by SDHCI capability registers, availability of that timing is indicated by a new quirk SDHCI_QUIRK_MMC_DDR52 and only enabled for Intel SDHCI controllers so far. Compared to 50 MHz at SDR high speed typically yielding ~45 MB/s read throughput with the eMMC chips tested, read performance goes up to ~80 MB/s at DDR52. As a side-effect, this change also fixes communication with some eMMC devices at SDR high speed mode due to the signaling voltage and UHS bits in the SDHCI controller no longer being left in an inappropriate state. o In sdhci(4), add two tunables hw.sdhci.quirk_clear as well as hw.sdhci.quirk_set, which (when hooked up in the front-end) allow to set/clear sdhci(4) quirks for debugging and testing purposes. However, especially for SDHCI controllers on the PCI bus which have no specific support code so far and, thus, are picked up as generic SDHCI controllers, hw.sdhci.quirk_set allows for setting the necessary quirks (if required). o In mmc(4), check and handle the return values of some more function calls instead of assuming that everything went right. In case failures actually are not problematic, indicate that by casting the return value to void.
* MFC: r315431marius2017-05-111-3/+33
| | | | | | | | | | | | | | | - Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2 registers. - Add slot type capability bits. These bits should allow recognizing removable card slots, embedded cards and shared buses (shared bus supposedly is always comprised of non-removable cards). - Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LO registers in sdhci_dumpregs(). - The drive type support flags in the CAPABILITIES2 register are for drive types A,C,D, drive type B is the default setting (value 0) of the drive strength field in the SDHCI_HOST_CONTROL2 register. Obtained from: DragonFlyBSD (9e3c8f63, 455bd1b1)
* MFC: r312939, r313250, r314811 (partial), r314887 (partial), r315760,marius2017-05-111-215/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r315845, 315430, r317981, r315466 o Fix some overly long lines, whitespace and other bugs according to style(9) as well as spelling etc. in mmc(4), mmcsd(4) and sdhci(4). o In the mmc(4) bridges and sdhci(4) (bus) front-ends: - Remove redundant assignments of the default bus_generic_print_child device method, - use DEVMETHOD_END, - use NULL instead of 0 for pointers. o Trim/adjust includes. o Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges as kernel drivers and their dependency onto mmc(4). o Add support for eMMC "partitions". Besides the user data area, i. e. the default partition, eMMC v4.41 and later devices can additionally provide up to: 1 enhanced user data area partition 2 boot partitions 1 RPMB (Replay Protected Memory Block) partition 4 general purpose partitions (optionally with a enhanced or extended attribute) Besides simply subdividing eMMC devices, some Intel NUCs having UEFI code in the boot partitions etc., another use case for the partition support is the activation of pseudo-SLC mode, which manufacturers of eMMC chips typically associate with the enhanced user data area and/ or the enhanced attribute of general purpose partitions. CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation. o Now that properly issuing CMD6 is crucial (so data isn't written to the wrong partition for example), make a step into the direction of correctly handling the timeout for these commands in the MMC layer. Also, do a SEND_STATUS when CMD6 is invoked with an R1B response as recommended by relevant specifications. o Add an IOCTL interface to mmcsd(4); this is sufficiently compatible with Linux so that the GNU mmc-utils can be ported to and used with FreeBSD (note that due to the remaining deficiencies outlined above SANITIZE operations issued by/with `mmc` currently most likely will fail). These latter have been added to ports as sysutils/mmc-utils. Among others, the `mmc` tool of mmc-utils allows for partitioning eMMC devices (tested working). o For devices following the eMMC specification v4.41 or later, year 0 is 2013 rather than 1997; so correct this for assembling the device ID string properly. o Let mmcsd.ko depend on mmc.ko. Additionally, bump MMC_VERSION as at least for some of the above a matching pair is required. o In the ACPI front-end of sdhci(4) describe the Intel eMMC and SDXC controllers as such in order to match the PCI one. Additionally, in the entry for the 80860F14 SDXC controller remove the eMMC-only SDHCI_QUIRK_INTEL_POWER_UP_RESET.
* MFC: r310309, r310340-310341, r311664, r311793-r311794marius2017-01-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | o sdhci/mmc: Minor whitespace cleanups o Add Braswell PCI IDs for Intel Cherryview o mmc: Accept even lower voltage for Cherryview And HP x2 210, per DragonFlyBSD 240bd9cd58f8259c12c14a8006837e698. o In mmcsd_task(), bio_resid was not being set to 0 on a successful read or write, resulting in random short-read and short-write returns for requests. Fixing this fixes nominal block I/O via mmcsd(4). Obtained from: DragonFlyBSD (fd4b97583be1a1e57234713c25f6e81bc0411cb0) o Add support for Intel Apollo Lake and Bay Trail eMMC PCI controllers. o Flesh out the support for Intel Braswell eMMC controllers further. o In sdhci_init_slot(), use the right capability field for determining the announced bus width based on MMC_CAP_*_BIT_DATA.
* MFC r308187, r311660, r311693, r311727, r311797:ian2017-01-151-3/+10
| | | | | | | | | | | | | | | | | | Toggle card insert/remove interrupt enable bits on events. Add a new sdhci interface method, get_card_present(). Now that the PRESENT_STATE register is only used for the inhibit bits loop in this function, sdhci_start_command(), eliminate the state variable and restructure the loop to read the register just once at the top of the loop. Add support for non-removable media, and a quirk to use polling to detect card insert/remove events on controllers that don't implement the insert and remove interrupts. Add sdhci_handle_card_present_locked() that can be called from the interrupt handler which already holds the mutex, and have sdhci_handle_card_present() be just a tiny wrapper that does the locking for external callers.
* Add a convenience macro that masks all the bits related to clock divisorsian2016-05-261-0/+3
| | | | | in all versions of the sdhci spec (the HI bits are just unused reserved bits in earlier versions).
* Add support for the BCM57765 card reader.adrian2015-10-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the BCM57765[2] card reader function included in Broadcom's BCM57766 ethernet/sd3.0 controller. This controller is commonly found in laptops and Apple hardware (MBP, iMac, etc). The BCM57765 chipset is almost fully compatible with the SD3.0 spec, but does not support deriving a frequency below 781KHz from its default base clock via the standard SD3.0-configured 10-bit clock divisor. If such a divisor is set, card identification (which requires a 400KHz clock frequency) will time out[1]. As a work-around, I've made use of an undocumented device-specific clock control register to switch the controller to a 63MHz clock source when targeting clock speeds below 781KHz; the clock source is likewise switched back to the 200MHz clock when targeting speeds greater than 781KHz. Additionally, this patch fixes a small sdhci_pci bug; the sdhci_pci_softc->quirks flag was not copied to the sdhci_slot, resulting in `quirk` behavior not being applied by sdhci.c. [1] A number of Linux/FreeBSD users have noted that bringing up the chipsets' associated ethernet interface will allow SD cards to enumerate (slowly). This is a controller implementation side-effect triggered by the ethernet driver's reading of the hardware statistics registers. [2] This may also fix card detection when using the BCM57785 chipset, but I don't have access to the BCM57785 chipset and can't verify. I actually snagged some BCM57785 hardware recently (2012 Retina MacBook Pro) and can confirm that this also fixes card enumeration with the BCM57785 chipset; with the patch, I can boot off of the internal sdcard reader. PR: kern/203385 Submitted by: Landon Fuller <landon@landonf.org>
* Raise the SDHCI timeout to 10 seconds and add a sysctl to allow changingloos2015-05-211-0/+1
| | | | | | | | | | | | | this value at runtime. The SD card specification says that a block write or a block erase can take up to 250ms to complete and thus, under some circumstances, the existent 2 seconds timeout was triggering with normal usage. This change fixes the sporadic controller timeout that happens on RPi and RPi 2. Discussed with: ian (some time ago)
* Add a new SDHCI quirk, SDHCI_QUIRK_DONT_SET_HISPD_BIT. Apparently someian2015-01-171-0/+2
| | | | | | | | | | | | | 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.
* Add defines for SDHCI 3.0 controllers.ian2015-01-171-0/+29
| | | | Submitted by: Michal Meloun <meloun@miracle.cz>
* Add a new sdhci quirk, SDHCI_QUIRK_WAITFOR_RESET_ASSERTED, to work aroundian2014-12-201-0/+2
| | | | | | | | | | | | | TI OMAP controllers which will return the reset-in-progress bit as zero if you read the status register too fast after setting the reset bit. The zero is apparently from a stale snapshot of the internal state presented in the interface register, and leads to a false indication that the reset is complete when it either hasn't started yet or is in-progress. The workaround is to first loop until the bit is seen as asserted, then do the normal loop waiting to see it de-asserted. Submitted by: Michal Meloun <meloun@miracle.cz>
* When command and data interrupts have been aggregated together, don't doian2014-12-201-1/+4
| | | | | | the data-completed processing if a command-error interrupt is also asserted. Reviewed by: Michal Meloun <meloun@miracle.cz>
* - Nuke unused sdhci_softc.marius2014-08-311-0/+2
| | | | | | | | | | | | | - Static'ize sdhci_debug local to sdhci.c. - Const'ify PCI device description strings. - Nuke redundant resource ID members from sdhci_pci_softc. - Nuke unused hw.sdhci_pci.debug tunable. - Add support for using MSI instead of INTx, controllable via the tunable hw.sdhci.enable_msi (defaulting to on) and tested with a RICOH R5CE823 SD controller. - Use NULL instead of 0 for pointers. MFC after: 3 days
* Add timeout logic to sdhci, separate from the timeouts done by the hardware.ian2014-02-151-0/+1
| | | | | | | | | | | | If the hardware is not in a good state (like maybe clocks aren't running because of a configuration glitch) its timeout clock may also not work correctly, and the next command sent will hang that thread forever. The thread in question is usually the one and only thread (at init time) or a bio queue worker thread whose lockup will eventually lead to the whole system locking up when it runs out of buffers. No sd card command should take longer than 250ms. This new code establishes a 1-second timeout to allow plenty of safety margin over that.
* Fix the definition of the SDHCI_STATE_DAT and SDHCI_STATE_CMD fields, andian2014-02-121-2/+3
| | | | add SDHCI_RETUNE_REQUEST. None of these are actually used in the code yet.
* Add a new SDHCI_QUIRK_DONT_SHIFT_RESPONSE for hardware that pre-shiftsian2013-08-181-0/+2
| | | | | | the response bits the way we do in software. While the hardware is just doing the sensible thing rather than leaving it to the software, it's in violation of the spec by doing so. Grrrr.
* Add named constants for 8-bit bus support. The sdhci and mmc driversian2013-08-161-0/+3
| | | | | don't have support for this yet, but some low-level hardware is ready for it when the higher layers catch up.
* Add hooks for plugging platform-provided transfer backend.gonzo2013-02-281-1/+5
| | | | | | | | | | | | | In order to use platorm backend hardware driver should impement three methods: - platform_start_transfer and platform_finish_transfer to start and finish transfer - platform_will_handle - check whether transaction is suitable for backend. If not - driver will fall back to PIO mode. Submitted by: Daisuke Aoyama <aoyama at peach.ne.jp> Approved by: ian@
* Various timing-related fixes:gonzo2013-02-161-0/+1
| | | | | | | | | | - Replace divisor numbers with more descirptive names - Properly calculate minimum frequency for SDHCI 3.0 - Properly calculate frequency for SDHCI 3.0 in mmcbr_set_clock - Add min_freq method to sdhci_if.m and provide default implementation. By re-implementing this method hardware drivers can control frequency controller operates when executing initialization sequence
* - Get proper maximum clock frequency for SDHCI v3.0 and highergonzo2012-11-301-0/+1
|
* Add new quirks:gonzo2012-10-291-2/+14
| | | | | | | | - Data timeout is broken - Data timeout uses SD clock - Capabilities register is unavailable Add calculations for clock divisor for SDHCI 3.0
* Split sdhci driver in two parts: sdhci and sdhci_pci.gonzo2012-10-161-17/+75
| | | | | | | | | | | sdchi encapsulates a generic SD Host Controller logic that relies on actual hardware driver for register access. sdhci_pci implements driver for PCI SDHC controllers using new SDHCI interface No kernel config modifications are required, but if you load sdhc as a module you must switch to sdhci_pci instead.
* Add support for RICOH R5CE823 card reader, that can be found inglebius2012-02-091-0/+9
| | | | | | | some Lenovo laptops. The conroller needs a quirk to lower its frequency, and after that it operates normally.
* Import sdhci (PCI SD Host Controller) driver.mav2008-10-211-0/+190
Driver supports PCI devices with class 8 and subclass 5 according to SD Host Controller Specification. Update NOTES, enable module and static build. Enable related mmc and mmcsd modules build. Discussed on: mobile@, current@
OpenPOWER on IntegriCloud