drm/meson: add resume/suspend hooks
cover drm/meson: add resume/suspend hooks
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
Neil Armstrong (2):
drm/meson: dw_hdmi: add resume/suspend hooks
drm/meson: add resume/suspend hooks
drivers/gpu/drm/meson/meson_drv.c | 32 ++++++++ drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++-------- 2 files changed, 108 insertions(+), 34 deletions(-)
Signature · 1 line
2.22.0
PATCH 1/2 drm/meson: dw_hdmi: add resume/suspend hooks
Add the suspens and resume hooks to:
- reset the whole HDMI glue and HDMI controller on suspend
- re-init the HDMI glue and HDMI controller on resume
The HDMI glue init is refactored to be re-used from the resume hook.
It makes usage of dw_hdmi_resume() to recover a functionnal DDC bus.
--- drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++-------- 1 file changed, 76 insertions(+), 34 deletions(-)
drivers/gpu/drm/meson/meson_dw_hdmi.c +76 -34
@@ -799,6 +799,47 @@ static bool meson_hdmi_connector_is_available(struct device *dev)return false; } +static void meson_dw_hdmi_init (struct meson_dw_hdmi *meson_dw_hdmi) +{ +struct meson_drm *priv = meson_dw_hdmi->priv; + +/* Enable clocks */ +regmap_update_bits (priv->hhi,HHI_HDMI_CLK_CNTL ,0xffff ,0x100 ); + +/* Bring HDMITX MEM output of power down */ +regmap_update_bits (priv->hhi,HHI_MEM_PD_REG0 ,0xff <<8 ,0 ); + +/* Reset HDMITX APB & TX & PHY */ +reset_control_reset (meson_dw_hdmi->hdmitx_apb); +reset_control_reset (meson_dw_hdmi->hdmitx_ctrl); +reset_control_reset (meson_dw_hdmi->hdmitx_phy); + +/* Enable APB3 fail on error */ +if (!meson_vpu_is_compatible (priv,"amlogic,meson-g12a-vpu" )) { +writel_bits_relaxed (BIT (15 ),BIT (15 ), + meson_dw_hdmi->hdmitx +HDMITX_TOP_CTRL_REG ); +writel_bits_relaxed (BIT (15 ),BIT (15 ), + meson_dw_hdmi->hdmitx +HDMITX_DWC_CTRL_REG ); + } + +/* Bring out of reset */ + meson_dw_hdmi->data->top_write (meson_dw_hdmi, +HDMITX_TOP_SW_RESET ,0 ); + +msleep (20 ); + + meson_dw_hdmi->data->top_write (meson_dw_hdmi, +HDMITX_TOP_CLK_CNTL ,0xff ); + +/* Enable HDMI-TX Interrupt */ + meson_dw_hdmi->data->top_write (meson_dw_hdmi,HDMITX_TOP_INTR_STAT_CLR , +HDMITX_TOP_INTR_CORE ); + + meson_dw_hdmi->data->top_write (meson_dw_hdmi,HDMITX_TOP_INTR_MASKN , +HDMITX_TOP_INTR_CORE ); + +} +static int meson_dw_hdmi_bind (struct device *dev,struct device *master,void *data) {
@@ -922,40 +963,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master,DRM_DEBUG_DRIVER ("encoder initialized\n" ); -/* Enable clocks */ -regmap_update_bits (priv->hhi,HHI_HDMI_CLK_CNTL ,0xffff ,0x100 ); - -/* Bring HDMITX MEM output of power down */ -regmap_update_bits (priv->hhi,HHI_MEM_PD_REG0 ,0xff <<8 ,0 ); - -/* Reset HDMITX APB & TX & PHY */ -reset_control_reset (meson_dw_hdmi->hdmitx_apb); -reset_control_reset (meson_dw_hdmi->hdmitx_ctrl); -reset_control_reset (meson_dw_hdmi->hdmitx_phy); - -/* Enable APB3 fail on error */ -if (!meson_vpu_is_compatible (priv,"amlogic,meson-g12a-vpu" )) { -writel_bits_relaxed (BIT (15 ),BIT (15 ), - meson_dw_hdmi->hdmitx +HDMITX_TOP_CTRL_REG ); -writel_bits_relaxed (BIT (15 ),BIT (15 ), - meson_dw_hdmi->hdmitx +HDMITX_DWC_CTRL_REG ); - } - -/* Bring out of reset */ - meson_dw_hdmi->data->top_write (meson_dw_hdmi, -HDMITX_TOP_SW_RESET ,0 ); - -msleep (20 ); - - meson_dw_hdmi->data->top_write (meson_dw_hdmi, -HDMITX_TOP_CLK_CNTL ,0xff ); - -/* Enable HDMI-TX Interrupt */ - meson_dw_hdmi->data->top_write (meson_dw_hdmi,HDMITX_TOP_INTR_STAT_CLR , -HDMITX_TOP_INTR_CORE ); - - meson_dw_hdmi->data->top_write (meson_dw_hdmi,HDMITX_TOP_INTR_MASKN , -HDMITX_TOP_INTR_CORE ); +meson_dw_hdmi_init (meson_dw_hdmi);/* Bridge / Connector */
@@ -991,6 +999,34 @@ static const struct component_ops meson_dw_hdmi_ops = { .unbind = meson_dw_hdmi_unbind, }; +static int __maybe_unused meson_dw_hdmi_pm_suspend (struct device *dev) +{ +struct meson_dw_hdmi *meson_dw_hdmi =dev_get_drvdata (dev); + +if (!meson_dw_hdmi) +return 0 ; + +/* Reset TOP */ + meson_dw_hdmi->data->top_write (meson_dw_hdmi, +HDMITX_TOP_SW_RESET ,0 ); + +return 0 ; +} + +static int __maybe_unused meson_dw_hdmi_pm_resume (struct device *dev) +{ +struct meson_dw_hdmi *meson_dw_hdmi =dev_get_drvdata (dev); + +if (!meson_dw_hdmi) +return 0 ; + +meson_dw_hdmi_init (meson_dw_hdmi); + +dw_hdmi_resume (meson_dw_hdmi->hdmi); + +return 0 ; +} +static int meson_dw_hdmi_probe (struct platform_device *pdev) {return component_add (&pdev->dev, &meson_dw_hdmi_ops);
@@ -1003,6 +1039,11 @@ static int meson_dw_hdmi_remove(struct platform_device *pdev)return 0 ; } +static const struct dev_pm_ops meson_dw_hdmi_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (meson_dw_hdmi_pm_suspend, + meson_dw_hdmi_pm_resume) +}; +static const struct of_device_id meson_dw_hdmi_of_table[] = { { .compatible ="amlogic,meson-gxbb-dw-hdmi" , .data = &meson_dw_hdmi_gx_data },
@@ -1022,6 +1063,7 @@ static struct platform_driver meson_dw_hdmi_platform_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = meson_dw_hdmi_of_table, + .pm = &meson_dw_hdmi_pm_ops, }, };module_platform_driver (meson_dw_hdmi_platform_driver);
Signature · 1 line
2.22.0
PATCH 2/2 drm/meson: add resume/suspend hooks
In reply to Neil ArmstrongAdd the suspend and resume hooks to:
- save and disable the entire DRM driver on suspend
- re-init the entire VPU subsystem on resume, to recover CRTC and pixel generator functionnal usage after DDR suspend, then recover DRM driver state
--- drivers/gpu/drm/meson/meson_drv.c | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/gpu/drm/meson/meson_drv.c +32 -0
@@ -361,6 +361,33 @@ static const struct component_master_ops meson_drv_master_ops = { .unbind = meson_drv_unbind, }; +static int __maybe_unused meson_drv_pm_suspend (struct device *dev) +{ +struct meson_drm *priv =dev_get_drvdata (dev); + +if (!priv) +return 0 ; + +return drm_mode_config_helper_suspend (priv->drm); +} + +static int __maybe_unused meson_drv_pm_resume (struct device *dev) +{ +struct meson_drm *priv =dev_get_drvdata (dev); + +if (!priv) +return 0 ; + +meson_vpu_init (priv); +meson_venc_init (priv); +meson_vpp_init (priv); +meson_viu_init (priv); + +drm_mode_config_helper_resume (priv->drm); + +return 0 ; +} +static int compare_of (struct device *dev,void *data) { DRM_DEBUG_DRIVER("Comparing of node %pOF with %pOF\n",
@@ -452,11 +479,16 @@ static const struct of_device_id dt_match[] = { };MODULE_DEVICE_TABLE (of, dt_match); +static const struct dev_pm_ops meson_drv_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (meson_drv_pm_suspend, meson_drv_pm_resume) +}; +static struct platform_driver meson_drm_platform_driver = { .probe = meson_drv_probe, .driver = { .name ="meson-drm" , .of_match_table = dt_match, + .pm = &meson_drv_pm_ops, }, };
Signature · 6 lines
2.22.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Neil Armstrong
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
No idea about the hw, but looks all neatly integrated into pm stuff, so on both patches:
Quoted 16 lines
Neil Armstrong (2):
drm/meson:dw_hdmi: add resume/suspend hooks
drm/meson: add resume/suspend hooksdrivers/gpu/drm/meson/meson_drv.c | 32 ++++++++ drivers/gpu/drm/meson/meson_dw_hdmi.c | 110 ++++++++++++++++++-------- 2 files changed, 108 insertions(+), 34 deletions(-)Signature · 6 lines
2.22.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Neil Armstrong
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
Tested on my G12A SEI510 board, and I verified that it fixes suspend/resume issues previously seen.
Kevin
Quoted 10 lines · Kevin Hilman
Quoted 7 lines · Neil Armstrong
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
Quoted 7 lines
Tested-by Kevin Hilman <[email protected]>Tested on my G12A SEI510 board, and I verified that it fixes suspend/resume issues previously seen.
Kevin
Thanks,
Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
s/suspens/suspend
Neil
Kevin Hilman
maintainerQuoted 16 lines · Neil Armstrong
Quoted 15 lines · Kevin Hilman
Quoted 7 lines · Neil Armstrong
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
Tested-by Kevin Hilman <[email protected]>Tested on my G12A SEI510 board, and I verified that it fixes suspend/resume issues previously seen.
Quoted 7 lines
Quoted 2 lines
Kevin
Thanks,
Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
s/suspens/suspend
Is there any chance of getting this in a a fix for v5.4 so we have a working suspend/resume in v5.4?
Thanks,
Kevin
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 21 lines · Kevin Hilman
Quoted 19 lines · Neil Armstrong
Quoted 17 lines · Kevin Hilman
Quoted 7 lines · Neil Armstrong
This serie adds the resume/suspend hooks in the Amlogic Meson VPU main driver and the DW-HDMI Glue driver to correctly save state and disable HW before suspend, and succesfully re-init the HW to recover functionnal display after resume.
This serie has been tested on Amlogic G12A based SEI510 board, using the newly accepted VRTC driver and the rtcwake utility.
Tested-by Kevin Hilman <[email protected]>Tested on my G12A SEI510 board, and I verified that it fixes suspend/resume issues previously seen.
Kevin
Quoted 7 lines
Quoted 4 lines
Thanks,
Applying to drm-misc-next (for v5.5), with a typo fix in the first patch commit log:
s/suspens/suspendIs there any chance of getting this in a a fix for v5.4 so we have a working suspend/resume in v5.4?
Nop, it's already applied to drm-misc-next and is already out of the window for 5.4 anyway.
Neil
Quoted 5 lines
Thanks,
Kevin