aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mmc
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Regularize my copyright noticeWarner Losh2019-12-0411-13/+11
| | | | | | | | | | | | 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
* Remove "all rights reserved" from copyright for the file I own.Emmanuel Vadot2019-12-033-3/+0
| | | | | | | | Some of the files have both me and Jared McNeill and he gave me permission to remove it from his files too. Notes: svn path=/head/; revision=355357
* Fix dwmmc(4) driver attachment when ext_resources are not present.Ruslan Bukin2019-10-151-5/+25
| | | | | | | | | | | | Ignore only ENOENT (no DTS properties found) and ENODEV (driver not present) non-zero return values from ext_resources. Reviewed by: manu Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22043 Notes: svn path=/head/; revision=353575
* Fix the driver attachment in cases when the external resource devicesRuslan Bukin2019-10-141-17/+9
| | | | | | | | | | | | | | (resets, regulators, clocks) are not available. Rely on a system initialization done by a bootloader in that cases. This fixes operation on Terasic DE10-Pro (an Intel Stratix 10 development kit). Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=353493
* dwmmc: Reset the dma controller at attachEmmanuel Vadot2019-10-091-0/+1
| | | | | | | | | | | If the bootloader enabled DMA we need to fully reset the DMA controller otherwise we might have some stale data in it that provoke weird behavior. MFC after: 1 week Notes: svn path=/head/; revision=353354
* Enhance support of extres in dwmmc driver.Michal Meloun2019-08-182-5/+60
| | | | | | | | | Handle all clocks, regulators and resets defined by dwmmc bindings. MFC after: 2 weeks Notes: svn path=/head/; revision=351185
* Fix MMCCAM kernel build.Ruslan Bukin2019-07-301-0/+2
| | | | | | | Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=350443
* Add support for the SD/MMC controller found in Terasic DE10-ProRuslan Bukin2019-07-301-0/+8
| | | | | | | | | | | (an Intel Stratix 10 GX/SX FPGA Development Kit). Set the bus speed manually due to lack of clock management support. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=350440
* Correct spelling, partion -> partition.Ian Lepore2019-07-221-3/+3
| | | | Notes: svn path=/head/; revision=350231
* Fix cut-and-pasto that slipped through my testing.Warner Losh2019-07-041-1/+1
| | | | Notes: svn path=/head/; revision=349731
* Implement missing MMCBR ivarsWarner Losh2019-07-041-3/+4
| | | | | | | | | | All MMCBR bridges have to implement all the MMCBR variables. This implements them for everybody that currently doesn't. A common routine for this should be written. Notes: svn path=/head/; revision=349728
* Since r349571 we need all the accessor to be present for set or getEmmanuel Vadot2019-07-011-0/+12
| | | | | | | | | | | | otherwise we panic. dwmmc don't handle VCCQ (voltage for the IO line of the SD/eMMC) or TIMING. Add the needed accessor in the {read,write}_ivar functions. Reviewed by: imp (previous version) Notes: svn path=/head/; revision=349584
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* Add some CMD53-related definitionsIlya Bakulin2019-04-101-16/+25
| | | | | | | | | | | In preparation to adding block mode functions, add necessary definitions. Reviewed by: bz Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D19832 Notes: svn path=/head/; revision=346100
* Add new fields to mmc_data in preparation to SDIO CMD53 block mode supportIlya Bakulin2019-04-101-0/+3
| | | | | | | | | | | | | | | | SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes, with a maximum of 511 blocks per request. Extend mmc_data structure to properly describe such requests, and initialize the new fields in kernel and userland consumers. No actual driver changes happen yet, these will follow in the separate changes. Reviewed by: bz Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D19779 Notes: svn path=/head/; revision=346097
* mmc: dwmmc: Match on "rockchip,rk3288-dw-mshc" compatibleEmmanuel Vadot2019-02-271-2/+2
| | | | | | | | | | | This is the common denominator for rockchip compatible from RK3288 to RK3399. The other compatible are generally present in the DTS but the controllers are the same. MFC after: 1 week Notes: svn path=/head/; revision=344627
* Remove All Rights ReservedWarner Losh2019-02-059-9/+9
| | | | | | | | Remove the all rights reserved clause from my copyright, and make other minor tweaks needed where that might have created ambiguity. Notes: svn path=/head/; revision=343811
* - Restore setting the clock for devices which support the default/legacyMarius Strobl2018-11-171-8/+14
| | | | | | | | | | | | | | transfer mode only (lost with r321385). [1] - Similarly, don't try to set the power class on MMC devices that comply to version 4.0 of the system specification but are operated in default/ legacy transfer or 1-bit bus mode as no power class is specified for these cases. Trying to set a power class nevertheless resulted in an - albeit harmless - error message. PR: 231713 [1] Notes: svn path=/head/; revision=340495
* Avoid uninitialized read of ext_csd.Marius Strobl2018-09-061-3/+5
| | | | | | | | | Reported by: Coverity CID: 1395275 Approved by: re (gjb, kib) Notes: svn path=/head/; revision=338513
* The read accessors generated by __BUS_ACCESSOR() have the problem thatMarius Strobl2018-08-241-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | they don't check the result of BUS_READ_IVAR(9) and silently return stack garbage on failure in case a bus doesn't implement a particular instance variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ, yet, this in turn can cause mmc(4) to get into a state in which re-tuning seems to be necessary but is inappropriate, causing mmc_wait_for_request() to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and instead provide a version of the latter which returns retune_req_none if reading MMCBR_IVAR_RETUNE_REQ fails. One more straight-forward solution would have been to change mmc(4) to not call mmcbr_get_retune_req() if the current transfer mode doesn't require re-tuning to begin with. However, for modes such as SDR50, it depends on the controller whether periodic re-tuning is need. Therefore, knowledge of whether a particular transfer mode does require re-tuning should be kept to the bridge drivers. This change is the generic version of r338271, as intended not requiring bridge drivers to be touched (unless transfer modes beyond high speed are to be supported that is). Approved by: re (gjb) Notes: svn path=/head/; revision=338304
* - Use le32dec(9) for decoding EXT_CSD values where it makes sense. [1]Marius Strobl2018-08-232-39/+26
| | | | | | | | | | - Locally cache some instance variable values in mmc_discover_cards() in order to improve the code readability a bit. Obtained from: NetBSD [1] Notes: svn path=/head/; revision=338280
* Obtain the bus mode (MMC or SD) from the directly superordinatedMarius Strobl2018-08-231-3/+3
| | | | | | | | bus rather than reaching up to the bridge and use the cached mode in mmcsd_delete(), too. Notes: svn path=/head/; revision=338275
* Fix building GENERIC-MMCCAM on arm64Ilya Bakulin2018-05-251-0/+2
| | | | | | | | | | | | | Since GENERIC includes quite a few drivers now, all MMC drivers should have appropriate MMCCAM-related ifdefs and include opt_mmccam.h so that those ifdefs are actually processed correctly. Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D15569 Notes: svn path=/head/; revision=334218
* - If present, take advantage of the R/W cache of eMMC revision 1.5 andMarius Strobl2018-05-152-14/+115
| | | | | | | | | | | | | | later devices. These caches work akin to the ones found in HDDs/SSDs that ada(4)/da(4) also enable if existent, but likewise increase the likelihood of data loss in case of a sudden power outage etc. On the other hand, write performance is up to twice as high for e. g. 1 GiB files depending on the actual chip and transfer mode employed. For maximum data integrity, the usage of eMMC caches can be disabled via the hw.mmcsd.cache tunable. - Get rid of the NOP mmcsd_open(). Notes: svn path=/head/; revision=333647
* Restore style(9) conformance after r320844 (actually requested pre-Marius Strobl2018-05-151-74/+75
| | | | | | | commit) and bring the r320844 additions in line with existing bits. Notes: svn path=/head/; revision=333646
* Let mmcsd_ioctl() ensure appropriate privileges via priv_check(9).Marius Strobl2018-05-141-6/+12
| | | | Notes: svn path=/head/; revision=333614
* dwmmc_rockchip: Add ifdefs on EXT_RESOURCESEmmanuel Vadot2018-02-281-0/+8
| | | | | | | | | | The old RK3188 kernel config uses dwmmc but isn't compiled with EXT_RESOURCES. Add ifdefs around code using EXT_RESOURCES code. Reported by: rpokala Notes: svn path=/head/; revision=330125
* dwmmc_rockchip: Add support for rk3328-dw-mshcEmmanuel Vadot2018-02-261-2/+46
| | | | | | | | | | * Do not use pio mode like rk2928 * Change clocks frequency in update_ios Tested-On: Pine64 Rock64 (RK3328) Notes: svn path=/head/; revision=330038
* dwmmc: Add clock support and other improvementsEmmanuel Vadot2018-02-262-32/+101
| | | | | | | | | | | | | | | | | | * If compiled with EXT_RESOURCES look up the "biu" and "ciu" clocks in the DT * Don't use custom property "bus-frequency" but the standard one "clock-frequency" * Use the DT property max-frequency and fall back to 200Mhz if it don't exists * Add more mmc caps suported by the controller * Always ack all interrupts * Subclassed driver can supply an update_ios so they can handle update the clocks accordingly * Take care of the DDR bit in update_ios (no functional change since we do not support voltage change for now) * Make use of the FDT bus-width property Notes: svn path=/head/; revision=330037
* Use the correct revision specifier (EXT_CSD revision rather thanMarius Strobl2018-01-131-1/+1
| | | | | | | | | | system specification version) for deciding whether the EXT_CSD register includes the EXT_CSD_GEN_CMD6_TIME field. Submitted by: Masanobu SAITOH Notes: svn path=/head/; revision=327929
* Fix a bug introduced in r327355; in mmcsd_ioctl_cmd() when ensuringMarius Strobl2018-01-131-1/+1
| | | | | | | | | that userland doesn't switch partitions on its own, compare against the partition mmcsd_ioctl_cmd() is going to switch to (based on the device node used) rather than the currently selected partition. Notes: svn path=/head/; revision=327926