Skip to content

Commit

Permalink
MLK-25340-1: drm: imx: hdp: Added power off function
Browse files Browse the repository at this point in the history
The power off need to be handled for the remove case so the
clock enable counts are correct.

Signed-off-by: Oliver Brown <oliver.brown@nxp.com>
  • Loading branch information
nxpobrown committed Mar 29, 2021
1 parent b6181a1 commit e8a7398
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/imx/mhdp/cdns-mhdp-imx.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ int cdns_mhdp_firmware_init_imx8qm(struct cdns_mhdp_device *mhdp);
int cdns_mhdp_resume_imx8qm(struct cdns_mhdp_device *mhdp);
int cdns_mhdp_suspend_imx8qm(struct cdns_mhdp_device *mhdp);
int cdns_mhdp_power_on_imx8qm(struct cdns_mhdp_device *mhdp);
int cdns_mhdp_power_off_imx8qm(struct cdns_mhdp_device *mhdp);
int cdns_mhdp_power_on_ls1028a(struct cdns_mhdp_device *mhdp);
void cdns_mhdp_pclk_rate_ls1028a(struct cdns_mhdp_device *mhdp);
#endif /* CDNS_MHDP_IMX_H_ */
75 changes: 75 additions & 0 deletions drivers/gpu/drm/imx/mhdp/cdns-mhdp-imx8qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,65 @@ static int imx8qm_ipg_clk_enable(struct imx_mhdp_device *imx_mhdp)
return ret;
}

static int imx8qm_ipg_clk_disable(struct imx_mhdp_device *imx_mhdp)
{
int ret;
struct imx_hdp_clks *clks = &imx_mhdp->clks;
struct device *dev = imx_mhdp->mhdp.dev;

ret = clk_prepare_enable(clks->clk_i2s_bypass);
if (ret < 0) {
dev_err(dev, "%s, pre clk i2s bypass error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_i2s);
if (ret < 0) {
dev_err(dev, "%s, pre clk i2s error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_apb_ctrl);
if (ret < 0) {
dev_err(dev, "%s, pre clk apb ctrl error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_apb_csr);
if (ret < 0) {
dev_err(dev, "%s, pre clk apb csr error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_msi);
if (ret < 0) {
dev_err(dev, "%s, pre clk msierror\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_lis);
if (ret < 0) {
dev_err(dev, "%s, pre clk lis error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->lpcg_apb);
if (ret < 0) {
dev_err(dev, "%s, pre clk apb error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->clk_core);
if (ret < 0) {
dev_err(dev, "%s, pre clk core error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->clk_ipg);
if (ret < 0) {
dev_err(dev, "%s, pre clk_ipg error\n", __func__);
return ret;
}
ret = clk_prepare_enable(clks->dig_pll);
if (ret < 0) {
dev_err(dev, "%s, pre dig pll error\n", __func__);
return ret;
}
return ret;
}

static void imx8qm_ipg_clk_set_rate(struct imx_mhdp_device *imx_mhdp)
{
struct imx_hdp_clks *clks = &imx_mhdp->clks;
Expand Down Expand Up @@ -464,6 +523,7 @@ int cdns_mhdp_power_on_imx8qm(struct cdns_mhdp_device *mhdp)
{
struct imx_mhdp_device *imx_mhdp =
container_of(mhdp, struct imx_mhdp_device, mhdp);

/* Power on PM Domains */

imx8qm_attach_pm_domains(imx_mhdp);
Expand All @@ -487,6 +547,21 @@ int cdns_mhdp_power_on_imx8qm(struct cdns_mhdp_device *mhdp)
return 0;
}

int cdns_mhdp_power_off_imx8qm(struct cdns_mhdp_device *mhdp)
{
struct imx_mhdp_device *imx_mhdp =
container_of(mhdp, struct imx_mhdp_device, mhdp);

imx8qm_phy_reset(0);
imx8qm_pixel_clk_disable(imx_mhdp);
imx8qm_ipg_clk_disable(imx_mhdp);

/* Power off PM Domains */
imx8qm_detach_pm_domains(imx_mhdp);

return 0;
}

void cdns_mhdp_plat_init_imx8qm(struct cdns_mhdp_device *mhdp)
{
struct imx_mhdp_device *imx_mhdp =
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/imx/mhdp/cdns-mhdp-imxdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static struct cdns_plat_data imx8qm_hdmi_drv_data = {
.phy_set = cdns_hdmi_phy_set_imx8qm,
.phy_video_valid = cdns_hdmi_phy_video_valid_imx8qm,
.power_on = cdns_mhdp_power_on_imx8qm,
.power_off = cdns_mhdp_power_off_imx8qm,
.firmware_init = cdns_mhdp_firmware_init_imx8qm,
.resume = cdns_mhdp_resume_imx8qm,
.suspend = cdns_mhdp_suspend_imx8qm,
Expand All @@ -98,6 +99,7 @@ static struct cdns_plat_data imx8qm_dp_drv_data = {
.unbind = cdns_dp_unbind,
.phy_set = cdns_dp_phy_set_imx8qm,
.power_on = cdns_mhdp_power_on_imx8qm,
.power_off = cdns_mhdp_power_off_imx8qm,
.firmware_init = cdns_mhdp_firmware_init_imx8qm,
.resume = cdns_mhdp_resume_imx8qm,
.suspend = cdns_mhdp_suspend_imx8qm,
Expand Down

0 comments on commit e8a7398

Please sign in to comment.