Subhash Jadavani | 6bdc0ae | 2018-02-21 10:28:47 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef UFS_QCOM_H_ |
| 15 | #define UFS_QCOM_H_ |
| 16 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 17 | #include <linux/phy/phy.h> |
| 18 | #include <linux/pm_qos.h> |
| 19 | #include "ufshcd.h" |
| 20 | |
Subhash Jadavani | a889db0 | 2016-12-09 10:24:58 -0800 | [diff] [blame] | 21 | #define MAX_UFS_QCOM_HOSTS 2 |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 22 | #define MAX_U32 (~(u32)0) |
| 23 | #define MPHY_TX_FSM_STATE 0x41 |
Sayali Lokhande | 26c4bb5 | 2017-09-12 14:44:46 +0530 | [diff] [blame] | 24 | #define MPHY_RX_FSM_STATE 0xC1 |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 25 | #define TX_FSM_HIBERN8 0x1 |
| 26 | #define HBRN8_POLL_TOUT_MS 100 |
| 27 | #define DEFAULT_CLK_RATE_HZ 1000000 |
| 28 | #define BUS_VECTOR_NAME_LEN 32 |
| 29 | |
| 30 | #define UFS_HW_VER_MAJOR_SHFT (28) |
| 31 | #define UFS_HW_VER_MAJOR_MASK (0x000F << UFS_HW_VER_MAJOR_SHFT) |
| 32 | #define UFS_HW_VER_MINOR_SHFT (16) |
| 33 | #define UFS_HW_VER_MINOR_MASK (0x0FFF << UFS_HW_VER_MINOR_SHFT) |
| 34 | #define UFS_HW_VER_STEP_SHFT (0) |
| 35 | #define UFS_HW_VER_STEP_MASK (0xFFFF << UFS_HW_VER_STEP_SHFT) |
| 36 | |
| 37 | /* vendor specific pre-defined parameters */ |
| 38 | #define SLOW 1 |
| 39 | #define FAST 2 |
| 40 | |
| 41 | #define UFS_QCOM_LIMIT_NUM_LANES_RX 2 |
| 42 | #define UFS_QCOM_LIMIT_NUM_LANES_TX 2 |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 43 | #define UFS_QCOM_LIMIT_HSGEAR_RX UFS_HS_G3 |
| 44 | #define UFS_QCOM_LIMIT_HSGEAR_TX UFS_HS_G3 |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 45 | #define UFS_QCOM_LIMIT_PWMGEAR_RX UFS_PWM_G4 |
| 46 | #define UFS_QCOM_LIMIT_PWMGEAR_TX UFS_PWM_G4 |
| 47 | #define UFS_QCOM_LIMIT_RX_PWR_PWM SLOW_MODE |
| 48 | #define UFS_QCOM_LIMIT_TX_PWR_PWM SLOW_MODE |
| 49 | #define UFS_QCOM_LIMIT_RX_PWR_HS FAST_MODE |
| 50 | #define UFS_QCOM_LIMIT_TX_PWR_HS FAST_MODE |
| 51 | #define UFS_QCOM_LIMIT_HS_RATE PA_HS_MODE_B |
| 52 | #define UFS_QCOM_LIMIT_DESIRED_MODE FAST |
| 53 | |
| 54 | /* QCOM UFS host controller vendor specific registers */ |
| 55 | enum { |
| 56 | REG_UFS_SYS1CLK_1US = 0xC0, |
| 57 | REG_UFS_TX_SYMBOL_CLK_NS_US = 0xC4, |
| 58 | REG_UFS_LOCAL_PORT_ID_REG = 0xC8, |
| 59 | REG_UFS_PA_ERR_CODE = 0xCC, |
| 60 | REG_UFS_RETRY_TIMER_REG = 0xD0, |
| 61 | REG_UFS_PA_LINK_STARTUP_TIMER = 0xD8, |
| 62 | REG_UFS_CFG1 = 0xDC, |
| 63 | REG_UFS_CFG2 = 0xE0, |
| 64 | REG_UFS_HW_VERSION = 0xE4, |
| 65 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 66 | UFS_TEST_BUS = 0xE8, |
| 67 | UFS_TEST_BUS_CTRL_0 = 0xEC, |
| 68 | UFS_TEST_BUS_CTRL_1 = 0xF0, |
| 69 | UFS_TEST_BUS_CTRL_2 = 0xF4, |
| 70 | UFS_UNIPRO_CFG = 0xF8, |
| 71 | |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 72 | /* |
| 73 | * QCOM UFS host controller vendor specific registers |
| 74 | * added in HW Version 3.0.0 |
| 75 | */ |
| 76 | UFS_AH8_CFG = 0xFC, |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 79 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 80 | /* QCOM UFS host controller vendor specific debug registers */ |
| 81 | enum { |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 82 | UFS_DBG_RD_REG_UAWM = 0x100, |
| 83 | UFS_DBG_RD_REG_UARM = 0x200, |
| 84 | UFS_DBG_RD_REG_TXUC = 0x300, |
| 85 | UFS_DBG_RD_REG_RXUC = 0x400, |
| 86 | UFS_DBG_RD_REG_DFC = 0x500, |
| 87 | UFS_DBG_RD_REG_TRLUT = 0x600, |
| 88 | UFS_DBG_RD_REG_TMRLUT = 0x700, |
| 89 | UFS_UFS_DBG_RD_REG_OCSC = 0x800, |
| 90 | |
| 91 | UFS_UFS_DBG_RD_DESC_RAM = 0x1500, |
| 92 | UFS_UFS_DBG_RD_PRDT_RAM = 0x1700, |
| 93 | UFS_UFS_DBG_RD_RESP_RAM = 0x1800, |
| 94 | UFS_UFS_DBG_RD_EDTL_RAM = 0x1900, |
| 95 | }; |
| 96 | |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 97 | #define UFS_CNTLR_2_x_x_VEN_REGS_OFFSET(x) (0x000 + x) |
| 98 | #define UFS_CNTLR_3_x_x_VEN_REGS_OFFSET(x) (0x400 + x) |
| 99 | |
| 100 | /* bit definitions for REG_UFS_CFG1 register */ |
| 101 | #define QUNIPRO_SEL UFS_BIT(0) |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 102 | #define TEST_BUS_EN BIT(18) |
Sayali Lokhande | 6db5274 | 2017-10-04 11:56:14 +0530 | [diff] [blame] | 103 | #define TEST_BUS_SEL 0x780000 |
Subhash Jadavani | 9c80770 | 2017-04-01 00:35:51 -0700 | [diff] [blame] | 104 | #define UFS_REG_TEST_BUS_EN BIT(30) |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 105 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 106 | /* bit definitions for REG_UFS_CFG2 register */ |
| 107 | #define UAWM_HW_CGC_EN (1 << 0) |
| 108 | #define UARM_HW_CGC_EN (1 << 1) |
| 109 | #define TXUC_HW_CGC_EN (1 << 2) |
| 110 | #define RXUC_HW_CGC_EN (1 << 3) |
| 111 | #define DFC_HW_CGC_EN (1 << 4) |
| 112 | #define TRLUT_HW_CGC_EN (1 << 5) |
| 113 | #define TMRLUT_HW_CGC_EN (1 << 6) |
| 114 | #define OCSC_HW_CGC_EN (1 << 7) |
| 115 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 116 | /* bit definition for UFS_UFS_TEST_BUS_CTRL_n */ |
| 117 | #define TEST_BUS_SUB_SEL_MASK 0x1F /* All XXX_SEL fields are 5 bits wide */ |
| 118 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 119 | #define REG_UFS_CFG2_CGC_EN_ALL (UAWM_HW_CGC_EN | UARM_HW_CGC_EN |\ |
| 120 | TXUC_HW_CGC_EN | RXUC_HW_CGC_EN |\ |
| 121 | DFC_HW_CGC_EN | TRLUT_HW_CGC_EN |\ |
| 122 | TMRLUT_HW_CGC_EN | OCSC_HW_CGC_EN) |
| 123 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 124 | /* bit definitions for UFS_AH8_CFG register */ |
| 125 | #define CC_UFS_HCLK_REQ_EN BIT(1) |
| 126 | #define CC_UFS_SYS_CLK_REQ_EN BIT(2) |
| 127 | #define CC_UFS_ICE_CORE_CLK_REQ_EN BIT(3) |
| 128 | #define CC_UFS_UNIPRO_CORE_CLK_REQ_EN BIT(4) |
| 129 | #define CC_UFS_AUXCLK_REQ_EN BIT(5) |
| 130 | |
| 131 | #define UFS_HW_CLK_CTRL_EN (CC_UFS_SYS_CLK_REQ_EN |\ |
| 132 | CC_UFS_ICE_CORE_CLK_REQ_EN |\ |
| 133 | CC_UFS_UNIPRO_CORE_CLK_REQ_EN |\ |
| 134 | CC_UFS_AUXCLK_REQ_EN) |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 135 | /* bit offset */ |
| 136 | enum { |
| 137 | OFFSET_UFS_PHY_SOFT_RESET = 1, |
| 138 | OFFSET_CLK_NS_REG = 10, |
| 139 | }; |
| 140 | |
| 141 | /* bit masks */ |
| 142 | enum { |
| 143 | MASK_UFS_PHY_SOFT_RESET = 0x2, |
| 144 | MASK_TX_SYMBOL_CLK_1US_REG = 0x3FF, |
| 145 | MASK_CLK_NS_REG = 0xFFFC00, |
| 146 | }; |
| 147 | |
| 148 | enum ufs_qcom_phy_init_type { |
| 149 | UFS_PHY_INIT_FULL, |
| 150 | UFS_PHY_INIT_CFG_RESTORE, |
| 151 | }; |
| 152 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 153 | /* QCOM UFS debug print bit mask */ |
| 154 | #define UFS_QCOM_DBG_PRINT_REGS_EN BIT(0) |
| 155 | #define UFS_QCOM_DBG_PRINT_ICE_REGS_EN BIT(1) |
| 156 | #define UFS_QCOM_DBG_PRINT_TEST_BUS_EN BIT(2) |
| 157 | |
| 158 | #define UFS_QCOM_DBG_PRINT_ALL \ |
| 159 | (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_ICE_REGS_EN | \ |
| 160 | UFS_QCOM_DBG_PRINT_TEST_BUS_EN) |
| 161 | |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 162 | /* QUniPro Vendor specific attributes */ |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 163 | #define PA_VS_CONFIG_REG1 0x9000 |
| 164 | #define SAVECONFIGTIME_MODE_MASK 0x6000 |
| 165 | |
| 166 | #define PA_VS_CLK_CFG_REG 0x9004 |
| 167 | #define PA_VS_CLK_CFG_REG_MASK 0x1FF |
| 168 | |
| 169 | #define DL_VS_CLK_CFG 0xA00B |
| 170 | #define DL_VS_CLK_CFG_MASK 0x3FF |
| 171 | |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 172 | #define DME_VS_CORE_CLK_CTRL 0xD002 |
| 173 | /* bit and mask definitions for DME_VS_CORE_CLK_CTRL attribute */ |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 174 | #define DME_VS_CORE_CLK_CTRL_MAX_CORE_CLK_1US_CYCLES_MASK 0xFF |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 175 | #define DME_VS_CORE_CLK_CTRL_CORE_CLK_DIV_EN_BIT BIT(8) |
| 176 | #define DME_VS_CORE_CLK_CTRL_DME_HW_CGC_EN BIT(9) |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 177 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 178 | static inline void |
| 179 | ufs_qcom_get_controller_revision(struct ufs_hba *hba, |
| 180 | u8 *major, u16 *minor, u16 *step) |
| 181 | { |
| 182 | u32 ver = ufshcd_readl(hba, REG_UFS_HW_VERSION); |
| 183 | |
| 184 | *major = (ver & UFS_HW_VER_MAJOR_MASK) >> UFS_HW_VER_MAJOR_SHFT; |
| 185 | *minor = (ver & UFS_HW_VER_MINOR_MASK) >> UFS_HW_VER_MINOR_SHFT; |
| 186 | *step = (ver & UFS_HW_VER_STEP_MASK) >> UFS_HW_VER_STEP_SHFT; |
| 187 | }; |
| 188 | |
| 189 | static inline void ufs_qcom_assert_reset(struct ufs_hba *hba) |
| 190 | { |
| 191 | ufshcd_rmwl(hba, MASK_UFS_PHY_SOFT_RESET, |
| 192 | 1 << OFFSET_UFS_PHY_SOFT_RESET, REG_UFS_CFG1); |
| 193 | |
| 194 | /* |
| 195 | * Make sure assertion of ufs phy reset is written to |
| 196 | * register before returning |
| 197 | */ |
| 198 | mb(); |
| 199 | } |
| 200 | |
| 201 | static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) |
| 202 | { |
| 203 | ufshcd_rmwl(hba, MASK_UFS_PHY_SOFT_RESET, |
| 204 | 0 << OFFSET_UFS_PHY_SOFT_RESET, REG_UFS_CFG1); |
| 205 | |
| 206 | /* |
| 207 | * Make sure de-assertion of ufs phy reset is written to |
| 208 | * register before returning |
| 209 | */ |
| 210 | mb(); |
| 211 | } |
| 212 | |
| 213 | struct ufs_qcom_bus_vote { |
| 214 | uint32_t client_handle; |
| 215 | uint32_t curr_vote; |
| 216 | int min_bw_vote; |
| 217 | int max_bw_vote; |
| 218 | int saved_vote; |
| 219 | bool is_max_bw_needed; |
| 220 | struct device_attribute max_bus_bw; |
| 221 | }; |
| 222 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 223 | /** |
| 224 | * struct ufs_qcom_ice_data - ICE related information |
| 225 | * @vops: pointer to variant operations of ICE |
| 226 | * @async_done: completion for supporting ICE's driver asynchronous nature |
| 227 | * @pdev: pointer to the proper ICE platform device |
| 228 | * @state: UFS-ICE interface's internal state (see |
| 229 | * ufs-qcom-ice.h for possible internal states) |
| 230 | * @quirks: UFS-ICE interface related quirks |
| 231 | * @crypto_engine_err: crypto engine errors |
| 232 | */ |
| 233 | struct ufs_qcom_ice_data { |
| 234 | struct qcom_ice_variant_ops *vops; |
| 235 | struct platform_device *pdev; |
| 236 | int state; |
| 237 | |
| 238 | u16 quirks; |
| 239 | |
| 240 | bool crypto_engine_err; |
| 241 | }; |
| 242 | |
Yaniv Gardi | bfdbe8b | 2015-03-31 17:37:13 +0300 | [diff] [blame] | 243 | /* Host controller hardware version: major.minor.step */ |
| 244 | struct ufs_hw_version { |
| 245 | u16 step; |
| 246 | u16 minor; |
| 247 | u8 major; |
| 248 | }; |
Yaniv Gardi | cad2e03 | 2015-03-31 17:37:14 +0300 | [diff] [blame] | 249 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 250 | #ifdef CONFIG_DEBUG_FS |
| 251 | struct qcom_debugfs_files { |
| 252 | struct dentry *debugfs_root; |
| 253 | struct dentry *dbg_print_en; |
| 254 | struct dentry *testbus; |
| 255 | struct dentry *testbus_en; |
| 256 | struct dentry *testbus_cfg; |
| 257 | struct dentry *testbus_bus; |
| 258 | struct dentry *dbg_regs; |
| 259 | struct dentry *pm_qos; |
| 260 | }; |
| 261 | #endif |
| 262 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 263 | struct ufs_qcom_testbus { |
| 264 | u8 select_major; |
| 265 | u8 select_minor; |
| 266 | }; |
| 267 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 268 | /* PM QoS voting state */ |
| 269 | enum ufs_qcom_pm_qos_state { |
| 270 | PM_QOS_UNVOTED, |
| 271 | PM_QOS_VOTED, |
| 272 | PM_QOS_REQ_VOTE, |
| 273 | PM_QOS_REQ_UNVOTE, |
| 274 | }; |
| 275 | |
| 276 | /** |
| 277 | * struct ufs_qcom_pm_qos_cpu_group - data related to cluster PM QoS voting |
| 278 | * logic |
| 279 | * @req: request object for PM QoS |
| 280 | * @vote_work: work object for voting procedure |
| 281 | * @unvote_work: work object for un-voting procedure |
| 282 | * @host: back pointer to the main structure |
| 283 | * @state: voting state machine current state |
| 284 | * @latency_us: requested latency value used for cluster voting, in |
| 285 | * microseconds |
| 286 | * @mask: cpu mask defined for this cluster |
| 287 | * @active_reqs: number of active requests on this cluster |
| 288 | */ |
| 289 | struct ufs_qcom_pm_qos_cpu_group { |
| 290 | struct pm_qos_request req; |
| 291 | struct work_struct vote_work; |
| 292 | struct work_struct unvote_work; |
| 293 | struct ufs_qcom_host *host; |
| 294 | enum ufs_qcom_pm_qos_state state; |
| 295 | s32 latency_us; |
| 296 | cpumask_t mask; |
| 297 | int active_reqs; |
| 298 | }; |
| 299 | |
| 300 | /** |
| 301 | * struct ufs_qcom_pm_qos - data related to PM QoS voting logic |
| 302 | * @groups: PM QoS cpu group state array |
| 303 | * @enable_attr: sysfs attribute to enable/disable PM QoS voting logic |
| 304 | * @latency_attr: sysfs attribute to set latency value |
| 305 | * @workq: single threaded workqueue to run PM QoS voting/unvoting |
| 306 | * @num_clusters: number of clusters defined |
| 307 | * @default_cpu: cpu to use for voting for request not specifying a cpu |
| 308 | * @is_enabled: flag specifying whether voting logic is enabled |
| 309 | */ |
| 310 | struct ufs_qcom_pm_qos { |
| 311 | struct ufs_qcom_pm_qos_cpu_group *groups; |
| 312 | struct device_attribute enable_attr; |
| 313 | struct device_attribute latency_attr; |
| 314 | struct workqueue_struct *workq; |
| 315 | int num_groups; |
| 316 | int default_cpu; |
| 317 | bool is_enabled; |
| 318 | }; |
| 319 | |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 320 | struct ufs_qcom_host { |
Yaniv Gardi | cad2e03 | 2015-03-31 17:37:14 +0300 | [diff] [blame] | 321 | /* |
| 322 | * Set this capability if host controller supports the QUniPro mode |
| 323 | * and if driver wants the Host controller to operate in QUniPro mode. |
| 324 | * Note: By default this capability will be kept enabled if host |
| 325 | * controller supports the QUniPro mode. |
| 326 | */ |
| 327 | #define UFS_QCOM_CAP_QUNIPRO UFS_BIT(0) |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 328 | |
| 329 | /* |
| 330 | * Set this capability if host controller can retain the secure |
| 331 | * configuration even after UFS controller core power collapse. |
| 332 | */ |
| 333 | #define UFS_QCOM_CAP_RETAIN_SEC_CFG_AFTER_PWR_COLLAPSE UFS_BIT(1) |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 334 | |
| 335 | /* |
| 336 | * Set this capability if host controller supports Qunipro internal |
| 337 | * clock gating. |
| 338 | */ |
| 339 | #define UFS_QCOM_CAP_QUNIPRO_CLK_GATING UFS_BIT(2) |
| 340 | |
| 341 | /* |
| 342 | * Set this capability if host controller supports SVS2 frequencies. |
| 343 | */ |
| 344 | #define UFS_QCOM_CAP_SVS2 UFS_BIT(3) |
Yaniv Gardi | cad2e03 | 2015-03-31 17:37:14 +0300 | [diff] [blame] | 345 | u32 caps; |
| 346 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 347 | struct phy *generic_phy; |
| 348 | struct ufs_hba *hba; |
| 349 | struct ufs_qcom_bus_vote bus_vote; |
| 350 | struct ufs_pa_layer_attr dev_req_params; |
| 351 | struct clk *rx_l0_sync_clk; |
| 352 | struct clk *tx_l0_sync_clk; |
| 353 | struct clk *rx_l1_sync_clk; |
| 354 | struct clk *tx_l1_sync_clk; |
Yaniv Gardi | bfdbe8b | 2015-03-31 17:37:13 +0300 | [diff] [blame] | 355 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 356 | /* PM Quality-of-Service (QoS) data */ |
| 357 | struct ufs_qcom_pm_qos pm_qos; |
| 358 | |
| 359 | bool disable_lpm; |
| 360 | bool is_lane_clks_enabled; |
| 361 | bool sec_cfg_updated; |
| 362 | struct ufs_qcom_ice_data ice; |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 363 | void __iomem *dev_ref_clk_ctrl_mmio; |
| 364 | bool is_dev_ref_clk_enabled; |
Yaniv Gardi | bfdbe8b | 2015-03-31 17:37:13 +0300 | [diff] [blame] | 365 | struct ufs_hw_version hw_ver; |
Yaniv Gardi | f06fcc7 | 2015-10-28 13:15:51 +0200 | [diff] [blame] | 366 | u32 dev_ref_clk_en_mask; |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 367 | #ifdef CONFIG_DEBUG_FS |
| 368 | struct qcom_debugfs_files debugfs_files; |
| 369 | #endif |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 370 | /* Bitmask for enabling debug prints */ |
| 371 | u32 dbg_print_en; |
| 372 | struct ufs_qcom_testbus testbus; |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 373 | |
Subhash Jadavani | 9c80770 | 2017-04-01 00:35:51 -0700 | [diff] [blame] | 374 | spinlock_t ice_work_lock; |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 375 | struct work_struct ice_cfg_work; |
| 376 | struct request *req_pending; |
Subhash Jadavani | 9c80770 | 2017-04-01 00:35:51 -0700 | [diff] [blame] | 377 | struct ufs_vreg *vddp_ref_clk; |
Neeraj Soni | c692cb9 | 2018-04-18 17:20:22 +0530 | [diff] [blame] | 378 | bool work_pending; |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 379 | }; |
| 380 | |
Yaniv Gardi | eba5ed3 | 2016-03-10 17:37:21 +0200 | [diff] [blame] | 381 | static inline u32 |
| 382 | ufs_qcom_get_debug_reg_offset(struct ufs_qcom_host *host, u32 reg) |
| 383 | { |
| 384 | if (host->hw_ver.major <= 0x02) |
| 385 | return UFS_CNTLR_2_x_x_VEN_REGS_OFFSET(reg); |
| 386 | |
| 387 | return UFS_CNTLR_3_x_x_VEN_REGS_OFFSET(reg); |
| 388 | }; |
| 389 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 390 | #define ufs_qcom_is_link_off(hba) ufshcd_is_link_off(hba) |
| 391 | #define ufs_qcom_is_link_active(hba) ufshcd_is_link_active(hba) |
| 392 | #define ufs_qcom_is_link_hibern8(hba) ufshcd_is_link_hibern8(hba) |
| 393 | |
Sayali Lokhande | 6db5274 | 2017-10-04 11:56:14 +0530 | [diff] [blame] | 394 | bool ufs_qcom_testbus_cfg_is_ok(struct ufs_qcom_host *host, u8 select_major, |
| 395 | u8 select_minor); |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 396 | int ufs_qcom_testbus_config(struct ufs_qcom_host *host); |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 397 | void ufs_qcom_print_hw_debug_reg_all(struct ufs_hba *hba, void *priv, |
| 398 | void (*print_fn)(struct ufs_hba *hba, int offset, int num_regs, |
| 399 | char *str, void *priv)); |
Yaniv Gardi | 6e3fd44 | 2015-10-28 13:15:50 +0200 | [diff] [blame] | 400 | |
Yaniv Gardi | cad2e03 | 2015-03-31 17:37:14 +0300 | [diff] [blame] | 401 | static inline bool ufs_qcom_cap_qunipro(struct ufs_qcom_host *host) |
| 402 | { |
| 403 | if (host->caps & UFS_QCOM_CAP_QUNIPRO) |
| 404 | return true; |
| 405 | else |
| 406 | return false; |
| 407 | } |
| 408 | |
Subhash Jadavani | cce6fbc | 2016-08-11 11:35:26 -0700 | [diff] [blame] | 409 | static inline bool ufs_qcom_cap_qunipro_clk_gating(struct ufs_qcom_host *host) |
| 410 | { |
| 411 | return !!(host->caps & UFS_QCOM_CAP_QUNIPRO_CLK_GATING); |
| 412 | } |
| 413 | |
| 414 | static inline bool ufs_qcom_cap_svs2(struct ufs_qcom_host *host) |
| 415 | { |
| 416 | return !!(host->caps & UFS_QCOM_CAP_SVS2); |
| 417 | } |
| 418 | |
Yaniv Gardi | 81c0fc5 | 2015-01-15 16:32:37 +0200 | [diff] [blame] | 419 | #endif /* UFS_QCOM_H_ */ |