armbian-build/patch/u-boot/v2026.04/v5-3-4-ufs-rockchip-Add-device-reset-support.patch

106 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mecid <mecid@mecomediagroup.de>
Date: Fri, 20 Feb 2026 21:55:32 +0100
Subject: [ARCHEOLOGY] Rock-4D: Add Edge + RK3576 Mainline U-Boot (with UFS
support) (#9421)
> X-Git-Archeology: > recovered message: > * Rock-4D: Edge (u-boot and kernel)
> X-Git-Archeology: > recovered message: > * RK3576: Mainline u-boot ufs boot enablement patches
> X-Git-Archeology: > recovered message: > * Rock-4D: Use Mainline u-boot 2026.04-rc2
> X-Git-Archeology: > recovered message: > * Rock-4D: Update KERNEL_TEST_TARGET to edge
> X-Git-Archeology: > recovered message: > * Rock-4D: Use Mainline u-boot on vendor and edge
> X-Git-Archeology: > recovered message: > * Remove vendor branch check for mainline uboot
> X-Git-Archeology: - Revision 77f919f6cd5db012127fdbdd9dd506c5e4346a8f: https://github.com/armbian/build/commit/77f919f6cd5db012127fdbdd9dd506c5e4346a8f
> X-Git-Archeology: Date: Fri, 20 Feb 2026 21:55:32 +0100
> X-Git-Archeology: From: Mecid <mecid@mecomediagroup.de>
> X-Git-Archeology: Subject: Rock-4D: Add Edge + RK3576 Mainline U-Boot (with UFS support) (#9421)
> X-Git-Archeology:
---
drivers/ufs/Kconfig | 4 ++
drivers/ufs/ufs-rockchip.c | 22 ++++++++++
drivers/ufs/ufs-rockchip.h | 1 +
3 files changed, 27 insertions(+)
diff --git a/drivers/ufs/Kconfig b/drivers/ufs/Kconfig
index 111111111111..222222222222 100644
--- a/drivers/ufs/Kconfig
+++ b/drivers/ufs/Kconfig
@@ -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.
diff --git a/drivers/ufs/ufs-rockchip.c b/drivers/ufs/ufs-rockchip.c
index 111111111111..222222222222 100644
--- a/drivers/ufs/ufs-rockchip.c
+++ b/drivers/ufs/ufs-rockchip.c
@@ -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>
@@ -153,11 +154,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;
@@ -175,6 +196,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[] = {
diff --git a/drivers/ufs/ufs-rockchip.h b/drivers/ufs/ufs-rockchip.h
index 111111111111..222222222222 100644
--- a/drivers/ufs/ufs-rockchip.h
+++ b/drivers/ufs/ufs-rockchip.h
@@ -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;
--
Armbian