Lines Matching refs:ipc_pm
18 void ipc_pm_signal_hpda_doorbell(struct iosm_pm *ipc_pm, u32 identifier, in ipc_pm_signal_hpda_doorbell() argument
21 if (host_slp_check && ipc_pm->host_pm_state != IPC_MEM_HOST_PM_ACTIVE && in ipc_pm_signal_hpda_doorbell()
22 ipc_pm->host_pm_state != IPC_MEM_HOST_PM_ACTIVE_WAIT) { in ipc_pm_signal_hpda_doorbell()
23 ipc_pm->pending_hpda_update = true; in ipc_pm_signal_hpda_doorbell()
24 dev_dbg(ipc_pm->dev, in ipc_pm_signal_hpda_doorbell()
26 ipc_pm->host_pm_state, identifier); in ipc_pm_signal_hpda_doorbell()
30 if (!ipc_pm_trigger(ipc_pm, IPC_PM_UNIT_IRQ, true)) { in ipc_pm_signal_hpda_doorbell()
31 ipc_pm->pending_hpda_update = true; in ipc_pm_signal_hpda_doorbell()
32 dev_dbg(ipc_pm->dev, "Pending HPDA update set. identifier:%d", in ipc_pm_signal_hpda_doorbell()
36 ipc_pm->pending_hpda_update = false; in ipc_pm_signal_hpda_doorbell()
39 ipc_cp_irq_hpda_update(ipc_pm->pcie, identifier); in ipc_pm_signal_hpda_doorbell()
41 ipc_pm_trigger(ipc_pm, IPC_PM_UNIT_IRQ, false); in ipc_pm_signal_hpda_doorbell()
45 static bool ipc_pm_link_activate(struct iosm_pm *ipc_pm) in ipc_pm_link_activate() argument
47 if (ipc_pm->cp_state == IPC_MEM_DEV_PM_ACTIVE) in ipc_pm_link_activate()
50 if (ipc_pm->cp_state == IPC_MEM_DEV_PM_SLEEP) { in ipc_pm_link_activate()
51 if (ipc_pm->ap_state == IPC_MEM_DEV_PM_SLEEP) { in ipc_pm_link_activate()
53 ipc_cp_irq_sleep_control(ipc_pm->pcie, in ipc_pm_link_activate()
55 ipc_pm->ap_state = IPC_MEM_DEV_PM_ACTIVE_WAIT; in ipc_pm_link_activate()
60 if (ipc_pm->ap_state == IPC_MEM_DEV_PM_ACTIVE_WAIT) in ipc_pm_link_activate()
71 bool ipc_pm_wait_for_device_active(struct iosm_pm *ipc_pm) in ipc_pm_wait_for_device_active() argument
75 if (ipc_pm->ap_state != IPC_MEM_DEV_PM_ACTIVE) { in ipc_pm_wait_for_device_active()
82 set_bit(0, &ipc_pm->host_sleep_pend); in ipc_pm_wait_for_device_active()
88 (&ipc_pm->host_sleep_complete, in ipc_pm_wait_for_device_active()
90 dev_err(ipc_pm->dev, in ipc_pm_wait_for_device_active()
92 IPC_MEM_DEV_PM_ACTIVE, ipc_pm->ap_state); in ipc_pm_wait_for_device_active()
105 clear_bit(0, &ipc_pm->host_sleep_pend); in ipc_pm_wait_for_device_active()
113 static void ipc_pm_on_link_sleep(struct iosm_pm *ipc_pm) in ipc_pm_on_link_sleep() argument
118 ipc_pm->cp_state = IPC_MEM_DEV_PM_SLEEP; in ipc_pm_on_link_sleep()
119 ipc_pm->ap_state = IPC_MEM_DEV_PM_SLEEP; in ipc_pm_on_link_sleep()
121 ipc_cp_irq_sleep_control(ipc_pm->pcie, IPC_MEM_DEV_PM_SLEEP); in ipc_pm_on_link_sleep()
124 static void ipc_pm_on_link_wake(struct iosm_pm *ipc_pm, bool ack) in ipc_pm_on_link_wake() argument
126 ipc_pm->ap_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_on_link_wake()
129 ipc_pm->cp_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_on_link_wake()
131 ipc_cp_irq_sleep_control(ipc_pm->pcie, IPC_MEM_DEV_PM_ACTIVE); in ipc_pm_on_link_wake()
134 if (test_bit(CONSUME_STATE, &ipc_pm->host_sleep_pend)) in ipc_pm_on_link_wake()
135 complete(&ipc_pm->host_sleep_complete); in ipc_pm_on_link_wake()
144 if (ipc_pm->pending_hpda_update && in ipc_pm_on_link_wake()
145 ipc_pm->host_pm_state == IPC_MEM_HOST_PM_ACTIVE) in ipc_pm_on_link_wake()
146 ipc_pm_signal_hpda_doorbell(ipc_pm, IPC_HP_PM_TRIGGER, true); in ipc_pm_on_link_wake()
149 bool ipc_pm_trigger(struct iosm_pm *ipc_pm, enum ipc_pm_unit unit, bool active) in ipc_pm_trigger() argument
156 new_cond = ipc_pm->pm_cond; in ipc_pm_trigger()
157 old_cond = ipc_pm->pm_cond; in ipc_pm_trigger()
184 ipc_pm->pm_cond = new_cond; in ipc_pm_trigger()
187 ipc_pm_on_link_wake(ipc_pm, unit == IPC_PM_UNIT_LINK); in ipc_pm_trigger()
189 ipc_pm_on_link_sleep(ipc_pm); in ipc_pm_trigger()
192 link_active = ipc_pm_link_activate(ipc_pm); in ipc_pm_trigger()
202 bool ipc_pm_prepare_host_sleep(struct iosm_pm *ipc_pm) in ipc_pm_prepare_host_sleep() argument
205 if (ipc_pm->host_pm_state != IPC_MEM_HOST_PM_ACTIVE) { in ipc_pm_prepare_host_sleep()
206 dev_err(ipc_pm->dev, "host_pm_state=%d\tExpected to be: %d", in ipc_pm_prepare_host_sleep()
207 ipc_pm->host_pm_state, IPC_MEM_HOST_PM_ACTIVE); in ipc_pm_prepare_host_sleep()
211 ipc_pm->host_pm_state = IPC_MEM_HOST_PM_SLEEP_WAIT_D3; in ipc_pm_prepare_host_sleep()
216 bool ipc_pm_prepare_host_active(struct iosm_pm *ipc_pm) in ipc_pm_prepare_host_active() argument
218 if (ipc_pm->host_pm_state != IPC_MEM_HOST_PM_SLEEP) { in ipc_pm_prepare_host_active()
219 dev_err(ipc_pm->dev, "host_pm_state=%d\tExpected to be: %d", in ipc_pm_prepare_host_active()
220 ipc_pm->host_pm_state, IPC_MEM_HOST_PM_SLEEP); in ipc_pm_prepare_host_active()
225 ipc_pm->host_pm_state = IPC_MEM_HOST_PM_ACTIVE_WAIT; in ipc_pm_prepare_host_active()
230 void ipc_pm_set_s2idle_sleep(struct iosm_pm *ipc_pm, bool sleep) in ipc_pm_set_s2idle_sleep() argument
233 ipc_pm->ap_state = IPC_MEM_DEV_PM_SLEEP; in ipc_pm_set_s2idle_sleep()
234 ipc_pm->cp_state = IPC_MEM_DEV_PM_SLEEP; in ipc_pm_set_s2idle_sleep()
235 ipc_pm->device_sleep_notification = IPC_MEM_DEV_PM_SLEEP; in ipc_pm_set_s2idle_sleep()
237 ipc_pm->ap_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_set_s2idle_sleep()
238 ipc_pm->cp_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_set_s2idle_sleep()
239 ipc_pm->device_sleep_notification = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_set_s2idle_sleep()
240 ipc_pm->pm_cond.link = IPC_PM_ACTIVE; in ipc_pm_set_s2idle_sleep()
244 bool ipc_pm_dev_slp_notification(struct iosm_pm *ipc_pm, u32 cp_pm_req) in ipc_pm_dev_slp_notification() argument
246 if (cp_pm_req == ipc_pm->device_sleep_notification) in ipc_pm_dev_slp_notification()
249 ipc_pm->device_sleep_notification = cp_pm_req; in ipc_pm_dev_slp_notification()
252 switch (ipc_pm->cp_state) { in ipc_pm_dev_slp_notification()
260 ipc_pm_trigger(ipc_pm, IPC_PM_UNIT_LINK, false); in ipc_pm_dev_slp_notification()
264 dev_err(ipc_pm->dev, in ipc_pm_dev_slp_notification()
266 ipc_pm->cp_state, cp_pm_req); in ipc_pm_dev_slp_notification()
275 ipc_pm_trigger(ipc_pm, IPC_PM_UNIT_LINK, true); in ipc_pm_dev_slp_notification()
282 dev_err(ipc_pm->dev, in ipc_pm_dev_slp_notification()
284 ipc_pm->cp_state, cp_pm_req); in ipc_pm_dev_slp_notification()
290 dev_err(ipc_pm->dev, "confused loc-pm=%d, req-pm=%d", in ipc_pm_dev_slp_notification()
291 ipc_pm->cp_state, cp_pm_req); in ipc_pm_dev_slp_notification()
301 struct iosm_pm *ipc_pm = &ipc_protocol->pm; in ipc_pm_init() local
303 ipc_pm->pcie = ipc_imem->pcie; in ipc_pm_init()
304 ipc_pm->dev = ipc_imem->dev; in ipc_pm_init()
306 ipc_pm->pm_cond.irq = IPC_PM_SLEEP; in ipc_pm_init()
307 ipc_pm->pm_cond.hs = IPC_PM_SLEEP; in ipc_pm_init()
308 ipc_pm->pm_cond.link = IPC_PM_ACTIVE; in ipc_pm_init()
310 ipc_pm->cp_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_init()
311 ipc_pm->ap_state = IPC_MEM_DEV_PM_ACTIVE; in ipc_pm_init()
312 ipc_pm->host_pm_state = IPC_MEM_HOST_PM_ACTIVE; in ipc_pm_init()
317 init_completion(&ipc_pm->host_sleep_complete); in ipc_pm_init()
322 clear_bit(0, &ipc_pm->host_sleep_pend); in ipc_pm_init()
330 struct iosm_pm *ipc_pm = &proto->pm; in ipc_pm_deinit() local
332 complete(&ipc_pm->host_sleep_complete); in ipc_pm_deinit()