Skip to content

Commit

Permalink
Merge pull request #398 from dmatora/polaris
Browse files Browse the repository at this point in the history
Added broken support for Polaris cards (AMD RX 460/470/480/560/570/580)
  • Loading branch information
Cozmonat authored Feb 26, 2018
2 parents 3b11a55 + 5e1be83 commit 2563155
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
11 changes: 11 additions & 0 deletions GPUSensors/RadeonSensors/RadeonSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ bool RadeonSensors::managedStart(IOService *provider)
!strncasecmp("HAINAN", card.bios_name, 64)) {
card.int_thermal_type = THERMAL_TYPE_SI;
}
else if (!strncasecmp("POLARIS", card.bios_name, 64)) {
card.int_thermal_type = THERMAL_TYPE_PL;
}
else if (!strncasecmp("VEGA10", card.bios_name, 64)) {
card.int_thermal_type = THERMAL_TYPE_VEGA;
}
Expand Down Expand Up @@ -288,6 +291,10 @@ bool RadeonSensors::managedStart(IOService *provider)
card.int_thermal_type = THERMAL_TYPE_CI;
break;

case CHIP_FAMILY_POLARIS:
card.int_thermal_type = THERMAL_TYPE_PL;
break;

case CHIP_FAMILY_KAVERI:
case CHIP_FAMILY_KABINI:
card.int_thermal_type = THERMAL_TYPE_KV;
Expand Down Expand Up @@ -323,6 +330,10 @@ bool RadeonSensors::managedStart(IOService *provider)
card.get_core_temp = ci_get_temp;
radeon_info(&card, "adding Sea Islands (CI) thermal sensor\n");
break;
case THERMAL_TYPE_PL:
card.get_core_temp = pl_get_temp;
radeon_info(&card, "adding Arctic Islands (Polaris) thermal sensor\n");
break;
case THERMAL_TYPE_KV:
card.get_core_temp = kv_get_temp;
radeon_info(&card, "adding Sea Islands (Kaveri) thermal sensor\n");
Expand Down
19 changes: 19 additions & 0 deletions GPUSensors/RadeonSensors/cik.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ int ci_get_temp(struct radeon_device *rdev)
return actual_temp;
}

/* get temperature in millidegrees */
int pl_get_temp(struct radeon_device *rdev)
{
u32 temp;
int actual_temp = 0;

temp = (RREG32_IND(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >>
CTF_TEMP_SHIFT;

if (temp & 0x200)
actual_temp = 255;
else
actual_temp = temp & 0x1ff;

//actual_temp = actual_temp * 1000;

return actual_temp;
}

/* get temperature in millidegrees */
int kv_get_temp(struct radeon_device *rdev)
{
Expand Down
17 changes: 17 additions & 0 deletions GPUSensors/RadeonSensors/cik.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
#include "radeon.h"

#define RREG32_SMC(reg) tn_smc_rreg(rdev, (reg))
#define RREG32_IND(reg) mm_smc_rreg(rdev, (reg))
#define TN_SMC_IND_INDEX_0 0x200
#define TN_SMC_IND_DATA_0 0x204
#define MM_SMC_IND_INDEX_11 (0x1AC * 4)
#define MM_SMC_IND_DATA_11 (0x1AD * 4)

static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg)
{
Expand All @@ -56,8 +59,22 @@ static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg)
return r;
}

static inline u32 mm_smc_rreg(struct radeon_device *rdev, u32 reg)
{
//unsigned long flags;
u32 r;

//spin_lock_irqsave(&rdev->smc_idx_lock, flags);
WREG32(MM_SMC_IND_INDEX_11, (reg));
r = RREG32(MM_SMC_IND_DATA_11);

//spin_unlock_irqrestore(&rdev->smc_idx_lock, flags);
return r;
}


int ci_get_temp(struct radeon_device *rdev);
int pl_get_temp(struct radeon_device *rdev);
int kv_get_temp(struct radeon_device *rdev);

#endif
1 change: 1 addition & 0 deletions GPUSensors/RadeonSensors/radeon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum radeon_int_thermal_type {
THERMAL_TYPE_SI,
THERMAL_TYPE_EMC2103_WITH_INTERNAL,
THERMAL_TYPE_CI,
THERMAL_TYPE_PL,
THERMAL_TYPE_KV,
THERMAL_TYPE_VEGA,
};
Expand Down
2 changes: 2 additions & 0 deletions GPUSensors/RadeonSensors/radeon_chipinfo_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,6 @@ static RADEONCardInfo RADEONCards[] = {
{ 0x67B9, CHIP_FAMILY_HAWAII, 0, 0, 0, 0, 0 },
{ 0x67BA, CHIP_FAMILY_HAWAII, 0, 0, 0, 0, 0 },
{ 0x67BE, CHIP_FAMILY_HAWAII, 0, 0, 0, 0, 0 },
{ 0x67EF, CHIP_FAMILY_POLARIS, 0, 0, 0, 0, 0 },
{ 0x67DF, CHIP_FAMILY_POLARIS, 0, 0, 0, 0, 0 },
};
1 change: 1 addition & 0 deletions GPUSensors/RadeonSensors/radeon_family.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ enum radeon_family {
CHIP_FAMILY_KAVERI,
CHIP_FAMILY_KABINI,
CHIP_FAMILY_HAWAII,
CHIP_FAMILY_POLARIS,
CHIP_FAMILY_MULLINS,
CHIP_FAMILY_LAST
};
Expand Down

0 comments on commit 2563155

Please sign in to comment.