18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * UFS PHY driver data for Samsung EXYNOS7 SoC
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2020 Samsung Electronics Co., Ltd.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#ifndef _PHY_EXYNOS7_UFS_H_
88c2ecf20Sopenharmony_ci#define _PHY_EXYNOS7_UFS_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include "phy-samsung-ufs.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define EXYNOS7_EMBEDDED_COMBO_PHY_CTRL	0x720
138c2ecf20Sopenharmony_ci#define EXYNOS7_EMBEDDED_COMBO_PHY_CTRL_MASK	0x1
148c2ecf20Sopenharmony_ci#define EXYNOS7_EMBEDDED_COMBO_PHY_CTRL_EN	BIT(0)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/* Calibration for phy initialization */
178c2ecf20Sopenharmony_cistatic const struct samsung_ufs_phy_cfg exynos7_pre_init_cfg[] = {
188c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x00f, 0xfa, PWR_MODE_ANY),
198c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x010, 0x82, PWR_MODE_ANY),
208c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x011, 0x1e, PWR_MODE_ANY),
218c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x017, 0x84, PWR_MODE_ANY),
228c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x035, 0x58, PWR_MODE_ANY),
238c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x036, 0x32, PWR_MODE_ANY),
248c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x037, 0x40, PWR_MODE_ANY),
258c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x03b, 0x83, PWR_MODE_ANY),
268c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x042, 0x88, PWR_MODE_ANY),
278c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x043, 0xa6, PWR_MODE_ANY),
288c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x048, 0x74, PWR_MODE_ANY),
298c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x04c, 0x5b, PWR_MODE_ANY),
308c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x04d, 0x83, PWR_MODE_ANY),
318c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x05c, 0x14, PWR_MODE_ANY),
328c2ecf20Sopenharmony_ci	END_UFS_PHY_CFG
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/* Calibration for HS mode series A/B */
368c2ecf20Sopenharmony_cistatic const struct samsung_ufs_phy_cfg exynos7_pre_pwr_hs_cfg[] = {
378c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x00f, 0xfa, PWR_MODE_HS_ANY),
388c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x010, 0x82, PWR_MODE_HS_ANY),
398c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x011, 0x1e, PWR_MODE_HS_ANY),
408c2ecf20Sopenharmony_ci	/* Setting order: 1st(0x16, 2nd(0x15) */
418c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x016, 0xff, PWR_MODE_HS_ANY),
428c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x015, 0x80, PWR_MODE_HS_ANY),
438c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x017, 0x94, PWR_MODE_HS_ANY),
448c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x036, 0x32, PWR_MODE_HS_ANY),
458c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x037, 0x43, PWR_MODE_HS_ANY),
468c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x038, 0x3f, PWR_MODE_HS_ANY),
478c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x042, 0x88, PWR_MODE_HS_G2_SER_A),
488c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x042, 0xbb, PWR_MODE_HS_G2_SER_B),
498c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x043, 0xa6, PWR_MODE_HS_ANY),
508c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x048, 0x74, PWR_MODE_HS_ANY),
518c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x034, 0x35, PWR_MODE_HS_G2_SER_A),
528c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x034, 0x36, PWR_MODE_HS_G2_SER_B),
538c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x035, 0x5b, PWR_MODE_HS_G2_SER_A),
548c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x035, 0x5c, PWR_MODE_HS_G2_SER_B),
558c2ecf20Sopenharmony_ci	END_UFS_PHY_CFG
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* Calibration for HS mode series A/B atfer PMC */
598c2ecf20Sopenharmony_cistatic const struct samsung_ufs_phy_cfg exynos7_post_pwr_hs_cfg[] = {
608c2ecf20Sopenharmony_ci	PHY_COMN_REG_CFG(0x015, 0x00, PWR_MODE_HS_ANY),
618c2ecf20Sopenharmony_ci	PHY_TRSV_REG_CFG(0x04d, 0x83, PWR_MODE_HS_ANY),
628c2ecf20Sopenharmony_ci	END_UFS_PHY_CFG
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cistatic const struct samsung_ufs_phy_cfg *exynos7_ufs_phy_cfgs[CFG_TAG_MAX] = {
668c2ecf20Sopenharmony_ci	[CFG_PRE_INIT]		= exynos7_pre_init_cfg,
678c2ecf20Sopenharmony_ci	[CFG_PRE_PWR_HS]	= exynos7_pre_pwr_hs_cfg,
688c2ecf20Sopenharmony_ci	[CFG_POST_PWR_HS]	= exynos7_post_pwr_hs_cfg,
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic struct samsung_ufs_phy_drvdata exynos7_ufs_phy = {
728c2ecf20Sopenharmony_ci	.cfg = exynos7_ufs_phy_cfgs,
738c2ecf20Sopenharmony_ci	.isol = {
748c2ecf20Sopenharmony_ci		.offset = EXYNOS7_EMBEDDED_COMBO_PHY_CTRL,
758c2ecf20Sopenharmony_ci		.mask = EXYNOS7_EMBEDDED_COMBO_PHY_CTRL_MASK,
768c2ecf20Sopenharmony_ci		.en = EXYNOS7_EMBEDDED_COMBO_PHY_CTRL_EN,
778c2ecf20Sopenharmony_ci	},
788c2ecf20Sopenharmony_ci	.has_symbol_clk = 1,
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#endif /* _PHY_EXYNOS7_UFS_H_ */
82