aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mmc
Commit message (Collapse)AuthorAgeFilesLines
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-252-2/+2
| | | | Sponsored by: Netflix
* jh7110: enable MMC driverMitchell Horne2024-05-071-0/+114
| | | | | | | | Add a variant of the existing dwmmc driver, and enable it in the GENERIC kernel. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44026
* mmc_fdt_parse: remove redundant bootverbose checkAndriy Gapon2024-01-281-1/+1
|
* dwmmc: fix a typoAndriy Gapon2024-01-281-1/+1
|
* regulator: Move regulator code in dev/regulatorEmmanuel Vadot2024-01-104-4/+4
| | | | | | | | | | | We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: emaste, imp Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43194
* hwreset: Move reset code in dev/hwresetEmmanuel Vadot2024-01-101-1/+1
| | | | | | | | | | | We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: imp Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43192
* clk: Move clock code in dev/clkEmmanuel Vadot2024-01-104-4/+4
| | | | | | | | | | | We've removed kernel option EXT_RESOURCES almost two years ago. While it was ok to have some code under a common 'extres' subdirectory at first, we now have a lot of consumer of it and we made it mandatory so no need to have it under a cryptic name. Reviewed by: mhorne Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D43191
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2711-11/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-163-3/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1611-22/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1610-20/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-128-8/+8
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* mmc(4): Don't call bridge driver for timings not requiring tuningMarius Strobl2023-04-181-0/+9
| | | | | | | | | | | | The original idea behind calling into the bridge driver was to have the logic deciding whether tuning is actually required for a particular bus timing in a given slot as well as doing the sanity checking only on the controller layer which also generally is better suited for these due to say SDHCI_SDR50_NEEDS_TUNING. On another thought, not every such driver should need to check whether tuning is required at all, though, and not everything is SDHCI in the first place. Adjust sdhci{,_fsl_fdt}(4) accordingly, but keep sdhci_generic_tune() a bit cautious still.
* mmc: purge EOL release compatibilityElliott Mitchell2023-02-041-5/+0
| | | | | | | | | Remove support for FreeBSD 7 needed for a product that's not shipped FreeBSD 7 in ~15 years.... Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/603 Differential Revision: https://reviews.freebsd.org/D35560
* sdio: Add CCCR speed definesEmmanuel Vadot2022-08-101-1/+13
| | | | Those are the defines needed to change speed on a SDIO card.
* kerneldump: remove physical argument from d_dumperMitchell Horne2022-05-131-4/+2
| | | | | | | | | | | The physical address argument is essentially ignored by every dumper method. In addition, the dump routines don't actually pass a real address; every call to dump_append() passes a value of zero for physical. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35173
* mmc: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-068-32/+11
|
* Extend device_get_property APIKornel Duleba2022-03-101-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | In order to support various types of data stored in device tree properties or ACPI _DSD packages, create a new enum so the caller can specify the expected type of a property they want to read, according to the binding. The bus logic will use that information to process the underlying data. For example in DT all integer properties are stored in BE format. In order to get constant results across different platforms we need to convert its endianness to match the host. Another example are ACPI_TYPE_INTEGER properties stored as uint64_t. Before this patch the ACPI logic would refuse to read them if the provided buffer was smaller than 8 bytes. Now this can be handled by using DEVICE_PROP_UINT32 type. Modify the existing consumers of this API to reflect the changes and update the man pages accordingly. Reviewed by: mw Obtained from: Semihalf MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33457
* dwmmc: Make ext_resources non-optionalEmmanuel Vadot2022-02-213-19/+0
| | | | | | | | EXT_RESOURCES have been introduced in 12-CURRENT and all supported releases have it enabled in their kernel config. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33822
* mmc: Make ext_resources non-optionalEmmanuel Vadot2022-02-213-10/+0
| | | | | | | | EXT_RESOURCES have been introduced in 12-CURRENT and all supported releases have it enabled in their kernel config. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33821
* mmc_da: implement d_dump method, sddadumpAndriy Gapon2022-01-121-0/+15
| | | | | | | | | | | | | | | | | | | | sddadump has been derived from sddastart. mmc_sim interface has grown a new method, cam_poll, to support polled operation. mmc_sim code has been changed to provide a sim_poll hook only if the controller implements the new method. The hooks is implemented in terms of the new mmc_sim_cam_poll method. Additionally, in-progress CCB-s now have CAM_REQ_INPROG status to satisfy xpt_pollwait(). mmc_sim_cam_poll method has been implemented in dwmmc host controller. Reviewed by: manu, mav, imp MFC after: 2 weeks Relnotes: perhaps Differential Revision: https://reviews.freebsd.org/D33843
* mmc: Fix HS200/HS400 capability checkKornel Duleba2021-11-291-2/+4
| | | | | | | | | | | | | | | HS200 and HS400 speeds can be enabled either with 1.2, or 1.8V signaling voltage. Because of that we have four cabability flags: MMC_CAP_MMC_HS200_120, MMC_CAP_MMC_HS200_180, MMC_CAP_MMC_HS400_120, MMC_CAP_MMC_HS400_180. MMC logic only enables HS200/HS400 mode if both flags are set for the corresponding speed. Fix that by being more permissive in host timing cap check. Reviewed by: manu, mw MFC after: 2 weeks Obtained from: Semihalf Sponsored by: Alstom Group Differential revision: https://reviews.freebsd.org/D33130
* mmc: plug set-but-not-used varsMateusz Guzik2021-11-251-4/+0
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* dwmmc: Calculate the maximum transaction length correctly.Michal Meloun2021-10-081-8/+7
| | | | | | | | | | We should reserve two descriptors (not MMC_SECTORS) for potentially unaligned (so bounced) buffer fragments, one for the starting fragment and one for the ending fragment. Submitted by: kjopek@gmail.com MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D30387
* mmc: Fix regression in 8a8166e5bcfb breaking Stratix 10 bootJessica Clarke2021-09-291-3/+3
| | | | | | | | | | | | | | | | The refactoring in 8a8166e5bcfb introduced a functional change that breaks booting on the Stratix 10, hanging when it should be attaching da0. Previously OF_getencprop was called with a pointer to host->f_max, so if it wasn't present then the existing value was left untouched, but after that commit it will instead clobber the value with 0. The dwmmc driver, as used on the Stratix 10, sets a default value before calling mmc_fdt_parse and so was broken by this functional change. It appears that aw_mmc also does the same thing, so was presumably also broken on some boards. Fixes: 8a8166e5bcfb ("mmc: switch mmc_helper to device_ api") Reviewed by: manu, mw Differential Revision: https://reviews.freebsd.org/D32209
* mmc: fix 1-byte reallocs (when it should have been sizeof device_t)Mateusz Guzik2021-09-251-1/+1
| | | | | | | | | | | | Reported by KASAN: panic: ASan: Invalid access, 8-byte write at 0xfffffe00f0992610, RedZonePartial(1) panic() at panic+0xb5/frame 0xffffffff86a595b0 __asan_store8_noabort() at __asan_store8_noabort+0x376/frame 0xffffffff86a59670 mmc_go_discovery() at mmc_go_discovery+0x6c61/frame 0xffffffff86a5a790 mmc_delayed_attach() at mmc_delayed_attach+0x35/frame 0xffffffff86a5a7b0 [snip] Sponsored by: Rubicon Communications, LLC ("Netgate")
* dwmmc: Remove dwmmc_setup_bus call from start_cmdEmmanuel Vadot2021-09-211-3/+0
| | | | | | There is no need to re-setup the bus before each commands. Tested-on: Rock64, RockPro64 Reported by: avg
* dwmmc: Properly implement power_off/power_upEmmanuel Vadot2021-09-213-12/+11
| | | | | | | | | | | Write to the PWREN register should be done in update_ios based on the power_mode value in the ios struct. Also none of the manual (RockChip and Altera) and Linux talks about the needed for an inverted PWREN value so just remove this. This fixes eMMC (and possibly SD) when u-boot didn't setup the controller. Reported by: avg Tested-on: Rock64, RockPro64
* mmc: switch mmc_helper to device_ apiBartlomiej Grzesik2021-09-205-135/+229
| | | | | | | | | | | | 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
* Address the reported mmc serialization issue.Scott Long2021-08-101-7/+1
| | | | | | | | | | Reset the mmc owner before calling the bridge release host callback. Some people are hitting the "mmc: host bridge didn't serialize us." panic as the bridge is released before the mmc owner is reset. Submitted by: luiz Sponsored by: Rubicon Communications, LLC ("Netgate")
* mmc_fdt_helper: correct typo in DT property nameBartłomiej Grzesik2021-08-091-1/+1
| | | | | | | | | | | 'no-1-8-v' is a proper name according to the DT binding documentation (https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/mmc-controller.yaml). Fixes: e63fbd7bb7a25 MFC after: 1 week Sponsored by: Semihalf
* mmc: Drain the intrhook in mmc_detach()Yang Zhong2021-07-221-0/+1
| | | | | | | | | | | | | | | | Buggy SD card drivers may attach and detach a mmc(4) driver instance in quick succession. In this case mmc(4) must disestablish its intrhook callback during detach. Thus, this change adds a call to config_intrhook_drain(), which blocks or does nothing if the intrhook is running or has already ran (the SD card was plugged in), and disestablishes the hook if it hasn't ran yet (the SD card was not plugged in). PR: 254373 Reviewed by: imp, manu, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31262
* dwmmc: Fix MMCCAM block size supportEmmanuel Vadot2021-07-221-4/+12
| | | | | | | | | When using SDIO the block size if per function and most of the time not equal to MMC_SECTOR_SIZE, fix sdio on dwmmc by setting the correct block size in the mmc registers. MFC after: 1 month Sponsored by: Diablotin Systems
* newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh2021-06-231-6/+5
| | | | | | | | | | | | | | | | | | | | | | bus_child_{pnpinfo,location} with sbuf Now that the upper layers all go through a layer to tie into these information functions that translates an sbuf into char * and len. The current interface suffers issues of what to do in cases of truncation, etc. Instead, migrate all these functions to using struct sbuf and these issues go away. The caller is also in charge of any memory allocation and/or expansion that's needed during this process. Create a bus_generic_child_{pnpinfo,location} and make it default. It just returns success. This is for those busses that have no information for these items. Migrate the now-empty routines to using this as appropriate. Document these new interfaces with man pages, and oversight from before. Reviewed by: jhb, bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29937
* mmc:: Undo my conversion of (bool) to !!.Warner Losh2021-06-031-2/+2
| | | | | | | | The need for !! over (bool) pre-dates gcc 4.2, so go with the patch as-submitted because the kernel tends to prefer that. Suggested by: emaste@ Sponsored by: Netflix
* mmc-fdt: fix mmc_fdt_gpio_get_{present,readonly}Priit Trees2021-06-031-2/+2
| | | | | | | | | | | Currently, mmc_fdt_gpio_get_{present,readonly} return all time true. true ^ 100b = true false ^ 100b = true since that's done after promotion to integers. Use !! to convert the bit to a bool before xor. Reviewed by: imp@ (converted to (bool) to !! for portability) Pull Request: https://github.com/freebsd/freebsd-src/pull/461
* mmc: ignore CRC errors from CMD13 (status) when changing ratesAustin Shafer2021-06-031-2/+14
| | | | | | | | | | | | | Update mmc_switch_status to ignore a few CRC errrors when asking for the card status after setting the new rate with CMD6. Since the card may take a little while to make the switch, it's possible we'll get a communications error if we sent the command at the wrong time. Several low end laptops needs this workaround as they have a window that seems longer than other systems. This is known to fix at least the Acer Aspire A114-32-P7E5. Reviewed by: imp@, manu@ Differential Revision: https://reviews.freebsd.org/D24740
* dwmmc: Add bus_generic_add_child in the methodsEmmanuel Vadot2021-05-211-0/+2
| | | | | | | Otherwise sdiob cannot add it's children. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30295
* mmc: dwmmc: Call mmc_fdt_set_powerEmmanuel Vadot2021-05-211-0/+2
| | | | | | | | This allow us to powerup/down the card and enabling/disabling the regulators if any. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30292
* mmc_fdt_helper: Add mmc_fdt_set_powerEmmanuel Vadot2021-05-212-0/+43
| | | | | | | | This helper can be used to enable/disable the regulator and starting the power sequence of sd/sdio/eMMC cards. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30291
* mmc_fdt_helpers: Parse the optional pwrseq element.Emmanuel Vadot2021-05-212-0/+10
| | | | | | | | | If a sd/emmc node have a pwrseq property parse it and get the corresponding driver. This can later be used to powerup/powerdown the SDIO card or eMMC. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30289
* mmc: Add mmc-pwrseq driverEmmanuel Vadot2021-05-212-0/+232
| | | | | | | | This driver is used to power up sdio card or eMMC. It handle the reset-gpio, clocks and needed delays for powerup/powerdown. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30288
* dwmmc: Add \n to a debug printfEmmanuel Vadot2021-04-271-1/+1
|
* mmc: dwmmc: Convert driver to use the mmc_sim interfaceEmmanuel Vadot2021-04-272-151/+42
| | | | | | | | A lot more generic cam related things are done in mmc_sim so this simplify the driver a lot. Differential Revision: https://reviews.freebsd.org/D27487 Reviewed by: kibab
* Consider the broken card detect flag that comes from 'broken-cd;'Ruslan Bukin2021-04-271-1/+2
| | | | | | | | | | | | dts property. This fixes operation on Intel Stratix 10 devices. Tested on Terasic DE10-Pro. Reviewed by: manu Sponsored by: UKRI Differential revision: https://reviews.freebsd.org/D29999
* dwmmc: Multiple busdma fixes.Michal Meloun2021-02-031-15/+32
| | | | | | | | | | | | | | | - limit maximum segment size to 2048 bytes. Although dwmmc supports a buffer fragment with a maximum length of 4095 bytes, use the nearest lower power of two as the maximum fragment size. Otherwise, busdma create excessive buffer fragments. - fix off by one error in computation of the maximum data transfer length. - in addition, reserve two DMA descriptors that can be used by busdma bouncing. The beginning or end of the buffer can be misaligned. - Don’t ignore errors passed to bus_dmamap_load() callback function. - In theory, a DMA engine may be running at time when next dma descriptor is constructed. Create a full DMA descriptor before OWN bit is set. MFC after: 2 weeks
* mmcsd(4): properly set BIO error when partition switching failsMarius Strobl2021-01-211-6/+4
| | | | | | | While at it, remove redundant braces and goto in mmcsd_task(). Reported by: Coverity CID: 1419639
* dwmmc: dwmmc_switch_vccq is only used in MMCCAM kernelEmmanuel Vadot2020-11-161-2/+2
| | | | | | | Silence the build for non MMCCAM kernel Notes: svn path=/head/; revision=367721
* mmc: clean up empty lines in .c and .h filesMateusz Guzik2020-09-012-2/+0
| | | | Notes: svn path=/head/; revision=365205
* dwmmc: remove printf even under bootverboseBjoern A. Zeeb2020-08-171-5/+1
| | | | | | | | | | | | | Remove two debugging printfs, even if hidden under boot -v. They seemed to be of debug nature and always spit onto the console when running camcontrol devlist -v. Reviewed by: manu MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D25962 Notes: svn path=/head/; revision=364324