drm/radeon/dpm: move platform caps fetching to a separate function
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 21 Aug 2013 14:02:32 +0000 (10:02 -0400)
committerChristian König <christian.koenig@amd.com>
Tue, 18 Feb 2014 15:11:30 +0000 (16:11 +0100)
It's needed by by both the asic specific functions and the
extended table parser.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
13 files changed:
drivers/gpu/drm/radeon/btc_dpm.c
drivers/gpu/drm/radeon/ci_dpm.c
drivers/gpu/drm/radeon/cypress_dpm.c
drivers/gpu/drm/radeon/kv_dpm.c
drivers/gpu/drm/radeon/ni_dpm.c
drivers/gpu/drm/radeon/r600_dpm.c
drivers/gpu/drm/radeon/r600_dpm.h
drivers/gpu/drm/radeon/rs780_dpm.c
drivers/gpu/drm/radeon/rv6xx_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.c
drivers/gpu/drm/radeon/si_dpm.c
drivers/gpu/drm/radeon/sumo_dpm.c
drivers/gpu/drm/radeon/trinity_dpm.c

index ea103ccdf4bd517205b95e82a1437e4cf510f8f2..f81d7ca134db19d12782f2005177639e64b6a44c 100644 (file)
@@ -2601,6 +2601,10 @@ int btc_dpm_init(struct radeon_device *rdev)
        pi->min_vddc_in_table = 0;
        pi->max_vddc_in_table = 0;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = rv7xx_parse_power_table(rdev);
        if (ret)
                return ret;
index 8d49104ca6c254efa86f4287059323be28ba3f29..4a0c4018604672c295fe4bb42f0f1bcf0348e9d7 100644 (file)
@@ -4959,9 +4959,6 @@ static int ci_parse_power_table(struct radeon_device *rdev)
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
        for (i = 0; i < state_array->ucNumEntries; i++) {
                u8 *idx;
                power_state = (union pplib_power_state *)power_state_offset;
@@ -5077,6 +5074,12 @@ int ci_dpm_init(struct radeon_device *rdev)
                ci_dpm_fini(rdev);
                return ret;
        }
+
+       ret = r600_get_platform_caps(rdev);
+       if (ret) {
+               ci_dpm_fini(rdev);
+               return ret;
+       }
        ret = ci_parse_power_table(rdev);
        if (ret) {
                ci_dpm_fini(rdev);
index cf783fc0ef21920f7d0e50156bddbd9c24299150..5a9a5f4d7888ca5775a299293d2bc2f2aa47c8d9 100644 (file)
@@ -2036,6 +2036,10 @@ int cypress_dpm_init(struct radeon_device *rdev)
        pi->min_vddc_in_table = 0;
        pi->max_vddc_in_table = 0;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = rv7xx_parse_power_table(rdev);
        if (ret)
                return ret;
index 351db361239db1d2800f845b2e9e9d02d541cc2b..b5bb3a5654ce1464936f0472bfbe9c257470b8f7 100644 (file)
@@ -2538,9 +2538,6 @@ static int kv_parse_power_table(struct radeon_device *rdev)
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
        for (i = 0; i < state_array->ucNumEntries; i++) {
                u8 *idx;
                power_state = (union pplib_power_state *)power_state_offset;
@@ -2590,6 +2587,10 @@ int kv_dpm_init(struct radeon_device *rdev)
                return -ENOMEM;
        rdev->pm.dpm.priv = pi;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = r600_parse_extended_power_table(rdev);
        if (ret)
                return ret;
index 1217fbcbdcca1521a81a3cf57ff844f743210347..89fc5b976d9bb31f2772ae806c0d1857e9203e95 100644 (file)
@@ -4025,9 +4025,6 @@ static int ni_parse_power_table(struct radeon_device *rdev)
                                  power_info->pplib.ucNumStates, GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
 
        for (i = 0; i < power_info->pplib.ucNumStates; i++) {
                power_state = (union pplib_power_state *)
@@ -4089,6 +4086,10 @@ int ni_dpm_init(struct radeon_device *rdev)
        pi->min_vddc_in_table = 0;
        pi->max_vddc_in_table = 0;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = ni_parse_power_table(rdev);
        if (ret)
                return ret;
index e4cc9b314ce974fe5caacf91a000cb9a76a584d6..e8b6e4ab312bda864fcda9eba68d3c7d6e6f20d5 100644 (file)
@@ -834,6 +834,26 @@ static int r600_parse_clk_voltage_dep_table(struct radeon_clock_voltage_dependen
        return 0;
 }
 
+int r600_get_platform_caps(struct radeon_device *rdev)
+{
+       struct radeon_mode_info *mode_info = &rdev->mode_info;
+       union power_info *power_info;
+       int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
+        u16 data_offset;
+       u8 frev, crev;
+
+       if (!atom_parse_data_header(mode_info->atom_context, index, NULL,
+                                  &frev, &crev, &data_offset))
+               return -EINVAL;
+       power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
+
+       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
+       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
+       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
+
+       return 0;
+}
+
 /* sizeof(ATOM_PPLIB_EXTENDEDHEADER) */
 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V2 12
 #define SIZE_OF_ATOM_PPLIB_EXTENDEDHEADER_V3 14
index 07eab2b04e81b5db420a6ee96152c8b8e94e4092..46b9d2a03018d854cb07c72d3eaeee9aa8f4a10d 100644 (file)
@@ -215,6 +215,8 @@ void r600_stop_dpm(struct radeon_device *rdev);
 
 bool r600_is_internal_thermal_sensor(enum radeon_int_thermal_type sensor);
 
+int r600_get_platform_caps(struct radeon_device *rdev);
+
 int r600_parse_extended_power_table(struct radeon_device *rdev);
 void r600_free_extended_power_table(struct radeon_device *rdev);
 
index 8512085b0aefe0139c6ffabdc69114510ae3e2f3..02f7710de4700f59ae21b98f49bfc04cda5383b3 100644 (file)
@@ -807,9 +807,6 @@ static int rs780_parse_power_table(struct radeon_device *rdev)
                                  power_info->pplib.ucNumStates, GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
 
        for (i = 0; i < power_info->pplib.ucNumStates; i++) {
                power_state = (union pplib_power_state *)
@@ -859,6 +856,10 @@ int rs780_dpm_init(struct radeon_device *rdev)
                return -ENOMEM;
        rdev->pm.dpm.priv = pi;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = rs780_parse_power_table(rdev);
        if (ret)
                return ret;
index bebf31c4d841ccaa07b86d9bae96c7abb5c223be..e7045b08571567989dc9ac7a30d86cbda793cbf2 100644 (file)
@@ -1891,9 +1891,6 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
                                  power_info->pplib.ucNumStates, GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
 
        for (i = 0; i < power_info->pplib.ucNumStates; i++) {
                power_state = (union pplib_power_state *)
@@ -1943,6 +1940,10 @@ int rv6xx_dpm_init(struct radeon_device *rdev)
                return -ENOMEM;
        rdev->pm.dpm.priv = pi;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = rv6xx_parse_power_table(rdev);
        if (ret)
                return ret;
index 5b2ea8ac07312c8380b563b85b885b5f90ad8edb..9098c86ca006007133725c3b9ee5f425b9b8e361 100644 (file)
@@ -2281,9 +2281,6 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
                                  power_info->pplib.ucNumStates, GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
 
        for (i = 0; i < power_info->pplib.ucNumStates; i++) {
                power_state = (union pplib_power_state *)
@@ -2361,6 +2358,10 @@ int rv770_dpm_init(struct radeon_device *rdev)
        pi->min_vddc_in_table = 0;
        pi->max_vddc_in_table = 0;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = rv7xx_parse_power_table(rdev);
        if (ret)
                return ret;
index eafb0e6bc67ec5c7207d087ef0abc0e087c2f3a1..d5024778cabefec066abf7e5a4ae8c4fb2c896fb 100644 (file)
@@ -6271,9 +6271,6 @@ static int si_parse_power_table(struct radeon_device *rdev)
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
        for (i = 0; i < state_array->ucNumEntries; i++) {
                u8 *idx;
                power_state = (union pplib_power_state *)power_state_offset;
@@ -6350,6 +6347,10 @@ int si_dpm_init(struct radeon_device *rdev)
        pi->min_vddc_in_table = 0;
        pi->max_vddc_in_table = 0;
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = si_parse_power_table(rdev);
        if (ret)
                return ret;
index 8b47b3cd0357cf7065aace2c90fa0751b203b506..3f0e8d7b8dbe3995a54862a48d25f812149a31fb 100644 (file)
@@ -1484,9 +1484,6 @@ static int sumo_parse_power_table(struct radeon_device *rdev)
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
        for (i = 0; i < state_array->ucNumEntries; i++) {
                u8 *idx;
                power_state = (union pplib_power_state *)power_state_offset;
@@ -1772,6 +1769,10 @@ int sumo_dpm_init(struct radeon_device *rdev)
 
        sumo_construct_boot_and_acpi_state(rdev);
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = sumo_parse_power_table(rdev);
        if (ret)
                return ret;
index 2da0e17eb96060e3027e185106e5f4366561d799..2a2822c03329e7fcefcb016e3e7bae5128c45777 100644 (file)
@@ -1694,9 +1694,6 @@ static int trinity_parse_power_table(struct radeon_device *rdev)
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
-       rdev->pm.dpm.platform_caps = le32_to_cpu(power_info->pplib.ulPlatformCaps);
-       rdev->pm.dpm.backbias_response_time = le16_to_cpu(power_info->pplib.usBackbiasTime);
-       rdev->pm.dpm.voltage_response_time = le16_to_cpu(power_info->pplib.usVoltageTime);
        for (i = 0; i < state_array->ucNumEntries; i++) {
                u8 *idx;
                power_state = (union pplib_power_state *)power_state_offset;
@@ -1895,6 +1892,10 @@ int trinity_dpm_init(struct radeon_device *rdev)
 
        trinity_construct_boot_state(rdev);
 
+       ret = r600_get_platform_caps(rdev);
+       if (ret)
+               return ret;
+
        ret = trinity_parse_power_table(rdev);
        if (ret)
                return ret;