aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon.h')
-rw-r--r--drivers/gpu/drm/radeon/radeon.h535
1 files changed, 526 insertions, 9 deletions
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 142ce6cc69f5..9b7025d02cd0 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -96,6 +96,7 @@ extern int radeon_pcie_gen2;
96extern int radeon_msi; 96extern int radeon_msi;
97extern int radeon_lockup_timeout; 97extern int radeon_lockup_timeout;
98extern int radeon_fastfb; 98extern int radeon_fastfb;
99extern int radeon_dpm;
99 100
100/* 101/*
101 * Copy from radeon_drv.h so we don't have to include both and have conflicting 102 * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -150,6 +151,13 @@ extern int radeon_fastfb;
150#define RADEON_RESET_MC (1 << 10) 151#define RADEON_RESET_MC (1 << 10)
151#define RADEON_RESET_DISPLAY (1 << 11) 152#define RADEON_RESET_DISPLAY (1 << 11)
152 153
154/* max cursor sizes (in pixels) */
155#define CURSOR_WIDTH 64
156#define CURSOR_HEIGHT 64
157
158#define CIK_CURSOR_WIDTH 128
159#define CIK_CURSOR_HEIGHT 128
160
153/* 161/*
154 * Errata workarounds. 162 * Errata workarounds.
155 */ 163 */
@@ -192,6 +200,7 @@ struct radeon_clock {
192 uint32_t default_mclk; 200 uint32_t default_mclk;
193 uint32_t default_sclk; 201 uint32_t default_sclk;
194 uint32_t default_dispclk; 202 uint32_t default_dispclk;
203 uint32_t current_dispclk;
195 uint32_t dp_extclk; 204 uint32_t dp_extclk;
196 uint32_t max_pixel_clock; 205 uint32_t max_pixel_clock;
197}; 206};
@@ -211,13 +220,51 @@ int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
211 u32 clock, 220 u32 clock,
212 bool strobe_mode, 221 bool strobe_mode,
213 struct atom_clock_dividers *dividers); 222 struct atom_clock_dividers *dividers);
223int radeon_atom_get_memory_pll_dividers(struct radeon_device *rdev,
224 u32 clock,
225 bool strobe_mode,
226 struct atom_mpll_param *mpll_param);
214void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type); 227void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
228int radeon_atom_get_voltage_gpio_settings(struct radeon_device *rdev,
229 u16 voltage_level, u8 voltage_type,
230 u32 *gpio_value, u32 *gpio_mask);
231void radeon_atom_set_engine_dram_timings(struct radeon_device *rdev,
232 u32 eng_clock, u32 mem_clock);
233int radeon_atom_get_voltage_step(struct radeon_device *rdev,
234 u8 voltage_type, u16 *voltage_step);
235int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
236 u16 voltage_id, u16 *voltage);
237int radeon_atom_get_leakage_vddc_based_on_leakage_idx(struct radeon_device *rdev,
238 u16 *voltage,
239 u16 leakage_idx);
240int radeon_atom_round_to_true_voltage(struct radeon_device *rdev,
241 u8 voltage_type,
242 u16 nominal_voltage,
243 u16 *true_voltage);
244int radeon_atom_get_min_voltage(struct radeon_device *rdev,
245 u8 voltage_type, u16 *min_voltage);
246int radeon_atom_get_max_voltage(struct radeon_device *rdev,
247 u8 voltage_type, u16 *max_voltage);
248int radeon_atom_get_voltage_table(struct radeon_device *rdev,
249 u8 voltage_type, u8 voltage_mode,
250 struct atom_voltage_table *voltage_table);
251bool radeon_atom_is_voltage_gpio(struct radeon_device *rdev,
252 u8 voltage_type, u8 voltage_mode);
253void radeon_atom_update_memory_dll(struct radeon_device *rdev,
254 u32 mem_clock);
255void radeon_atom_set_ac_timing(struct radeon_device *rdev,
256 u32 mem_clock);
257int radeon_atom_init_mc_reg_table(struct radeon_device *rdev,
258 u8 module_index,
259 struct atom_mc_reg_table *reg_table);
260int radeon_atom_get_memory_info(struct radeon_device *rdev,
261 u8 module_index, struct atom_memory_info *mem_info);
262int radeon_atom_get_mclk_range_table(struct radeon_device *rdev,
263 bool gddr5, u8 module_index,
264 struct atom_memory_clock_range_table *mclk_range_table);
265int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
266 u16 voltage_id, u16 *voltage);
215void rs690_pm_info(struct radeon_device *rdev); 267void rs690_pm_info(struct radeon_device *rdev);
216extern int rv6xx_get_temp(struct radeon_device *rdev);
217extern int rv770_get_temp(struct radeon_device *rdev);
218extern int evergreen_get_temp(struct radeon_device *rdev);
219extern int sumo_get_temp(struct radeon_device *rdev);
220extern int si_get_temp(struct radeon_device *rdev);
221extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw, 268extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
222 unsigned *bankh, unsigned *mtaspect, 269 unsigned *bankh, unsigned *mtaspect,
223 unsigned *tile_split); 270 unsigned *tile_split);
@@ -549,6 +596,20 @@ struct radeon_scratch {
549int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg); 596int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
550void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg); 597void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
551 598
599/*
600 * GPU doorbell structures, functions & helpers
601 */
602struct radeon_doorbell {
603 u32 num_pages;
604 bool free[1024];
605 /* doorbell mmio */
606 resource_size_t base;
607 resource_size_t size;
608 void __iomem *ptr;
609};
610
611int radeon_doorbell_get(struct radeon_device *rdev, u32 *page);
612void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell);
552 613
553/* 614/*
554 * IRQS. 615 * IRQS.
@@ -600,10 +661,21 @@ struct evergreen_irq_stat_regs {
600 u32 afmt_status6; 661 u32 afmt_status6;
601}; 662};
602 663
664struct cik_irq_stat_regs {
665 u32 disp_int;
666 u32 disp_int_cont;
667 u32 disp_int_cont2;
668 u32 disp_int_cont3;
669 u32 disp_int_cont4;
670 u32 disp_int_cont5;
671 u32 disp_int_cont6;
672};
673
603union radeon_irq_stat_regs { 674union radeon_irq_stat_regs {
604 struct r500_irq_stat_regs r500; 675 struct r500_irq_stat_regs r500;
605 struct r600_irq_stat_regs r600; 676 struct r600_irq_stat_regs r600;
606 struct evergreen_irq_stat_regs evergreen; 677 struct evergreen_irq_stat_regs evergreen;
678 struct cik_irq_stat_regs cik;
607}; 679};
608 680
609#define RADEON_MAX_HPD_PINS 6 681#define RADEON_MAX_HPD_PINS 6
@@ -620,6 +692,7 @@ struct radeon_irq {
620 bool hpd[RADEON_MAX_HPD_PINS]; 692 bool hpd[RADEON_MAX_HPD_PINS];
621 bool afmt[RADEON_MAX_AFMT_BLOCKS]; 693 bool afmt[RADEON_MAX_AFMT_BLOCKS];
622 union radeon_irq_stat_regs stat_regs; 694 union radeon_irq_stat_regs stat_regs;
695 bool dpm_thermal;
623}; 696};
624 697
625int radeon_irq_kms_init(struct radeon_device *rdev); 698int radeon_irq_kms_init(struct radeon_device *rdev);
@@ -677,6 +750,22 @@ struct radeon_ring {
677 u32 idx; 750 u32 idx;
678 u64 last_semaphore_signal_addr; 751 u64 last_semaphore_signal_addr;
679 u64 last_semaphore_wait_addr; 752 u64 last_semaphore_wait_addr;
753 /* for CIK queues */
754 u32 me;
755 u32 pipe;
756 u32 queue;
757 struct radeon_bo *mqd_obj;
758 u32 doorbell_page_num;
759 u32 doorbell_offset;
760 unsigned wptr_offs;
761};
762
763struct radeon_mec {
764 struct radeon_bo *hpd_eop_obj;
765 u64 hpd_eop_gpu_addr;
766 u32 num_pipe;
767 u32 num_mec;
768 u32 num_queue;
680}; 769};
681 770
682/* 771/*
@@ -778,15 +867,22 @@ struct r600_blit {
778}; 867};
779 868
780/* 869/*
781 * SI RLC stuff 870 * RLC stuff
782 */ 871 */
783struct si_rlc { 872#include "clearstate_defs.h"
873
874struct radeon_rlc {
784 /* for power gating */ 875 /* for power gating */
785 struct radeon_bo *save_restore_obj; 876 struct radeon_bo *save_restore_obj;
786 uint64_t save_restore_gpu_addr; 877 uint64_t save_restore_gpu_addr;
878 volatile uint32_t *sr_ptr;
879 u32 *reg_list;
880 u32 reg_list_size;
787 /* for clear state */ 881 /* for clear state */
788 struct radeon_bo *clear_state_obj; 882 struct radeon_bo *clear_state_obj;
789 uint64_t clear_state_gpu_addr; 883 uint64_t clear_state_gpu_addr;
884 volatile uint32_t *cs_ptr;
885 struct cs_section_def *cs_data;
790}; 886};
791 887
792int radeon_ib_get(struct radeon_device *rdev, int ring, 888int radeon_ib_get(struct radeon_device *rdev, int ring,
@@ -883,6 +979,7 @@ struct radeon_cs_parser {
883 u32 cs_flags; 979 u32 cs_flags;
884 u32 ring; 980 u32 ring;
885 s32 priority; 981 s32 priority;
982 struct ww_acquire_ctx ticket;
886}; 983};
887 984
888extern int radeon_cs_finish_pages(struct radeon_cs_parser *p); 985extern int radeon_cs_finish_pages(struct radeon_cs_parser *p);
@@ -934,6 +1031,8 @@ struct radeon_wb {
934#define CAYMAN_WB_DMA1_RPTR_OFFSET 2304 1031#define CAYMAN_WB_DMA1_RPTR_OFFSET 2304
935#define R600_WB_UVD_RPTR_OFFSET 2560 1032#define R600_WB_UVD_RPTR_OFFSET 2560
936#define R600_WB_EVENT_OFFSET 3072 1033#define R600_WB_EVENT_OFFSET 3072
1034#define CIK_WB_CP1_WPTR_OFFSET 3328
1035#define CIK_WB_CP2_WPTR_OFFSET 3584
937 1036
938/** 1037/**
939 * struct radeon_pm - power management datas 1038 * struct radeon_pm - power management datas
@@ -958,6 +1057,7 @@ struct radeon_wb {
958enum radeon_pm_method { 1057enum radeon_pm_method {
959 PM_METHOD_PROFILE, 1058 PM_METHOD_PROFILE,
960 PM_METHOD_DYNPM, 1059 PM_METHOD_DYNPM,
1060 PM_METHOD_DPM,
961}; 1061};
962 1062
963enum radeon_dynpm_state { 1063enum radeon_dynpm_state {
@@ -983,11 +1083,24 @@ enum radeon_voltage_type {
983}; 1083};
984 1084
985enum radeon_pm_state_type { 1085enum radeon_pm_state_type {
1086 /* not used for dpm */
986 POWER_STATE_TYPE_DEFAULT, 1087 POWER_STATE_TYPE_DEFAULT,
987 POWER_STATE_TYPE_POWERSAVE, 1088 POWER_STATE_TYPE_POWERSAVE,
1089 /* user selectable states */
988 POWER_STATE_TYPE_BATTERY, 1090 POWER_STATE_TYPE_BATTERY,
989 POWER_STATE_TYPE_BALANCED, 1091 POWER_STATE_TYPE_BALANCED,
990 POWER_STATE_TYPE_PERFORMANCE, 1092 POWER_STATE_TYPE_PERFORMANCE,
1093 /* internal states */
1094 POWER_STATE_TYPE_INTERNAL_UVD,
1095 POWER_STATE_TYPE_INTERNAL_UVD_SD,
1096 POWER_STATE_TYPE_INTERNAL_UVD_HD,
1097 POWER_STATE_TYPE_INTERNAL_UVD_HD2,
1098 POWER_STATE_TYPE_INTERNAL_UVD_MVC,
1099 POWER_STATE_TYPE_INTERNAL_BOOT,
1100 POWER_STATE_TYPE_INTERNAL_THERMAL,
1101 POWER_STATE_TYPE_INTERNAL_ACPI,
1102 POWER_STATE_TYPE_INTERNAL_ULV,
1103 POWER_STATE_TYPE_INTERNAL_3DPERF,
991}; 1104};
992 1105
993enum radeon_pm_profile_type { 1106enum radeon_pm_profile_type {
@@ -1016,12 +1129,17 @@ struct radeon_pm_profile {
1016 1129
1017enum radeon_int_thermal_type { 1130enum radeon_int_thermal_type {
1018 THERMAL_TYPE_NONE, 1131 THERMAL_TYPE_NONE,
1132 THERMAL_TYPE_EXTERNAL,
1133 THERMAL_TYPE_EXTERNAL_GPIO,
1019 THERMAL_TYPE_RV6XX, 1134 THERMAL_TYPE_RV6XX,
1020 THERMAL_TYPE_RV770, 1135 THERMAL_TYPE_RV770,
1136 THERMAL_TYPE_ADT7473_WITH_INTERNAL,
1021 THERMAL_TYPE_EVERGREEN, 1137 THERMAL_TYPE_EVERGREEN,
1022 THERMAL_TYPE_SUMO, 1138 THERMAL_TYPE_SUMO,
1023 THERMAL_TYPE_NI, 1139 THERMAL_TYPE_NI,
1024 THERMAL_TYPE_SI, 1140 THERMAL_TYPE_SI,
1141 THERMAL_TYPE_EMC2103_WITH_INTERNAL,
1142 THERMAL_TYPE_CI,
1025}; 1143};
1026 1144
1027struct radeon_voltage { 1145struct radeon_voltage {
@@ -1075,6 +1193,201 @@ struct radeon_power_state {
1075 */ 1193 */
1076#define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */ 1194#define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
1077 1195
1196enum radeon_dpm_auto_throttle_src {
1197 RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL,
1198 RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL
1199};
1200
1201enum radeon_dpm_event_src {
1202 RADEON_DPM_EVENT_SRC_ANALOG = 0,
1203 RADEON_DPM_EVENT_SRC_EXTERNAL = 1,
1204 RADEON_DPM_EVENT_SRC_DIGITAL = 2,
1205 RADEON_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3,
1206 RADEON_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
1207};
1208
1209struct radeon_ps {
1210 u32 caps; /* vbios flags */
1211 u32 class; /* vbios flags */
1212 u32 class2; /* vbios flags */
1213 /* UVD clocks */
1214 u32 vclk;
1215 u32 dclk;
1216 /* asic priv */
1217 void *ps_priv;
1218};
1219
1220struct radeon_dpm_thermal {
1221 /* thermal interrupt work */
1222 struct work_struct work;
1223 /* low temperature threshold */
1224 int min_temp;
1225 /* high temperature threshold */
1226 int max_temp;
1227 /* was interrupt low to high or high to low */
1228 bool high_to_low;
1229};
1230
1231enum radeon_clk_action
1232{
1233 RADEON_SCLK_UP = 1,
1234 RADEON_SCLK_DOWN
1235};
1236
1237struct radeon_blacklist_clocks
1238{
1239 u32 sclk;
1240 u32 mclk;
1241 enum radeon_clk_action action;
1242};
1243
1244struct radeon_clock_and_voltage_limits {
1245 u32 sclk;
1246 u32 mclk;
1247 u32 vddc;
1248 u32 vddci;
1249};
1250
1251struct radeon_clock_array {
1252 u32 count;
1253 u32 *values;
1254};
1255
1256struct radeon_clock_voltage_dependency_entry {
1257 u32 clk;
1258 u16 v;
1259};
1260
1261struct radeon_clock_voltage_dependency_table {
1262 u32 count;
1263 struct radeon_clock_voltage_dependency_entry *entries;
1264};
1265
1266struct radeon_cac_leakage_entry {
1267 u16 vddc;
1268 u32 leakage;
1269};
1270
1271struct radeon_cac_leakage_table {
1272 u32 count;
1273 struct radeon_cac_leakage_entry *entries;
1274};
1275
1276struct radeon_phase_shedding_limits_entry {
1277 u16 voltage;
1278 u32 sclk;
1279 u32 mclk;
1280};
1281
1282struct radeon_phase_shedding_limits_table {
1283 u32 count;
1284 struct radeon_phase_shedding_limits_entry *entries;
1285};
1286
1287struct radeon_ppm_table {
1288 u8 ppm_design;
1289 u16 cpu_core_number;
1290 u32 platform_tdp;
1291 u32 small_ac_platform_tdp;
1292 u32 platform_tdc;
1293 u32 small_ac_platform_tdc;
1294 u32 apu_tdp;
1295 u32 dgpu_tdp;
1296 u32 dgpu_ulv_power;
1297 u32 tj_max;
1298};
1299
1300struct radeon_dpm_dynamic_state {
1301 struct radeon_clock_voltage_dependency_table vddc_dependency_on_sclk;
1302 struct radeon_clock_voltage_dependency_table vddci_dependency_on_mclk;
1303 struct radeon_clock_voltage_dependency_table vddc_dependency_on_mclk;
1304 struct radeon_clock_voltage_dependency_table vddc_dependency_on_dispclk;
1305 struct radeon_clock_array valid_sclk_values;
1306 struct radeon_clock_array valid_mclk_values;
1307 struct radeon_clock_and_voltage_limits max_clock_voltage_on_dc;
1308 struct radeon_clock_and_voltage_limits max_clock_voltage_on_ac;
1309 u32 mclk_sclk_ratio;
1310 u32 sclk_mclk_delta;
1311 u16 vddc_vddci_delta;
1312 u16 min_vddc_for_pcie_gen2;
1313 struct radeon_cac_leakage_table cac_leakage_table;
1314 struct radeon_phase_shedding_limits_table phase_shedding_limits_table;
1315 struct radeon_ppm_table *ppm_table;
1316};
1317
1318struct radeon_dpm_fan {
1319 u16 t_min;
1320 u16 t_med;
1321 u16 t_high;
1322 u16 pwm_min;
1323 u16 pwm_med;
1324 u16 pwm_high;
1325 u8 t_hyst;
1326 u32 cycle_delay;
1327 u16 t_max;
1328 bool ucode_fan_control;
1329};
1330
1331enum radeon_pcie_gen {
1332 RADEON_PCIE_GEN1 = 0,
1333 RADEON_PCIE_GEN2 = 1,
1334 RADEON_PCIE_GEN3 = 2,
1335 RADEON_PCIE_GEN_INVALID = 0xffff
1336};
1337
1338enum radeon_dpm_forced_level {
1339 RADEON_DPM_FORCED_LEVEL_AUTO = 0,
1340 RADEON_DPM_FORCED_LEVEL_LOW = 1,
1341 RADEON_DPM_FORCED_LEVEL_HIGH = 2,
1342};
1343
1344struct radeon_dpm {
1345 struct radeon_ps *ps;
1346 /* number of valid power states */
1347 int num_ps;
1348 /* current power state that is active */
1349 struct radeon_ps *current_ps;
1350 /* requested power state */
1351 struct radeon_ps *requested_ps;
1352 /* boot up power state */
1353 struct radeon_ps *boot_ps;
1354 /* default uvd power state */
1355 struct radeon_ps *uvd_ps;
1356 enum radeon_pm_state_type state;
1357 enum radeon_pm_state_type user_state;
1358 u32 platform_caps;
1359 u32 voltage_response_time;
1360 u32 backbias_response_time;
1361 void *priv;
1362 u32 new_active_crtcs;
1363 int new_active_crtc_count;
1364 u32 current_active_crtcs;
1365 int current_active_crtc_count;
1366 struct radeon_dpm_dynamic_state dyn_state;
1367 struct radeon_dpm_fan fan;
1368 u32 tdp_limit;
1369 u32 near_tdp_limit;
1370 u32 near_tdp_limit_adjusted;
1371 u32 sq_ramping_threshold;
1372 u32 cac_leakage;
1373 u16 tdp_od_limit;
1374 u32 tdp_adjustment;
1375 u16 load_line_slope;
1376 bool power_control;
1377 bool ac_power;
1378 /* special states active */
1379 bool thermal_active;
1380 bool uvd_active;
1381 /* thermal handling */
1382 struct radeon_dpm_thermal thermal;
1383 /* forced levels */
1384 enum radeon_dpm_forced_level forced_level;
1385};
1386
1387void radeon_dpm_enable_power_state(struct radeon_device *rdev,
1388 enum radeon_pm_state_type dpm_state);
1389
1390
1078struct radeon_pm { 1391struct radeon_pm {
1079 struct mutex mutex; 1392 struct mutex mutex;
1080 /* write locked while reprogramming mclk */ 1393 /* write locked while reprogramming mclk */
@@ -1128,6 +1441,9 @@ struct radeon_pm {
1128 /* internal thermal controller on rv6xx+ */ 1441 /* internal thermal controller on rv6xx+ */
1129 enum radeon_int_thermal_type int_thermal_type; 1442 enum radeon_int_thermal_type int_thermal_type;
1130 struct device *int_hwmon_dev; 1443 struct device *int_hwmon_dev;
1444 /* dpm */
1445 bool dpm_enabled;
1446 struct radeon_dpm dpm;
1131}; 1447};
1132 1448
1133int radeon_pm_get_type_index(struct radeon_device *rdev, 1449int radeon_pm_get_type_index(struct radeon_device *rdev,
@@ -1266,6 +1582,10 @@ struct radeon_asic {
1266 int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp); 1582 int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp);
1267 bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp); 1583 bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
1268 void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); 1584 void (*vm_flush)(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
1585
1586 u32 (*get_rptr)(struct radeon_device *rdev, struct radeon_ring *ring);
1587 u32 (*get_wptr)(struct radeon_device *rdev, struct radeon_ring *ring);
1588 void (*set_wptr)(struct radeon_device *rdev, struct radeon_ring *ring);
1269 } ring[RADEON_NUM_RINGS]; 1589 } ring[RADEON_NUM_RINGS];
1270 /* irqs */ 1590 /* irqs */
1271 struct { 1591 struct {
@@ -1325,7 +1645,7 @@ struct radeon_asic {
1325 bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd); 1645 bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1326 void (*set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd); 1646 void (*set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
1327 } hpd; 1647 } hpd;
1328 /* power management */ 1648 /* static power management */
1329 struct { 1649 struct {
1330 void (*misc)(struct radeon_device *rdev); 1650 void (*misc)(struct radeon_device *rdev);
1331 void (*prepare)(struct radeon_device *rdev); 1651 void (*prepare)(struct radeon_device *rdev);
@@ -1340,7 +1660,26 @@ struct radeon_asic {
1340 void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes); 1660 void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
1341 void (*set_clock_gating)(struct radeon_device *rdev, int enable); 1661 void (*set_clock_gating)(struct radeon_device *rdev, int enable);
1342 int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk); 1662 int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk);
1663 int (*get_temperature)(struct radeon_device *rdev);
1343 } pm; 1664 } pm;
1665 /* dynamic power management */
1666 struct {
1667 int (*init)(struct radeon_device *rdev);
1668 void (*setup_asic)(struct radeon_device *rdev);
1669 int (*enable)(struct radeon_device *rdev);
1670 void (*disable)(struct radeon_device *rdev);
1671 int (*pre_set_power_state)(struct radeon_device *rdev);
1672 int (*set_power_state)(struct radeon_device *rdev);
1673 void (*post_set_power_state)(struct radeon_device *rdev);
1674 void (*display_configuration_changed)(struct radeon_device *rdev);
1675 void (*fini)(struct radeon_device *rdev);
1676 u32 (*get_sclk)(struct radeon_device *rdev, bool low);
1677 u32 (*get_mclk)(struct radeon_device *rdev, bool low);
1678 void (*print_power_state)(struct radeon_device *rdev, struct radeon_ps *ps);
1679 void (*debugfs_print_current_performance_level)(struct radeon_device *rdev, struct seq_file *m);
1680 int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level);
1681 bool (*vblank_too_short)(struct radeon_device *rdev);
1682 } dpm;
1344 /* pageflipping */ 1683 /* pageflipping */
1345 struct { 1684 struct {
1346 void (*pre_page_flip)(struct radeon_device *rdev, int crtc); 1685 void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
@@ -1505,6 +1844,36 @@ struct si_asic {
1505 uint32_t tile_mode_array[32]; 1844 uint32_t tile_mode_array[32];
1506}; 1845};
1507 1846
1847struct cik_asic {
1848 unsigned max_shader_engines;
1849 unsigned max_tile_pipes;
1850 unsigned max_cu_per_sh;
1851 unsigned max_sh_per_se;
1852 unsigned max_backends_per_se;
1853 unsigned max_texture_channel_caches;
1854 unsigned max_gprs;
1855 unsigned max_gs_threads;
1856 unsigned max_hw_contexts;
1857 unsigned sc_prim_fifo_size_frontend;
1858 unsigned sc_prim_fifo_size_backend;
1859 unsigned sc_hiz_tile_fifo_size;
1860 unsigned sc_earlyz_tile_fifo_size;
1861
1862 unsigned num_tile_pipes;
1863 unsigned num_backends_per_se;
1864 unsigned backend_disable_mask_per_asic;
1865 unsigned backend_map;
1866 unsigned num_texture_channel_caches;
1867 unsigned mem_max_burst_length_bytes;
1868 unsigned mem_row_size_in_kb;
1869 unsigned shader_engine_tile_size;
1870 unsigned num_gpus;
1871 unsigned multi_gpu_tile_size;
1872
1873 unsigned tile_config;
1874 uint32_t tile_mode_array[32];
1875};
1876
1508union radeon_asic_config { 1877union radeon_asic_config {
1509 struct r300_asic r300; 1878 struct r300_asic r300;
1510 struct r100_asic r100; 1879 struct r100_asic r100;
@@ -1513,6 +1882,7 @@ union radeon_asic_config {
1513 struct evergreen_asic evergreen; 1882 struct evergreen_asic evergreen;
1514 struct cayman_asic cayman; 1883 struct cayman_asic cayman;
1515 struct si_asic si; 1884 struct si_asic si;
1885 struct cik_asic cik;
1516}; 1886};
1517 1887
1518/* 1888/*
@@ -1657,6 +2027,7 @@ struct radeon_device {
1657 struct radeon_gart gart; 2027 struct radeon_gart gart;
1658 struct radeon_mode_info mode_info; 2028 struct radeon_mode_info mode_info;
1659 struct radeon_scratch scratch; 2029 struct radeon_scratch scratch;
2030 struct radeon_doorbell doorbell;
1660 struct radeon_mman mman; 2031 struct radeon_mman mman;
1661 struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS]; 2032 struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS];
1662 wait_queue_head_t fence_queue; 2033 wait_queue_head_t fence_queue;
@@ -1684,13 +2055,18 @@ struct radeon_device {
1684 const struct firmware *mc_fw; /* NI MC firmware */ 2055 const struct firmware *mc_fw; /* NI MC firmware */
1685 const struct firmware *ce_fw; /* SI CE firmware */ 2056 const struct firmware *ce_fw; /* SI CE firmware */
1686 const struct firmware *uvd_fw; /* UVD firmware */ 2057 const struct firmware *uvd_fw; /* UVD firmware */
2058 const struct firmware *mec_fw; /* CIK MEC firmware */
2059 const struct firmware *sdma_fw; /* CIK SDMA firmware */
2060 const struct firmware *smc_fw; /* SMC firmware */
1687 struct r600_blit r600_blit; 2061 struct r600_blit r600_blit;
1688 struct r600_vram_scratch vram_scratch; 2062 struct r600_vram_scratch vram_scratch;
1689 int msi_enabled; /* msi enabled */ 2063 int msi_enabled; /* msi enabled */
1690 struct r600_ih ih; /* r6/700 interrupt ring */ 2064 struct r600_ih ih; /* r6/700 interrupt ring */
1691 struct si_rlc rlc; 2065 struct radeon_rlc rlc;
2066 struct radeon_mec mec;
1692 struct work_struct hotplug_work; 2067 struct work_struct hotplug_work;
1693 struct work_struct audio_work; 2068 struct work_struct audio_work;
2069 struct work_struct reset_work;
1694 int num_crtc; /* number of crtcs */ 2070 int num_crtc; /* number of crtcs */
1695 struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */ 2071 struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
1696 bool audio_enabled; 2072 bool audio_enabled;
@@ -1727,6 +2103,9 @@ void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v,
1727u32 r100_io_rreg(struct radeon_device *rdev, u32 reg); 2103u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
1728void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v); 2104void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1729 2105
2106u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 offset);
2107void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v);
2108
1730/* 2109/*
1731 * Cast helper 2110 * Cast helper
1732 */ 2111 */
@@ -1754,6 +2133,18 @@ void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1754#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v)) 2133#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
1755#define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg)) 2134#define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg))
1756#define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v)) 2135#define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
2136#define RREG32_SMC(reg) tn_smc_rreg(rdev, (reg))
2137#define WREG32_SMC(reg, v) tn_smc_wreg(rdev, (reg), (v))
2138#define RREG32_RCU(reg) r600_rcu_rreg(rdev, (reg))
2139#define WREG32_RCU(reg, v) r600_rcu_wreg(rdev, (reg), (v))
2140#define RREG32_CG(reg) eg_cg_rreg(rdev, (reg))
2141#define WREG32_CG(reg, v) eg_cg_wreg(rdev, (reg), (v))
2142#define RREG32_PIF_PHY0(reg) eg_pif_phy0_rreg(rdev, (reg))
2143#define WREG32_PIF_PHY0(reg, v) eg_pif_phy0_wreg(rdev, (reg), (v))
2144#define RREG32_PIF_PHY1(reg) eg_pif_phy1_rreg(rdev, (reg))
2145#define WREG32_PIF_PHY1(reg, v) eg_pif_phy1_wreg(rdev, (reg), (v))
2146#define RREG32_UVD_CTX(reg) r600_uvd_ctx_rreg(rdev, (reg))
2147#define WREG32_UVD_CTX(reg, v) r600_uvd_ctx_wreg(rdev, (reg), (v))
1757#define WREG32_P(reg, val, mask) \ 2148#define WREG32_P(reg, val, mask) \
1758 do { \ 2149 do { \
1759 uint32_t tmp_ = RREG32(reg); \ 2150 uint32_t tmp_ = RREG32(reg); \
@@ -1774,6 +2165,9 @@ void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
1774#define RREG32_IO(reg) r100_io_rreg(rdev, (reg)) 2165#define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
1775#define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v)) 2166#define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
1776 2167
2168#define RDOORBELL32(offset) cik_mm_rdoorbell(rdev, (offset))
2169#define WDOORBELL32(offset, v) cik_mm_wdoorbell(rdev, (offset), (v))
2170
1777/* 2171/*
1778 * Indirect registers accessor 2172 * Indirect registers accessor
1779 */ 2173 */
@@ -1792,6 +2186,96 @@ static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uin
1792 WREG32(RADEON_PCIE_DATA, (v)); 2186 WREG32(RADEON_PCIE_DATA, (v));
1793} 2187}
1794 2188
2189static inline u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg)
2190{
2191 u32 r;
2192
2193 WREG32(TN_SMC_IND_INDEX_0, (reg));
2194 r = RREG32(TN_SMC_IND_DATA_0);
2195 return r;
2196}
2197
2198static inline void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2199{
2200 WREG32(TN_SMC_IND_INDEX_0, (reg));
2201 WREG32(TN_SMC_IND_DATA_0, (v));
2202}
2203
2204static inline u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg)
2205{
2206 u32 r;
2207
2208 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff));
2209 r = RREG32(R600_RCU_DATA);
2210 return r;
2211}
2212
2213static inline void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2214{
2215 WREG32(R600_RCU_INDEX, ((reg) & 0x1fff));
2216 WREG32(R600_RCU_DATA, (v));
2217}
2218
2219static inline u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg)
2220{
2221 u32 r;
2222
2223 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff));
2224 r = RREG32(EVERGREEN_CG_IND_DATA);
2225 return r;
2226}
2227
2228static inline void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2229{
2230 WREG32(EVERGREEN_CG_IND_ADDR, ((reg) & 0xffff));
2231 WREG32(EVERGREEN_CG_IND_DATA, (v));
2232}
2233
2234static inline u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg)
2235{
2236 u32 r;
2237
2238 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
2239 r = RREG32(EVERGREEN_PIF_PHY0_DATA);
2240 return r;
2241}
2242
2243static inline void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2244{
2245 WREG32(EVERGREEN_PIF_PHY0_INDEX, ((reg) & 0xffff));
2246 WREG32(EVERGREEN_PIF_PHY0_DATA, (v));
2247}
2248
2249static inline u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg)
2250{
2251 u32 r;
2252
2253 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
2254 r = RREG32(EVERGREEN_PIF_PHY1_DATA);
2255 return r;
2256}
2257
2258static inline void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2259{
2260 WREG32(EVERGREEN_PIF_PHY1_INDEX, ((reg) & 0xffff));
2261 WREG32(EVERGREEN_PIF_PHY1_DATA, (v));
2262}
2263
2264static inline u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg)
2265{
2266 u32 r;
2267
2268 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff));
2269 r = RREG32(R600_UVD_CTX_DATA);
2270 return r;
2271}
2272
2273static inline void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v)
2274{
2275 WREG32(R600_UVD_CTX_INDEX, ((reg) & 0x1ff));
2276 WREG32(R600_UVD_CTX_DATA, (v));
2277}
2278
1795void r100_pll_errata_after_index(struct radeon_device *rdev); 2279void r100_pll_errata_after_index(struct radeon_device *rdev);
1796 2280
1797 2281
@@ -1840,6 +2324,16 @@ void r100_pll_errata_after_index(struct radeon_device *rdev);
1840 (rdev->flags & RADEON_IS_IGP)) 2324 (rdev->flags & RADEON_IS_IGP))
1841#define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND)) 2325#define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND))
1842#define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN)) 2326#define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN))
2327#define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE))
2328
2329#define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \
2330 (rdev->ddev->pdev->device == 0x6850) || \
2331 (rdev->ddev->pdev->device == 0x6858) || \
2332 (rdev->ddev->pdev->device == 0x6859) || \
2333 (rdev->ddev->pdev->device == 0x6840) || \
2334 (rdev->ddev->pdev->device == 0x6841) || \
2335 (rdev->ddev->pdev->device == 0x6842) || \
2336 (rdev->ddev->pdev->device == 0x6843))
1843 2337
1844/* 2338/*
1845 * BIOS helpers. 2339 * BIOS helpers.
@@ -1892,6 +2386,9 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
1892#define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib)) 2386#define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
1893#define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp)) 2387#define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)].is_lockup((rdev), (cp))
1894#define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm)) 2388#define radeon_ring_vm_flush(rdev, r, vm) (rdev)->asic->ring[(r)].vm_flush((rdev), (r), (vm))
2389#define radeon_ring_get_rptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_rptr((rdev), (r))
2390#define radeon_ring_get_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].get_wptr((rdev), (r))
2391#define radeon_ring_set_wptr(rdev, r) (rdev)->asic->ring[(r)->idx].set_wptr((rdev), (r))
1895#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev)) 2392#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
1896#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev)) 2393#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
1897#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc)) 2394#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
@@ -1915,6 +2412,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
1915#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l)) 2412#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
1916#define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e)) 2413#define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
1917#define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d)) 2414#define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
2415#define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
1918#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s))) 2416#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
1919#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r))) 2417#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
1920#define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev)) 2418#define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
@@ -1935,6 +2433,21 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
1935#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) 2433#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
1936#define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev)) 2434#define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
1937#define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev)) 2435#define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
2436#define radeon_dpm_init(rdev) rdev->asic->dpm.init((rdev))
2437#define radeon_dpm_setup_asic(rdev) rdev->asic->dpm.setup_asic((rdev))
2438#define radeon_dpm_enable(rdev) rdev->asic->dpm.enable((rdev))
2439#define radeon_dpm_disable(rdev) rdev->asic->dpm.disable((rdev))
2440#define radeon_dpm_pre_set_power_state(rdev) rdev->asic->dpm.pre_set_power_state((rdev))
2441#define radeon_dpm_set_power_state(rdev) rdev->asic->dpm.set_power_state((rdev))
2442#define radeon_dpm_post_set_power_state(rdev) rdev->asic->dpm.post_set_power_state((rdev))
2443#define radeon_dpm_display_configuration_changed(rdev) rdev->asic->dpm.display_configuration_changed((rdev))
2444#define radeon_dpm_fini(rdev) rdev->asic->dpm.fini((rdev))
2445#define radeon_dpm_get_sclk(rdev, l) rdev->asic->dpm.get_sclk((rdev), (l))
2446#define radeon_dpm_get_mclk(rdev, l) rdev->asic->dpm.get_mclk((rdev), (l))
2447#define radeon_dpm_print_power_state(rdev, ps) rdev->asic->dpm.print_power_state((rdev), (ps))
2448#define radeon_dpm_debugfs_print_current_performance_level(rdev, m) rdev->asic->dpm.debugfs_print_current_performance_level((rdev), (m))
2449#define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l))
2450#define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev))
1938 2451
1939/* Common functions */ 2452/* Common functions */
1940/* AGP */ 2453/* AGP */
@@ -2054,6 +2567,10 @@ extern int ni_mc_load_microcode(struct radeon_device *rdev);
2054#if defined(CONFIG_ACPI) 2567#if defined(CONFIG_ACPI)
2055extern int radeon_acpi_init(struct radeon_device *rdev); 2568extern int radeon_acpi_init(struct radeon_device *rdev);
2056extern void radeon_acpi_fini(struct radeon_device *rdev); 2569extern void radeon_acpi_fini(struct radeon_device *rdev);
2570extern bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device *rdev);
2571extern int radeon_acpi_pcie_performance_request(struct radeon_device *rdev,
2572 u8 perf_req, bool advertise);
2573extern int radeon_acpi_pcie_notify_device_ready(struct radeon_device *rdev);
2057#else 2574#else
2058static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } 2575static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
2059static inline void radeon_acpi_fini(struct radeon_device *rdev) { } 2576static inline void radeon_acpi_fini(struct radeon_device *rdev) { }