ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / include / mach / thermal.h
index 589f7ad..800eb74 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/thermal.h
  *
- * Copyright (C) 2010-2012 NVIDIA Corporation.
+ * Copyright (c) 2010-2013 NVIDIA CORPORATION. All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
 #define __MACH_THERMAL_H
 
 #include <linux/therm_est.h>
+#include <linux/thermal.h>
 
-#ifndef CONFIG_THERMAL
-#endif
-
-enum thermal_device_id {
-       THERMAL_DEVICE_ID_NULL = 0x0,
-       THERMAL_DEVICE_ID_NCT_EXT = 0x1,
-       THERMAL_DEVICE_ID_NCT_INT = 0x2,
-       THERMAL_DEVICE_ID_TSENSOR = 0x4,
-       THERMAL_DEVICE_ID_SKIN = 0x8,
+struct tegra_cooling_device {
+       char *cdev_type;
+       int *trip_temperatures;
+       int trip_temperatures_num;
 };
 
-#define THERMAL_DEVICE_MAX     (4)
-
-enum balanced_throttle_id {
-       BALANCED_THROTTLE_ID_TJ,
-       BALANCED_THROTTLE_ID_SKIN,
-};
+#define MAX_THROT_TABLE_SIZE   (64)
+#define NO_CAP                 (ULONG_MAX) /* no cap */
+#define CPU_THROT_LOW          0 /* lowest throttle freq. only used for CPU */
 
-struct skin_therm_est_subdevice {
-       enum thermal_device_id id;
-       long coeffs[HIST_LEN];
-};
-
-/* All units in millicelsius */
-struct tegra_thermal_data {
-       enum thermal_device_id shutdown_device_id;
-       long temp_shutdown;
-       enum thermal_device_id throttle_edp_device_id;
-#ifdef CONFIG_TEGRA_EDP_LIMITS
-       long edp_offset;
-       long hysteresis_edp;
+#ifdef CONFIG_ARCH_TEGRA_12x_SOC
+#define GBUS_CNT               1
+#else
+#define GBUS_CNT               0
 #endif
-       long temp_throttle;
-       int tc1;
-       int tc2;
-       long passive_delay;
-};
 
-struct tegra_skin_data {
-       enum thermal_device_id skin_device_id;
-       long temp_throttle_skin;
-       int tc1_skin;
-       int tc2_skin;
-       int passive_delay_skin;
+#ifdef CONFIG_TEGRA_DUAL_CBUS
+#define CBUS_CNT               2
+#else
+#define CBUS_CNT               1
+#endif
 
-       long skin_temp_offset;
-       long skin_period;
-       int skin_devs_size;
-       struct skin_therm_est_subdevice skin_devs[];
-};
-
-struct tegra_thermal_device {
-       char *name;
-       enum thermal_device_id id;
-       void *data;
-       long offset;
-       int (*get_temp) (void *, long *);
-       int (*get_temp_low)(void *, long *);
-       int (*set_limits) (void *, long, long);
-       int (*set_alert)(void *, void (*)(void *), void *);
-       int (*set_shutdown_temp)(void *, long);
-       struct thermal_zone_device *thz;
-       struct list_head node;
-};
+/* cpu, gpu(0|1), cbus(1|2), sclk, emc */
+#define NUM_OF_CAP_FREQS       (1 + GBUS_CNT + CBUS_CNT + 1 + 1)
 
 struct throttle_table {
-       unsigned int cpu_freq;
-       int core_cap_level;
+       unsigned long cap_freqs[NUM_OF_CAP_FREQS];
 };
 
-#define MAX_THROT_TABLE_SIZE   (32)
-
 struct balanced_throttle {
-       enum balanced_throttle_id id;
-
-       int is_throttling;
-       int throttle_index;
        struct thermal_cooling_device *cdev;
-
        struct list_head node;
-
+       unsigned long cur_state;
+       int throttle_count;
        int throt_tab_size;
-       struct throttle_table throt_tab[MAX_THROT_TABLE_SIZE];
+       struct throttle_table *throt_tab;
 };
 
 #ifdef CONFIG_TEGRA_THERMAL_THROTTLE
-int balanced_throttle_register(struct balanced_throttle *bthrot);
-#else
-static inline int balanced_throttle_register(struct balanced_throttle *bthrot)
-{ return 0; }
-#endif
-
-#ifdef CONFIG_TEGRA_THERMAL
-int tegra_thermal_init(struct tegra_thermal_data *data,
-                               struct tegra_skin_data *skin_data,
-                               struct balanced_throttle *throttle_list,
-                               int throttle_list_size);
-int tegra_thermal_device_register(struct tegra_thermal_device *device);
-int tegra_thermal_exit(void);
+int tegra_throttle_init(struct mutex *cpu_lock);
+struct thermal_cooling_device *balanced_throttle_register(
+               struct balanced_throttle *bthrot,
+               char *type);
+void tegra_throttle_exit(void);
+bool tegra_is_throttling(int *count);
+unsigned long tegra_throttle_governor_speed(unsigned long requested_speed);
 #else
-static inline int tegra_thermal_init(struct tegra_thermal_data *data,
-                                       struct tegra_skin_data *skin_data,
-                                       struct balanced_throttle *throttle_list,
-                                       int throttle_list_size)
+static inline int tegra_throttle_init(struct mutex *cpu_lock)
 { return 0; }
-static inline int tegra_thermal_device_register(struct tegra_thermal_device *device)
-{ return 0; }
-static inline int tegra_thermal_exit(void)
-{ return 0; }
-#endif
+static inline struct thermal_cooling_device *balanced_throttle_register(
+               struct balanced_throttle *bthrot,
+               char *type)
+{ return ERR_PTR(-ENODEV); }
+static inline void tegra_throttle_exit(void)
+{}
+static inline bool tegra_is_throttling(int *count)
+{ return false; }
+static inline unsigned long tegra_throttle_governor_speed(
+       unsigned long requested_speed)
+{ return requested_speed; }
+#endif /* CONFIG_TEGRA_THERMAL_THROTTLE */
 
 #endif /* __MACH_THERMAL_H */