Lines Matching defs:rtwdev
13 static int rtw_ips_pwr_up(struct rtw_dev *rtwdev)
17 ret = rtw_core_start(rtwdev);
19 rtw_err(rtwdev, "leave idle state failed\n");
21 rtw_coex_ips_notify(rtwdev, COEX_IPS_LEAVE);
22 rtw_set_channel(rtwdev);
27 int rtw_enter_ips(struct rtw_dev *rtwdev)
29 if (!test_bit(RTW_FLAG_POWERON, rtwdev->flags))
32 rtw_coex_ips_notify(rtwdev, COEX_IPS_ENTER);
34 rtw_core_stop(rtwdev);
35 rtw_hci_link_ps(rtwdev, true);
42 struct rtw_dev *rtwdev = data;
46 rtw_vif_port_config(rtwdev, rtwvif, config);
49 int rtw_leave_ips(struct rtw_dev *rtwdev)
53 if (test_bit(RTW_FLAG_POWERON, rtwdev->flags))
56 rtw_hci_link_ps(rtwdev, false);
58 ret = rtw_ips_pwr_up(rtwdev);
60 rtw_err(rtwdev, "failed to leave ips state\n");
64 rtw_iterate_vifs(rtwdev, rtw_restore_port_cfg_iter, rtwdev);
69 void rtw_power_mode_change(struct rtw_dev *rtwdev, bool enter)
74 request = rtw_read8(rtwdev, rtwdev->hci.rpwm_addr);
75 confirm = rtw_read8(rtwdev, rtwdev->hci.cpwm_addr);
81 if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_PG)
87 if (rtw_fw_feature_check(&rtwdev->fw, FW_FEATURE_TX_WAKE))
90 rtw_write8(rtwdev, rtwdev->hci.rpwm_addr, request);
95 100, 15000, true, rtwdev,
96 rtwdev->hci.cpwm_addr);
107 rtw_fw_dump_dbg_info(rtwdev);
112 static void __rtw_leave_lps_deep(struct rtw_dev *rtwdev)
114 rtw_hci_deep_ps(rtwdev, false);
117 static int __rtw_fw_leave_lps_check_reg(struct rtw_dev *rtwdev)
134 if (rtw_read32_mask(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN) == 0)
142 static int __rtw_fw_leave_lps_check_c2h(struct rtw_dev *rtwdev)
144 if (wait_for_completion_timeout(&rtwdev->lps_leave_check,
150 static void rtw_fw_leave_lps_check(struct rtw_dev *rtwdev)
155 if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags))
156 fw = &rtwdev->wow_fw;
158 fw = &rtwdev->fw;
161 ret = __rtw_fw_leave_lps_check_c2h(rtwdev);
163 ret = __rtw_fw_leave_lps_check_reg(rtwdev);
166 rtw_write32_clr(rtwdev, REG_TCR, BIT_PWRMGT_HWDATA_EN);
167 rtw_warn(rtwdev, "firmware failed to leave lps state\n");
168 rtw_fw_dump_dbg_info(rtwdev);
172 static void rtw_fw_leave_lps_check_prepare(struct rtw_dev *rtwdev)
176 if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags))
177 fw = &rtwdev->wow_fw;
179 fw = &rtwdev->fw;
182 reinit_completion(&rtwdev->lps_leave_check);
185 static void rtw_leave_lps_core(struct rtw_dev *rtwdev)
187 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
194 rtw_hci_link_ps(rtwdev, false);
195 rtw_fw_leave_lps_check_prepare(rtwdev);
196 rtw_fw_set_pwr_mode(rtwdev);
197 rtw_fw_leave_lps_check(rtwdev);
199 clear_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags);
201 rtw_coex_lps_notify(rtwdev, COEX_LPS_DISABLE);
204 enum rtw_lps_deep_mode rtw_get_lps_deep_mode(struct rtw_dev *rtwdev)
206 if (test_bit(RTW_FLAG_WOWLAN, rtwdev->flags))
207 return rtwdev->lps_conf.wow_deep_mode;
209 return rtwdev->lps_conf.deep_mode;
212 static void __rtw_enter_lps_deep(struct rtw_dev *rtwdev)
214 if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_NONE)
217 if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) {
218 rtw_dbg(rtwdev, RTW_DBG_PS,
223 if (rtw_get_lps_deep_mode(rtwdev) == LPS_DEEP_MODE_PG)
224 rtw_fw_set_pg_info(rtwdev);
226 rtw_hci_deep_ps(rtwdev, true);
229 static void rtw_enter_lps_core(struct rtw_dev *rtwdev)
231 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
238 rtw_coex_lps_notify(rtwdev, COEX_LPS_ENABLE);
240 rtw_fw_set_pwr_mode(rtwdev);
241 rtw_hci_link_ps(rtwdev, true);
243 set_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags);
246 static void __rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id)
248 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
250 if (test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags))
256 rtw_enter_lps_core(rtwdev);
259 static void __rtw_leave_lps(struct rtw_dev *rtwdev)
261 struct rtw_lps_conf *conf = &rtwdev->lps_conf;
263 if (test_and_clear_bit(RTW_FLAG_LEISURE_PS_DEEP, rtwdev->flags)) {
264 rtw_dbg(rtwdev, RTW_DBG_PS,
266 __rtw_leave_lps_deep(rtwdev);
269 if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags))
274 rtw_leave_lps_core(rtwdev);
277 void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id)
279 lockdep_assert_held(&rtwdev->mutex);
281 if (rtwdev->coex.stat.wl_force_lps_ctrl)
284 __rtw_enter_lps(rtwdev, port_id);
285 __rtw_enter_lps_deep(rtwdev);
288 void rtw_leave_lps(struct rtw_dev *rtwdev)
290 lockdep_assert_held(&rtwdev->mutex);
292 __rtw_leave_lps_deep(rtwdev);
293 __rtw_leave_lps(rtwdev);
296 void rtw_leave_lps_deep(struct rtw_dev *rtwdev)
298 lockdep_assert_held(&rtwdev->mutex);
300 __rtw_leave_lps_deep(rtwdev);
304 struct rtw_dev *rtwdev;
329 void rtw_recalc_lps(struct rtw_dev *rtwdev, struct ieee80211_vif *new_vif)
331 struct rtw_vif_recalc_lps_iter_data data = { .rtwdev = rtwdev };
335 rtw_iterate_vifs(rtwdev, rtw_vif_recalc_lps_iter, &data);
338 rtwdev->ps_enabled = true;
340 rtwdev->ps_enabled = false;
341 rtw_leave_lps(rtwdev);