Move thermal query into new driver sensor source file

* thermal query still works pre-atombios init
This commit is contained in:
Alexander von Gluck IV
2011-11-27 14:41:35 -06:00
parent 8e844f63e9
commit 30207c6c8c
7 changed files with 115 additions and 76 deletions
@@ -287,9 +287,6 @@ radeon_init_accelerant(int device)
radeon_gpu_mc_setup();
TRACE("%s: Current GPU temperature: %" B_PRId32 " mC\n",
__func__, radeon_get_temp());
TRACE("%s done\n", __func__);
return B_OK;
}
-72
View File
@@ -851,75 +851,3 @@ radeon_gpu_gpio_setup()
return B_OK;
}
int32
radeon_get_temp()
{
// return GPU temp in millidegrees C
radeon_shared_info &info = *gInfo->shared_info;
uint32 rawTemp = 0;
int32 finalTemp = 0;
if (info.chipsetID == RADEON_JUNIPER) {
uint32 offset = (Read32(OUT, EVERGREEN_CG_THERMAL_CTRL)
& EVERGREEN_TOFFSET_MASK) >> EVERGREEN_TOFFSET_SHIFT;
rawTemp = (Read32(OUT, EVERGREEN_CG_TS0_STATUS)
& EVERGREEN_TS0_ADC_DOUT_MASK) >> EVERGREEN_TS0_ADC_DOUT_SHIFT;
if (offset & 0x100)
finalTemp = rawTemp / 2 - (0x200 - offset);
else
finalTemp = rawTemp / 2 + offset;
return finalTemp * 1000;
} else if (info.chipsetID == RADEON_SUMO
|| info.chipsetID == RADEON_SUMO2) {
uint32 rawTemp = Read32(OUT, EVERGREEN_CG_THERMAL_STATUS) & 0xff;
finalTemp = rawTemp - 49;
return finalTemp * 1000;
} else if (info.chipsetID >= RADEON_CEDAR) {
rawTemp = (Read32(OUT, EVERGREEN_CG_MULT_THERMAL_STATUS)
& EVERGREEN_ASIC_T_MASK) >> EVERGREEN_ASIC_T_SHIFT;
if (rawTemp & 0x400)
finalTemp = -256;
else if (rawTemp & 0x200)
finalTemp = 255;
else if (rawTemp & 0x100) {
finalTemp = rawTemp & 0x1ff;
finalTemp |= ~0x1ff;
} else
finalTemp = rawTemp & 0xff;
return (finalTemp * 1000) / 2;
} else if (info.chipsetID >= RADEON_RV770) {
rawTemp = (Read32(OUT, R700_CG_MULT_THERMAL_STATUS) & R700_ASIC_T_MASK)
>> R700_ASIC_T_SHIFT;
if (rawTemp & 0x400)
finalTemp = -256;
else if (rawTemp & 0x200)
finalTemp = 255;
else if (rawTemp & 0x100) {
finalTemp = rawTemp & 0x1ff;
finalTemp |= ~0x1ff;
} else
finalTemp = rawTemp & 0xff;
return (finalTemp * 1000) / 2;
} else if (info.chipsetID >= RADEON_R600) {
rawTemp = (Read32(OUT, R600_CG_THERMAL_STATUS) & R600_ASIC_T_MASK)
>> R600_ASIC_T_SHIFT;
finalTemp = rawTemp & 0xff;
if (rawTemp & 0x100)
finalTemp -= 256;
return finalTemp * 1000;
}
return -1;
}
-1
View File
@@ -179,7 +179,6 @@ status_t radeon_gpu_irq_setup();
status_t radeon_gpu_gpio_setup();
status_t radeon_gpu_i2c_attach(uint32 id, uint8 hw_line);
bool radeon_gpu_read_edid(uint32 connector, edid1_info *edid);
int32 radeon_get_temp();
#endif
@@ -12,6 +12,7 @@ KernelAddon radeon_hd :
driver.cpp
device.cpp
radeon_hd.cpp
sensors.cpp
: libgraphicscommon.a
;
@@ -11,6 +11,7 @@
#include "radeon_hd.h"
#include "sensors.h"
#include "AreaKeeper.h"
#include "driver.h"
@@ -764,6 +765,10 @@ radeon_hd_init(radeon_info &info)
}
TRACE("card(%ld): %s completed successfully!\n", info.id, __func__);
TRACE("card(%ld): GPU thermal status: %" B_PRId32 "C\n", info.id,
radeon_thermal_query(info) / 1000);
return B_OK;
}
@@ -0,0 +1,89 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck IV, kallisti5@unixzen.com
*/
#include "sensors.h"
#define TRACE_DRIVER
#ifdef TRACE_DRIVER
# define TRACE(x...) dprintf("radeon_hd: " x)
#else
# define TRACE(x...) ;
#endif
int32
radeon_thermal_query(radeon_info &info)
{
// return GPU temp in millidegrees C
uint32 rawTemp = 0;
int32 finalTemp = 0;
if (info.chipsetID == RADEON_JUNIPER) {
uint32 offset = (read32(info.registers + EVERGREEN_CG_THERMAL_CTRL)
& EVERGREEN_TOFFSET_MASK) >> EVERGREEN_TOFFSET_SHIFT;
rawTemp = (read32(info.registers + EVERGREEN_CG_TS0_STATUS)
& EVERGREEN_TS0_ADC_DOUT_MASK) >> EVERGREEN_TS0_ADC_DOUT_SHIFT;
if (offset & 0x100)
finalTemp = rawTemp / 2 - (0x200 - offset);
else
finalTemp = rawTemp / 2 + offset;
return finalTemp * 1000;
} else if (info.chipsetID == RADEON_SUMO
|| info.chipsetID == RADEON_SUMO2) {
uint32 rawTemp = read32(info.registers + EVERGREEN_CG_THERMAL_STATUS)
& 0xff;
finalTemp = rawTemp - 49;
return finalTemp * 1000;
} else if (info.chipsetID >= RADEON_CEDAR) {
rawTemp = (read32(info.registers + EVERGREEN_CG_MULT_THERMAL_STATUS)
& EVERGREEN_ASIC_T_MASK) >> EVERGREEN_ASIC_T_SHIFT;
if (rawTemp & 0x400)
finalTemp = -256;
else if (rawTemp & 0x200)
finalTemp = 255;
else if (rawTemp & 0x100) {
finalTemp = rawTemp & 0x1ff;
finalTemp |= ~0x1ff;
} else
finalTemp = rawTemp & 0xff;
return (finalTemp * 1000) / 2;
} else if (info.chipsetID >= RADEON_RV770) {
rawTemp = (read32(info.registers + R700_CG_MULT_THERMAL_STATUS)
& R700_ASIC_T_MASK) >> R700_ASIC_T_SHIFT;
if (rawTemp & 0x400)
finalTemp = -256;
else if (rawTemp & 0x200)
finalTemp = 255;
else if (rawTemp & 0x100) {
finalTemp = rawTemp & 0x1ff;
finalTemp |= ~0x1ff;
} else
finalTemp = rawTemp & 0xff;
return (finalTemp * 1000) / 2;
} else if (info.chipsetID >= RADEON_R600) {
rawTemp = (read32(info.registers + R600_CG_THERMAL_STATUS)
& R600_ASIC_T_MASK) >> R600_ASIC_T_SHIFT;
finalTemp = rawTemp & 0xff;
if (rawTemp & 0x100)
finalTemp -= 256;
return finalTemp * 1000;
}
return -1;
}
@@ -0,0 +1,20 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck IV, kallisti5@unixzen.com
*/
#ifndef SENSORS_H
#define SENSORS_H
#include "driver.h"
#include "device.h"
#include "radeon_hd.h"
int32 radeon_thermal_query(radeon_info &info);
#endif /* SENSORS_H */