summaryrefslogtreecommitdiff
path: root/drivers/mmc
Commit message (Collapse)AuthorAgeFilesLines
* fix(mmc): resolve the build errorJayanth Dodderi Chidanand2022-09-091-0/+1
| | | | | | | | Adding the header file plat/common/common_def.h to resolve the "SIZE_128" undeclared identifier error. Change-Id: I399edf4248776f6dd9f93e000b8672cadc71509d Signed-off-by: Jayanth Dodderi Chidanand <jayanthdodderi.chidanand@arm.com>
* feat(mmc): get boot partition sizeYann Gautier2022-09-071-0/+5
| | | | | | | | | | The boot partition size of an eMMC is given in ext_csd register, at offset 226 (BOOT_SIZE_MULT), which has to be multiplied by 128kB. Add a helper function mmc_boot_part_size() to get this eMMC boot partition size. Signed-off-by: Yann Gautier <yann.gautier@st.com> Change-Id: I0e8e0fc9632f147fa1b1b3374accb78439025403
* feat(mmc): manage SD Switch Function for high speed modeYann Gautier2022-08-161-1/+66
| | | | | | | | | | | | | | On SD-cards, Switch Function Command (CMD6) is used to switch functions, like setting High Speed mode. It is useful for high capacity cards to double frequency (from 25MHz by default to 50MHz). If the SD-card is High Capacity, a CMD6 is issued after filling the device information. If High Speed mode is supported and the switch is OK, then the max_bus_freq can be set to 50MHz. The driver set_ios() function should then be called to update peripheral configuration, especially clock prescaler. Change-Id: I2d6807aa7f9440d2b2f907a747cd3b47a2ba1545 Signed-off-by: Yann Gautier <yann.gautier@st.com>
* fix(mmc): remove broken, unsecure, unused eMMC RPMB handlingAhmad Fatoum2022-06-081-46/+0
| | | | | | | | | | | | | | | | | | | Replay-protected memory block access is enabled by writing 0x3 to PARTITION_ACCESS (bit[2:0]). Instead the driver is using the first boot partition, which does not provide any playback protection. Additionally, it unconditionally activates the first boot partition, potentially breaking boot for SoCs that consult boot partitions, require boot ack or downgrading to an old bootloader if the first partition happens to be the inactive one. Also, neither enabling or disabling the RPMB observes the PARTITION_SWITCH_TIME. As there are no in-tree users for these functions, drop them for now until a properly functional implementation is added. That one will likely share most code with the existing boot partition switch, which doesn't suffer from the described issues. Change-Id: Ia4a3f738f60a0dbcc33782f868cfbb1e1c5b664a Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
* refactor(mmc): replace magic value with new PART_CFG_BOOT_PARTITION_NO_ACCESSAhmad Fatoum2022-06-021-1/+1
| | | | | | | | | Disabling access to the boot partition reverts the MMC to read from the user area. Add a macro to make this clearer. Suggested-by: Manish V Badarkhe <Manish.Badarkhe@arm.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Change-Id: I34a5a987980bb4690d08d255f465b11a4697ed5a
* refactor(mmc): export user/boot partition switch functionsAhmad Fatoum2022-06-021-7/+29
| | | | | | | | | | | At the moment, mmc_boot_part_read_blocks() takes care to switch to the boot partition before transfer and back afterwards. This can introduce large overhead when reading small chunks. Give consumers of the API more control by exporting mmc_part_switch_current_boot() and mmc_part_switch_user(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Change-Id: Ib641f188071bb8e0196f4af495ec9ad4a292284f
* feat(drivers/mmc): boot partition read supportVyacheslav Yurkov2021-06-041-1/+75
| | | | | | | | Added a public function to read blocks from a current boot partition. switch between partitions has to respect eMMC partition switch timing. Signed-off-by: Vyacheslav Yurkov <uvv.mail@gmail.com> Change-Id: I55b0c910314253e5647486609583fd290dadd30a
* mmc: remove useless extra semicolonsYann Gautier2021-04-081-3/+3
| | | | | Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: If1d6b2040e482577292890e3554449096648c2ae
* Revert "mmc:prevent accessing to the released space in case of wrong usage"Yann Gautier2021-04-081-24/+24
| | | | | | | | | This reverts commit 13f3c5166f126b021e5f6e09e4a7c97f12495a35. The STM32MP1 platform can no more boot qwith this change. The driver will not be aware when the static struct in framework is updated. Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: Icc544e243136ee3b0067f316b71dff7dfd6526d6
* mmc:prevent accessing to the released space in case of wrong usagedeqi.hu2021-03-171-24/+24
| | | | | | | | | | 1.Since in mmc_init, the most of mmc_device_info passed in are temporary variables. In order to avoid referencing the released space on the stack when maybe MISUSED, it`s better to use global variables to store mmc_device_info in mmc.c 2.Delete redundant; Signed-off-by: deqi.hu@siengine.com Change-Id: I51ae90e7f878b19b4963508b3f7ec66339015ebc
* mmc: increase delay between ACMD41 retriesYann Gautier2019-10-031-1/+1
| | | | | | | | | | In the SD Specification, Power Up Diagram of Card figure, the Timeout value for initialization process (ACMD41 command retries) is 1 second. Align to match MMC cards (in mmc_send_op_cond()) and Linux kernel code, and set the delay between ACMD41 command retries to 10ms. Change-Id: I2e07cb9944e7d7b72f2d4b13e0505e6751458091 Signed-off-by: Yann Gautier <yann.gautier@st.com>
* drivers: mmc: Fix some issues with MMC stackTien Hock, Loh2019-03-071-4/+6
| | | | | | | | | | | | Some bugs in MMC stack needs to be fixed: - scr cannot be local as this will cause cache issue when invalidating after the read DMA transfer is completed - ACMD41 needs to send voltage information in initialization, otherwise the command is a query, thus will not initialize the controller - when checking device state, retry until the retries counter goes to zero before failing Signed-off-by: Tien Hock, Loh <tien.hock.loh@intel.com>
* mmc: correctly check ret in mmc_fill_device_infoYann Gautier2019-01-171-2/+2
| | | | | | | | In patch 93768644, ret will be MMC_STATE_TRAN (=4), which is a valid value. We shouldn't exit the function in that case, but only if ret is < 0. Change-Id: I776693fe847b6b45190af028f12d2e724ca46399 Signed-off-by: Yann Gautier <yann.gautier@st.com>
* Merge pull request #1724 from jbech-linaro/emmc_enumerationAntonio Niño Díaz2019-01-101-1/+1
|\ | | | | mmc: increase delay when initializing mmc
| * mmc: increase delay when initializing mmcJoakim Bech2018-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running TF-A 2.0 and later seems to cause a regression on HiKey 620. NOTICE: BL2: v2.0(release):v2.0 NOTICE: BL2: Built : 17:41:23, Dec 17 2018 NOTICE: acpu_dvfs_set_freq: set acpu freq success!ERROR: CMD1 failed after 100 retries ERROR: BL2: Failed to load image (-5) The reason seems to be that during emmc enumeration when BL2 sends the command OCR_SECTOR_MODE | OCR_VDD_MIN_2V7 | OCR_VDD_MIN_1V7 it for some reason takes some more time to get a reply. So a delay with mdelay(1), seems to not be enough any longer and therefore we increase it to mdelay(10) instead which makes the device boot as expected again. Signed-off-by: Joakim Bech <joakim.bech@linaro.org>
* | Sanitise includes across codebaseAntonio Nino Diaz2019-01-041-5/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enforce full include path for includes. Deprecate old paths. The following folders inside include/lib have been left unchanged: - include/lib/cpus/${ARCH} - include/lib/el3_runtime/${ARCH} The reason for this change is that having a global namespace for includes isn't a good idea. It defeats one of the advantages of having folders and it introduces problems that are sometimes subtle (because you may not know the header you are actually including if there are two of them). For example, this patch had to be created because two headers were called the same way: e0ea0928d5b7 ("Fix gpio includes of mt8173 platform to avoid collision."). More recently, this patch has had similar problems: 46f9b2c3a282 ("drivers: add tzc380 support"). This problem was introduced in commit 4ecca33988b9 ("Move include and source files to logical locations"). At that time, there weren't too many headers so it wasn't a real issue. However, time has shown that this creates problems. Platforms that want to preserve the way they include headers may add the removed paths to PLAT_INCLUDES, but this is discouraged. Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* drivers: mmc: check mmc_reset_to_idle returnYann Gautier2018-12-041-2/+8
| | | | Signed-off-by: Yann Gautier <yann.gautier@st.com>
* mmc: poll eMMC status after EXT_CSD commandHaojian Zhuang2018-11-261-0/+7
| | | | | | | | EXT_CSD command needs to access data from eMMC device. Add the operation of polling eMMC device status. Make sure the command is finished. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
* mmc: Update framework to use standard response typeYann Gautier2018-09-281-18/+18
| | | | | | | | | | | | Respect official response type and update response to follow official specification. All the MMC_RESPONSE_R(_x) are replaced with each corresponding define. Partly revert 2a82a9c95f6c06079f58d69315544a6b49cf64a4 for dw_mmc.c: Responses R1, R1B and R5 have CRC. Signed-off-by: Lionel Debieve <lionel.debieve@st.com> Signed-off-by: Yann Gautier <yann.gautier@st.com>
* drivers: mmc: Fix R2 response type definitionShawn Guo2018-09-281-2/+2
| | | | | | | | | | | | | | | | | The Poplar is broken on eMMC initialization because of commit 2a82a9c95f6c ("drivers: emmc: dw_mmc: Add response flag into response ID definition"). It changes the driver behavior on response type handling in dw_send_cmd(), because MMC_RESPONSE_R(2) and MMC_RESPONSE_R2 are different things. MMC core is still sending the former while we already changed to check the latter in dw_mmc driver. This patch fixes R2 response type in MMC core code. It's the same thing as what commit 94522ff7f6d2 ("drivers: mmc: Fix R3 response type definition") does for R3 response. With this fix, Poplar is back to work. Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
* drivers: mmc: Add missing response type for some commandsBryan O'Donoghue2018-09-041-3/+3
| | | | | | | | | | Add missing response type for SWITCH command and STOP_TRANSMISSION so that controller can be configured accordingly. [bod: ported this change from Jun's eMMC patches to the MMC driver] Signed-off-by: Jun Nie <jun.nie@linaro.org> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
* drivers: mmc: Fix R3 response type definitionBryan O'Donoghue2018-09-041-2/+2
| | | | | | | The R3 response type definition should be (1 << 0). Make sure we define the expected response code in the appropriate fashion. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
* drivers/mmc: Fix warning about usage of uninitialized variableAntonio Nino Diaz2018-08-101-1/+1
| | | | | | | Because of -Werror, this causes a build error. Change-Id: I37a8c4bbfe3f2ced5e17981a2814985919ad483b Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
* drivers/mmc: set buswidth and speed before reading dataHaojian Zhuang2018-08-101-2/+2
| | | | | | | | It should set buswidth and speed of mmc controller before accessing mmc. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
* drivers/mmc: make mmc_ext_csd aligned with 16 charHaojian Zhuang2018-08-101-1/+1
| | | | | | | | | | | | | DMA is always used in mmc driver. So the buffer address should always follow the DMA limitation. There're same requirement in mmc_read_blocks()/mmc_write_blocks() on parameter buf. Since parameter buf comes from io_block driver, it's already handled in io_block driver. At here, just make the minimum address alignment on 16 chars. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
* drivers/mmc: fix lba param to intHaojian Zhuang2018-08-101-6/+6
| | | | | | | | mmc_read_blocks()/mmc_write_blocks() derived from io_block_ops_t type. It means that lba param should be integer type, not unsigned integer type. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
* drivers/mmc: send CMD8 only for SD card in initializationHaojian Zhuang2018-08-101-9/+9
| | | | | | | Sending CMD8 before CMD1 just causes to fetch data failure in eMMC. Check whether it's eMMC first. If it's eMMC, send CMD1 command instead. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
* mmc: add required delays when retrying commandsYann Gautier2018-08-021-35/+42
| | | | | | A new function mmc_reset_to_idle is also created. Signed-off-by: Yann Gautier <yann.gautier@st.com>
* Add MMC frameworkYann Gautier2018-07-031-0/+714
This change is largely based on existing eMMC framework by Haojian Zhuang (@hzhuang1). The MMC framework supports both eMMC and SD card devices. It was written as a new framework since breaking few eMMC framework APIs. At card probe and after the reset to idle command (CMD0), a Send Interface Condition Command is sent (CMD8) to distinguish between eMMC and SD card devices. eMMC devices go through the same sequence as in the former eMMC framework. Else the framework uses commands dedicated to SD-cards for init or frequency switch. A structure is created to share info with the driver. It stores: - the MMC type (eMMC, SD or SD HC) - the device size - the max frequency supported by the device - the block size: 512 for eMMC and SD-HC and read from CSD structure for older SD-cards Restriction to align buffers on block size has been removed. Cache maintenance was removed and is expected to be done in the platform or device driver. The MMC framework includes some MISRA compliance coding style maybe not yet ported in the existing eMMC framework. Fixes ARM-software/tf-issues#597 Signed-off-by: Yann Gautier <yann.gautier@st.com>