[PATCH 5/5] scsi: ufs: renesas: Add reusable functions
Neil Armstrong
neil.armstrong at linaro.org
Mon Jan 5 16:20:37 CET 2026
On 1/3/26 01:22, Marek Vasut wrote:
> From: Yoshihiro Shimoda <yoshihiro.shimoda.uh at renesas.com>
>
> Since some settings can be reused on other UFS controller (R-Car S4-8
> ES1.2), add reusable functions.
>
> Ported from Linux kernel commit
> 44ca16f4970e ("scsi: ufs: renesas: Add reusable functions")
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh at renesas.com>
> Signed-off-by: Geert Uytterhoeven <geert+renesas at glider.be>
> Link: https://lore.kernel.org/r/446d67b751a96645799de3aeefec539735aa78c8.1741179611.git.geert+renesas@glider.be
> Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Bhupesh Sharma <bhupesh.linux at gmail.com>
> Cc: Neil Armstrong <neil.armstrong at linaro.org>
> Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh at renesas.com>
> Cc: u-boot at lists.denx.de
> ---
> drivers/ufs/ufs-renesas.c | 71 +++++++++++++++++++++++++++------------
> 1 file changed, 50 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/ufs/ufs-renesas.c b/drivers/ufs/ufs-renesas.c
> index b2edc3b5497..5652309911e 100644
> --- a/drivers/ufs/ufs-renesas.c
> +++ b/drivers/ufs/ufs-renesas.c
> @@ -130,21 +130,8 @@ static void ufs_renesas_indirect_poll(struct ufs_hba *hba, u32 gpio, u32 addr,
> ufs_renesas_write(hba, 0xf0, 0);
> }
>
> -static void ufs_renesas_write_phy_10ad_10af(struct ufs_hba *hba,
> - u32 data_10ad, u32 data_10af)
> +static void ufs_renesas_init_step1_to_3(struct ufs_hba *hba)
> {
> - ufs_renesas_write_phy(hba, 0x10ae, 0x0001);
> - ufs_renesas_write_phy(hba, 0x10ad, data_10ad);
> - ufs_renesas_write_phy(hba, 0x10af, data_10af);
> - ufs_renesas_write_phy(hba, 0x10b6, 0x0001);
> - ufs_renesas_write_phy(hba, 0x10ae, 0x0000);
> -}
> -
> -static void ufs_renesas_pre_init(struct ufs_hba *hba)
> -{
> - u32 timer_val;
> -
> - /* This setting is for SERIES B */
> ufs_renesas_write(hba, 0xc0, 0x49425308);
> ufs_renesas_write_d0_d4(hba, 0x00000104, 0x00000002);
> udelay(1);
> @@ -158,7 +145,10 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
>
> ufs_renesas_write(hba, 0xc0, 0x49425308);
> ufs_renesas_write(hba, 0xc0, 0x41584901);
> +}
>
> +static void ufs_renesas_init_step4_to_6(struct ufs_hba *hba)
> +{
> ufs_renesas_write_d0_d4(hba, 0x0000080c, 0x00000100);
> ufs_renesas_write_d0_d4(hba, 0x00000804, 0x00000000);
> ufs_renesas_write(hba, 0xd0, 0x0000080c);
> @@ -168,6 +158,11 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
>
> ufs_renesas_write(hba, 0xd0, 0x00000804);
> ufs_renesas_poll(hba, 0xd4, BIT(8) | BIT(6) | BIT(0), BIT(8) | BIT(6) | BIT(0));
> +}
> +
> +static u32 ufs_renesas_init_disable_timer(struct ufs_hba *hba)
> +{
> + u32 timer_val;
>
> ufs_renesas_write(hba, 0xd0, 0x00000d00);
> timer_val = ufs_renesas_read(hba, 0xd4) & 0x0000ffff;
> @@ -179,6 +174,45 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
> ufs_renesas_write(hba, 0xd0, 0x00000d2c);
> ufs_renesas_poll(hba, 0xd4, BIT(0), BIT(0));
>
> + return timer_val;
> +}
> +
> +static void ufs_renesas_init_enable_timer(struct ufs_hba *hba, u32 timer_val)
> +{
> + ufs_renesas_write(hba, 0xf0, 0);
> + ufs_renesas_write(hba, 0xd0, 0x00000d00);
> + ufs_renesas_write(hba, 0xd4, timer_val);
> +}
> +
> +static void ufs_renesas_write_phy_10ad_10af(struct ufs_hba *hba,
> + u32 data_10ad, u32 data_10af)
> +{
> + ufs_renesas_write_phy(hba, 0x10ae, 0x0001);
> + ufs_renesas_write_phy(hba, 0x10ad, data_10ad);
> + ufs_renesas_write_phy(hba, 0x10af, data_10af);
> + ufs_renesas_write_phy(hba, 0x10b6, 0x0001);
> + ufs_renesas_write_phy(hba, 0x10ae, 0x0000);
> +}
> +
> +static void ufs_renesas_init_compensation_and_slicers(struct ufs_hba *hba)
> +{
> + ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0001);
> + ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0002);
> + ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x0000);
> + ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x001a);
> +}
> +
> +static void ufs_renesas_pre_init(struct ufs_hba *hba)
> +{
> + u32 timer_val;
> +
> + /* This setting is for SERIES B */
> + ufs_renesas_init_step1_to_3(hba);
> +
> + ufs_renesas_init_step4_to_6(hba);
> +
> + timer_val = ufs_renesas_init_disable_timer(hba);
> +
> /* phy setup */
> ufs_renesas_indirect_write(hba, 1, 0x01, 0x001f);
> ufs_renesas_indirect_write(hba, 7, 0x5d, 0x0014);
> @@ -214,10 +248,7 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
> ufs_renesas_write_phy(hba, 0x4000, 0x0000);
> ufs_renesas_write_phy(hba, 0x4001, 0x0000);
>
> - ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0001);
> - ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0002);
> - ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x0000);
> - ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x001a);
> + ufs_renesas_init_compensation_and_slicers(hba);
>
> ufs_renesas_indirect_write(hba, 7, 0x70, 0x0016);
> ufs_renesas_indirect_write(hba, 7, 0x71, 0x0016);
> @@ -244,9 +275,7 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
> ufs_renesas_indirect_poll(hba, 7, 0x41, 0, BIT(7));
> /* end of phy setup */
>
> - ufs_renesas_write(hba, 0xf0, 0);
> - ufs_renesas_write(hba, 0xd0, 0x00000d00);
> - ufs_renesas_write(hba, 0xd4, timer_val);
> + ufs_renesas_init_enable_timer(hba, timer_val);
> }
>
> static int ufs_renesas_hce_enable_notify(struct ufs_hba *hba,
Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>
Thanks,
Neil
More information about the U-Boot
mailing list