2 * Copyright 2011-2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Alexander von Gluck IV, kallisti5@unixzen.com
15 # define TRACE(x...) dprintf("radeon_hd: " x)
17 # define TRACE(x...) ;
22 radeon_thermal_query(radeon_info
&info
)
24 // return GPU temp in millidegrees C
29 if (info
.chipsetID
>= RADEON_CAPEVERDE
) {
30 rawTemp
= (read32(info
.registers
+ SI_CG_MULT_THERMAL_STATUS
)
31 & SI_CTF_TEMP_MASK
) >> SI_CTF_TEMP_SHIFT
;
36 finalTemp
= rawTemp
& 0x1ff;
38 return finalTemp
* 1000;
39 } else if (info
.chipsetID
== RADEON_JUNIPER
) {
40 uint32 offset
= (read32(info
.registers
+ EVERGREEN_CG_THERMAL_CTRL
)
41 & EVERGREEN_TOFFSET_MASK
) >> EVERGREEN_TOFFSET_SHIFT
;
42 rawTemp
= (read32(info
.registers
+ EVERGREEN_CG_TS0_STATUS
)
43 & EVERGREEN_TS0_ADC_DOUT_MASK
) >> EVERGREEN_TS0_ADC_DOUT_SHIFT
;
46 finalTemp
= rawTemp
/ 2 - (0x200 - offset
);
48 finalTemp
= rawTemp
/ 2 + offset
;
50 return finalTemp
* 1000;
51 } else if (info
.chipsetID
== RADEON_SUMO
52 || info
.chipsetID
== RADEON_SUMO2
) {
53 uint32 rawTemp
= read32(info
.registers
+ EVERGREEN_CG_THERMAL_STATUS
)
55 finalTemp
= rawTemp
- 49;
57 return finalTemp
* 1000;
58 } else if (info
.chipsetID
>= RADEON_CEDAR
) {
59 rawTemp
= (read32(info
.registers
+ EVERGREEN_CG_MULT_THERMAL_STATUS
)
60 & EVERGREEN_ASIC_T_MASK
) >> EVERGREEN_ASIC_T_SHIFT
;
64 else if (rawTemp
& 0x200)
66 else if (rawTemp
& 0x100) {
67 finalTemp
= rawTemp
& 0x1ff;
70 finalTemp
= rawTemp
& 0xff;
72 return (finalTemp
* 1000) / 2;
73 } else if (info
.chipsetID
>= RADEON_RV770
) {
74 rawTemp
= (read32(info
.registers
+ R700_CG_MULT_THERMAL_STATUS
)
75 & R700_ASIC_T_MASK
) >> R700_ASIC_T_SHIFT
;
78 else if (rawTemp
& 0x200)
80 else if (rawTemp
& 0x100) {
81 finalTemp
= rawTemp
& 0x1ff;
84 finalTemp
= rawTemp
& 0xff;
86 return (finalTemp
* 1000) / 2;
87 } else if (info
.chipsetID
>= RADEON_R600
) {
88 rawTemp
= (read32(info
.registers
+ R600_CG_THERMAL_STATUS
)
89 & R600_ASIC_T_MASK
) >> R600_ASIC_T_SHIFT
;
90 finalTemp
= rawTemp
& 0xff;
95 return finalTemp
* 1000;