aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mmc
Commit message (Collapse)AuthorAgeFilesLines
* mmc_fdt_parse: remove redundant bootverbose checkAndriy Gapon2024-02-171-1/+1
| | | | (cherry picked from commit 43ca38eb59ff194fb6d8ad589e74147d94717bf4)
* dwmmc: fix a typoAndriy Gapon2024-02-171-1/+1
| | | | (cherry picked from commit ea7f45d3d8d5d41a9cded5765dea43ed215a663b)
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-233-3/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 031beb4e239b)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-2311-22/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-2310-20/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* mmc(4): Don't call bridge driver for timings not requiring tuningMarius Strobl2023-08-061-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(4) accordingly keeping sdhci_generic_tune() a bit cautious still. (cherry picked from commit bd15d31cef50060d90356384ba7b878d398fc9f3)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-258-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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* sdio: Add CCCR speed definesEmmanuel Vadot2023-02-021-1/+13
| | | | | | Those are the defines needed to change speed on a SDIO card. (cherry picked from commit 348164aa9e5d862b65c8436861a3eb2b33bcb16e)
* kerneldump: remove physical argument from d_dumperMitchell Horne2022-06-271-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 (cherry picked from commit 489ba2223676ec251ab1bfe2906d2a62959c8ce3)
* dwmmc: Make ext_resources non-optionalEmmanuel Vadot2022-05-163-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 (cherry picked from commit b4cc0f7d28e2f4ae12db3be75658ac5b8c1293f1)
* mmc: Make ext_resources non-optionalEmmanuel Vadot2022-05-163-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 (cherry picked from commit 78f8b4aafaa0030cfda4d1a775150441ac0a5343)
* dwmmc: Properly implement power_off/power_upEmmanuel Vadot2022-05-163-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 (cherry picked from commit af32e2cc32b2516826e301d5f857ff7343b1210e)
* dwmmc: Remove dwmmc_setup_bus call from start_cmdEmmanuel Vadot2022-05-161-3/+0
| | | | | | | | There is no need to re-setup the bus before each commands. Tested-on: Rock64, RockPro64 Reported by: avg (cherry picked from commit 559f60214b7498ac068c5aa1f2bdecc1610bab53)
* dwmmc: Fix MMCCAM block size supportEmmanuel Vadot2022-05-161-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 (cherry picked from commit 990a1dbf6fe1a9f4dc491d3e4e276034919b94f3)
* Extend device_get_property APIKornel Duleba2022-03-291-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 (cherry picked from commit b344de4d0d163cbd8bf88cb5d226c18fe96f488f)
* mmc: switch mmc_helper to device_ apiBartlomiej Grzesik2022-03-295-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 (cherry picked from commit 8a8166e5bcfb50e2b7280581b600d098fa6c9fc7) mmc: Fix regression in 8a8166e5bcfb breaking Stratix 10 boot 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 (cherry picked from commit 4a331971d2f1083f35b87197da0614fa3e0e53cb)
* mmc: Fix HS200/HS400 capability checkKornel Duleba2022-03-071-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 (cherry picked from commit 8661e085fb953855dbc7059f21a64a05ae61b22c)
* mmc_da: implement d_dump method, sddadumpAndriy Gapon2022-01-261-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. Relnotes: perhaps (cherry picked from commit 44682688f038edbf34591b25ce36412a7f2d6d07)
* dwmmc: Calculate the maximum transaction length correctly.Michal Meloun2022-01-201-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 (cherry picked from commit dfb7360222856e7e4f5e0e5564281a25af63319c)
* mmc: fix 1-byte reallocs (when it should have been sizeof device_t)Mateusz Guzik2021-10-111-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") (cherry picked from commit 13c63ae08df43d4e662b73ea3e05137fff88e639)
* mmc_fdt_helper: correct typo in DT property nameMarcin Wojtas2021-10-071-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 Submitted by: Bartlomiej Grzesik <bag@semihalf.com> Sponsored by: Semihalf (cherry picked from commit d8789cd0ae278a86f92247a87d98bb54f15b5592)
* mmc: Drain the intrhook in mmc_detach()Yang Zhong2021-07-291-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 Sponsored by: The FreeBSD Foundation (cherry picked from commit d5341d72a11be200e536ac7d8967449a3f521792)
* dwmmc: Add bus_generic_add_child in the methodsEmmanuel Vadot2021-07-221-0/+2
| | | | | | | | | Otherwise sdiob cannot add it's children. Sponsored by: Diablotin Systems Differential Revision: https://reviews.freebsd.org/D30295 (cherry picked from commit c99d887ca8c420297d2db335ce56075eb12443aa)
* mmc: dwmmc: Call mmc_fdt_set_powerEmmanuel Vadot2021-07-221-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 (cherry picked from commit ce41765c21ac56a37c60a0e8cd227ee3396740cc)
* mmc_fdt_helper: Add mmc_fdt_set_powerEmmanuel Vadot2021-07-222-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 (cherry picked from commit 03d4e8bb6592fefab7b17f1d163adba4e35a12c2)
* mmc_fdt_helpers: Parse the optional pwrseq element.Emmanuel Vadot2021-07-222-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 (cherry picked from commit b0387990a784050ef3a14ea49cb513b5eb737844)
* mmc: Add mmc-pwrseq driverEmmanuel Vadot2021-07-222-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 (cherry picked from commit 5b2a81f58dc722ca76065536f07ba47efd98dc63)
* dwmmc: Add \n to a debug printfEmmanuel Vadot2021-07-221-1/+1
| | | | (cherry picked from commit 7cbdf8a05db7da9c78e8ac74542febc646d24abd)
* mmc: dwmmc: Convert driver to use the mmc_sim interfaceEmmanuel Vadot2021-07-222-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 (cherry picked from commit f1cc48e5da505004259343392ee4a27b8338fca4)
* dwmmc: Multiple busdma fixes.Michal Meloun2021-02-111-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 (cherry picked from commit 8727c174b0fe44766bb7ea765dac6d5f82818103)
* 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
* dwmmc: Add MMCCAM partEmmanuel Vadot2020-07-242-4/+328
| | | | | | | | | | Add support for MMCCAM for dwmmc Submitted by: kibab Tested On: Rock64, RockPro64 Notes: svn path=/head/; revision=363489
* mmc_fdt_helpers: Drain the cd pin taskqueue in mmc_fdt_gpio_teardownEmmanuel Vadot2020-04-161-0/+2
| | | | | | | | | We have no use for it now. MFC after: 1 month Notes: svn path=/head/; revision=360009
* mmc_fdt_helpers: Always init the timoutEmmanuel Vadot2020-04-161-3/+4
| | | | | | | | | | | We use the taskqueue to schedule card detection so always init it. This is a proper solution instead of r359965. MFC after: 1 month MFH: r359924 Notes: svn path=/head/; revision=360008
* Revert r359965Emmanuel Vadot2020-04-161-14/+10
| | | | | | | This cause board without a cd-gpio to not schedule a card detection. Notes: svn path=/head/; revision=360007
* mmc_fdt_helpers: Do not schedule a card detection is there is no cd gpioEmmanuel Vadot2020-04-151-10/+14
| | | | | | | | | | | | If the fdt node doesn't have a cd-gpios properties or if the node is set as non-removable we do not init the card detection timeout task as it is useless so don't schedule it too. MFC after: 1 month X-MFC-With: r359924 Notes: svn path=/head/; revision=359965
* arm: dwmmc: Use mmc_fdt_helpersEmmanuel Vadot2020-04-146-18/+13
| | | | | | | | | | Use the mmc_fdt_parse function instead of parsing everything in the driver. MFC after: 1 month Notes: svn path=/head/; revision=359927
* Those functions are here to help fdt mmc controller drivers to parseEmmanuel Vadot2020-04-142-0/+490
| | | | | | | | | | | | | | | | | | | | | the dts to find the supported speeds and the regulators. Not all DTS have every settings properly defined so host controller will still have to add some caps themselves. It also add a mmc_fdt_gpio_setup function which will read the cd-gpios property and register it as the CD pin. If the pin support interrupts one will be registered and the cd_helper function will be called. If the pin doesn't support interrupts the internal taskqueue will poll for change and call the same cd_helper function. mmc_fdt_gpio_setup will also parse the wp-gpio property and MMC drivers can know the write-protect pin value by calling the mmc_fdt_gpio_get_readonly function. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D23267 Notes: svn path=/head/; revision=359924
* dwmmc: Rework the DMA engineEmmanuel Vadot2020-03-043-27/+24
| | | | | | | | | | | | | | Each segment can be up to 4096 bytes in chain structure according to the RK3399 TRM Part 2. Set the buffers in full ring where the last one point to the first one. Correctly reports the MMC_IVAR_MAX_DATA. Use CACHE_LINE_SIZE for bus_dma alignment. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D23894 Notes: svn path=/head/; revision=358635
* mmc: dwmmc: Fix off by one errorEmmanuel Vadot2020-02-281-1/+1
| | | | | | | | | | | The IVAR_MAX_DATA is supposed to have the number of descriptor X the mmc block size and desc_count contain all this information + 1. Reported by: phk MFC after: 1 week Notes: svn path=/head/; revision=358450
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-262-2/+4
| | | | | | | | | | | | | | | | | | | 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
* Ever since the block layer expanded its command syntax beyond justScott Long2020-02-071-2/+5
| | | | | | | | | | | BIO_READ and BIO_WRITE, we've handled this expanded syntax poorly in drivers when the driver doesn't support a particular command. Do a sweep and fix that. Reported by: imp Notes: svn path=/head/; revision=357647
* Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. PassWarner Losh2020-01-271-2/+0
| | | | | | | in the parameters needed for the different sims, but it's almost all identical. Notes: svn path=/head/; revision=357181
* dwmmc: Remove max_hz from the softcEmmanuel Vadot2020-01-162-4/+2
| | | | | | | We never use it so directly set the value to the mmc host structure. Notes: svn path=/head/; revision=356813
* dwmmc: Use device_delete_childrenEmmanuel Vadot2019-12-111-7/+1
| | | | | | | | | | | Instead of first detaching the children(s) and then delete them, use the device_delete_children function that does all of that. MFC after: 1 month Suggested by: ian Notes: svn path=/head/; revision=355629
* dwmmc: Handle the card detect interruptEmmanuel Vadot2019-12-116-4/+81
| | | | | | | | | | | | | | | | | The driver used to always add the mmc device as it's child even it no card was detected. Add a function that will detect if the card is present or not and that will attach/detach the mmc device. The function is either call on attach (as we won't have the interrupt fired) or from two taskqueues. The first taskqueue will directly call the function when the sdcard was present and is now removed and the other one will delay a bit the attach when we didn't had a card and now have one. This is mostly based on comments from the sdhci driver where it describe a situation when the CD pin is detected before the others pins are connected. MFC after: 1 month Notes: svn path=/head/; revision=355627
* dwmmc: Add a detach methodEmmanuel Vadot2019-12-113-1/+63
| | | | | | | | | | | | | This method will disable the regulators, clocks and assert the reset of the module. It will also detach it's children (the mmc device) and release it's resources. While here enable the regulators on attach as we need them to power up the sdcard or emmc. MFC after: 1 month Notes: svn path=/head/; revision=355625