Lines Matching refs:hba
119 #define ufshcd_is_link_off(hba) ((hba)->uic_link_state == UIC_LINK_OFF_STATE) argument
120 #define ufshcd_is_link_active(hba) ((hba)->uic_link_state == \ argument
122 #define ufshcd_is_link_hibern8(hba) ((hba)->uic_link_state == \ argument
124 #define ufshcd_is_link_broken(hba) ((hba)->uic_link_state == \ argument
126 #define ufshcd_set_link_off(hba) ((hba)->uic_link_state = UIC_LINK_OFF_STATE) argument
127 #define ufshcd_set_link_active(hba) ((hba)->uic_link_state = \ argument
129 #define ufshcd_set_link_hibern8(hba) ((hba)->uic_link_state = \ argument
131 #define ufshcd_set_link_broken(hba) ((hba)->uic_link_state = \ argument
345 int (*apply_dev_quirks)(struct ufs_hba *hba);
346 void (*fixup_dev_quirks)(struct ufs_hba *hba);
350 void (*dbg_register_dump)(struct ufs_hba *hba);
352 int (*device_reset)(struct ufs_hba *hba);
353 void (*config_scaling_param)(struct ufs_hba *hba,
356 int (*program_key)(struct ufs_hba *hba,
358 void (*event_notify)(struct ufs_hba *hba,
946 static inline bool ufshcd_is_clkgating_allowed(struct ufs_hba *hba) in ufshcd_is_clkgating_allowed() argument
948 return hba->caps & UFSHCD_CAP_CLK_GATING; in ufshcd_is_clkgating_allowed()
950 static inline bool ufshcd_can_hibern8_during_gating(struct ufs_hba *hba) in ufshcd_can_hibern8_during_gating() argument
952 return hba->caps & UFSHCD_CAP_HIBERN8_WITH_CLK_GATING; in ufshcd_can_hibern8_during_gating()
954 static inline int ufshcd_is_clkscaling_supported(struct ufs_hba *hba) in ufshcd_is_clkscaling_supported() argument
956 return hba->caps & UFSHCD_CAP_CLK_SCALING; in ufshcd_is_clkscaling_supported()
958 static inline bool ufshcd_can_autobkops_during_suspend(struct ufs_hba *hba) in ufshcd_can_autobkops_during_suspend() argument
960 return hba->caps & UFSHCD_CAP_AUTO_BKOPS_SUSPEND; in ufshcd_can_autobkops_during_suspend()
962 static inline bool ufshcd_is_rpm_autosuspend_allowed(struct ufs_hba *hba) in ufshcd_is_rpm_autosuspend_allowed() argument
964 return hba->caps & UFSHCD_CAP_RPM_AUTOSUSPEND; in ufshcd_is_rpm_autosuspend_allowed()
967 static inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba) in ufshcd_is_intr_aggr_allowed() argument
969 return (hba->caps & UFSHCD_CAP_INTR_AGGR) && in ufshcd_is_intr_aggr_allowed()
970 !(hba->quirks & UFSHCD_QUIRK_BROKEN_INTR_AGGR); in ufshcd_is_intr_aggr_allowed()
973 static inline bool ufshcd_can_aggressive_pc(struct ufs_hba *hba) in ufshcd_can_aggressive_pc() argument
975 return !!(ufshcd_is_link_hibern8(hba) && in ufshcd_can_aggressive_pc()
976 (hba->caps & UFSHCD_CAP_AGGR_POWER_COLLAPSE)); in ufshcd_can_aggressive_pc()
979 static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) in ufshcd_is_auto_hibern8_supported() argument
981 return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) && in ufshcd_is_auto_hibern8_supported()
982 !(hba->quirks & UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8); in ufshcd_is_auto_hibern8_supported()
985 static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba) in ufshcd_is_auto_hibern8_enabled() argument
987 return FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit) ? true : false; in ufshcd_is_auto_hibern8_enabled()
990 static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba) in ufshcd_is_wb_allowed() argument
992 return hba->caps & UFSHCD_CAP_WB_EN; in ufshcd_is_wb_allowed()
995 static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba) in ufshcd_is_user_access_allowed() argument
997 return !hba->shutting_down; in ufshcd_is_user_access_allowed()
1000 #define ufshcd_writel(hba, val, reg) \ argument
1001 writel((val), (hba)->mmio_base + (reg))
1002 #define ufshcd_readl(hba, reg) \ argument
1003 readl((hba)->mmio_base + (reg))
1012 static inline void ufshcd_rmwl(struct ufs_hba *hba, u32 mask, u32 val, u32 reg) in ufshcd_rmwl() argument
1016 tmp = ufshcd_readl(hba, reg); in ufshcd_rmwl()
1019 ufshcd_writel(hba, tmp, reg); in ufshcd_rmwl()
1024 int ufshcd_hba_enable(struct ufs_hba *hba);
1026 int ufshcd_link_recovery(struct ufs_hba *hba);
1027 int ufshcd_make_hba_operational(struct ufs_hba *hba);
1029 int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
1030 int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
1032 int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
1035 void ufshcd_parse_dev_ref_clk_freq(struct ufs_hba *hba, struct clk *refclk);
1036 void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);
1037 void ufshcd_hba_stop(struct ufs_hba *hba);
1038 void ufshcd_schedule_eh_work(struct ufs_hba *hba);
1051 static inline void ufshcd_set_variant(struct ufs_hba *hba, void *variant) in ufshcd_set_variant() argument
1053 BUG_ON(!hba); in ufshcd_set_variant()
1054 hba->priv = variant; in ufshcd_set_variant()
1061 static inline void *ufshcd_get_variant(struct ufs_hba *hba) in ufshcd_get_variant() argument
1063 BUG_ON(!hba); in ufshcd_get_variant()
1064 return hba->priv; in ufshcd_get_variant()
1067 struct ufs_hba *hba) in ufshcd_keep_autobkops_enabled_except_suspend() argument
1069 return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND; in ufshcd_keep_autobkops_enabled_except_suspend()
1072 static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) in ufshcd_wb_get_query_index() argument
1074 if (hba->dev_info.wb_buffer_type == WB_BUF_MODE_LU_DEDICATED) in ufshcd_wb_get_query_index()
1075 return hba->dev_info.wb_dedicated_lu; in ufshcd_wb_get_query_index()
1080 void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
1081 void ufs_hwmon_remove(struct ufs_hba *hba);
1082 void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
1084 static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} in ufs_hwmon_probe() argument
1085 static inline void ufs_hwmon_remove(struct ufs_hba *hba) {} in ufs_hwmon_remove() argument
1086 static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} in ufs_hwmon_notify_event() argument
1097 extern int ufshcd_shutdown(struct ufs_hba *hba);
1098 extern int ufshcd_dme_configure_adapt(struct ufs_hba *hba,
1101 extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
1103 extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
1105 extern int ufshcd_config_pwr_mode(struct ufs_hba *hba,
1114 static inline int ufshcd_dme_set(struct ufs_hba *hba, u32 attr_sel, in ufshcd_dme_set() argument
1117 return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, in ufshcd_dme_set()
1121 static inline int ufshcd_dme_st_set(struct ufs_hba *hba, u32 attr_sel, in ufshcd_dme_st_set() argument
1124 return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, in ufshcd_dme_st_set()
1128 static inline int ufshcd_dme_peer_set(struct ufs_hba *hba, u32 attr_sel, in ufshcd_dme_peer_set() argument
1131 return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR, in ufshcd_dme_peer_set()
1135 static inline int ufshcd_dme_peer_st_set(struct ufs_hba *hba, u32 attr_sel, in ufshcd_dme_peer_st_set() argument
1138 return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST, in ufshcd_dme_peer_st_set()
1142 static inline int ufshcd_dme_get(struct ufs_hba *hba, in ufshcd_dme_get() argument
1145 return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL); in ufshcd_dme_get()
1148 static inline int ufshcd_dme_peer_get(struct ufs_hba *hba, in ufshcd_dme_peer_get() argument
1151 return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_PEER); in ufshcd_dme_peer_get()
1162 static inline int ufshcd_disable_host_tx_lcc(struct ufs_hba *hba) in ufshcd_disable_host_tx_lcc() argument
1164 return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0); in ufshcd_disable_host_tx_lcc()
1168 int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
1173 int ufshcd_read_desc_param(struct ufs_hba *hba,
1179 int ufshcd_query_attr_retry(struct ufs_hba *hba, enum query_opcode opcode,
1182 int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
1184 int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
1187 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
1188 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
1189 void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups);
1192 int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
1195 int ufshcd_hold(struct ufs_hba *hba, bool async);
1196 void ufshcd_release(struct ufs_hba *hba);
1198 void ufshcd_map_desc_id_to_length(struct ufs_hba *hba, enum desc_idn desc_id,
1201 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba);
1203 int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
1205 int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
1212 int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
1217 static inline const char *ufshcd_get_var_name(struct ufs_hba *hba) in ufshcd_get_var_name() argument
1219 if (hba->vops) in ufshcd_get_var_name()
1220 return hba->vops->name; in ufshcd_get_var_name()
1224 static inline int ufshcd_vops_init(struct ufs_hba *hba) in ufshcd_vops_init() argument
1226 if (hba->vops && hba->vops->init) in ufshcd_vops_init()
1227 return hba->vops->init(hba); in ufshcd_vops_init()
1232 static inline void ufshcd_vops_exit(struct ufs_hba *hba) in ufshcd_vops_exit() argument
1234 if (hba->vops && hba->vops->exit) in ufshcd_vops_exit()
1235 return hba->vops->exit(hba); in ufshcd_vops_exit()
1238 static inline u32 ufshcd_vops_get_ufs_hci_version(struct ufs_hba *hba) in ufshcd_vops_get_ufs_hci_version() argument
1240 if (hba->vops && hba->vops->get_ufs_hci_version) in ufshcd_vops_get_ufs_hci_version()
1241 return hba->vops->get_ufs_hci_version(hba); in ufshcd_vops_get_ufs_hci_version()
1243 return ufshcd_readl(hba, REG_UFS_VERSION); in ufshcd_vops_get_ufs_hci_version()
1246 static inline int ufshcd_vops_clk_scale_notify(struct ufs_hba *hba, in ufshcd_vops_clk_scale_notify() argument
1249 if (hba->vops && hba->vops->clk_scale_notify) in ufshcd_vops_clk_scale_notify()
1250 return hba->vops->clk_scale_notify(hba, up, status); in ufshcd_vops_clk_scale_notify()
1254 static inline void ufshcd_vops_event_notify(struct ufs_hba *hba, in ufshcd_vops_event_notify() argument
1258 if (hba->vops && hba->vops->event_notify) in ufshcd_vops_event_notify()
1259 hba->vops->event_notify(hba, evt, data); in ufshcd_vops_event_notify()
1262 static inline int ufshcd_vops_setup_clocks(struct ufs_hba *hba, bool on, in ufshcd_vops_setup_clocks() argument
1265 if (hba->vops && hba->vops->setup_clocks) in ufshcd_vops_setup_clocks()
1266 return hba->vops->setup_clocks(hba, on, status); in ufshcd_vops_setup_clocks()
1270 static inline int ufshcd_vops_hce_enable_notify(struct ufs_hba *hba, in ufshcd_vops_hce_enable_notify() argument
1273 if (hba->vops && hba->vops->hce_enable_notify) in ufshcd_vops_hce_enable_notify()
1274 return hba->vops->hce_enable_notify(hba, status); in ufshcd_vops_hce_enable_notify()
1278 static inline int ufshcd_vops_link_startup_notify(struct ufs_hba *hba, in ufshcd_vops_link_startup_notify() argument
1281 if (hba->vops && hba->vops->link_startup_notify) in ufshcd_vops_link_startup_notify()
1282 return hba->vops->link_startup_notify(hba, status); in ufshcd_vops_link_startup_notify()
1287 static inline int ufshcd_vops_phy_initialization(struct ufs_hba *hba) in ufshcd_vops_phy_initialization() argument
1289 if (hba->vops && hba->vops->phy_initialization) in ufshcd_vops_phy_initialization()
1290 return hba->vops->phy_initialization(hba); in ufshcd_vops_phy_initialization()
1295 static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, in ufshcd_vops_pwr_change_notify() argument
1300 if (hba->vops && hba->vops->pwr_change_notify) in ufshcd_vops_pwr_change_notify()
1301 return hba->vops->pwr_change_notify(hba, status, in ufshcd_vops_pwr_change_notify()
1307 static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba, in ufshcd_vops_setup_task_mgmt() argument
1310 if (hba->vops && hba->vops->setup_task_mgmt) in ufshcd_vops_setup_task_mgmt()
1311 return hba->vops->setup_task_mgmt(hba, tag, tm_function); in ufshcd_vops_setup_task_mgmt()
1314 static inline void ufshcd_vops_hibern8_notify(struct ufs_hba *hba, in ufshcd_vops_hibern8_notify() argument
1318 if (hba->vops && hba->vops->hibern8_notify) in ufshcd_vops_hibern8_notify()
1319 return hba->vops->hibern8_notify(hba, cmd, status); in ufshcd_vops_hibern8_notify()
1322 static inline int ufshcd_vops_apply_dev_quirks(struct ufs_hba *hba) in ufshcd_vops_apply_dev_quirks() argument
1324 if (hba->vops && hba->vops->apply_dev_quirks) in ufshcd_vops_apply_dev_quirks()
1325 return hba->vops->apply_dev_quirks(hba); in ufshcd_vops_apply_dev_quirks()
1329 static inline void ufshcd_vops_fixup_dev_quirks(struct ufs_hba *hba) in ufshcd_vops_fixup_dev_quirks() argument
1331 if (hba->vops && hba->vops->fixup_dev_quirks) in ufshcd_vops_fixup_dev_quirks()
1332 hba->vops->fixup_dev_quirks(hba); in ufshcd_vops_fixup_dev_quirks()
1335 static inline int ufshcd_vops_suspend(struct ufs_hba *hba, enum ufs_pm_op op, in ufshcd_vops_suspend() argument
1338 if (hba->vops && hba->vops->suspend) in ufshcd_vops_suspend()
1339 return hba->vops->suspend(hba, op, status); in ufshcd_vops_suspend()
1344 static inline int ufshcd_vops_resume(struct ufs_hba *hba, enum ufs_pm_op op) in ufshcd_vops_resume() argument
1346 if (hba->vops && hba->vops->resume) in ufshcd_vops_resume()
1347 return hba->vops->resume(hba, op); in ufshcd_vops_resume()
1352 static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba) in ufshcd_vops_dbg_register_dump() argument
1354 if (hba->vops && hba->vops->dbg_register_dump) in ufshcd_vops_dbg_register_dump()
1355 hba->vops->dbg_register_dump(hba); in ufshcd_vops_dbg_register_dump()
1358 static inline int ufshcd_vops_device_reset(struct ufs_hba *hba) in ufshcd_vops_device_reset() argument
1360 if (hba->vops && hba->vops->device_reset) in ufshcd_vops_device_reset()
1361 return hba->vops->device_reset(hba); in ufshcd_vops_device_reset()
1366 static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, in ufshcd_vops_config_scaling_param() argument
1370 if (hba->vops && hba->vops->config_scaling_param) in ufshcd_vops_config_scaling_param()
1371 hba->vops->config_scaling_param(hba, profile, data); in ufshcd_vops_config_scaling_param()
1391 int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
1394 int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask);
1395 int ufshcd_write_ee_control(struct ufs_hba *hba);
1396 int ufshcd_update_ee_control(struct ufs_hba *hba, u16 *mask, u16 *other_mask,
1399 static inline int ufshcd_update_ee_drv_mask(struct ufs_hba *hba, in ufshcd_update_ee_drv_mask() argument
1402 return ufshcd_update_ee_control(hba, &hba->ee_drv_mask, in ufshcd_update_ee_drv_mask()
1403 &hba->ee_usr_mask, set, clr); in ufshcd_update_ee_drv_mask()
1406 static inline int ufshcd_update_ee_usr_mask(struct ufs_hba *hba, in ufshcd_update_ee_usr_mask() argument
1409 return ufshcd_update_ee_control(hba, &hba->ee_usr_mask, in ufshcd_update_ee_usr_mask()
1410 &hba->ee_drv_mask, set, clr); in ufshcd_update_ee_usr_mask()
1413 static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba) in ufshcd_rpm_get_sync() argument
1415 return pm_runtime_get_sync(&hba->sdev_ufs_device->sdev_gendev); in ufshcd_rpm_get_sync()
1418 static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) in ufshcd_rpm_put_sync() argument
1420 return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev); in ufshcd_rpm_put_sync()
1423 static inline int ufshcd_rpm_put(struct ufs_hba *hba) in ufshcd_rpm_put() argument
1425 return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev); in ufshcd_rpm_put()