aboutsummaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc-uclass.c
AgeCommit message (Collapse)AuthorFilesLines
2021-07-06dm: define LOG_CATEGORY for all uclassPatrick Delaunay1-0/+2
Define LOG_CATEGORY for all uclass to allow filtering with log command. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-22mmc: mmc-uclass: change to static about dm functionJaehoon Chung1-12/+12
Change to static about dm function. They can be used with wrapper functions. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-04-06mmc: mmc-uclass: Use dev_seq() to read aliases node's indexAswath Govindraju1-7/+5
Use dev_seq() to read aliases node's index and pass it as device number for creating bulk device. Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2020-12-13dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass1-3/+3
We use 'priv' for private data but often use 'platdata' for platform data. We can't really use 'pdata' since that is ambiguous (it could mean private or platform data). Rename some of the latter variables to end with 'plat' for consistency. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass1-1/+1
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-21mmc: mmc_of_parse: Enable 52 MHz support with "cap-mmc-highspeed"Alexandru Gagniuc1-1/+1
"cap-mmc-highspeed" enables support for 26 MHz MMC, but there is no additional flag to enable 52 MHz MMC. In Linux. "cap-mmc-highspeed" is used for MMC HS at both 26MHz and 52MHz. Use the same approach and enable MMC_CAP(MMC_HS_52) host capability when "cap-mmc-highspeed" is found in the devicetree. In the event an MMC card doesn't support 52 MHz, it will be clocked at a speed based on its EXT CSD, even on 52 MHz host controllers Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com> Tested-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
2020-10-12mmc: add a mmc_hs400_prepare_ddr() interfaceYangbo Lu1-0/+15
Add a mmc_hs400_prepare_ddr() interface for controllers which needs preparation before switching to DDR mode for HS400 mode. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2020-10-12mmc: add a reinit() APIYangbo Lu1-0/+15
For DM_MMC, the controller re-initialization is needed to clear old configuration for mmc rescan. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2020-07-27Move eSDHC adapter card identification to board filesYangbo Lu1-3/+1
The eSDHC adapter card identification and multiplexing configuration through FPGA had been implemented in both common mmc driver and fsl_esdhc driver. However it is proper to move these code to board files and do it during board initialization. The FPGA registers are also board specific. This patch is to move eSDHC adapter card identification and multiplexing configuration from mmc driver to specific board files. And the option CONFIG_FSL_ESDHC_ADAPTER_IDENT is no longer needed. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> [Rebased, Removed T1040QDS change as board does not exist] Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2020-05-18common: Drop log.h from common headerSimon Glass1-0/+1
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-24dm: mmc: Update mmc_get_mmc_dev() to use const *Simon Glass1-1/+1
This function does not modify the device to change it to use const *, so that callers with a const udevice * can call it without a cast. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2020-04-22mmc: Add option to adjust b_max before long readMarek Vasut1-0/+16
Add getter function which permits adjusting the maximum number of blocks that could be read in a single sustained read transfer based on the location of the source/target buffer and length, before such transfer starts. This is mainly useful on systems which have various DMA restrictions for different memory locations, e.g. DMA limited to 32bit addresses, and where a bounce buffer is used to work around such restrictions. Since the U-Boot bounce buffer is mallocated, it's size is limited by the malloc area size, and the read transfer to such a buffer must also be limited. However, as not all areas are limited equally, the b_max should be adjusted accordinly as needed to avoid degrading performance unnecessarily. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
2020-03-09mmc: Add a deferred_probe() APIFaiz Abbas1-0/+15
Add a deferred_probe() API for platforms that want to do some configurations just before starting to enumerate the device. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
2020-02-05dm: core: Create a new header file for 'compat' featuresSimon Glass1-0/+2
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-10mmc: add a driver callback for power-cycleYann Gautier1-0/+14
Some MMC peripherals require specific power cycle sequence, where some registers need to be written between the regulator is turned off and then back on. This is the case for the MMC IP embedded in STM32MP1 SoC. In STM32MP157 reference manual [1], the power cycle sequence is: 1. Reset the SDMMC with the RCC.SDMMCxRST register bit. This will reset the SDMMC to the reset state and the CPSM and DPSM to the Idle state. 2. Disable the Vcc power to the card. 3. Set the SDMMC in power-cycle state. This will make that the SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are driven low, to prevent the card from being supplied through the signal lines. 4. After minimum 1ms enable the Vcc power to the card. 5. After the power ramp period set the SDMMC to the power-off state for minimum 1ms. The SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are set to drive “1”. 6. After the 1ms delay set the SDMMC to power-on state in which the SDMMC_CK clock will be enabled. 7. After 74 SDMMC_CK cycles the first command can be sent to the card. The step 3. cannot be handled by the current framework implementation. A new callback (host_power_cycle) is created, and called in mmc_power_cycle(), after mmc_power_off(). The incorrect power cycle sequence has shown some boot failures on STM32MP1 with some SD-cards, especially on cold boots when the input frequency is low (<= 25MHz). Those failures are no more seen with this correct power cycle sequence. [1] https://www.st.com/resource/en/reference_manual/DM00327659.pdf Signed-off-by: Yann Gautier <yann.gautier@st.com>
2019-09-05mmc: Rename timeout parameters for clarificationSam Protsenko1-4/+4
It's quite hard to figure out time units for various function that have timeout parameters. This leads to possible errors when one forgets to convert ms to us, for example. Let's rename those parameters correspondingly to 'timeout_us' and 'timeout_ms' to prevent such issues further. While at it, add time units info as comments to struct mmc fields. This commit doesn't change the behavior, only renames parameters names. Buildman should report no changes at all. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Igor Opaniuk <igor.opaniuk@gmail.com>
2019-09-05dm: mmc: remove unused U_BOOT_DRIVER(mmc)Andy Yan1-4/+0
When look through the code, I found this bare metal drives is not used, so remove it. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-08-30mmc: invalidate block cache after hwpart switched successfullyWeijie Gao1-1/+6
eMMC device has multiple hw partitions both address from zero. However the mmc driver lacks block cache invalidation for switch hwpart. This causes a problem that data of current hw partition is cached before switching to another hw partition. And the following read operation of the latter hw partition will get wrong data when reading from the addresses that have been cached previously. To solve this problem, invalidate block cache after a successful mmc_switch_part() operation. Signed-off-by: Weijie Gao <weijie.gao@mediatek.com> Tested-by: Felix Brack <fb@ltec.ch>
2019-07-15mmc: Parse no-1-8-v DT propertyPeng Fan1-0/+5
Parse no-1-8-v DT Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
2019-07-15mmc: Parse HS400 Enhanced strobe DT propertiesPeng Fan1-0/+2
Add HS400 Enhanced strobe properties parsing support to mmc_of_parse(). Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
2019-07-15mmc: support hs400 enhanced strobe modePeng Fan1-0/+17
eMMC 5.1+ supports HS400 Enhances Strobe mode without the need for tuning procedure. The flow is as following: - set HS_TIMIMG (Highspeed) - Host change freq to <= 52Mhz - set the bus width to Enhanced strobe and DDR8Bit(CMD6), EXT_CSD[183] = 0x86 instead of 0x80 - set HS_TIMING to 0x3 (HS400) - Host change freq to <= 200Mhz - Host select HS400 enhanced strobe complete Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-07-15mmc: if possible, poll the busy state using DAT0Jean-Jacques Hiblot1-2/+0
Using the DAT0 line as a rdy/busy line is an alternative to reading the status register of the card. It especially useful in situation where the bus is not in a good shape, like when modes are switched. This is also how the linux driver behaves. Note of warning: As per the specification, while polling on DAT0 the CLK must not turned off: "[...] Without a clock edge the Device (unless previously disconnected by a deselect command (CMD7)) will force the DAT0 line down, forever. [...]" Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2019-07-15Revert "mmc: Add a new callback function to perform the 74 clocks cycle ↵Jean-Jacques Hiblot1-13/+0
sequence" This reverts commit 318a7a576bc49aa8b4207e694d3fbd48c663d6ac. The last and only user of this callback had been the omap_hsmmc driver. It is not used anymore. Removing the callback. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2019-07-15mmc: Read sd card detect properties from DTT Karthik Reddy1-0/+9
This patch reads card detect properties from device tree & added mmc capability macros in mmc.h. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2019-02-16mmc: Downgrade SD/MMC from UHS/HS200/HS400 modes before bootMarek Vasut1-0/+19
Older kernel versions or systems which do not connect eMMC reset line properly may not be able to handle situations where either the eMMC is left in HS200/HS400 mode or SD card in UHS modes by the bootloader and may misbehave. Downgrade the eMMC to HS/HS52 mode and/or SD card to non-UHS mode before booting the kernel to allow such older kernels to work with modern U-Boot. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Tom Rini <trini@konsulko.com>
2018-12-03mmc: Parse HS400 DT propertiesMarek Vasut1-0/+4
Add HS400 properties parsing support to mmc_of_parse(). Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Jaehoon Chung <jh80.chung@samsung.com> Cc: Jean-Jacques Hiblot <jjhiblot@ti.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Simon Glass <sjg@chromium.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-2/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-27Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTRTom Rini1-2/+0
We have a large number of places where while we historically referenced gd in the code we no longer do, as well as cases where the code added that line "just in case" during development and never dropped it. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-01-22mmc: let mmc_of_parse() fail for insane bus-width valueMasahiro Yamada1-4/+2
You must fix your DT if it specifies insane bus-width, for example, bus-width = <3>; debug() is not displayed in usual configuration, so people will not even notice weirdness. Use dev_err() instead, then let it fail. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-22mmc: do not overwrite cfg->f_max if "max-frequency" if missingMasahiro Yamada1-1/+2
mmc_of_parse() in U-Boot is a pussy helper; it sets cfg->f_max to 52MHz even if DT does not provide "max-frequency" at all. This can overwrite cfg->f_max that may have been set to a reasonable default. As the DT binding says, "max-frequency" is an optional property. Do nothing if DT does not specify it. This is the behavior of mmc_of_parse() in Linux. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-12mmc: add a Kconfig option to enable the support for MMC write operationsJean-Jacques Hiblot1-1/+1
This allows using CONFIG_IS_ENABLED(MMC_WRITE) to compile out code needed only if write support is required. The option is added for u-boot and for SPL Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-01-12mmc: make UHS and HS200 optionalJean-Jacques Hiblot1-0/+4
Supporting USH and HS200 increases the code size as it brings in IO voltage control, tuning and fatter data structures. Use Kconfig configuration to select which of those features should be built in. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-01-12dm: mmc: update mmc_of_parse()Jean-Jacques Hiblot1-16/+20
* convert to livetree API * don't fail because of an invalid bus-width, instead default to 1-bit. * recognize 1.2v DDR and 1.2v HS200 flags Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-01-12dm: mmc: Add a library function to parse generic dt bindingKishon Vijay Abraham I1-0/+46
Add a new function to parse host controller dt node and set mmc_config. This function can be used by mmc controller drivers to set the generic mmc_config. This function can be extended to set other UHS mode caps once UHS mode support is added. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-01-12mmc: Add support for UHS modesJean-Jacques Hiblot1-0/+14
Add UHS modes to the list of supported modes, get the UHS capabilites of the SDcard and implement the procedure to switch the voltage (UHS modes use 1v8 IO lines) During the voltage switch procedure, DAT0 is used by the card to signal when it's ready. The optional card_busy() callback can be used to get this information from the host driver. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-01-12mmc: Add a execute_tuning() callback to the mmc operations.Kishon Vijay Abraham I1-0/+14
Tuning is a mandatory step in the initialization of SDR104 and HS200 modes. This callback execute the tuning process. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-01-12mmc: Add a new callback function to perform the 74 clocks cycle sequenceJean-Jacques Hiblot1-0/+13
Add a new callback function *send_init_stream* which start a sequence of at least 74 clock cycles. The mmc core uses *mmc_send_init_stream* in order to invoke the callback function. This will be used during power cycle where the specification requires such a sequence after power up. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2017-08-17dm: mmc: Drop CONFIG_DM_MMC_OPSSimon Glass1-4/+0
All boards which use DM_MMC have now been converted to use DM_MMC_OPS. Drop the option and good riddance. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-01dm: mmc: Allow disabling driver model in SPLSimon Glass1-3/+3
At present if U-Boot proper uses driver model for MMC, then SPL has to also. While this is desirable, it places a significant barrier to moving to driver model in some cases. For example, with a space-constrained SPL it may be necessary to enable CONFIG_SPL_OF_PLATDATA which involves adjusting some drivers. Add new SPL versions of the options for DM_MMC, DM_MMC_OPS and BLK. By default these follow their non-SPL versions, but this can be changed by boards which need it. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-09dm: mmc: Avoid probing block devices in find_mmc_device()Simon Glass1-2/+4
We do not need to probe the block device here, so avoid doing so. The MMC device itself must be active, but the block device can come later. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: mmc: Convert uclass to livetreeSimon Glass1-1/+2
Update the mmc uclass to support a live device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: mmc: Rewrite mmc_blk_probe()Simon Glass1-6/+11
This function is called when the MMC block device is being probed. There is a recursive call in this function since find_mmc_device() itself can cause the MMC device to be probed. Admittedly the MMC device should already be probed, since we would not be probing its child otherwise, but the current code is unnecessarily convoluted. Rewrite this to access the MMC structure directly. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: mmc: Check that drivers have operationsSimon Glass1-0/+4
When binding a new MMC device, make sure that it has the required operations. Since for now we still support *not* having the operations (with CONFIG_DM_MMC_OPS not enabled) it makes sense to add this check. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-06-01dm: core: Replace of_offset with accessor (part 2)Simon Glass1-1/+1
At present devices use a simple integer offset to record the device tree node associated with the device. In preparation for supporting a live device tree, which uses a node pointer instead, refactor existing code to access this field through an inline function. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-04-04dm: core: Add flags parameter to device_remove()Stefan Roese1-1/+1
This patch adds the flags parameter to device_remove() and changes all calls to this function to provide the default value of DM_REMOVE_NORMAL for "normal" device removal. This is in preparation for the driver specific pre-OS (e.g. DMA cancelling) remove support. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Simon Glass <sjg@chromium.org> Acked-by: Simon Glass <sjg@chromium.org>
2017-02-09mmc: init mmc block devices on probeFiach Antaw1-0/+12
MMC devices accessed exclusively via the driver model were not being initialized before being exposed as block devices, causing issues in scenarios where the MMC device is first accessed via the uclass block interface. Signed-off-by: Fiach Antaw <fiach.antaw@uqconnect.edu.au>
2017-02-09mmc: mmc-uclass: use the fixed devnum with alias nodeJaehoon Chung1-3/+10
If there are alias nodes as "mmc", use the devnum as alias index number. This patch is for fixing a problem of Exynos4 series. Problem is the below thing. Current legacy mode: EXYNOS DWMMC: 0, SAMSUNG SDHCI: 1 After using DM: SAMSUNG SDHCI: 0, EXYNOS DWMMC: 1 Dev index is swapped. Then u-boot can't find the kernel image..because it is already set to 0 as mmcdev. If change from legacy to DM, also needs to touch all exynos4 config file. For using simply, just supporting the fixed devnum with alias node is better than it. Usage: alaise { .... mmc0 = &sdhci2; /* eMMC */ mmc1 = &sdhci1; /* SD */ ... } Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2016-10-28mmc: refactor two core functionsMasahiro Yamada1-13/+2
Drop unneeded variables and assignments. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2016-10-09dm: mmc: Support eraseSimon Glass1-0/+1
At present erase is not suported with CONFIG_DM_OPS. Add it so that MMC devices can be erased. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-08-05mmc: display mmc list information like mmc_legacy typeXu Ziyuan1-1/+1
It's nicer to see this: => mmc list dwmmc@ff0c0000: 0 dwmmc@ff0f0000: 1 (eMMC) than this: => mmc list dwmmc@ff0c0000: 0dwmmc@ff0f0000: 1 (eMMC) With the former, it's much clearer which mmc devices are on. Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com> Acked-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com> Tested-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>