]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ufs: rockchip: Add device reset support
authorAlexey Charkov <alchark@gmail.com>
Tue, 20 Jan 2026 18:09:04 +0000 (22:09 +0400)
committerNeil Armstrong <neil.armstrong@linaro.org>
Thu, 12 Mar 2026 08:30:44 +0000 (09:30 +0100)
Wire up the GPIO line which Rockchip RK3576 UFS controller uses to reset
the connected UFS device.

This seems necessary at least for some UFS modules and fixes the following
error while enumerating UFS storage:

ufshcd-rockchip ufshc@2a2d0000: ufshcd_link_startup: Device not present
ufshcd-rockchip ufshc@2a2d0000: link startup failed -6
ufshcd-rockchip ufshc@2a2d0000: ufshcd_pltfrm_init() failed -6

Note that the GPIO descriptor for device resets is already required by the
DT binding (link enclosed).

Link: https://elixir.bootlin.com/linux/v6.18.5/source/Documentation/devicetree/bindings/ufs/rockchip,rk3576-ufshc.yaml#L70
Fixes: 76465ce21ee4 ("ufs: rockchip: Add initial support")
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Alexey Charkov <alchark@gmail.com>
Link: https://patch.msgid.link/20260120-rk3576-ufs-v5-3-0edb61b301b7@gmail.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/ufs/Kconfig
drivers/ufs/ufs-rockchip.c
drivers/ufs/ufs-rockchip.h

index 6c75bb2a0790df7ccec92dfd1051faf16824bc74..49472933de36a4d9fe8e7d4491b0f110e468db62 100644 (file)
@@ -76,6 +76,10 @@ config UFS_RENESAS_GEN5
 config UFS_ROCKCHIP
        bool "Rockchip specific hooks to UFS controller platform driver"
        depends on UFS
+       depends on DM_GPIO
+       depends on RESET_ROCKCHIP
+       depends on SPL_DM_GPIO || !SPL_UFS_SUPPORT
+       depends on SPL_RESET_ROCKCHIP || !SPL_UFS_SUPPORT
        help
          This selects the Rockchip specific additions to UFSHCD platform driver.
 
index 8ce3c269cf7735878c74ce62336a2fd4131a4bdb..d799710453e130816e880586de05cf53b146898c 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2025 Rockchip Electronics Co.Ltd.
  */
 
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <clk.h>
 #include <dm.h>
@@ -150,11 +151,31 @@ static int ufs_rockchip_common_init(struct ufs_hba *hba)
                return err;
        }
 
+       err = gpio_request_by_name(dev, "reset-gpios", 0, &host->device_reset,
+                                  GPIOD_IS_OUT | GPIOD_ACTIVE_LOW);
+       if (err) {
+               dev_err(dev, "Cannot get reset GPIO\n");
+               return err;
+       }
+
        host->hba = hba;
 
        return 0;
 }
 
+static int ufs_rockchip_device_reset(struct ufs_hba *hba)
+{
+       struct ufs_rockchip_host *host = dev_get_priv(hba->dev);
+
+       dm_gpio_set_value(&host->device_reset, true);
+       udelay(20);
+
+       dm_gpio_set_value(&host->device_reset, false);
+       udelay(20);
+
+       return 0;
+}
+
 static int ufs_rockchip_rk3576_init(struct ufs_hba *hba)
 {
        int ret = 0;
@@ -172,6 +193,7 @@ static struct ufs_hba_ops ufs_hba_rk3576_vops = {
        .init = ufs_rockchip_rk3576_init,
        .phy_initialization = ufs_rockchip_rk3576_phy_init,
        .hce_enable_notify = ufs_rockchip_hce_enable_notify,
+       .device_reset = ufs_rockchip_device_reset,
 };
 
 static const struct udevice_id ufs_rockchip_of_match[] = {
index 3dcb80f570206fda13f738d33d861f4d20f4c471..50c2539da78ab9b86b6e592ba9d00b089cf1f4c0 100644 (file)
@@ -72,6 +72,7 @@ struct ufs_rockchip_host {
        void __iomem *ufs_sys_ctrl;
        void __iomem *mphy_base;
        struct reset_ctl_bulk rsts;
+       struct gpio_desc device_reset;
        struct clk ref_out_clk;
        uint64_t caps;
        uint32_t phy_config_mode;