162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2017, HiSilicon. All rights reserved. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef UFS_HISI_H_ 762306a36Sopenharmony_ci#define UFS_HISI_H_ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define HBRN8_POLL_TOUT_MS 1000 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* 1262306a36Sopenharmony_ci * ufs sysctrl specific define 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci#define PSW_POWER_CTRL (0x04) 1562306a36Sopenharmony_ci#define PHY_ISO_EN (0x08) 1662306a36Sopenharmony_ci#define HC_LP_CTRL (0x0C) 1762306a36Sopenharmony_ci#define PHY_CLK_CTRL (0x10) 1862306a36Sopenharmony_ci#define PSW_CLK_CTRL (0x14) 1962306a36Sopenharmony_ci#define CLOCK_GATE_BYPASS (0x18) 2062306a36Sopenharmony_ci#define RESET_CTRL_EN (0x1C) 2162306a36Sopenharmony_ci#define UFS_SYSCTRL (0x5C) 2262306a36Sopenharmony_ci#define UFS_DEVICE_RESET_CTRL (0x60) 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#define BIT_UFS_PSW_ISO_CTRL (1 << 16) 2562306a36Sopenharmony_ci#define BIT_UFS_PSW_MTCMOS_EN (1 << 0) 2662306a36Sopenharmony_ci#define BIT_UFS_REFCLK_ISO_EN (1 << 16) 2762306a36Sopenharmony_ci#define BIT_UFS_PHY_ISO_CTRL (1 << 0) 2862306a36Sopenharmony_ci#define BIT_SYSCTRL_LP_ISOL_EN (1 << 16) 2962306a36Sopenharmony_ci#define BIT_SYSCTRL_PWR_READY (1 << 8) 3062306a36Sopenharmony_ci#define BIT_SYSCTRL_REF_CLOCK_EN (1 << 24) 3162306a36Sopenharmony_ci#define MASK_SYSCTRL_REF_CLOCK_SEL (0x3 << 8) 3262306a36Sopenharmony_ci#define MASK_SYSCTRL_CFG_CLOCK_FREQ (0xFF) 3362306a36Sopenharmony_ci#define UFS_FREQ_CFG_CLK (0x39) 3462306a36Sopenharmony_ci#define BIT_SYSCTRL_PSW_CLK_EN (1 << 4) 3562306a36Sopenharmony_ci#define MASK_UFS_CLK_GATE_BYPASS (0x3F) 3662306a36Sopenharmony_ci#define BIT_SYSCTRL_LP_RESET_N (1 << 0) 3762306a36Sopenharmony_ci#define BIT_UFS_REFCLK_SRC_SEl (1 << 0) 3862306a36Sopenharmony_ci#define MASK_UFS_SYSCRTL_BYPASS (0x3F << 16) 3962306a36Sopenharmony_ci#define MASK_UFS_DEVICE_RESET (0x1 << 16) 4062306a36Sopenharmony_ci#define BIT_UFS_DEVICE_RESET (0x1) 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * M-TX Configuration Attributes for Hixxxx 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_ci#define MPHY_TX_FSM_STATE 0x41 4662306a36Sopenharmony_ci#define TX_FSM_HIBERN8 0x1 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* 4962306a36Sopenharmony_ci * Hixxxx UFS HC specific Registers 5062306a36Sopenharmony_ci */ 5162306a36Sopenharmony_cienum { 5262306a36Sopenharmony_ci UFS_REG_OCPTHRTL = 0xc0, 5362306a36Sopenharmony_ci UFS_REG_OOCPR = 0xc4, 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci UFS_REG_CDACFG = 0xd0, 5662306a36Sopenharmony_ci UFS_REG_CDATX1 = 0xd4, 5762306a36Sopenharmony_ci UFS_REG_CDATX2 = 0xd8, 5862306a36Sopenharmony_ci UFS_REG_CDARX1 = 0xdc, 5962306a36Sopenharmony_ci UFS_REG_CDARX2 = 0xe0, 6062306a36Sopenharmony_ci UFS_REG_CDASTA = 0xe4, 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci UFS_REG_LBMCFG = 0xf0, 6362306a36Sopenharmony_ci UFS_REG_LBMSTA = 0xf4, 6462306a36Sopenharmony_ci UFS_REG_UFSMODE = 0xf8, 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci UFS_REG_HCLKDIV = 0xfc, 6762306a36Sopenharmony_ci}; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* AHIT - Auto-Hibernate Idle Timer */ 7062306a36Sopenharmony_ci#define UFS_AHIT_AH8ITV_MASK 0x3FF 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* REG UFS_REG_OCPTHRTL definition */ 7362306a36Sopenharmony_ci#define UFS_HCLKDIV_NORMAL_VALUE 0xE4 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* vendor specific pre-defined parameters */ 7662306a36Sopenharmony_ci#define SLOW 1 7762306a36Sopenharmony_ci#define FAST 2 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#define UFS_HISI_CAP_RESERVED BIT(0) 8062306a36Sopenharmony_ci#define UFS_HISI_CAP_PHY10nm BIT(1) 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_cistruct ufs_hisi_host { 8362306a36Sopenharmony_ci struct ufs_hba *hba; 8462306a36Sopenharmony_ci void __iomem *ufs_sys_ctrl; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci struct reset_control *rst; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci uint64_t caps; 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci bool in_suspend; 9162306a36Sopenharmony_ci}; 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define ufs_sys_ctrl_writel(host, val, reg) \ 9462306a36Sopenharmony_ci writel((val), (host)->ufs_sys_ctrl + (reg)) 9562306a36Sopenharmony_ci#define ufs_sys_ctrl_readl(host, reg) readl((host)->ufs_sys_ctrl + (reg)) 9662306a36Sopenharmony_ci#define ufs_sys_ctrl_set_bits(host, mask, reg) \ 9762306a36Sopenharmony_ci ufs_sys_ctrl_writel( \ 9862306a36Sopenharmony_ci (host), ((mask) | (ufs_sys_ctrl_readl((host), (reg)))), (reg)) 9962306a36Sopenharmony_ci#define ufs_sys_ctrl_clr_bits(host, mask, reg) \ 10062306a36Sopenharmony_ci ufs_sys_ctrl_writel((host), \ 10162306a36Sopenharmony_ci ((~(mask)) & (ufs_sys_ctrl_readl((host), (reg)))), \ 10262306a36Sopenharmony_ci (reg)) 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci#endif /* UFS_HISI_H_ */ 105