Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: MIT */
0002 #ifndef __NVKM_THERM_H__
0003 #define __NVKM_THERM_H__
0004 #include <core/subdev.h>
0005 
0006 #include <subdev/bios.h>
0007 #include <subdev/bios/therm.h>
0008 #include <subdev/timer.h>
0009 
0010 enum nvkm_therm_thrs_direction {
0011     NVKM_THERM_THRS_FALLING = 0,
0012     NVKM_THERM_THRS_RISING = 1
0013 };
0014 
0015 enum nvkm_therm_thrs_state {
0016     NVKM_THERM_THRS_LOWER = 0,
0017     NVKM_THERM_THRS_HIGHER = 1
0018 };
0019 
0020 enum nvkm_therm_thrs {
0021     NVKM_THERM_THRS_FANBOOST = 0,
0022     NVKM_THERM_THRS_DOWNCLOCK = 1,
0023     NVKM_THERM_THRS_CRITICAL = 2,
0024     NVKM_THERM_THRS_SHUTDOWN = 3,
0025     NVKM_THERM_THRS_NR
0026 };
0027 
0028 enum nvkm_therm_fan_mode {
0029     NVKM_THERM_CTRL_NONE = 0,
0030     NVKM_THERM_CTRL_MANUAL = 1,
0031     NVKM_THERM_CTRL_AUTO = 2,
0032 };
0033 
0034 enum nvkm_therm_attr_type {
0035     NVKM_THERM_ATTR_FAN_MIN_DUTY = 0,
0036     NVKM_THERM_ATTR_FAN_MAX_DUTY = 1,
0037     NVKM_THERM_ATTR_FAN_MODE = 2,
0038 
0039     NVKM_THERM_ATTR_THRS_FAN_BOOST = 10,
0040     NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST = 11,
0041     NVKM_THERM_ATTR_THRS_DOWN_CLK = 12,
0042     NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST = 13,
0043     NVKM_THERM_ATTR_THRS_CRITICAL = 14,
0044     NVKM_THERM_ATTR_THRS_CRITICAL_HYST = 15,
0045     NVKM_THERM_ATTR_THRS_SHUTDOWN = 16,
0046     NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST = 17,
0047 };
0048 
0049 struct nvkm_therm_clkgate_init {
0050     u32 addr;
0051     u8  count;
0052     u32 data;
0053 };
0054 
0055 struct nvkm_therm_clkgate_pack {
0056     const struct nvkm_therm_clkgate_init *init;
0057 };
0058 
0059 struct nvkm_therm {
0060     const struct nvkm_therm_func *func;
0061     struct nvkm_subdev subdev;
0062 
0063     /* automatic thermal management */
0064     struct nvkm_alarm alarm;
0065     spinlock_t lock;
0066     struct nvbios_therm_trip_point *last_trip;
0067     int mode;
0068     int cstate;
0069     int suspend;
0070 
0071     /* bios */
0072     struct nvbios_therm_sensor bios_sensor;
0073 
0074     /* fan priv */
0075     struct nvkm_fan *fan;
0076 
0077     /* alarms priv */
0078     struct {
0079         spinlock_t alarm_program_lock;
0080         struct nvkm_alarm therm_poll_alarm;
0081         enum nvkm_therm_thrs_state alarm_state[NVKM_THERM_THRS_NR];
0082     } sensor;
0083 
0084     /* what should be done if the card overheats */
0085     struct {
0086         void (*downclock)(struct nvkm_therm *, bool active);
0087         void (*pause)(struct nvkm_therm *, bool active);
0088     } emergency;
0089 
0090     /* ic */
0091     struct i2c_client *ic;
0092 
0093     int (*fan_get)(struct nvkm_therm *);
0094     int (*fan_set)(struct nvkm_therm *, int);
0095 
0096     int (*attr_get)(struct nvkm_therm *, enum nvkm_therm_attr_type);
0097     int (*attr_set)(struct nvkm_therm *, enum nvkm_therm_attr_type, int);
0098 
0099     bool clkgating_enabled;
0100 };
0101 
0102 int nvkm_therm_temp_get(struct nvkm_therm *);
0103 int nvkm_therm_fan_sense(struct nvkm_therm *);
0104 int nvkm_therm_cstate(struct nvkm_therm *, int, int);
0105 void nvkm_therm_clkgate_init(struct nvkm_therm *,
0106                  const struct nvkm_therm_clkgate_pack *);
0107 void nvkm_therm_clkgate_enable(struct nvkm_therm *);
0108 void nvkm_therm_clkgate_fini(struct nvkm_therm *, bool);
0109 
0110 int nv40_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0111 int nv50_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0112 int g84_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0113 int gt215_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0114 int gf119_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0115 int gk104_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0116 int gm107_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0117 int gm200_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0118 int gp100_therm_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_therm **);
0119 #endif