aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/sdhci
Commit message (Collapse)AuthorAgeFilesLines
...
* sdhci_fsl_fdt: Implement pulse width detection errataHubert Mazur2021-12-081-2/+20
| | | | | | | | | | | Some boards do not detect pulse width reliably. Implement workaround by writing 0 to special register. Apply errata for board by adding flag to chosen soc specific data. Obtained from: Semihalf Sponsored by: Alstom Group Reviewed by: mw, manu Differential Revision: https://reviews.freebsd.org/D33222
* sdhci_fsl_fdt: Provide more accurate clk calculationArtur Rojek2021-11-051-17/+57
| | | | | | | | | | | | | | | | | SDHCI controllers found in the QorIQ SoCs offer improved accuracy of the clock frequency selection, compared to the SDHCI standard. Frequency selection is performed using two divider registers, named prescaler and divisor, according to the following formula: frequency = base clock / (prescaler * divisor), where prescaler can be bypassed (set to 1) and divisor permitted to take odd values. Rather than depend on clock division precalculated by sdhci core, make use of this property of the divider registers and achieve frequencies closer to the ones requested. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32706
* sdhci_fsl_fdt: Add full support for software resetArtur Rojek2021-11-051-3/+25
| | | | | | | | | | | | | | When performing software reset, this controller does not clear all the required hw registers. In particular, tuning block is left in enabled state, inhibiting operation of some eMMC cards. The existing solution was to disable the ability to call SDHCI_RESET_ALL. As this issue is now better understood, enable the SDHCI_RESET_ALL flag, provide a custom reset devmethod and clear selected registers by hand. Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D32705
* sdhci: Provide devmethod for software resetArtur Rojek2021-11-053-77/+87
| | | | | | | | | | | Some sdhci controllers require custom software reset logic. Accommodate this need by introducing a new SDHCI_RESET devmethod. Move the existing reset logic into sdhci_generic_reset and use it as a default for the aforementioned method. Obtained from: Semihalf Sponsored by: Alstom Group Differeential revision: https://reviews.freebsd.org/D32704
* sdhci: Fix crash caused by M_WAITOK in sdhci dumpsBartlomiej Grzesik2021-10-051-2/+10
| | | | | | | | | | | | In some contexts it is illegal to wait for memory allocation, causing kernel panic. By default sbuf_new passes M_WAITOK to malloc, which caused crashes when sdhci_dumpcaps or sdhci_dumpregs was callend in non sutiable context. Add SBUF_NOWAIT flag to sbuf_new to fix this. Obtained from: Semihalf Differential revision: https://reviews.freebsd.org/D32075
* sdhci: add a missing newlineMitchell Horne2021-09-291-1/+1
|
* sdhci_xenon: add ACPI supportBartlomiej Grzesik2021-09-291-0/+140
| | | | | | | | Add support for ACPI device probing for SDHCI controller found on Marvell chips. Reviewed by: mw Sponsored by: Semihalf Differential revision: https://reviews.freebsd.org/D31600
* sdhci_xenon: split driver file into generic file and fdt partsBartlomiej Grzesik2021-09-293-146/+262
| | | | | | | | | | This patch splits driver code into two seperate files sdhci_xenon.c and sdhci_xenon_fdt.c. This will allow future implementation of ACPI discovery of sdhci on Xenon chips. Reviewed by: mw Sponsored by: Semihalf Differential revision: https://reviews.freebsd.org/D31599
* mmc: switch mmc_helper to device_ apiBartlomiej Grzesik2021-09-202-2/+2
| | | | | | | | | | | | Add generic mmc_helper which uses newly introduced device_*_property api. Thanks to this change the sd/mmc drivers will be capable of parsing both DT and ACPI description. Ensure backward compatibility for all mmc_fdt_helper users. Reviewed by: manu, mw Sponsored by: Semihalf Differential revision: https://reviews.freebsd.org/D31598
* sdhci: add sysctls to dump sdhci registers and capabilitesBartlomiej Grzesik2021-09-131-58/+165
| | | | | | | | | Add sysctls dev.sdhci.X.slotY.dumpregs and dev.sdhci.X.slotY.dumpcaps which dumps sdhci registers or capabilities. Obtained from: Semihalf Reviewed by: mw Differential revision: https://reviews.freebsd.org/D31406
* sdhci_xenon: remove redundant code in property parsingBartlomiej Grzesik2021-08-171-37/+32
| | | | | | | | | | | Remove redundant ofw property parsing in driver code, is already taken care of in mmc_fdt_helpers. Move ofw parsing to attach method. Reviewed by: manu Sponsored by: Semihalf Differential Revision: https://reviews.freebsd.org/D31409
* sdhci_xenon: add AP807 compatible stringBartlomiej Grzesik2021-08-171-0/+1
| | | | | | | | | This patch adds compatible string for xenon controller found on AP807 north brige. It is fully compatible with existing driver. Reviewed by: manu Sponsored by: Semihalf Differential Revision: https://reviews.freebsd.org/D31407
* Call wakeup() with the lock held to avoid missed wakeup races.Scott Long2021-08-101-1/+1
| | | | | Submitted by: luiz Sponsored by: Rubicon Communications, LLC ("Netgate")
* MMCCAM: fix a panic after cam_sim_alloc_dev() removal in sdhci.cBjoern A. Zeeb2021-07-071-1/+1
| | | | | | | | | | | | During the removal of cam_sim_alloc_dev() in aeb04e88f51a706ef4b6a380bf5e82d15203fb6a for sdhci.c and the follow-up build-fix in a72af82e3169fcacfedf9047120679300a4296f8 slot->dev and slot->bus got mixed up for MMCCAM; slot->dev is only used in the !MMCCAM case so is uninitialised here leading to a panic; switch back to slot->bus to return to the status quo. Reviewed by: imp (ack on arm@) X-Differential Revision: https://reviews.freebsd.org/D30857
* cam: Fix GENERIC-MMCCAM buildWarner Losh2021-06-281-1/+1
| | | | | | | Fix forgotten argument and type error. MMCCAM isn't enabled by default, and I'd mistakenly thought it was, so these went undetected precommit. Sponsored by: Netflix
* sdhci: stop using cam_sim_alloc_devWarner Losh2021-06-281-2/+2
| | | | | Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30857
* sdhci_xenon: add UHS supportMarcin Wojtas2021-06-022-0/+44
| | | | | | | | | | | | | | | This patch adds the necessary methods resolution to the sdhci_xenon driver which are required to configure UHS modes for SD/MMC devices. Apart from the two generic routines, the custom sdhci_xenon_set_uhs_timing function is responsible for setting the SDHCI_HOST_CONTROL2 register with appropriate mode select values - in case of HS200 and HS400 they are non-standard. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30565 MFC after: 2 weeks
* sdhci_xenon: improve the VCCQ voltage switch sequenceMarcin Wojtas2021-06-021-16/+68
| | | | | | | | | | | | Improve the VCCQ voltage switch, so that to properly handle the SDHCI_HOST_CONTROL2 register signaling flags and along with manipulating the regulator. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30564 MFC after: 2 weeks
* sdhci_xenon: allow to properly disable the UHS signalingMarcin Wojtas2021-06-021-6/+8
| | | | | | | | | | | | | | | Until now the "no-1-8-v" DT flag wrongly disabled the SDHCI_CAN_VDD_180 - slot 1.8V power supply capability, whereas it refers to the signaling voltage. Fix the sdhci_xenon_read_4 and allow to disable the UHS modes depending on the DT property or PHY slow mode. While at it - make sure the unsupported 1.2V signaling is always disabled and not reported in the bootverbose log. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30563 MFC after: 2 weeks
* sdhci_xenon: enable MMC FDT parsingMarcin Wojtas2021-06-021-16/+17
| | | | | | | | | | | | | The mmc_fdt_parse allows to parse more MMC-related FDT properties. Start using it. "wp-inverted" property, VQMMC and newly added VMMC power supply parsing is now done in a generic code. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30562 MFC after: 2 weeks
* sdhci: allow setting MMC capabilities before sdhci_init_slotMarcin Wojtas2021-06-021-1/+2
| | | | | | | | | | | | | With this change the host controller drivers can set the MMC capabilities (e.g. using mmc_fdt_parse() helper) before calling sdhci_init_slot(). This way the configuration dump (eg. in bootverbose) can include the possible additional information. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30561 MFC after: 2 weeks
* sdhci: extend bus_dma_tag boundary to 64-bit spaceMarcin Wojtas2021-06-021-4/+5
| | | | | | | | | | | | This patch adds support for the SDHCI_CAN_DO_64BIT capability, so that to allow 64-bit DMA operation for the controllers which support this feature. Reviewed by: manu Obtained from: Semihalf Sponsored by: Marvell Differential Revision: https://reviews.freebsd.org/D30560 MFC after: 2 weeks
* mmccam: Add two new XPT for MMC and use them in mmc_sim and sdhciEmmanuel Vadot2021-05-211-0/+2
| | | | | | | | | | | | | | | | | For the discovery phase of SD/eMMC we need to do some transaction in a async way. The classic CAM XPT_{GET,SET}_TRAN_SETTING cannot be used in a async way. This also allow us to split the discovery phase into a more complete state machine and we don't mtx_sleep with a random number to wait for completion of the tasks. For mmc_sim we now do the SET_TRAN_SETTING in a taskqueue so we can call the needed function for regulators/clocks without the cam lock(s). This part is still needed to be done for sdhci. We also now save the host OCR in the discovery phase as it wasn't done before and only worked because the same ccb was reused. Reviewed by: imp, kibab, bz Differential Revision: https://reviews.freebsd.org/D30038
* sdhci_fsl_fdt: Skip vccq reconfiguration without regulatorMarcin Wojtas2021-05-201-4/+4
| | | | | | | | | | | There is no need to preform any voltage reconfiguration in case the vccq regulator is not physically attached to the slot. Submitted by: Lukasz Hajec <lha@semihalf.com> Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30355
* sdhci_fsl_fdt.c: Read supported voltages from dts.Marcin Wojtas2021-05-141-8/+65
| | | | | | | | | | | | We shouldn't overwrite capability register. Instead, voltages supported by the controller have to be read from dts, as the hardware doesn't report correct values. Submitted by: Lukasz Hajec <lha@semihalf.com> Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30123
* sdhci_fsl_fdt.c: Add a missing call to mmc_fdt_parse.Marcin Wojtas2021-05-141-4/+106
| | | | | | | | | | | Add a missing call to mmc_fdt_parse, without it some dts properties are not parsed. Submitted by: Lukasz Hajec <lha@semihalf.com> Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30122
* sdhci_fsl_fdt.c: Add support for LS1028a.Marcin Wojtas2021-05-141-0/+7
| | | | | | | | | | Add data specific for SoC, including all necessary quirks. Submitted by: Lukasz Hajec <lha@semihalf.com> Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30121
* sdhci_fsl_fdt: specify base clk divisor per SoCMarcin Wojtas2021-05-071-4/+8
| | | | | | | | | | | | | Only LS1046A and LS1028A require the base clk to be divided by 2. Implement that by moving the divider to a SoC specific data. This commit fixes base clk setup for the entire SoC family, including the already suported LS2160A. Submitted by: Lukasz Hajec <lha@semihalf.com> Reviewed by: manu Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D30120
* Make MAXPHYS tunable. Bump MAXPHYS to 1M.Konstantin Belousov2020-11-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace MAXPHYS by runtime variable maxphys. It is initialized from MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys. Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer cache buffers exactly to atop(maxbcachebuf) (currently it is sized to atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1. The +1 for pbufs allow several pbuf consumers, among them vmapbuf(), to use unaligned buffers still sized to maxphys, esp. when such buffers come from userspace (*). Overall, we save significant amount of otherwise wasted memory in b_pages[] for buffer cache buffers, while bumping MAXPHYS to desired high value. Eliminate all direct uses of the MAXPHYS constant in kernel and driver sources, except a place which initialize maxphys. Some random (and arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted straight. Some drivers, which use MAXPHYS to size embeded structures, get private MAXPHYS-like constant; their convertion is out of scope for this work. Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs, dev/siis, where either submitted by, or based on changes by mav. Suggested by: mav (*) Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions) Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27225 Notes: svn path=/head/; revision=368124
* sdhci: mmccam: Update vccq in the driver iosEmmanuel Vadot2020-11-261-0/+5
| | | | | | | Otherwise we always report that the card is running at 1.2V. Notes: svn path=/head/; revision=368061
* sdhci: Only print mmccam debug code if hw.sdhci.debug is > 1Emmanuel Vadot2020-11-261-8/+16
| | | | Notes: svn path=/head/; revision=368060
* sdhci: clean up empty lines in .c and .h filesMateusz Guzik2020-09-012-7/+2
| | | | Notes: svn path=/head/; revision=365158
* Introduce the SDHCI driver for NXP QorIQ Layerscape SoCsMarcin Wojtas2020-09-011-0/+680
| | | | | | | | | | | | | | | | | | | | | Implement support for an eSDHC controller found in NXP QorIQ Layerscape SoCs. This driver has been tested with NXP LS1046A and LX2160A (Honeycomb board), which is incompatible with the existing sdhci_fsl driver (aiming at older chips from this family). As such, it is not intended as replacement for the old driver, but rather serves as an improved alternative for SoCs that support it. It comes with support for both PIO and Single DMA modes and samples the clock from the extres clk API. Submitted by: Artur Rojek <ar@semihalf.com> Reviewed by: manu, mmel, kibab Obtained from: Semihalf Sponsored by: Alstom Group Differential Revision: https://reviews.freebsd.org/D26153 Notes: svn path=/head/; revision=365054
* sdhci(4): Recognize the Texas Instruments PCIxx12 card reader.Mark Johnston2020-08-251-0/+3
| | | | | | | | | PR: 248650 Submitted by: Lars Herschke <lhersch@dssgmbh.de> MFC after: 1 week Notes: svn path=/head/; revision=364779
* mmccam: Add a generic mmccam_start_discovery functionEmmanuel Vadot2020-07-221-44/+2
| | | | | | | | | | | This is a generic function start a scan request for the given cam_sim. Other driver can now just use this function to request a new rescan. Submitted by: kibab Notes: svn path=/head/; revision=363425
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* No need to have an extra layer of indirection here. Call the sdhci_cam_requiestWarner Losh2020-01-271-16/+1
| | | | | | | routine directly when handling a MMIO request. Notes: svn path=/head/; revision=357182
* Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. PassWarner Losh2020-01-271-26/+2
| | | | | | | in the parameters needed for the different sims, but it's almost all identical. Notes: svn path=/head/; revision=357181
* Regularize my copyright noticeWarner Losh2019-12-041-2/+1
| | | | | | | | | | | | o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
* Relax the sdhci(4) check that filters out the 1.8v voltage option unlessIan Lepore2019-10-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | | the slot is flagged as 'embedded'. The features related to embedded and shared slots were added in v3.0 of the sdhci spec. Hardware prior to v3 sometimes supported 1.8v on non- removable devices in embedded systems, but had no way to indicate that via the standard sdhci registers (instead they use out of band metadata such as FDT data). This change adds the controller specification version to the check for whether to filter out the 1.8v selection. On older hardware, the 1.8v option is allowed to remain. On 3.0 or later it still requires the embedded-slot flag to remain. This is part of the fix for PR 241301 (eMMC not detected on Beaglebone). Changes to the sdhci_ti driver are also needed for a full fix. PR: 241301 Notes: svn path=/head/; revision=353651
* Allow the sdhci timeout sysctl var to be set as a tunable. Also, add aIan Lepore2019-08-101-2/+2
| | | | | | | missing newline in a warning printf. Notes: svn path=/head/; revision=350847
* Add emmc support for Rockchip RK3399 SoC.Ganbold Tsagaankhuu2019-07-201-0/+245
| | | | | | | | | | Tested on NanoPC-T4 board. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D20156 Notes: svn path=/head/; revision=350162
* Add support for the GPIO SD Card VCC regulator/switch and the GPIO SD CardLuiz Otavio O Souza2019-06-101-0/+83
| | | | | | | | | | | | | | detection pins to the Marvell Xenon SDHCI controller. These features are enable by 'vqmmc-supply' and 'cd-gpios' properties in the DTS. This fixes the SD Card detection on espressobin. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=348882
* Improve sdhci slot_printf() debug printing.Bjoern A. Zeeb2019-06-081-4/+9
| | | | | | | | | | | | | | | | | | | Currently slot_printf() uses two printf() calls to print the device-slot name, and actual message. When other printf()s are ongoing in parallel this can lead to interleaved message on the console, which is especially unhelpful for debugging or error messages. Take a hit on the stack and vsnprintf() the message to the buffer. This way it can be printed along with the device-slot name in one go avoiding console gibberish. Reviewed by: marius MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19747 Notes: svn path=/head/; revision=348801
* Introduce sim_dev and cam_sim_alloc_dev().Bjoern A. Zeeb2019-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add cam_sim_alloc_dev() as a wrapper to cam_sim_alloc() which takes a device_t instead of the unit_number (which we can derive from the dev again). Add device_t sim_dev to struct cam_sim. It will be used to pass through the bus for cases when both sides of CAM speak newbus already and we want to link them (yet make the calls through CAM for now). SDIO will be the first consumer of this. For that make use of cam_sim_alloc_dev() in sdhci under MMCCAM. This will also allow people to start iterating more on the idea to newbus-ify CAM without changing 50+ device drivers from the start. Also to be clear there are callers to cam_sim_alloc() which do not have a device_t (e.g., XPT) or provide their own unit number so we cannot simply switch the KPI entirely. Submitted by: kibab (original idea, see https://reviews.freebsd.org/D12467) Reviewed by: imp, chuck MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19746 Notes: svn path=/head/; revision=348800
* Improve error/debug messages in sdhci.cBjoern A. Zeeb2019-06-011-3/+5
| | | | | | | | | | | | | | When starting a command also print the opcode and flags. More consitently print flags as hex. Use slot_printf rather than printf in one case. MFC after: 6 weeks Reviewed by: marius, kibab, imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19748 Notes: svn path=/head/; revision=348493
* Implement CMD53 block mode support for SDHCI and AllWinner-based boardsIlya Bakulin2019-04-101-12/+39
| | | | | | | | | | | | If a custom block size requested, use it, otherwise revert to the previous logic of using just a data size if it's less than MMC_BLOCK_SIZE, and MMC_BLOCK_SIZE otherwise. Reviewed by: bz Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D19783 Notes: svn path=/head/; revision=346098
* Use information about max data size that the controller is able to operateIlya Bakulin2019-04-011-0/+14
| | | | | | | | | | | | | | Using DFLTPHYS/MAXPHYS is not always OK, instead make it possible for the controller driver to provide maximum data size to MMCCAM, and use it there. The old stack already does this. Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15892 Notes: svn path=/head/; revision=345775
* Whitespace cleanup in sdhci.cBjoern A. Zeeb2019-03-211-52/+48
| | | | | | | | | | | No functional changes. Replace whitespace by tabs, indent with 4 spaces, coalesce multi-line shorter than 80 characters, MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345372
* Align struct sdhci_slot MMCCAM members.Bjoern A. Zeeb2019-03-211-4/+4
| | | | | | | | | | Whitespace only, no functional change. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=345370