aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2012-01-26 21:54:58 -0500
committerInki Dae <inki.dae@samsung.com>2012-01-26 23:03:59 -0500
commit373af0c0c539b109ea978e96f217df0fc20aa261 (patch)
treea506424edac1363cb2bc339387a2d51e1493b479 /drivers
parentf15013033e2dd363b3ad181bfd27fa4e8e8ffda8 (diff)
drm/exynos: fixed pm feature for fimd module.
this patch separates fimd specific power on/off function from pm function and the pm interfaces will call that function for power on or off. and also removes unnecessary codes of resume function. Signed-off-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c109
1 files changed, 59 insertions, 50 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index ca83139cd309..b6a737d196ae 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -158,7 +158,8 @@ static void fimd_dpms(struct device *subdrv_dev, int mode)
158 case DRM_MODE_DPMS_STANDBY: 158 case DRM_MODE_DPMS_STANDBY:
159 case DRM_MODE_DPMS_SUSPEND: 159 case DRM_MODE_DPMS_SUSPEND:
160 case DRM_MODE_DPMS_OFF: 160 case DRM_MODE_DPMS_OFF:
161 pm_runtime_put_sync(subdrv_dev); 161 if (!ctx->suspended)
162 pm_runtime_put_sync(subdrv_dev);
162 break; 163 break;
163 default: 164 default:
164 DRM_DEBUG_KMS("unspecified mode %d\n", mode); 165 DRM_DEBUG_KMS("unspecified mode %d\n", mode);
@@ -734,6 +735,46 @@ static void fimd_clear_win(struct fimd_context *ctx, int win)
734 writel(val, ctx->regs + SHADOWCON); 735 writel(val, ctx->regs + SHADOWCON);
735} 736}
736 737
738static int fimd_power_on(struct fimd_context *ctx, bool enable)
739{
740 struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
741 struct device *dev = subdrv->manager.dev;
742
743 DRM_DEBUG_KMS("%s\n", __FILE__);
744
745 if (enable != false && enable != true)
746 return -EINVAL;
747
748 if (enable) {
749 int ret;
750
751 ret = clk_enable(ctx->bus_clk);
752 if (ret < 0)
753 return ret;
754
755 ret = clk_enable(ctx->lcd_clk);
756 if (ret < 0) {
757 clk_disable(ctx->bus_clk);
758 return ret;
759 }
760
761 ctx->suspended = false;
762
763 /* if vblank was enabled status, enable it again. */
764 if (test_and_clear_bit(0, &ctx->irq_flags))
765 fimd_enable_vblank(dev);
766
767 fimd_apply(dev);
768 } else {
769 clk_disable(ctx->lcd_clk);
770 clk_disable(ctx->bus_clk);
771
772 ctx->suspended = true;
773 }
774
775 return 0;
776}
777
737static int __devinit fimd_probe(struct platform_device *pdev) 778static int __devinit fimd_probe(struct platform_device *pdev)
738{ 779{
739 struct device *dev = &pdev->dev; 780 struct device *dev = &pdev->dev;
@@ -911,39 +952,30 @@ out:
911#ifdef CONFIG_PM_SLEEP 952#ifdef CONFIG_PM_SLEEP
912static int fimd_suspend(struct device *dev) 953static int fimd_suspend(struct device *dev)
913{ 954{
914 int ret; 955 struct fimd_context *ctx = get_fimd_context(dev);
915 956
916 if (pm_runtime_suspended(dev)) 957 if (pm_runtime_suspended(dev))
917 return 0; 958 return 0;
918 959
919 ret = pm_runtime_suspend(dev); 960 /*
920 if (ret < 0) 961 * do not use pm_runtime_suspend(). if pm_runtime_suspend() is
921 return ret; 962 * called here, an error would be returned by that interface
922 963 * because the usage_count of pm runtime is more than 1.
923 return 0; 964 */
965 return fimd_power_on(ctx, false);
924} 966}
925 967
926static int fimd_resume(struct device *dev) 968static int fimd_resume(struct device *dev)
927{ 969{
928 int ret; 970 struct fimd_context *ctx = get_fimd_context(dev);
929
930 ret = pm_runtime_resume(dev);
931 if (ret < 0) {
932 DRM_ERROR("failed to resume runtime pm.\n");
933 return ret;
934 }
935
936 pm_runtime_disable(dev);
937
938 ret = pm_runtime_set_active(dev);
939 if (ret < 0) {
940 DRM_ERROR("failed to active runtime pm.\n");
941 pm_runtime_enable(dev);
942 pm_runtime_suspend(dev);
943 return ret;
944 }
945 971
946 pm_runtime_enable(dev); 972 /*
973 * if entered to sleep when lcd panel was on, the usage_count
974 * of pm runtime would still be 1 so in this case, fimd driver
975 * should be on directly not drawing on pm runtime interface.
976 */
977 if (!pm_runtime_suspended(dev))
978 return fimd_power_on(ctx, true);
947 979
948 return 0; 980 return 0;
949} 981}
@@ -956,39 +988,16 @@ static int fimd_runtime_suspend(struct device *dev)
956 988
957 DRM_DEBUG_KMS("%s\n", __FILE__); 989 DRM_DEBUG_KMS("%s\n", __FILE__);
958 990
959 clk_disable(ctx->lcd_clk); 991 return fimd_power_on(ctx, false);
960 clk_disable(ctx->bus_clk);
961
962 ctx->suspended = true;
963 return 0;
964} 992}
965 993
966static int fimd_runtime_resume(struct device *dev) 994static int fimd_runtime_resume(struct device *dev)
967{ 995{
968 struct fimd_context *ctx = get_fimd_context(dev); 996 struct fimd_context *ctx = get_fimd_context(dev);
969 int ret;
970 997
971 DRM_DEBUG_KMS("%s\n", __FILE__); 998 DRM_DEBUG_KMS("%s\n", __FILE__);
972 999
973 ret = clk_enable(ctx->bus_clk); 1000 return fimd_power_on(ctx, true);
974 if (ret < 0)
975 return ret;
976
977 ret = clk_enable(ctx->lcd_clk);
978 if (ret < 0) {
979 clk_disable(ctx->bus_clk);
980 return ret;
981 }
982
983 ctx->suspended = false;
984
985 /* if vblank was enabled status, enable it again. */
986 if (test_and_clear_bit(0, &ctx->irq_flags))
987 fimd_enable_vblank(dev);
988
989 fimd_apply(dev);
990
991 return 0;
992} 1001}
993#endif 1002#endif
994 1003