Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dsi: Implement RPM suspend/resume callbacks

The bus clocks are always enabled/disabled along with the power
domain, so move it to the runtime suspend/resume ops. This cleans
up the clock code a bit. Get rid of the clk_mutex mutex since it
isn't needed.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>

authored by

Archit Taneja and committed by
Rob Clark
f54ca1a0 f6be1121

+49 -41
+5
drivers/gpu/drm/msm/dsi/dsi.c
··· 161 161 {} 162 162 }; 163 163 164 + static const struct dev_pm_ops dsi_pm_ops = { 165 + SET_RUNTIME_PM_OPS(msm_dsi_runtime_suspend, msm_dsi_runtime_resume, NULL) 166 + }; 167 + 164 168 static struct platform_driver dsi_driver = { 165 169 .probe = dsi_dev_probe, 166 170 .remove = dsi_dev_remove, 167 171 .driver = { 168 172 .name = "msm_dsi", 169 173 .of_match_table = dt_match, 174 + .pm = &dsi_pm_ops, 170 175 }, 171 176 }; 172 177
+2
drivers/gpu/drm/msm/dsi/dsi.h
··· 179 179 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host, 180 180 struct drm_device *dev); 181 181 int msm_dsi_host_init(struct msm_dsi *msm_dsi); 182 + int msm_dsi_runtime_suspend(struct device *dev); 183 + int msm_dsi_runtime_resume(struct device *dev); 182 184 183 185 /* dsi phy */ 184 186 struct msm_dsi_phy;
+42 -41
drivers/gpu/drm/msm/dsi/dsi_host.c
··· 135 135 struct completion video_comp; 136 136 struct mutex dev_mutex; 137 137 struct mutex cmd_mutex; 138 - struct mutex clk_mutex; 139 138 spinlock_t intr_lock; /* Protect interrupt ctrl register */ 140 139 141 140 u32 err_work_state; ··· 457 458 clk_disable_unprepare(msm_host->bus_clks[i]); 458 459 } 459 460 461 + int msm_dsi_runtime_suspend(struct device *dev) 462 + { 463 + struct platform_device *pdev = to_platform_device(dev); 464 + struct msm_dsi *msm_dsi = platform_get_drvdata(pdev); 465 + struct mipi_dsi_host *host = msm_dsi->host; 466 + struct msm_dsi_host *msm_host = to_msm_dsi_host(host); 467 + 468 + if (!msm_host->cfg_hnd) 469 + return 0; 470 + 471 + dsi_bus_clk_disable(msm_host); 472 + 473 + return 0; 474 + } 475 + 476 + int msm_dsi_runtime_resume(struct device *dev) 477 + { 478 + struct platform_device *pdev = to_platform_device(dev); 479 + struct msm_dsi *msm_dsi = platform_get_drvdata(pdev); 480 + struct mipi_dsi_host *host = msm_dsi->host; 481 + struct msm_dsi_host *msm_host = to_msm_dsi_host(host); 482 + 483 + if (!msm_host->cfg_hnd) 484 + return 0; 485 + 486 + return dsi_bus_clk_enable(msm_host); 487 + } 488 + 460 489 static int dsi_link_clk_enable_6g(struct msm_dsi_host *msm_host) 461 490 { 462 491 int ret; ··· 624 597 clk_disable_unprepare(msm_host->esc_clk); 625 598 clk_disable_unprepare(msm_host->byte_clk); 626 599 } 627 - } 628 - 629 - static int dsi_clk_ctrl(struct msm_dsi_host *msm_host, bool enable) 630 - { 631 - int ret = 0; 632 - 633 - mutex_lock(&msm_host->clk_mutex); 634 - if (enable) { 635 - ret = dsi_bus_clk_enable(msm_host); 636 - if (ret) { 637 - pr_err("%s: Can not enable bus clk, %d\n", 638 - __func__, ret); 639 - goto unlock_ret; 640 - } 641 - ret = dsi_link_clk_enable(msm_host); 642 - if (ret) { 643 - pr_err("%s: Can not enable link clk, %d\n", 644 - __func__, ret); 645 - dsi_bus_clk_disable(msm_host); 646 - goto unlock_ret; 647 - } 648 - } else { 649 - dsi_link_clk_disable(msm_host); 650 - dsi_bus_clk_disable(msm_host); 651 - } 652 - 653 - unlock_ret: 654 - mutex_unlock(&msm_host->clk_mutex); 655 - return ret; 656 600 } 657 601 658 602 static int dsi_calc_clk_rate(struct msm_dsi_host *msm_host) ··· 1700 1702 } 1701 1703 1702 1704 msm_host->pdev = pdev; 1705 + msm_dsi->host = &msm_host->base; 1703 1706 1704 1707 ret = dsi_host_parse_dt(msm_host); 1705 1708 if (ret) { ··· 1757 1758 init_completion(&msm_host->video_comp); 1758 1759 mutex_init(&msm_host->dev_mutex); 1759 1760 mutex_init(&msm_host->cmd_mutex); 1760 - mutex_init(&msm_host->clk_mutex); 1761 1761 spin_lock_init(&msm_host->intr_lock); 1762 1762 1763 1763 /* setup workqueue */ ··· 1764 1766 INIT_WORK(&msm_host->err_work, dsi_err_worker); 1765 1767 INIT_WORK(&msm_host->hpd_work, dsi_hpd_worker); 1766 1768 1767 - msm_dsi->host = &msm_host->base; 1768 1769 msm_dsi->id = msm_host->id; 1769 1770 1770 1771 DBG("Dsi Host %d initialized", msm_host->id); ··· 1785 1788 msm_host->workqueue = NULL; 1786 1789 } 1787 1790 1788 - mutex_destroy(&msm_host->clk_mutex); 1789 1791 mutex_destroy(&msm_host->cmd_mutex); 1790 1792 mutex_destroy(&msm_host->dev_mutex); 1791 1793 ··· 1885 1889 * mdp clock need to be enabled to receive dsi interrupt 1886 1890 */ 1887 1891 pm_runtime_get_sync(&msm_host->pdev->dev); 1888 - dsi_clk_ctrl(msm_host, 1); 1892 + dsi_link_clk_enable(msm_host); 1889 1893 1890 1894 /* TODO: vote for bus bandwidth */ 1891 1895 ··· 1915 1919 1916 1920 /* TODO: unvote for bus bandwidth */ 1917 1921 1918 - dsi_clk_ctrl(msm_host, 0); 1922 + dsi_link_clk_disable(msm_host); 1919 1923 pm_runtime_put_autosuspend(&msm_host->pdev->dev); 1920 1924 } 1921 1925 ··· 2165 2169 * and only turned on before MDP START. 2166 2170 * This part of code should be enabled once mdp driver support it. 2167 2171 */ 2168 - /* if (msm_panel->mode == MSM_DSI_CMD_MODE) 2169 - dsi_clk_ctrl(msm_host, 0); */ 2172 + /* if (msm_panel->mode == MSM_DSI_CMD_MODE) { 2173 + * dsi_link_clk_disable(msm_host); 2174 + * pm_runtime_put_autosuspend(&msm_host->pdev->dev); 2175 + * } 2176 + */ 2170 2177 2171 2178 return 0; 2172 2179 } ··· 2226 2227 } 2227 2228 2228 2229 pm_runtime_get_sync(&msm_host->pdev->dev); 2229 - ret = dsi_clk_ctrl(msm_host, 1); 2230 + ret = dsi_link_clk_enable(msm_host); 2230 2231 if (ret) { 2231 - pr_err("%s: failed to enable clocks. ret=%d\n", __func__, ret); 2232 + pr_err("%s: failed to enable link clocks. ret=%d\n", 2233 + __func__, ret); 2232 2234 goto fail_disable_reg; 2233 2235 } 2234 2236 ··· 2253 2253 return 0; 2254 2254 2255 2255 fail_disable_clk: 2256 - dsi_clk_ctrl(msm_host, 0); 2256 + dsi_link_clk_disable(msm_host); 2257 + pm_runtime_put_autosuspend(&msm_host->pdev->dev); 2257 2258 fail_disable_reg: 2258 2259 dsi_host_regulator_disable(msm_host); 2259 2260 unlock_ret: ··· 2279 2278 2280 2279 pinctrl_pm_select_sleep_state(&msm_host->pdev->dev); 2281 2280 2282 - dsi_clk_ctrl(msm_host, 0); 2281 + dsi_link_clk_disable(msm_host); 2283 2282 pm_runtime_put_autosuspend(&msm_host->pdev->dev); 2284 2283 2285 2284 dsi_host_regulator_disable(msm_host);