Lines Matching +full:autosuspend +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0
6 * by the DRM_PANEL_SIMPLE driver because its power sequencing is non-standard.
10 #include <linux/delay.h>
72 if (p->el3_was_on) in atana33xc20_suspend()
73 atana33xc20_wait(p->el_on3_off_time, 150); in atana33xc20_suspend()
75 drm_dp_dpcd_set_powered(p->aux, false); in atana33xc20_suspend()
76 ret = regulator_disable(p->supply); in atana33xc20_suspend()
79 p->powered_off_time = ktime_get_boottime(); in atana33xc20_suspend()
80 p->el3_was_on = false; in atana33xc20_suspend()
92 atana33xc20_wait(p->powered_off_time, 500); in atana33xc20_resume()
94 ret = regulator_enable(p->supply); in atana33xc20_resume()
97 drm_dp_dpcd_set_powered(p->aux, true); in atana33xc20_resume()
98 p->powered_on_time = ktime_get_boottime(); in atana33xc20_resume()
100 if (p->no_hpd) { in atana33xc20_resume()
105 if (p->hpd_gpio) { in atana33xc20_resume()
106 ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, in atana33xc20_resume()
116 } else if (p->aux->wait_hpd_asserted) { in atana33xc20_resume()
117 ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US); in atana33xc20_resume()
136 drm_dp_dpcd_set_powered(p->aux, false); in atana33xc20_resume()
137 regulator_disable(p->supply); in atana33xc20_resume()
146 /* Disabling when already disabled is a no-op */ in atana33xc20_disable()
147 if (!p->enabled) in atana33xc20_disable()
150 gpiod_set_value_cansleep(p->el_on3_gpio, 0); in atana33xc20_disable()
151 p->el_on3_off_time = ktime_get_boottime(); in atana33xc20_disable()
152 p->enabled = false; in atana33xc20_disable()
161 p->el3_was_on = true; in atana33xc20_disable()
176 /* Enabling when already enabled is a no-op */ in atana33xc20_enable()
177 if (p->enabled) in atana33xc20_enable()
186 * non-obvious. in atana33xc20_enable()
188 if (WARN_ON(p->el3_was_on)) in atana33xc20_enable()
189 return -EIO; in atana33xc20_enable()
195 atana33xc20_wait(p->powered_on_time, 400); in atana33xc20_enable()
197 gpiod_set_value_cansleep(p->el_on3_gpio, 1); in atana33xc20_enable()
198 p->enabled = true; in atana33xc20_enable()
208 /* Unpreparing when already unprepared is a no-op */ in atana33xc20_unprepare()
209 if (!p->prepared) in atana33xc20_unprepare()
213 * Purposely do a put_sync, don't use autosuspend. The panel's tcon in atana33xc20_unprepare()
217 * NOTE: we still want autosuspend for cases where we only turn on in atana33xc20_unprepare()
220 ret = pm_runtime_put_sync_suspend(panel->dev); in atana33xc20_unprepare()
223 p->prepared = false; in atana33xc20_unprepare()
233 /* Preparing when already prepared is a no-op */ in atana33xc20_prepare()
234 if (p->prepared) in atana33xc20_prepare()
237 ret = pm_runtime_get_sync(panel->dev); in atana33xc20_prepare()
239 pm_runtime_put_autosuspend(panel->dev); in atana33xc20_prepare()
242 p->prepared = true; in atana33xc20_prepare()
251 struct dp_aux_ep_device *aux_ep = to_dp_aux_ep_dev(panel->dev); in atana33xc20_get_modes()
254 pm_runtime_get_sync(panel->dev); in atana33xc20_get_modes()
256 if (!p->edid) in atana33xc20_get_modes()
257 p->edid = drm_get_edid(connector, &aux_ep->aux->ddc); in atana33xc20_get_modes()
258 num = drm_add_edid_modes(connector, p->edid); in atana33xc20_get_modes()
260 pm_runtime_mark_last_busy(panel->dev); in atana33xc20_get_modes()
261 pm_runtime_put_autosuspend(panel->dev); in atana33xc20_get_modes()
287 struct device *dev = &aux_ep->dev; in atana33xc20_probe()
292 return -ENOMEM; in atana33xc20_probe()
295 panel->aux = aux_ep->aux; in atana33xc20_probe()
297 panel->supply = devm_regulator_get(dev, "power"); in atana33xc20_probe()
298 if (IS_ERR(panel->supply)) in atana33xc20_probe()
299 return dev_err_probe(dev, PTR_ERR(panel->supply), in atana33xc20_probe()
302 panel->el_on3_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); in atana33xc20_probe()
303 if (IS_ERR(panel->el_on3_gpio)) in atana33xc20_probe()
304 return dev_err_probe(dev, PTR_ERR(panel->el_on3_gpio), in atana33xc20_probe()
307 panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); in atana33xc20_probe()
308 if (!panel->no_hpd) { in atana33xc20_probe()
309 panel->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); in atana33xc20_probe()
310 if (IS_ERR(panel->hpd_gpio)) in atana33xc20_probe()
311 return dev_err_probe(dev, PTR_ERR(panel->hpd_gpio), in atana33xc20_probe()
325 drm_panel_init(&panel->base, dev, &atana33xc20_funcs, DRM_MODE_CONNECTOR_eDP); in atana33xc20_probe()
328 ret = drm_panel_dp_aux_backlight(&panel->base, aux_ep->aux); in atana33xc20_probe()
335 drm_panel_add(&panel->base); in atana33xc20_probe()
342 struct device *dev = &aux_ep->dev; in atana33xc20_remove()
345 drm_panel_remove(&panel->base); in atana33xc20_remove()
346 drm_panel_disable(&panel->base); in atana33xc20_remove()
347 drm_panel_unprepare(&panel->base); in atana33xc20_remove()
349 kfree(panel->edid); in atana33xc20_remove()
354 struct device *dev = &aux_ep->dev; in atana33xc20_shutdown()
357 drm_panel_disable(&panel->base); in atana33xc20_shutdown()
358 drm_panel_unprepare(&panel->base); in atana33xc20_shutdown()