Skip to content

Commit 44ca16f

Browse files
shimodaymartinkpetersen
authored andcommitted
scsi: ufs: renesas: Add reusable functions
Since some settings can be reused on other UFS controller (R-Car S4-8 ES1.2), add reusable functions. Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/446d67b751a96645799de3aeefec539735aa78c8.1741179611.git.geert+renesas@glider.be Signed-off-by: Martin K. Petersen <[email protected]>
1 parent cca2b80 commit 44ca16f

File tree

1 file changed

+50
-21
lines changed

1 file changed

+50
-21
lines changed

drivers/ufs/host/ufs-renesas.c

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,8 @@ static void ufs_renesas_indirect_poll(struct ufs_hba *hba, u32 gpio, u32 addr,
135135
ufs_renesas_write(hba, 0xf0, 0);
136136
}
137137

138-
static void ufs_renesas_write_phy_10ad_10af(struct ufs_hba *hba,
139-
u32 data_10ad, u32 data_10af)
138+
static void ufs_renesas_init_step1_to_3(struct ufs_hba *hba)
140139
{
141-
ufs_renesas_write_phy(hba, 0x10ae, 0x0001);
142-
ufs_renesas_write_phy(hba, 0x10ad, data_10ad);
143-
ufs_renesas_write_phy(hba, 0x10af, data_10af);
144-
ufs_renesas_write_phy(hba, 0x10b6, 0x0001);
145-
ufs_renesas_write_phy(hba, 0x10ae, 0x0000);
146-
}
147-
148-
static void ufs_renesas_pre_init(struct ufs_hba *hba)
149-
{
150-
u32 timer_val;
151-
152-
/* This setting is for SERIES B */
153140
ufs_renesas_write(hba, 0xc0, 0x49425308);
154141
ufs_renesas_write_d0_d4(hba, 0x00000104, 0x00000002);
155142
udelay(1);
@@ -163,7 +150,10 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
163150

164151
ufs_renesas_write(hba, 0xc0, 0x49425308);
165152
ufs_renesas_write(hba, 0xc0, 0x41584901);
153+
}
166154

155+
static void ufs_renesas_init_step4_to_6(struct ufs_hba *hba)
156+
{
167157
ufs_renesas_write_d0_d4(hba, 0x0000080c, 0x00000100);
168158
ufs_renesas_write_d0_d4(hba, 0x00000804, 0x00000000);
169159
ufs_renesas_write(hba, 0xd0, 0x0000080c);
@@ -173,6 +163,11 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
173163

174164
ufs_renesas_write(hba, 0xd0, 0x00000804);
175165
ufs_renesas_poll(hba, 0xd4, BIT(8) | BIT(6) | BIT(0), BIT(8) | BIT(6) | BIT(0));
166+
}
167+
168+
static u32 ufs_renesas_init_disable_timer(struct ufs_hba *hba)
169+
{
170+
u32 timer_val;
176171

177172
ufs_renesas_write(hba, 0xd0, 0x00000d00);
178173
timer_val = ufs_renesas_read(hba, 0xd4) & 0x0000ffff;
@@ -184,6 +179,45 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
184179
ufs_renesas_write(hba, 0xd0, 0x00000d2c);
185180
ufs_renesas_poll(hba, 0xd4, BIT(0), BIT(0));
186181

182+
return timer_val;
183+
}
184+
185+
static void ufs_renesas_init_enable_timer(struct ufs_hba *hba, u32 timer_val)
186+
{
187+
ufs_renesas_write(hba, 0xf0, 0);
188+
ufs_renesas_write(hba, 0xd0, 0x00000d00);
189+
ufs_renesas_write(hba, 0xd4, timer_val);
190+
}
191+
192+
static void ufs_renesas_write_phy_10ad_10af(struct ufs_hba *hba,
193+
u32 data_10ad, u32 data_10af)
194+
{
195+
ufs_renesas_write_phy(hba, 0x10ae, 0x0001);
196+
ufs_renesas_write_phy(hba, 0x10ad, data_10ad);
197+
ufs_renesas_write_phy(hba, 0x10af, data_10af);
198+
ufs_renesas_write_phy(hba, 0x10b6, 0x0001);
199+
ufs_renesas_write_phy(hba, 0x10ae, 0x0000);
200+
}
201+
202+
static void ufs_renesas_init_compensation_and_slicers(struct ufs_hba *hba)
203+
{
204+
ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0001);
205+
ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0002);
206+
ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x0000);
207+
ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x001a);
208+
}
209+
210+
static void ufs_renesas_pre_init(struct ufs_hba *hba)
211+
{
212+
u32 timer_val;
213+
214+
/* This setting is for SERIES B */
215+
ufs_renesas_init_step1_to_3(hba);
216+
217+
ufs_renesas_init_step4_to_6(hba);
218+
219+
timer_val = ufs_renesas_init_disable_timer(hba);
220+
187221
/* phy setup */
188222
ufs_renesas_indirect_write(hba, 1, 0x01, 0x001f);
189223
ufs_renesas_indirect_write(hba, 7, 0x5d, 0x0014);
@@ -219,10 +253,7 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
219253
ufs_renesas_write_phy(hba, 0x4000, 0x0000);
220254
ufs_renesas_write_phy(hba, 0x4001, 0x0000);
221255

222-
ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0001);
223-
ufs_renesas_write_phy_10ad_10af(hba, 0x0000, 0x0002);
224-
ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x0000);
225-
ufs_renesas_write_phy_10ad_10af(hba, 0x0080, 0x001a);
256+
ufs_renesas_init_compensation_and_slicers(hba);
226257

227258
ufs_renesas_indirect_write(hba, 7, 0x70, 0x0016);
228259
ufs_renesas_indirect_write(hba, 7, 0x71, 0x0016);
@@ -249,9 +280,7 @@ static void ufs_renesas_pre_init(struct ufs_hba *hba)
249280
ufs_renesas_indirect_poll(hba, 7, 0x41, 0, BIT(7));
250281
/* end of phy setup */
251282

252-
ufs_renesas_write(hba, 0xf0, 0);
253-
ufs_renesas_write(hba, 0xd0, 0x00000d00);
254-
ufs_renesas_write(hba, 0xd4, timer_val);
283+
ufs_renesas_init_enable_timer(hba, timer_val);
255284
}
256285

257286
static int ufs_renesas_hce_enable_notify(struct ufs_hba *hba,

0 commit comments

Comments
 (0)