drm/radeon: make get_temperature functions a callback
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 21 Jun 2013 18:38:03 +0000 (14:38 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Jun 2013 14:49:16 +0000 (10:49 -0400)
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_pm.c

index 32f7640593f4281f8a6099436facc0b86e1de91a..91e615ff42888dcd2ecd0c3f3ec57d8dfe85bf8b 100644 (file)
@@ -220,11 +220,6 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
                                   struct atom_clock_dividers *dividers);
 void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
 void rs690_pm_info(struct radeon_device *rdev);
-extern int rv6xx_get_temp(struct radeon_device *rdev);
-extern int rv770_get_temp(struct radeon_device *rdev);
-extern int evergreen_get_temp(struct radeon_device *rdev);
-extern int sumo_get_temp(struct radeon_device *rdev);
-extern int si_get_temp(struct radeon_device *rdev);
 extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
                                    unsigned *bankh, unsigned *mtaspect,
                                    unsigned *tile_split);
@@ -1395,6 +1390,7 @@ struct radeon_asic {
                void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
                void (*set_clock_gating)(struct radeon_device *rdev, int enable);
                int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk);
+               int (*get_temperature)(struct radeon_device *rdev);
        } pm;
        /* pageflipping */
        struct {
@@ -2067,6 +2063,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
 #define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
 #define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
+#define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
index 25deb119d01eb437d629166b0cb9984ce8387486..9f5426388cf7dd70992811e75500f5b4af215064 100644 (file)
@@ -1052,6 +1052,7 @@ static struct radeon_asic r600_asic = {
                .get_pcie_lanes = &r600_get_pcie_lanes,
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = NULL,
+               .get_temperature = &rv6xx_get_temp,
        },
        .pflip = {
                .pre_page_flip = &rs600_pre_page_flip,
@@ -1146,6 +1147,7 @@ static struct radeon_asic rs780_asic = {
                .get_pcie_lanes = NULL,
                .set_pcie_lanes = NULL,
                .set_clock_gating = NULL,
+               .get_temperature = &rv6xx_get_temp,
        },
        .pflip = {
                .pre_page_flip = &rs600_pre_page_flip,
@@ -1253,6 +1255,7 @@ static struct radeon_asic rv770_asic = {
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = &radeon_atom_set_clock_gating,
                .set_uvd_clocks = &rv770_set_uvd_clocks,
+               .get_temperature = &rv770_get_temp,
        },
        .pflip = {
                .pre_page_flip = &rs600_pre_page_flip,
@@ -1360,6 +1363,7 @@ static struct radeon_asic evergreen_asic = {
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = NULL,
                .set_uvd_clocks = &evergreen_set_uvd_clocks,
+               .get_temperature = &evergreen_get_temp,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
@@ -1467,6 +1471,7 @@ static struct radeon_asic sumo_asic = {
                .set_pcie_lanes = NULL,
                .set_clock_gating = NULL,
                .set_uvd_clocks = &sumo_set_uvd_clocks,
+               .get_temperature = &sumo_get_temp,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
@@ -1574,6 +1579,7 @@ static struct radeon_asic btc_asic = {
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = NULL,
                .set_uvd_clocks = &evergreen_set_uvd_clocks,
+               .get_temperature = &evergreen_get_temp,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
@@ -1733,6 +1739,7 @@ static struct radeon_asic cayman_asic = {
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = NULL,
                .set_uvd_clocks = &evergreen_set_uvd_clocks,
+               .get_temperature = &evergreen_get_temp,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
@@ -2047,6 +2054,7 @@ static struct radeon_asic si_asic = {
                .set_pcie_lanes = &r600_set_pcie_lanes,
                .set_clock_gating = NULL,
                .set_uvd_clocks = &si_set_uvd_clocks,
+               .get_temperature = &si_get_temp,
        },
        .pflip = {
                .pre_page_flip = &evergreen_pre_page_flip,
index 68ba3ff5195e8c62dde91d4cf4e3a448c6d2950f..74f04a8c7db446897c2238e1a0ee42730cc5bfb9 100644 (file)
@@ -401,6 +401,7 @@ void r600_kms_blit_copy(struct radeon_device *rdev,
 int r600_mc_wait_for_idle(struct radeon_device *rdev);
 u32 r600_get_xclk(struct radeon_device *rdev);
 uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev);
+int rv6xx_get_temp(struct radeon_device *rdev);
 
 /* uvd */
 int r600_uvd_init(struct radeon_device *rdev);
@@ -434,6 +435,7 @@ int rv770_copy_dma(struct radeon_device *rdev,
 u32 rv770_get_xclk(struct radeon_device *rdev);
 int rv770_uvd_resume(struct radeon_device *rdev);
 int rv770_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
+int rv770_get_temp(struct radeon_device *rdev);
 
 /*
  * evergreen
@@ -488,6 +490,8 @@ int evergreen_copy_dma(struct radeon_device *rdev,
                       struct radeon_fence **fence);
 void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable);
 void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
+int evergreen_get_temp(struct radeon_device *rdev);
+int sumo_get_temp(struct radeon_device *rdev);
 
 /*
  * cayman
@@ -558,6 +562,7 @@ void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
 u32 si_get_xclk(struct radeon_device *rdev);
 uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev);
 int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
+int si_get_temp(struct radeon_device *rdev);
 
 /* DCE8 - CIK */
 void dce8_bandwidth_update(struct radeon_device *rdev);
index 788c64cb4b47e95ef66edbc1d5fcbbefb01c2e95..e8c1bea9b57b6f0fe95d6bad2ff179f66664ae14 100644 (file)
@@ -434,27 +434,10 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev,
        struct radeon_device *rdev = ddev->dev_private;
        int temp;
 
-       switch (rdev->pm.int_thermal_type) {
-       case THERMAL_TYPE_RV6XX:
-               temp = rv6xx_get_temp(rdev);
-               break;
-       case THERMAL_TYPE_RV770:
-               temp = rv770_get_temp(rdev);
-               break;
-       case THERMAL_TYPE_EVERGREEN:
-       case THERMAL_TYPE_NI:
-               temp = evergreen_get_temp(rdev);
-               break;
-       case THERMAL_TYPE_SUMO:
-               temp = sumo_get_temp(rdev);
-               break;
-       case THERMAL_TYPE_SI:
-               temp = si_get_temp(rdev);
-               break;
-       default:
+       if (rdev->asic->pm.get_temperature)
+               temp = radeon_get_temperature(rdev);
+       else
                temp = 0;
-               break;
-       }
 
        return snprintf(buf, PAGE_SIZE, "%d\n", temp);
 }
@@ -492,8 +475,7 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
        case THERMAL_TYPE_NI:
        case THERMAL_TYPE_SUMO:
        case THERMAL_TYPE_SI:
-               /* No support for TN yet */
-               if (rdev->family == CHIP_ARUBA)
+               if (rdev->asic->pm.get_temperature == NULL)
                        return err;
                rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev);
                if (IS_ERR(rdev->pm.int_hwmon_dev)) {