summaryrefslogtreecommitdiff
path: root/drivers/ufs/ufs.c
AgeCommit message (Collapse)Author
2025-10-28ufs: core: Rename ufs.c to ufs-uclass.cMarek Vasut
Previous commit folded existing ufs-uclass.c into ufs.c , which produced a nice and reviewable change , but also broke the UCLASS should be in *-uclass.c pattern. Fix it. Keep the change separate from the previous one to make this reviewable. Signed-off-by: Marek Vasut <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-10-28ufs: core: Fold ufs-uclass into ufsMarek Vasut
Move the few lines of ufs-uclass.c into ufs.c and remove the ufs-uclass.c . No functional change. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-10-28ufs: core: Add ufshcd_dme_enable() and ufshcd_dme_reset()Shawn Lin
In order for host drivers to use. Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Shawn Lin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-10-28ufs: Add bRefClkFreq attribute settingJared McArthur
A UFS device needs its bRefClkFreq attribute set to the correct value before switching to high speed. If bRefClkFreq is set to the wrong value, all transactions after the power mode change will fail. The bRefClkFreq depends on the host controller and the device. Query the device's current bRefClkFreq and compare with the ref_clk specified in the device-tree. If the two differ, set the bRefClkFreq to the device-tree's ref_clk frequency. Taken from Linux kernel v6.17 (drivers/ufs/core/ufshcd.c and include/ufs/ufs.h) and ported to U-Boot. Signed-off-by: Jared McArthur <[email protected]> Reviewed-by: Bryan Brattlof <[email protected]> Reviewed-by: Udit Kumar <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-10-28ufs: Add support for sending UFS attribute requestsJared McArthur
Some UFS attributes must be set before a UFS device is initialized. Add ufshcd_query_attr and ufshcd_query_attr_retry to send UFS attribute requests. Taken from Linux Kernel v6.17 (drivers/ufs/core/ufshcd.c) and ported to U-Boot. Signed-off-by: Jared McArthur <[email protected]> Reviewed-by: Bryan Brattlof <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Reviewed-by: Udit Kumar <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-10-28ufs: Fix wrong bitfield usage for Data Direction in Transfer RequestKunihiko Hayashi
Commit d232d7fdbf6f ("ufs: core: sync ufshci.h with Linux v6.12") updated the Data Direction values from bitmask values to simple enumerations. Before: enum { UTP_NO_DATA_TRANSFER = 0x00000000, UTP_HOST_TO_DEVICE = 0x02000000, UTP_DEVICE_TO_HOST = 0x04000000, }; Updated: enum utp_data_direction { UTP_NO_DATA_TRANSFER = 0, UTP_HOST_TO_DEVICE = 1, UTP_DEVICE_TO_HOST = 2, }; However, the U-Boot code still uses these values directly without shifting, and resulting in wrong bitfield placement in the Transfer Request Descriptor. This fixes the issue by applying the necessary shift to align the value. Fixes: d232d7fdbf6f ("ufs: core: sync ufshci.h with Linux v6.12") Signed-off-by: Kunihiko Hayashi <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-08-26ufs: amd-versal2: Configure RMMI and M-PHY registers for HS modeVenkatesh Yadav Abbarapu
Configure RMMI and M-PHY registers for HS mode required for selection of bit rate series A or B. If it is not a calibrated part, then switch back to SLOWAUTO_MODE and skip all these configurations. Implemented below sequence as per the DWC RMMI databook. 1. Override RMMI CBRATESEL with the desired rate. 2. Set TX_CFGUPDT_0 to 1'b1 for one TX_CFGCLK_0 cycle. 3. Override PHY rx_req to 1, then poll on PHY rx_ack register till it goes 1(both lanes). 4. Override PHY rx_req to 0, then poll on PHY rx_ack register till it goes 0(both lanes). 5. Remove PHY rx_req override(both lanes). 6. Start the LS PMC. Signed-off-by: Venkatesh Yadav Abbarapu <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
2025-03-18ufs: core: cosmetic fixupsNeil Armstrong
Fixes some alignment warnings, missing comments on write barrier, missing parenthesis around macro parameters and a comment typo. No functional changes intended. Reviewed-by: Neha Malcom Francis <[email protected]> Tested-by: Love Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-03-18ufs: core: mark unexported functions as staticNeil Armstrong
Mark the remaining local functions as static to avoid build warnings. Also drop the EXPORT_SYMBOL of ufshcd_map_desc_id_to_length. Tested-by: Love Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2025-03-18ufs: core: include missing include/ufs.hNeil Armstrong
Add missing ufs.h causing build warning on some symbols. Tested-by: Love Kumar <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: allow UFSHCI version 4.0Neil Armstrong
Add UFSHCI version 4.0 found on the recent Qualcomm UFS Controllers. Tested-by: Julius Lehmann <[email protected]> Tested-by: Caleb Connolly <[email protected]> #rb3gen2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: add get_max_pwr_mode callbackNeil Armstrong
Add a new get_max_pwr_mode callback to permit the UFS controller driver manipulate the max_pwr_mode struct right before setting the new pwr_mode to the UFS device. It can be used to limit the HS Gear with errata and hardware limitations on some UFS controllers. Tested-by: Julius Lehmann <[email protected]> Tested-by: Caleb Connolly <[email protected]> #rb3gen2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: add device_reset callbackNeil Armstrong
Add device_reset op to permit resetting the UFS device if the UFS controller drivers supports the operation. Tested-by: Julius Lehmann <[email protected]> Tested-by: Caleb Connolly <[email protected]> #rb3gen2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: core: remove link_startup_again logicNeil Armstrong
The link_startup_again logic was added in Linux to handle device that were set in LinkDown state, which should not be the case since U-boot doesn't set LinkDown state are init, and Linux sets the device active in ufshcd_init() for the first link startup. ufshcd_set_ufs_dev_active(hba) is called at ufshcd_init() right before scheduling an ufshcd_async_scan that will call ufshcd_device_init() then ufshcd_link_startup(). The comment in probe says: /* * We are assuming that device wasn't put in sleep/power-down * state exclusively during the boot stage before kernel. * This assumption helps avoid doing link startup twice during * ufshcd_probe_hba(). */ we can assume the same from U-Boot. While it worked to far, it breaks link startup for Qualcomm Controllers v5, let's just remove the logic. Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: Fix debug message in 'ufs_start'Bhupesh Sharma
Minor typo fix and rewording of printf message inside 'ufs_start' which announces the availability of the UFS device. Signed-off-by: Bhupesh Sharma <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: Add missing memory barriersBhupesh Sharma
Add missing wmb() and mb() barriers in the u-boot UFS core framework driver to allow registers updates to happen before follow-up read operations. This makes the barrier placement similar to the Linux UFS driver, synced from the Linux v6.9 release. Starting from the v6.10 release, the barriers were replaced with a register read-back in [1], this will ported to u-boot in a second time. [1] https://lore.kernel.org/all/20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com/ Signed-off-by: Bhupesh Sharma <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: Clear UECPA once due to LINERESET has happened during LINK_STARTUPBhupesh Sharma
Clear UECPA once in u-boot UFS driver due to LINERESET has happened during LINK_STARTUP. This makes the u-boot ufs driver behavior related to UECPA similar to Linux UFS driver. Ported from Linux kernel commit: 2355b66ed20c ("scsi: ufs: Handle LINERESET indication in err handler") Signed-off-by: Bhupesh Sharma <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: use dcache helpers for scsi_cmd data and only invalidate if necessaryNeil Armstrong
Now we have proper flush and invalidate helpers, we can use them directly to operate on the scsi_cmd data. Likewise, we do not need to flush then invalidate, just flush _or_ invalidate depending on the data direction. Reviewed-by: Neha Malcom Francis <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: split flush and invalidate to only invalidate when requiredNeil Armstrong
There is no need to flush and invalidate all data updated by the driver, mainly because on ARM platforms flush also invalidates the cachelines. Split the function in two and add the appropriate cacheline invalidates after the UFS DMA operation finishes to make sure we read from memory. Flushing then invalidating cacheline unaligned data causes data corruption issues on Qualcomm platforms, and is largely unnecessary anyway, so let's cleanup the cache operations. Reviewed-by: Neha Malcom Francis <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: fix dcache flush and invalidate range calculationNeil Armstrong
The current calculation will omit doing a flush/invalidate on the last cacheline if the base address is not aligned with DMA_MINALIGN. This causes commands failures and write corruptions on Qualcomm platforms. Reviewed-by: Neha Malcom Francis <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-10-14ufs: allocate descriptors with size aligned with DMA_MINALIGNNeil Armstrong
Align the allocation size with DMA_MINALIGN to make sure we do not flush/invalidate data from following allocations. Reviewed-by: Neha Malcom Francis <[email protected]> Tested-by: Venkatesh Yadav Abbarapu <[email protected]> Tested-by: Julius Lehmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-07ufs: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this driver directory and when needed add missing include files directly. Signed-off-by: Tom Rini <[email protected]>
2023-11-27Merge patch series "ufs: Add a PCI UFS controller support"Tom Rini
To quote the author: This adds a PCI UFS controller support and enables the support on QEMU RISC-V for testing. Requiring QEMU v8.2+.
2023-11-27ufs: Handle UFS 3.1 controllersBin Meng
Extend the version check to handle UFS 3.1 controllers as well. Tested on QEMU emulated UFS 3.1 controller. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-11-27ufs: Allow mmio registers on the PCI busBin Meng
Check if the UFS controller is on the PCI bus, and get its register base address accordingly. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]>
2023-11-27ufs: Add a line feed to the end of some dev_xxx() messagesBin Meng
Add a line feed to improve readability of some dev_xxx() messages. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-11-27ufs: Correct the UFS terminlogyBin Meng
UFS stands for Universal Flash Storage, not Subsytem. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Neha Malcom Francis <[email protected]>
2023-11-10tree-wide: Replace http:// link with https:// link for ti.comNishanth Menon
Replace instances of http://www.ti.com with https://www.ti.com Signed-off-by: Nishanth Menon <[email protected]>
2023-08-24ufs: Implement cache managementMarek Vasut
Add function to flush and invalidate cache over request and response queue entries, and perform flush and optional invalidate over block layer data that are passed into the UFS layer. This makes it possible to use UFS with caches enabled. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-08-24ufs: Use utp_transfer_req_desc pointer in ufshcd_get_tr_ocsMarek Vasut
Use utp_transfer_req_desc pointer to reference to utrdl queue instead of referencing the queue directly. This makes the code more consistent. No functional change. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-08-24ufs: Pass hba pointer to ufshcd_prepare_req_desc_hdr()Marek Vasut
Pass the hba pointer itself to ufshcd_prepare_req_desc_hdr() instead of duplicating utp_transfer_req_desc access at each call site. No functional change. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-08-24ufs: Handle UFS 3.0 controllersMarek Vasut
Extend the version check to handle UFS 3.0 controllers as well. Tested on R-Car S4 UFS 3.0 controller. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-08-24ufs: Add UFSHCD_QUIRK_HIBERN_FASTAUTOMarek Vasut
Add UFSHCD_QUIRK_HIBERN_FASTAUTO quirk for host controllers which supports auto-hibernate the capability but only FASTAUTO mode. Ported from Linux kernel commit 2f11bbc2c7f3 ("scsi: ufs: core: Add UFSHCD_QUIRK_HIBERN_FASTAUTO") Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-08-24ufs: Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESSMarek Vasut
Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS for host controllers which do not support 64-bit addressing. Ported from Linux kernel commit 6554400d6f66 ("scsi: ufs: core: Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS") with ufs_scsi_buffer_aligned() based on U-Boot generic bounce buffer. Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Bhupesh Sharma <[email protected]> Tested-by: Bhupesh Sharma <[email protected]>
2023-07-14ufs: Use 'TASK_TAG' to construct the ucd_req_ptr->header.dword_0Bhupesh Sharma
Instead of using the hard-coded value of 0x1f, use 'TASK_TAG' macro instead to construct the ucd_req_ptr->header.dword_0 This is in sync with what the Linux UFS driver does, i.e. set the byte0 equal to TASK_TAG (see [1]). Setting it to a fixed value of 0x1f is wrong as we define TASK_TAG as 0 inside u-boot ufs framework. So, instead we should use the macro value directly. [1]. https://github.com/torvalds/linux/blob/master/drivers/ufs/core/ufshcd.c#L2705 Signed-off-by: Bhupesh Sharma <[email protected]>
2023-05-06drivers: use dev_read_addr_ptr when cast to pointerJohan Jonker
The fdt_addr_t and phys_addr_t size have been decoupled. A 32bit CPU can expect 64-bit data from the device tree parser, so use dev_read_addr_ptr instead of the dev_read_addr function in the various files in the drivers directory that cast to a pointer. As we are there also streamline the error response to -EINVAL on return. Signed-off-by: Johan Jonker <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2020-12-13dm: treewide: Rename ..._platdata variables to just ..._platSimon Glass
Try to maintain some consistency between these variables by using _plat as a suffix for them. Signed-off-by: Simon Glass <[email protected]>
2020-12-13dm: treewide: Rename 'platdata' variables to just 'plat'Simon Glass
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 <[email protected]>
2020-08-03ufs: Drop dm.h header fileSimon Glass
This header file should not be included in other header files. Remove it and use a forward declaration instead. Also drop asm/io.h Signed-off-by: Simon Glass <[email protected]>
2020-05-18common: Drop linux/bitops.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <[email protected]>
2020-05-18common: Drop linux/delay.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <[email protected]>
2020-05-18common: Drop log.h from common headerSimon Glass
Move this header out of the common header. Signed-off-by: Simon Glass <[email protected]>
2020-02-19dma-mapping: move dma_map_(un)single() to <linux/dma-mapping.h>Masahiro Yamada
The implementation of dma_map_single() and dma_unmap_single() is exactly the same for all the architectures that support them. Factor them out to <linux/dma-mapping.h>, and make all drivers to include <linux/dma-mapping.h> instead of <asm/dma-mapping.h>. If we need to differentiate them for some architectures, we can move the generic definitions to <asm-generic/dma-mapping.h>. Add some comments to the helpers. The concept is quite similar to the DMA-API of Linux kernel. Drivers are agnostic about what is going on behind the scene. Just call dma_map_single() before the DMA, and dma_unmap_single() after it. Signed-off-by: Masahiro Yamada <[email protected]>
2020-02-05dm: core: Create a new header file for 'compat' featuresSimon Glass
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 <[email protected]>
2020-02-05dm: core: Require users of devres to include the headerSimon Glass
At present devres.h is included in all files that include dm.h but few make use of it. Also this pulls in linux/compat which adds several more headers. Drop the automatic inclusion and require files to include devres themselves. This provides a good indication of which files use devres. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Anatolij Gustschin <[email protected]>
2019-10-23ufs: Add Initial Support for UFS subsystemFaiz Abbas
Add Support for UFS Host Controller Interface (UFSHCI) for communicating with Universal Flash Storage (UFS) devices. The steps to initialize the host controller interface are the following: - Initiate the Host Controller Initialization process by writing to the Host controller enable register. - Configure the Host Controller base address registers by allocating a host memory space and related data structures. - Unipro link startup procedure - Check for connected device - Configure UFS host controller to process requests Also register this host controller as a SCSI host controller. Taken from Linux Kernel v5.2 (drivers/scsi/ufs/ufshcd.c) and ported to U-boot. Signed-off-by: Faiz Abbas <[email protected]>