video: tegra: host: gk20a: Unify devfreq profile
Arto Merilainen [Mon, 29 Jul 2013 11:15:15 +0000 (14:15 +0300)]
This patch unifies the gk20a devfreq profile to behave similarly as the
generic device profile (i.e. devfreq is initialised only if a governor is
specified). The patch also removes duplicate type from headers.

Bug 1330780

Change-Id: I41b6c16a43704b67287fbb6d0c7d787744403f21
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/263236
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>

drivers/video/tegra/host/gk20a/gk20a_scale.c
drivers/video/tegra/host/gk20a/gk20a_scale.h

index 0de6b65..a6beb4c 100644 (file)
@@ -34,6 +34,7 @@
 #include "gk20a.h"
 #include "pmu_gk20a.h"
 #include "clk_gk20a.h"
+#include "nvhost_scale.h"
 #include "gk20a_scale.h"
 
 static ssize_t nvhost_gk20a_scale_load_show(struct device *dev,
@@ -169,13 +170,6 @@ static int gk20a_scale_get_dev_status(struct device *dev,
        return 0;
 }
 
-static struct devfreq_dev_profile gk20a_scale_devfreq_profile = {
-       .initial_freq   = 0,
-       .polling_ms     = 0,
-       .target         = gk20a_scale_target,
-       .get_dev_status = gk20a_scale_get_dev_status,
-};
-
 /*
  * gk20a_scale_init(pdev)
  */
@@ -191,7 +185,6 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
        profile = kzalloc(sizeof(struct nvhost_device_profile), GFP_KERNEL);
        if (!profile)
                return;
-       pdata->power_profile = profile;
        profile->pdev = pdev;
        profile->last_event_type = DEVICE_UNKNOWN;
 
@@ -210,13 +203,26 @@ void nvhost_gk20a_scale_init(struct platform_device *pdev)
        if (device_create_file(&pdev->dev, &dev_attr_load))
                goto err_create_sysfs_entry;
 
-       pdata->power_manager = devfreq_add_device(&pdev->dev,
-                               &gk20a_scale_devfreq_profile,
-                               "", NULL);
+       /* Store device profile so we can access it if devfreq governor
+        * init needs that */
+       pdata->power_profile = profile;
+
+       if (pdata->devfreq_governor) {
+               struct devfreq *devfreq;
 
-       if (IS_ERR(pdata->power_manager))
-               pdata->power_manager = NULL;
+               profile->devfreq_profile.target = gk20a_scale_target;
+               profile->devfreq_profile.get_dev_status =
+                       gk20a_scale_get_dev_status;
 
+               devfreq = devfreq_add_device(&pdev->dev,
+                                       &profile->devfreq_profile,
+                                       pdata->devfreq_governor->name, NULL);
+
+               if (IS_ERR(devfreq))
+                       devfreq = NULL;
+
+               pdata->power_manager = devfreq;
+       }
        return;
 
 err_create_sysfs_entry:
index 438c602..661e34f 100644 (file)
 #include <linux/nvhost.h>
 #include <linux/devfreq.h>
 
+#include "nvhost_scale.h"
+
 struct platform_device;
 struct host1x_actmon;
 struct clk;
 
-/*
- * profile_rec - Device specific power management variables
- */
-
-struct nvhost_device_profile {
-       struct platform_device          *pdev;
-       struct host1x_actmon            *actmon;
-       struct clk                      *clk;
-
-       bool                            busy;
-       ktime_t                         last_event_time;
-       enum nvhost_devfreq_busy        last_event_type;
-
-       struct devfreq_dev_status       dev_stat;
-       struct nvhost_devfreq_ext_stat  ext_stat;
-
-       void                            *private_data;
-};
-
 /* Initialization and de-initialization for module */
 void nvhost_gk20a_scale_init(struct platform_device *);
 void nvhost_gk20a_scale_deinit(struct platform_device *);