Lines Matching refs:hba

23 static int ufs_hisi_check_hibern8(struct ufs_hba *hba)  in ufs_hisi_check_hibern8()  argument
31 err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0), in ufs_hisi_check_hibern8()
33 err |= ufshcd_dme_get(hba, in ufs_hisi_check_hibern8()
48 err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0), in ufs_hisi_check_hibern8()
50 err |= ufshcd_dme_get(hba, in ufs_hisi_check_hibern8()
55 dev_err(hba->dev, "%s: unable to get TX_FSM_STATE, err %d\n", in ufs_hisi_check_hibern8()
60 dev_err(hba->dev, "%s: invalid TX_FSM_STATE, lane0 = %d, lane1 = %d\n", in ufs_hisi_check_hibern8()
67 static void ufs_hisi_clk_init(struct ufs_hba *hba) in ufs_hisi_clk_init() argument
69 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_clk_init()
81 static void ufs_hisi_soc_init(struct ufs_hba *hba) in ufs_hisi_soc_init() argument
83 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_soc_init()
138 static int ufs_hisi_link_startup_pre_change(struct ufs_hba *hba) in ufs_hisi_link_startup_pre_change() argument
140 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_link_startup_pre_change()
146 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD0C1, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
148 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x156A, 0x0), 0x2); in ufs_hisi_link_startup_pre_change()
150 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8114, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
152 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8121, 0x0), 0x2D); in ufs_hisi_link_startup_pre_change()
154 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8122, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
158 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8127, 0x0), 0x98); in ufs_hisi_link_startup_pre_change()
160 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8128, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
164 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD085, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
166 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x800D, 0x4), 0x58); in ufs_hisi_link_startup_pre_change()
168 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x800D, 0x5), 0x58); in ufs_hisi_link_startup_pre_change()
170 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x800E, 0x4), 0xB); in ufs_hisi_link_startup_pre_change()
172 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x800E, 0x5), 0xB); in ufs_hisi_link_startup_pre_change()
174 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8009, 0x4), 0x1); in ufs_hisi_link_startup_pre_change()
176 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8009, 0x5), 0x1); in ufs_hisi_link_startup_pre_change()
178 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD085, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
180 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x8113, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
181 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD085, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
185 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0092, 0x4), 0xA); in ufs_hisi_link_startup_pre_change()
187 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0092, 0x5), 0xA); in ufs_hisi_link_startup_pre_change()
189 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008f, 0x4), 0xA); in ufs_hisi_link_startup_pre_change()
191 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008f, 0x5), 0xA); in ufs_hisi_link_startup_pre_change()
194 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008F, 0x4), 0x7); in ufs_hisi_link_startup_pre_change()
196 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008F, 0x5), 0x7); in ufs_hisi_link_startup_pre_change()
200 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0095, 0x4), 0x4F); in ufs_hisi_link_startup_pre_change()
202 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0095, 0x5), 0x4F); in ufs_hisi_link_startup_pre_change()
204 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0094, 0x4), 0x4F); in ufs_hisi_link_startup_pre_change()
206 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x0094, 0x5), 0x4F); in ufs_hisi_link_startup_pre_change()
208 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008B, 0x4), 0x4F); in ufs_hisi_link_startup_pre_change()
210 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x008B, 0x5), 0x4F); in ufs_hisi_link_startup_pre_change()
212 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x000F, 0x0), 0x5); in ufs_hisi_link_startup_pre_change()
214 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0x000F, 0x1), 0x5); in ufs_hisi_link_startup_pre_change()
216 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD085, 0x0), 0x1); in ufs_hisi_link_startup_pre_change()
218 ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(0xD0C1, 0x0), &value); in ufs_hisi_link_startup_pre_change()
220 dev_info(hba->dev, in ufs_hisi_link_startup_pre_change()
224 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD0C1, 0x0), 0x0); in ufs_hisi_link_startup_pre_change()
225 err = ufs_hisi_check_hibern8(hba); in ufs_hisi_link_startup_pre_change()
227 dev_err(hba->dev, "ufs_hisi_check_hibern8 error\n"); in ufs_hisi_link_startup_pre_change()
230 ufshcd_writel(hba, UFS_HCLKDIV_NORMAL_VALUE, UFS_REG_HCLKDIV); in ufs_hisi_link_startup_pre_change()
233 reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER); in ufs_hisi_link_startup_pre_change()
235 ufshcd_writel(hba, reg, REG_AUTO_HIBERNATE_IDLE_TIMER); in ufs_hisi_link_startup_pre_change()
238 ufshcd_disable_host_tx_lcc(hba); in ufs_hisi_link_startup_pre_change()
240 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xD0AB, 0x0), 0x0); in ufs_hisi_link_startup_pre_change()
241 ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(0xD0AB, 0x0), &value); in ufs_hisi_link_startup_pre_change()
244 dev_info(hba->dev, "WARN: close VS_Mk2ExtnSupport failed\n"); in ufs_hisi_link_startup_pre_change()
250 static int ufs_hisi_link_startup_post_change(struct ufs_hba *hba) in ufs_hisi_link_startup_post_change() argument
252 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_link_startup_post_change()
255 ufshcd_dme_set(hba, UIC_ARG_MIB(0x2044), 0x0); in ufs_hisi_link_startup_post_change()
257 ufshcd_dme_set(hba, UIC_ARG_MIB(0x2045), 0x0); in ufs_hisi_link_startup_post_change()
259 ufshcd_dme_set(hba, UIC_ARG_MIB(0x2040), 0x9); in ufs_hisi_link_startup_post_change()
268 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd09a), 0x80000000); in ufs_hisi_link_startup_post_change()
270 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd09c), 0x00000005); in ufs_hisi_link_startup_post_change()
275 static int ufs_hisi_link_startup_notify(struct ufs_hba *hba, in ufs_hisi_link_startup_notify() argument
282 err = ufs_hisi_link_startup_pre_change(hba); in ufs_hisi_link_startup_notify()
285 err = ufs_hisi_link_startup_post_change(hba); in ufs_hisi_link_startup_notify()
299 static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba) in ufs_hisi_pwr_change_pre_change() argument
301 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_pwr_change_pre_change()
309 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0xD0A0), 0x13); in ufs_hisi_pwr_change_pre_change()
311 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0x1552), 0x4f); in ufs_hisi_pwr_change_pre_change()
313 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0x1554), 0x4f); in ufs_hisi_pwr_change_pre_change()
315 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0x1556), 0x4f); in ufs_hisi_pwr_change_pre_change()
317 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0x15a7), 0xA); in ufs_hisi_pwr_change_pre_change()
319 ufshcd_dme_set(hba, UIC_ARG_MIB((u32)0x15a8), 0xA); in ufs_hisi_pwr_change_pre_change()
320 ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(0xd085, 0x0), 0x01); in ufs_hisi_pwr_change_pre_change()
323 if (hba->dev_quirks & UFS_DEVICE_QUIRK_HOST_VS_DEBUGSAVECONFIGTIME) { in ufs_hisi_pwr_change_pre_change()
326 ufshcd_dme_set(hba, UIC_ARG_MIB(0xD0A0), 0x10); in ufs_hisi_pwr_change_pre_change()
328 ufshcd_dme_set(hba, UIC_ARG_MIB(0x1556), 0x48); in ufs_hisi_pwr_change_pre_change()
332 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15A8), 0x1); in ufs_hisi_pwr_change_pre_change()
334 ufshcd_dme_set(hba, UIC_ARG_MIB(0x155c), 0x0); in ufs_hisi_pwr_change_pre_change()
336 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b0), 8191); in ufs_hisi_pwr_change_pre_change()
338 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b1), 65535); in ufs_hisi_pwr_change_pre_change()
340 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b2), 32767); in ufs_hisi_pwr_change_pre_change()
342 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd041), 8191); in ufs_hisi_pwr_change_pre_change()
344 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd042), 65535); in ufs_hisi_pwr_change_pre_change()
346 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd043), 32767); in ufs_hisi_pwr_change_pre_change()
348 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b3), 8191); in ufs_hisi_pwr_change_pre_change()
350 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b4), 65535); in ufs_hisi_pwr_change_pre_change()
352 ufshcd_dme_set(hba, UIC_ARG_MIB(0x15b5), 32767); in ufs_hisi_pwr_change_pre_change()
354 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd044), 8191); in ufs_hisi_pwr_change_pre_change()
356 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd045), 65535); in ufs_hisi_pwr_change_pre_change()
358 ufshcd_dme_set(hba, UIC_ARG_MIB(0xd046), 32767); in ufs_hisi_pwr_change_pre_change()
361 static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba, in ufs_hisi_pwr_change_notify() argument
370 dev_err(hba->dev, in ufs_hisi_pwr_change_notify()
382 dev_err(hba->dev, in ufs_hisi_pwr_change_notify()
387 ufs_hisi_pwr_change_pre_change(hba); in ufs_hisi_pwr_change_notify()
399 static int ufs_hisi_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op, in ufs_hisi_suspend() argument
402 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_suspend()
425 static int ufs_hisi_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) in ufs_hisi_resume() argument
427 struct ufs_hisi_host *host = ufshcd_get_variant(hba); in ufs_hisi_resume()
443 struct device *dev = host->hba->dev; in ufs_hisi_get_resource()
451 static void ufs_hisi_set_pm_lvl(struct ufs_hba *hba) in ufs_hisi_set_pm_lvl() argument
453 hba->rpm_lvl = UFS_PM_LVL_1; in ufs_hisi_set_pm_lvl()
454 hba->spm_lvl = UFS_PM_LVL_3; in ufs_hisi_set_pm_lvl()
461 static int ufs_hisi_init_common(struct ufs_hba *hba) in ufs_hisi_init_common() argument
464 struct device *dev = hba->dev; in ufs_hisi_init_common()
471 host->hba = hba; in ufs_hisi_init_common()
472 ufshcd_set_variant(hba, host); in ufs_hisi_init_common()
481 ufs_hisi_set_pm_lvl(hba); in ufs_hisi_init_common()
490 ufshcd_set_variant(hba, NULL); in ufs_hisi_init_common()
494 static int ufs_hi3660_init(struct ufs_hba *hba) in ufs_hi3660_init() argument
497 struct device *dev = hba->dev; in ufs_hi3660_init()
499 ret = ufs_hisi_init_common(hba); in ufs_hi3660_init()
505 ufs_hisi_clk_init(hba); in ufs_hi3660_init()
507 ufs_hisi_soc_init(hba); in ufs_hi3660_init()
512 static int ufs_hi3670_init(struct ufs_hba *hba) in ufs_hi3670_init() argument
515 struct device *dev = hba->dev; in ufs_hi3670_init()
518 ret = ufs_hisi_init_common(hba); in ufs_hi3670_init()
524 ufs_hisi_clk_init(hba); in ufs_hi3670_init()
526 ufs_hisi_soc_init(hba); in ufs_hi3670_init()
529 host = ufshcd_get_variant(hba); in ufs_hi3670_init()
572 struct ufs_hba *hba = platform_get_drvdata(pdev); in ufs_hisi_remove() local
574 ufshcd_remove(hba); in ufs_hisi_remove()