ARM: tegra: dvfs: Use common rail thermal profile init
Alex Frid [Fri, 6 Sep 2013 00:13:46 +0000 (17:13 -0700)]
Moved dvfs rail thermal profiles initialization to common tegra
dvfs code.

Change-Id: Iae26a9704135479bce90e108104af8569bb87848
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/271328
GVS: Gerrit_Virtual_Submit
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: Prashant Malani <pmalani@nvidia.com>
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

arch/arm/mach-tegra/dvfs.c
arch/arm/mach-tegra/dvfs.h
arch/arm/mach-tegra/tegra11_dvfs.c
arch/arm/mach-tegra/tegra12_dvfs.c
arch/arm/mach-tegra/tegra14_dvfs.c

index 3d4c7cb..80f1320 100644 (file)
@@ -1229,10 +1229,94 @@ static void tegra_dvfs_rail_register_vmin_cdev(struct dvfs_rail *rail)
                pr_err("tegra cooling device %s failed to register\n",
                       rail->vmin_cdev->cdev_type);
 }
+
 #else
 #define tegra_dvfs_rail_register_vmin_cdev(rail)
 #endif
 
+/*
+ * Validate rail thermal profile, and get its size. Valid profile:
+ * - voltage limits are descending with temperature increasing
+ * - the lowest limit is above rail minimum voltage in pll and
+ *   in dfll mode (if applicable)
+ * - the highest limit is below rail nominal voltage
+ */
+static int __init get_thermal_profile_size(
+       int *trips_table, int *limits_table,
+       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
+{
+       int i, min_mv;
+
+       for (i = 0; i < MAX_THERMAL_LIMITS - 1; i++) {
+               if (!limits_table[i+1])
+                       break;
+
+               if ((trips_table[i] >= trips_table[i+1]) ||
+                   (limits_table[i] < limits_table[i+1])) {
+                       pr_warn("%s: not ordered profile\n", rail->reg_id);
+                       return -EINVAL;
+               }
+       }
+
+       min_mv = max(rail->min_millivolts, d ? d->min_millivolts : 0);
+       if (limits_table[i] < min_mv) {
+               pr_warn("%s: thermal profile below Vmin\n", rail->reg_id);
+               return -EINVAL;
+       }
+
+       if (limits_table[0] > rail->nominal_millivolts) {
+               pr_warn("%s: thermal profile above Vmax\n", rail->reg_id);
+               return -EINVAL;
+       }
+       return i + 1;
+}
+
+void __init init_rail_vmax_thermal_profile(
+       int *therm_trips_table, int *therm_caps_table,
+       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
+{
+       int i = get_thermal_profile_size(therm_trips_table,
+                                        therm_caps_table, rail, d);
+       if (i <= 0) {
+               rail->vmax_cdev = NULL;
+               WARN(1, "%s: invalid Vmax thermal profile\n", rail->reg_id);
+               return;
+       }
+
+       /* Install validated thermal caps */
+       rail->therm_mv_caps = therm_caps_table;
+       rail->therm_mv_caps_num = i;
+
+       /* Setup trip-points if applicable */
+       if (rail->vmax_cdev) {
+               rail->vmax_cdev->trip_temperatures_num = i;
+               rail->vmax_cdev->trip_temperatures = therm_trips_table;
+       }
+}
+
+void __init init_rail_vmin_thermal_profile(
+       int *therm_trips_table, int *therm_floors_table,
+       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
+{
+       int i = get_thermal_profile_size(therm_trips_table,
+                                        therm_floors_table, rail, d);
+       if (i <= 0) {
+               rail->vmin_cdev = NULL;
+               WARN(1, "%s: invalid Vmin thermal profile\n", rail->reg_id);
+               return;
+       }
+
+       /* Install validated thermal floors */
+       rail->therm_mv_floors = therm_floors_table;
+       rail->therm_mv_floors_num = i;
+
+       /* Setup trip-points if applicable */
+       if (rail->vmin_cdev) {
+               rail->vmin_cdev->trip_temperatures_num = i;
+               rail->vmin_cdev->trip_temperatures = therm_trips_table;
+       }
+}
+
 /* Directly set cold temperature limit in dfll mode */
 int tegra_dvfs_rail_dfll_mode_set_cold(struct dvfs_rail *rail)
 {
index b7ddb59..38d0189 100644 (file)
@@ -229,9 +229,16 @@ int tegra_cpu_dvfs_alter(int edp_thermal_index, const cpumask_t *cpus,
                         bool before_clk_update, int cpu_event);
 int tegra_dvfs_dfll_mode_set(struct dvfs *d, unsigned long rate);
 int tegra_dvfs_dfll_mode_clear(struct dvfs *d, unsigned long rate);
+
 struct tegra_cooling_device *tegra_dvfs_get_cpu_vmax_cdev(void);
 struct tegra_cooling_device *tegra_dvfs_get_cpu_vmin_cdev(void);
 struct tegra_cooling_device *tegra_dvfs_get_core_vmin_cdev(void);
+void __init init_rail_vmin_thermal_profile(
+       int *therm_trips_table, int *therm_floors_table,
+       struct dvfs_rail *rail, struct dvfs_dfll_data *d);
+void __init init_rail_vmax_thermal_profile(
+       int *therm_trips_table, int *therm_caps_table,
+       struct dvfs_rail *rail, struct dvfs_dfll_data *d);
 int tegra_dvfs_rail_dfll_mode_set_cold(struct dvfs_rail *rail);
 
 #ifdef CONFIG_ARCH_TEGRA_12x_SOC
index e044e1a..6e7e319 100644 (file)
@@ -418,89 +418,6 @@ module_param_cb(disable_core, &tegra_dvfs_disable_core_ops,
 module_param_cb(disable_cpu, &tegra_dvfs_disable_cpu_ops,
        &tegra_dvfs_cpu_disabled, 0644);
 
-/*
- * Validate rail thermal profile, and get its size. Valid profile:
- * - voltage floors are descending with temperature increasing
- * - the lowest limit is above rail minimum voltage in pll and
- *   in dfll mode (if applicable)
- * - the highest limit is below rail nominal voltage
- */
-static int __init get_thermal_profile_size(
-       int *trips_table, int *limits_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i, min_mv;
-
-       for (i = 0; i < MAX_THERMAL_LIMITS - 1; i++) {
-               if (!limits_table[i+1])
-                       break;
-
-               if ((trips_table[i] >= trips_table[i+1]) ||
-                   (limits_table[i] < limits_table[i+1])) {
-                       pr_warning("%s: not ordered profile\n", rail->reg_id);
-                       return -EINVAL;
-               }
-       }
-
-       min_mv = max(rail->min_millivolts, d ? d->min_millivolts : 0);
-       if (limits_table[i] < min_mv) {
-               pr_warning("%s: thermal profile below Vmin\n", rail->reg_id);
-               return -EINVAL;
-       }
-
-       if (limits_table[0] > rail->nominal_millivolts) {
-               pr_warning("%s: thermal profile above Vmax\n", rail->reg_id);
-               return -EINVAL;
-       }
-       return i + 1;
-}
-
-static void __init init_rail_vmax_thermal_profile(
-       int *therm_trips_table, int *therm_caps_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i = get_thermal_profile_size(therm_trips_table,
-                                        therm_caps_table, rail, d);
-       if (i <= 0) {
-               rail->vmax_cdev = NULL;
-               WARN(1, "%s: invalid Vmax thermal profile\n", rail->reg_id);
-               return;
-       }
-
-       /* Install validated thermal caps */
-       rail->therm_mv_caps = therm_caps_table;
-       rail->therm_mv_caps_num = i;
-
-       /* Setup trip-points if applicable */
-       if (rail->vmax_cdev) {
-               rail->vmax_cdev->trip_temperatures_num = i;
-               rail->vmax_cdev->trip_temperatures = therm_trips_table;
-       }
-}
-
-static void __init init_rail_vmin_thermal_profile(
-       int *therm_trips_table, int *therm_floors_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i = get_thermal_profile_size(therm_trips_table,
-                                        therm_floors_table, rail, d);
-       if (i <= 0) {
-               rail->vmin_cdev = NULL;
-               WARN(1, "%s: invalid Vmin thermal profile\n", rail->reg_id);
-               return;
-       }
-
-       /* Install validated thermal floors */
-       rail->therm_mv_floors = therm_floors_table;
-       rail->therm_mv_floors_num = i;
-
-       /* Setup trip-points if applicable */
-       if (rail->vmin_cdev) {
-               rail->vmin_cdev->trip_temperatures_num = i;
-               rail->vmin_cdev->trip_temperatures = therm_trips_table;
-       }
-}
-
 static bool __init can_update_max_rate(struct clk *c, struct dvfs *d)
 {
        /* Don't update manual dvfs clocks */
index 03428a3..642f6b8 100644 (file)
@@ -395,46 +395,6 @@ module_param_cb(disable_cpu, &tegra_dvfs_disable_cpu_ops,
 module_param_cb(disable_gpu, &tegra_dvfs_disable_gpu_ops,
        &tegra_dvfs_gpu_disabled, 0644);
 
-/*
- * Install rail thermal profile provided:
- * - voltage floors are descending with temperature increasing
- * - and the lowest floor is above rail minimum voltage in pll and
- *   in dfll mode (if applicable)
- */
-static void __init init_rail_thermal_profile(
-       int *therm_trips_table, int *therm_floors_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i, min_mv;
-
-       for (i = 0; i < MAX_THERMAL_LIMITS - 1; i++) {
-               if (!therm_floors_table[i+1])
-                       break;
-
-               if ((therm_trips_table[i] >= therm_trips_table[i+1]) ||
-                   (therm_floors_table[i] < therm_floors_table[i+1])) {
-                       WARN(1, "%s: invalid thermal floors\n", rail->reg_id);
-                       return;
-               }
-       }
-
-       min_mv = max(rail->min_millivolts, d ? d->min_millivolts : 0);
-       if (therm_floors_table[i] < min_mv) {
-               WARN(1, "%s: thermal floor below Vmin\n", rail->reg_id);
-               return;
-       }
-
-       /* Install validated thermal floors */
-       rail->therm_mv_floors = therm_floors_table;
-       rail->therm_mv_floors_num = i + 1;
-
-       /* Setup trip-points, use the same trips in dfll mode (if applicable) */
-       if (rail->vmin_cdev) {
-               rail->vmin_cdev->trip_temperatures_num = i + 1;
-               rail->vmin_cdev->trip_temperatures = therm_trips_table;
-       }
-}
-
 static bool __init can_update_max_rate(struct clk *c, struct dvfs *d)
 {
        /* Don't update manual dvfs clocks */
index ec82642..ffffdd8 100644 (file)
@@ -419,89 +419,6 @@ module_param_cb(disable_core, &tegra_dvfs_disable_core_ops,
 module_param_cb(disable_cpu, &tegra_dvfs_disable_cpu_ops,
        &tegra_dvfs_cpu_disabled, 0644);
 
-/*
- * Validate rail thermal profile, and get its size. Valid profile:
- * - voltage floors are descending with temperature increasing
- * - the lowest limit is above rail minimum voltage in pll and
- *   in dfll mode (if applicable)
- * - the highest limit is below rail nominal voltage
- */
-static int __init get_thermal_profile_size(
-       int *trips_table, int *limits_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i, min_mv;
-
-       for (i = 0; i < MAX_THERMAL_LIMITS - 1; i++) {
-               if (!limits_table[i+1])
-                       break;
-
-               if ((trips_table[i] >= trips_table[i+1]) ||
-                   (limits_table[i] < limits_table[i+1])) {
-                       pr_warning("%s: not ordered profile\n", rail->reg_id);
-                       return -EINVAL;
-               }
-       }
-
-       min_mv = max(rail->min_millivolts, d ? d->min_millivolts : 0);
-       if (limits_table[i] < min_mv) {
-               pr_warning("%s: thermal profile below Vmin\n", rail->reg_id);
-               return -EINVAL;
-       }
-
-       if (limits_table[0] > rail->nominal_millivolts) {
-               pr_warning("%s: thermal profile above Vmax\n", rail->reg_id);
-               return -EINVAL;
-       }
-       return i + 1;
-}
-
-static void __init init_rail_vmax_thermal_profile(
-       int *therm_trips_table, int *therm_caps_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i = get_thermal_profile_size(therm_trips_table,
-                                        therm_caps_table, rail, d);
-       if (i <= 0) {
-               rail->vmax_cdev = NULL;
-               WARN(1, "%s: invalid Vmax thermal profile\n", rail->reg_id);
-               return;
-       }
-
-       /* Install validated thermal caps */
-       rail->therm_mv_caps = therm_caps_table;
-       rail->therm_mv_caps_num = i;
-
-       /* Setup trip-points if applicable */
-       if (rail->vmax_cdev) {
-               rail->vmax_cdev->trip_temperatures_num = i;
-               rail->vmax_cdev->trip_temperatures = therm_trips_table;
-       }
-}
-
-static void __init init_rail_vmin_thermal_profile(
-       int *therm_trips_table, int *therm_floors_table,
-       struct dvfs_rail *rail, struct dvfs_dfll_data *d)
-{
-       int i = get_thermal_profile_size(therm_trips_table,
-                                        therm_floors_table, rail, d);
-       if (i <= 0) {
-               rail->vmin_cdev = NULL;
-               WARN(1, "%s: invalid Vmin thermal profile\n", rail->reg_id);
-               return;
-       }
-
-       /* Install validated thermal floors */
-       rail->therm_mv_floors = therm_floors_table;
-       rail->therm_mv_floors_num = i;
-
-       /* Setup trip-points if applicable */
-       if (rail->vmin_cdev) {
-               rail->vmin_cdev->trip_temperatures_num = i;
-               rail->vmin_cdev->trip_temperatures = therm_trips_table;
-       }
-}
-
 static bool __init can_update_max_rate(struct clk *c, struct dvfs *d)
 {
        /* Don't update manual dvfs clocks */