aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 16:23:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 16:23:46 -0400
commit09fa30226130652af75152d9010c603c66d46f6e (patch)
tree26dc4ba7fc66dc0c10e442d81595dd319eef4c75 /drivers
parentbe53bfdb8088e9d1924199cc1a96e113756b1075 (diff)
parent1b2681ba271c9f5bb66cb0d8ceeaa215fcd218d8 (diff)
Merge branch 'drm-radeon-sitn-support' of git://people.freedesktop.org/~airlied/linux
Pull radeon southern islands / trinity support from Dave Airlie: "This is support from AMD for their newest GPU and APUs. The products called RadeonHD 7xxx, and the Trinity APU series. This did come in a bit late, due to some over-complicated AMD internal review process, which from the outside seems unnecessary once the company has decided it wants to support open source. However as I said previously I'd rather not put the people who've got this hw for 3 months now being forced to use fglrx on it if there is open code. Its pretty well self contained and just plugs into the driver in various places." * 'drm-radeon-sitn-support' of git://people.freedesktop.org/~airlied/linux: (48 commits) drm/radeon/kms: update duallink checks for DCE6 drm/radeon/kms: add trinity pci ids drm/radeon/kms: add radeon_asic struct for trinity drm/radeon/kms: add support for ucode loading on trinity (v2) drm/radeon/kms/vm: set vram base offset properly for TN drm/radeon/kms: Update evergreen functions for trinity drm/radeon/kms: cayman gpu init updates for trinity drm/radeon/kms: Add checks for TN in the DP bridge code drm/radeon/kms/DCE6.1: ss is not supported on the internal pplls drm/radeon/kms: disable PPLL0 on DCE6.1 when not in use drm/radeon/kms: Adjust pll picker for DCE6.1 drm/radeon/kms: DCE6.1 disp eng pll updates drm/radeon/kms: DCE6.1 watermark updates for TN drm/radeon/kms: no support for internal thermal sensor on TN yet drm/radeon/kms: add trinity (TN) chip family drm/radeon/kms: Add SI pci ids drm/radeon: Update radeon_info_ioctl for SI. (v2) drm/radeon/kms: add radeon_asic struct for SI drm/radeon/kms: add support for compute rings in CS ioctl on SI drm/radeon/kms: fill in startup/shutdown callbacks for SI ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/radeon/Makefile2
-rw-r--r--drivers/gpu/drm/radeon/ObjectID.h5
-rw-r--r--drivers/gpu/drm/radeon/atombios.h1109
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c100
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c6
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c71
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c25
-rw-r--r--drivers/gpu/drm/radeon/evergreen_blit_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/ni.c141
-rw-r--r--drivers/gpu/drm/radeon/nid.h1
-rw-r--r--drivers/gpu/drm/radeon/r600.c25
-rw-r--r--drivers/gpu/drm/radeon/r600d.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon.h55
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c208
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h25
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c78
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c63
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_family.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c32
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_reg.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c1
-rw-r--r--drivers/gpu/drm/radeon/si.c4128
-rw-r--r--drivers/gpu/drm/radeon/si_blit_shaders.c252
-rw-r--r--drivers/gpu/drm/radeon/si_blit_shaders.h32
-rw-r--r--drivers/gpu/drm/radeon/si_reg.h33
-rw-r--r--drivers/gpu/drm/radeon/sid.h886
33 files changed, 7173 insertions, 144 deletions
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index 84104153a684..9d83729956ff 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -71,7 +71,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
71 r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \ 71 r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \
72 evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \ 72 evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \
73 radeon_trace_points.o ni.o cayman_blit_shaders.o atombios_encoders.o \ 73 radeon_trace_points.o ni.o cayman_blit_shaders.o atombios_encoders.o \
74 radeon_semaphore.o radeon_sa.o atombios_i2c.o 74 radeon_semaphore.o radeon_sa.o atombios_i2c.o si.o si_blit_shaders.o
75 75
76radeon-$(CONFIG_COMPAT) += radeon_ioc32.o 76radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
77radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o 77radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
diff --git a/drivers/gpu/drm/radeon/ObjectID.h b/drivers/gpu/drm/radeon/ObjectID.h
index c61c3fe9fb98..ca4b038050d2 100644
--- a/drivers/gpu/drm/radeon/ObjectID.h
+++ b/drivers/gpu/drm/radeon/ObjectID.h
@@ -85,6 +85,7 @@
85#define ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA 0x1F 85#define ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA 0x1F
86#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY1 0x20 86#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY1 0x20
87#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY2 0x21 87#define ENCODER_OBJECT_ID_INTERNAL_UNIPHY2 0x21
88#define ENCODER_OBJECT_ID_INTERNAL_VCE 0x24
88 89
89#define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO 0xFF 90#define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO 0xFF
90 91
@@ -387,6 +388,10 @@
387 GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\ 388 GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
388 ENCODER_OBJECT_ID_NUTMEG << OBJECT_ID_SHIFT) 389 ENCODER_OBJECT_ID_NUTMEG << OBJECT_ID_SHIFT)
389 390
391#define ENCODER_VCE_ENUM_ID1 ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
392 GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
393 ENCODER_OBJECT_ID_INTERNAL_VCE << OBJECT_ID_SHIFT)
394
390/****************************************************/ 395/****************************************************/
391/* Connector Object ID definition - Shared with BIOS */ 396/* Connector Object ID definition - Shared with BIOS */
392/****************************************************/ 397/****************************************************/
diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h
index 1b50ad8919d5..4b04ba3828e8 100644
--- a/drivers/gpu/drm/radeon/atombios.h
+++ b/drivers/gpu/drm/radeon/atombios.h
@@ -101,6 +101,7 @@
101#define ATOM_LCD_SELFTEST_START (ATOM_DISABLE+5) 101#define ATOM_LCD_SELFTEST_START (ATOM_DISABLE+5)
102#define ATOM_LCD_SELFTEST_STOP (ATOM_ENABLE+5) 102#define ATOM_LCD_SELFTEST_STOP (ATOM_ENABLE+5)
103#define ATOM_ENCODER_INIT (ATOM_DISABLE+7) 103#define ATOM_ENCODER_INIT (ATOM_DISABLE+7)
104#define ATOM_INIT (ATOM_DISABLE+7)
104#define ATOM_GET_STATUS (ATOM_DISABLE+8) 105#define ATOM_GET_STATUS (ATOM_DISABLE+8)
105 106
106#define ATOM_BLANKING 1 107#define ATOM_BLANKING 1
@@ -251,25 +252,25 @@ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{
251 USHORT SetEngineClock; //Function Table,directly used by various SW components,latest version 1.1 252 USHORT SetEngineClock; //Function Table,directly used by various SW components,latest version 1.1
252 USHORT SetMemoryClock; //Function Table,directly used by various SW components,latest version 1.1 253 USHORT SetMemoryClock; //Function Table,directly used by various SW components,latest version 1.1
253 USHORT SetPixelClock; //Function Table,directly used by various SW components,latest version 1.2 254 USHORT SetPixelClock; //Function Table,directly used by various SW components,latest version 1.2
254 USHORT DynamicClockGating; //Atomic Table, indirectly used by various SW components,called from ASIC_Init 255 USHORT EnableDispPowerGating; //Atomic Table, indirectly used by various SW components,called from ASIC_Init
255 USHORT ResetMemoryDLL; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock 256 USHORT ResetMemoryDLL; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock
256 USHORT ResetMemoryDevice; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock 257 USHORT ResetMemoryDevice; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock
257 USHORT MemoryPLLInit; 258 USHORT MemoryPLLInit; //Atomic Table, used only by Bios
258 USHORT AdjustDisplayPll; //only used by Bios 259 USHORT AdjustDisplayPll; //Atomic Table, used by various SW componentes.
259 USHORT AdjustMemoryController; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock 260 USHORT AdjustMemoryController; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock
260 USHORT EnableASIC_StaticPwrMgt; //Atomic Table, only used by Bios 261 USHORT EnableASIC_StaticPwrMgt; //Atomic Table, only used by Bios
261 USHORT ASIC_StaticPwrMgtStatusChange; //Obsolete , only used by Bios 262 USHORT ASIC_StaticPwrMgtStatusChange; //Obsolete , only used by Bios
262 USHORT DAC_LoadDetection; //Atomic Table, directly used by various SW components,latest version 1.2 263 USHORT DAC_LoadDetection; //Atomic Table, directly used by various SW components,latest version 1.2
263 USHORT LVTMAEncoderControl; //Atomic Table,directly used by various SW components,latest version 1.3 264 USHORT LVTMAEncoderControl; //Atomic Table,directly used by various SW components,latest version 1.3
264 USHORT LCD1OutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 265 USHORT HW_Misc_Operation; //Atomic Table, directly used by various SW components,latest version 1.1
265 USHORT DAC1EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 266 USHORT DAC1EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1
266 USHORT DAC2EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1 267 USHORT DAC2EncoderControl; //Atomic Table, directly used by various SW components,latest version 1.1
267 USHORT DVOOutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 268 USHORT DVOOutputControl; //Atomic Table, directly used by various SW components,latest version 1.1
268 USHORT CV1OutputControl; //Atomic Table, Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead 269 USHORT CV1OutputControl; //Atomic Table, Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead
269 USHORT GetConditionalGoldenSetting; //only used by Bios 270 USHORT GetConditionalGoldenSetting; //Only used by Bios
270 USHORT TVEncoderControl; //Function Table,directly used by various SW components,latest version 1.1 271 USHORT TVEncoderControl; //Function Table,directly used by various SW components,latest version 1.1
271 USHORT TMDSAEncoderControl; //Atomic Table, directly used by various SW components,latest version 1.3 272 USHORT PatchMCSetting; //only used by BIOS
272 USHORT LVDSEncoderControl; //Atomic Table, directly used by various SW components,latest version 1.3 273 USHORT MC_SEQ_Control; //only used by BIOS
273 USHORT TV1OutputControl; //Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead 274 USHORT TV1OutputControl; //Atomic Table, Obsolete from Ry6xx, use DAC2 Output instead
274 USHORT EnableScaler; //Atomic Table, used only by Bios 275 USHORT EnableScaler; //Atomic Table, used only by Bios
275 USHORT BlankCRTC; //Atomic Table, directly used by various SW components,latest version 1.1 276 USHORT BlankCRTC; //Atomic Table, directly used by various SW components,latest version 1.1
@@ -282,7 +283,7 @@ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{
282 USHORT SetCRTC_Replication; //Atomic Table, used only by Bios 283 USHORT SetCRTC_Replication; //Atomic Table, used only by Bios
283 USHORT SelectCRTC_Source; //Atomic Table, directly used by various SW components,latest version 1.1 284 USHORT SelectCRTC_Source; //Atomic Table, directly used by various SW components,latest version 1.1
284 USHORT EnableGraphSurfaces; //Atomic Table, used only by Bios 285 USHORT EnableGraphSurfaces; //Atomic Table, used only by Bios
285 USHORT UpdateCRTC_DoubleBufferRegisters; 286 USHORT UpdateCRTC_DoubleBufferRegisters; //Atomic Table, used only by Bios
286 USHORT LUT_AutoFill; //Atomic Table, only used by Bios 287 USHORT LUT_AutoFill; //Atomic Table, only used by Bios
287 USHORT EnableHW_IconCursor; //Atomic Table, only used by Bios 288 USHORT EnableHW_IconCursor; //Atomic Table, only used by Bios
288 USHORT GetMemoryClock; //Atomic Table, directly used by various SW components,latest version 1.1 289 USHORT GetMemoryClock; //Atomic Table, directly used by various SW components,latest version 1.1
@@ -308,27 +309,36 @@ typedef struct _ATOM_MASTER_LIST_OF_COMMAND_TABLES{
308 USHORT SetVoltage; //Function Table,directly and/or indirectly used by various SW components,latest version 1.1 309 USHORT SetVoltage; //Function Table,directly and/or indirectly used by various SW components,latest version 1.1
309 USHORT DAC1OutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 310 USHORT DAC1OutputControl; //Atomic Table, directly used by various SW components,latest version 1.1
310 USHORT DAC2OutputControl; //Atomic Table, directly used by various SW components,latest version 1.1 311 USHORT DAC2OutputControl; //Atomic Table, directly used by various SW components,latest version 1.1
311 USHORT SetupHWAssistedI2CStatus; //Function Table,only used by Bios, obsolete soon.Switch to use "ReadEDIDFromHWAssistedI2C" 312 USHORT ComputeMemoryClockParam; //Function Table,only used by Bios, obsolete soon.Switch to use "ReadEDIDFromHWAssistedI2C"
312 USHORT ClockSource; //Atomic Table, indirectly used by various SW components,called from ASIC_Init 313 USHORT ClockSource; //Atomic Table, indirectly used by various SW components,called from ASIC_Init
313 USHORT MemoryDeviceInit; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock 314 USHORT MemoryDeviceInit; //Atomic Table, indirectly used by various SW components,called from SetMemoryClock
314 USHORT EnableYUV; //Atomic Table, indirectly used by various SW components,called from EnableVGARender 315 USHORT GetDispObjectInfo; //Atomic Table, indirectly used by various SW components,called from EnableVGARender
315 USHORT DIG1EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1 316 USHORT DIG1EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1
316 USHORT DIG2EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1 317 USHORT DIG2EncoderControl; //Atomic Table,directly used by various SW components,latest version 1.1
317 USHORT DIG1TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1 318 USHORT DIG1TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1
318 USHORT DIG2TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1 319 USHORT DIG2TransmitterControl; //Atomic Table,directly used by various SW components,latest version 1.1
319 USHORT ProcessAuxChannelTransaction; //Function Table,only used by Bios 320 USHORT ProcessAuxChannelTransaction; //Function Table,only used by Bios
320 USHORT DPEncoderService; //Function Table,only used by Bios 321 USHORT DPEncoderService; //Function Table,only used by Bios
322 USHORT GetVoltageInfo; //Function Table,only used by Bios since SI
321}ATOM_MASTER_LIST_OF_COMMAND_TABLES; 323}ATOM_MASTER_LIST_OF_COMMAND_TABLES;
322 324
323// For backward compatible 325// For backward compatible
324#define ReadEDIDFromHWAssistedI2C ProcessI2cChannelTransaction 326#define ReadEDIDFromHWAssistedI2C ProcessI2cChannelTransaction
325#define UNIPHYTransmitterControl DIG1TransmitterControl 327#define DPTranslatorControl DIG2EncoderControl
326#define LVTMATransmitterControl DIG2TransmitterControl 328#define UNIPHYTransmitterControl DIG1TransmitterControl
329#define LVTMATransmitterControl DIG2TransmitterControl
327#define SetCRTC_DPM_State GetConditionalGoldenSetting 330#define SetCRTC_DPM_State GetConditionalGoldenSetting
328#define SetUniphyInstance ASIC_StaticPwrMgtStatusChange 331#define SetUniphyInstance ASIC_StaticPwrMgtStatusChange
329#define HPDInterruptService ReadHWAssistedI2CStatus 332#define HPDInterruptService ReadHWAssistedI2CStatus
330#define EnableVGA_Access GetSCLKOverMCLKRatio 333#define EnableVGA_Access GetSCLKOverMCLKRatio
331#define GetDispObjectInfo EnableYUV 334#define EnableYUV GetDispObjectInfo
335#define DynamicClockGating EnableDispPowerGating
336#define SetupHWAssistedI2CStatus ComputeMemoryClockParam
337
338#define TMDSAEncoderControl PatchMCSetting
339#define LVDSEncoderControl MC_SEQ_Control
340#define LCD1OutputControl HW_Misc_Operation
341
332 342
333typedef struct _ATOM_MASTER_COMMAND_TABLE 343typedef struct _ATOM_MASTER_COMMAND_TABLE
334{ 344{
@@ -495,6 +505,34 @@ typedef struct _COMPUTE_MEMORY_ENGINE_PLL_PARAMETERS_V5
495// ucInputFlag 505// ucInputFlag
496#define ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN 1 // 1-StrobeMode, 0-PerformanceMode 506#define ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN 1 // 1-StrobeMode, 0-PerformanceMode
497 507
508// use for ComputeMemoryClockParamTable
509typedef struct _COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1
510{
511 union
512 {
513 ULONG ulClock;
514 ATOM_S_MPLL_FB_DIVIDER ulFbDiv; //Output:UPPER_WORD=FB_DIV_INTEGER, LOWER_WORD=FB_DIV_FRAC shl (16-FB_FRACTION_BITS)
515 };
516 UCHAR ucDllSpeed; //Output
517 UCHAR ucPostDiv; //Output
518 union{
519 UCHAR ucInputFlag; //Input : ATOM_PLL_INPUT_FLAG_PLL_STROBE_MODE_EN: 1-StrobeMode, 0-PerformanceMode
520 UCHAR ucPllCntlFlag; //Output:
521 };
522 UCHAR ucBWCntl;
523}COMPUTE_MEMORY_CLOCK_PARAM_PARAMETERS_V2_1;
524
525// definition of ucInputFlag
526#define MPLL_INPUT_FLAG_STROBE_MODE_EN 0x01
527// definition of ucPllCntlFlag
528#define MPLL_CNTL_FLAG_VCO_MODE_MASK 0x03
529#define MPLL_CNTL_FLAG_BYPASS_DQ_PLL 0x04
530#define MPLL_CNTL_FLAG_QDR_ENABLE 0x08
531#define MPLL_CNTL_FLAG_AD_HALF_RATE 0x10
532
533//MPLL_CNTL_FLAG_BYPASS_AD_PLL has a wrong name, should be BYPASS_DQ_PLL
534#define MPLL_CNTL_FLAG_BYPASS_AD_PLL 0x04
535
498typedef struct _DYNAMICE_MEMORY_SETTINGS_PARAMETER 536typedef struct _DYNAMICE_MEMORY_SETTINGS_PARAMETER
499{ 537{
500 ATOM_COMPUTE_CLOCK_FREQ ulClock; 538 ATOM_COMPUTE_CLOCK_FREQ ulClock;
@@ -562,6 +600,16 @@ typedef struct _DYNAMIC_CLOCK_GATING_PARAMETERS
562#define DYNAMIC_CLOCK_GATING_PS_ALLOCATION DYNAMIC_CLOCK_GATING_PARAMETERS 600#define DYNAMIC_CLOCK_GATING_PS_ALLOCATION DYNAMIC_CLOCK_GATING_PARAMETERS
563 601
564/****************************************************************************/ 602/****************************************************************************/
603// Structure used by EnableDispPowerGatingTable.ctb
604/****************************************************************************/
605typedef struct _ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1
606{
607 UCHAR ucDispPipeId; // ATOM_CRTC1, ATOM_CRTC2, ...
608 UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE
609 UCHAR ucPadding[2];
610}ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1;
611
612/****************************************************************************/
565// Structure used by EnableASIC_StaticPwrMgtTable.ctb 613// Structure used by EnableASIC_StaticPwrMgtTable.ctb
566/****************************************************************************/ 614/****************************************************************************/
567typedef struct _ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS 615typedef struct _ENABLE_ASIC_STATIC_PWR_MGT_PARAMETERS
@@ -807,6 +855,7 @@ typedef struct _ATOM_DIG_ENCODER_CONFIG_V4
807#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_1_62GHZ 0x00 855#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_1_62GHZ 0x00
808#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_2_70GHZ 0x01 856#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_2_70GHZ 0x01
809#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_5_40GHZ 0x02 857#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_5_40GHZ 0x02
858#define ATOM_ENCODER_CONFIG_V4_DPLINKRATE_3_24GHZ 0x03
810#define ATOM_ENCODER_CONFIG_V4_ENCODER_SEL 0x70 859#define ATOM_ENCODER_CONFIG_V4_ENCODER_SEL 0x70
811#define ATOM_ENCODER_CONFIG_V4_DIG0_ENCODER 0x00 860#define ATOM_ENCODER_CONFIG_V4_DIG0_ENCODER 0x00
812#define ATOM_ENCODER_CONFIG_V4_DIG1_ENCODER 0x10 861#define ATOM_ENCODER_CONFIG_V4_DIG1_ENCODER 0x10
@@ -814,6 +863,7 @@ typedef struct _ATOM_DIG_ENCODER_CONFIG_V4
814#define ATOM_ENCODER_CONFIG_V4_DIG3_ENCODER 0x30 863#define ATOM_ENCODER_CONFIG_V4_DIG3_ENCODER 0x30
815#define ATOM_ENCODER_CONFIG_V4_DIG4_ENCODER 0x40 864#define ATOM_ENCODER_CONFIG_V4_DIG4_ENCODER 0x40
816#define ATOM_ENCODER_CONFIG_V4_DIG5_ENCODER 0x50 865#define ATOM_ENCODER_CONFIG_V4_DIG5_ENCODER 0x50
866#define ATOM_ENCODER_CONFIG_V4_DIG6_ENCODER 0x60
817 867
818typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V4 868typedef struct _DIG_ENCODER_CONTROL_PARAMETERS_V4
819{ 869{
@@ -1171,6 +1221,106 @@ typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V4
1171#define ATOM_TRANSMITTER_CONFIG_V4_TRANSMITTER3 0x80 //EF 1221#define ATOM_TRANSMITTER_CONFIG_V4_TRANSMITTER3 0x80 //EF
1172 1222
1173 1223
1224typedef struct _ATOM_DIG_TRANSMITTER_CONFIG_V5
1225{
1226#if ATOM_BIG_ENDIAN
1227 UCHAR ucReservd1:1;
1228 UCHAR ucHPDSel:3;
1229 UCHAR ucPhyClkSrcId:2;
1230 UCHAR ucCoherentMode:1;
1231 UCHAR ucReserved:1;
1232#else
1233 UCHAR ucReserved:1;
1234 UCHAR ucCoherentMode:1;
1235 UCHAR ucPhyClkSrcId:2;
1236 UCHAR ucHPDSel:3;
1237 UCHAR ucReservd1:1;
1238#endif
1239}ATOM_DIG_TRANSMITTER_CONFIG_V5;
1240
1241typedef struct _DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5
1242{
1243 USHORT usSymClock; // Encoder Clock in 10kHz,(DP mode)= linkclock/10, (TMDS/LVDS/HDMI)= pixel clock, (HDMI deep color), =pixel clock * deep_color_ratio
1244 UCHAR ucPhyId; // 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4= UNIPHYE 5=UNIPHYF
1245 UCHAR ucAction; // define as ATOM_TRANSMITER_ACTION_xxx
1246 UCHAR ucLaneNum; // indicate lane number 1-8
1247 UCHAR ucConnObjId; // Connector Object Id defined in ObjectId.h
1248 UCHAR ucDigMode; // indicate DIG mode
1249 union{
1250 ATOM_DIG_TRANSMITTER_CONFIG_V5 asConfig;
1251 UCHAR ucConfig;
1252 };
1253 UCHAR ucDigEncoderSel; // indicate DIG front end encoder
1254 UCHAR ucDPLaneSet;
1255 UCHAR ucReserved;
1256 UCHAR ucReserved1;
1257}DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5;
1258
1259//ucPhyId
1260#define ATOM_PHY_ID_UNIPHYA 0
1261#define ATOM_PHY_ID_UNIPHYB 1
1262#define ATOM_PHY_ID_UNIPHYC 2
1263#define ATOM_PHY_ID_UNIPHYD 3
1264#define ATOM_PHY_ID_UNIPHYE 4
1265#define ATOM_PHY_ID_UNIPHYF 5
1266#define ATOM_PHY_ID_UNIPHYG 6
1267
1268// ucDigEncoderSel
1269#define ATOM_TRANMSITTER_V5__DIGA_SEL 0x01
1270#define ATOM_TRANMSITTER_V5__DIGB_SEL 0x02
1271#define ATOM_TRANMSITTER_V5__DIGC_SEL 0x04
1272#define ATOM_TRANMSITTER_V5__DIGD_SEL 0x08
1273#define ATOM_TRANMSITTER_V5__DIGE_SEL 0x10
1274#define ATOM_TRANMSITTER_V5__DIGF_SEL 0x20
1275#define ATOM_TRANMSITTER_V5__DIGG_SEL 0x40
1276
1277// ucDigMode
1278#define ATOM_TRANSMITTER_DIGMODE_V5_DP 0
1279#define ATOM_TRANSMITTER_DIGMODE_V5_LVDS 1
1280#define ATOM_TRANSMITTER_DIGMODE_V5_DVI 2
1281#define ATOM_TRANSMITTER_DIGMODE_V5_HDMI 3
1282#define ATOM_TRANSMITTER_DIGMODE_V5_SDVO 4
1283#define ATOM_TRANSMITTER_DIGMODE_V5_DP_MST 5
1284
1285// ucDPLaneSet
1286#define DP_LANE_SET__0DB_0_4V 0x00
1287#define DP_LANE_SET__0DB_0_6V 0x01
1288#define DP_LANE_SET__0DB_0_8V 0x02
1289#define DP_LANE_SET__0DB_1_2V 0x03
1290#define DP_LANE_SET__3_5DB_0_4V 0x08
1291#define DP_LANE_SET__3_5DB_0_6V 0x09
1292#define DP_LANE_SET__3_5DB_0_8V 0x0a
1293#define DP_LANE_SET__6DB_0_4V 0x10
1294#define DP_LANE_SET__6DB_0_6V 0x11
1295#define DP_LANE_SET__9_5DB_0_4V 0x18
1296
1297// ATOM_DIG_TRANSMITTER_CONFIG_V5 asConfig;
1298// Bit1
1299#define ATOM_TRANSMITTER_CONFIG_V5_COHERENT 0x02
1300
1301// Bit3:2
1302#define ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SEL_MASK 0x0c
1303#define ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SEL_SHIFT 0x02
1304
1305#define ATOM_TRANSMITTER_CONFIG_V5_P1PLL 0x00
1306#define ATOM_TRANSMITTER_CONFIG_V5_P2PLL 0x04
1307#define ATOM_TRANSMITTER_CONFIG_V5_P0PLL 0x08
1308#define ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SRC_EXT 0x0c
1309// Bit6:4
1310#define ATOM_TRANSMITTER_CONFIG_V5_HPD_SEL_MASK 0x70
1311#define ATOM_TRANSMITTER_CONFIG_V5_HPD_SEL_SHIFT 0x04
1312
1313#define ATOM_TRANSMITTER_CONFIG_V5_NO_HPD_SEL 0x00
1314#define ATOM_TRANSMITTER_CONFIG_V5_HPD1_SEL 0x10
1315#define ATOM_TRANSMITTER_CONFIG_V5_HPD2_SEL 0x20
1316#define ATOM_TRANSMITTER_CONFIG_V5_HPD3_SEL 0x30
1317#define ATOM_TRANSMITTER_CONFIG_V5_HPD4_SEL 0x40
1318#define ATOM_TRANSMITTER_CONFIG_V5_HPD5_SEL 0x50
1319#define ATOM_TRANSMITTER_CONFIG_V5_HPD6_SEL 0x60
1320
1321#define DIG_TRANSMITTER_CONTROL_PS_ALLOCATION_V1_5 DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5
1322
1323
1174/****************************************************************************/ 1324/****************************************************************************/
1175// Structures used by ExternalEncoderControlTable V1.3 1325// Structures used by ExternalEncoderControlTable V1.3
1176// ASIC Families: Evergreen, Llano, NI 1326// ASIC Families: Evergreen, Llano, NI
@@ -1793,6 +1943,7 @@ typedef struct _ENABLE_SPREAD_SPECTRUM_ON_PPLL_V2
1793#define ATOM_PPLL_SS_TYPE_V3_P1PLL 0x00 1943#define ATOM_PPLL_SS_TYPE_V3_P1PLL 0x00
1794#define ATOM_PPLL_SS_TYPE_V3_P2PLL 0x04 1944#define ATOM_PPLL_SS_TYPE_V3_P2PLL 0x04
1795#define ATOM_PPLL_SS_TYPE_V3_DCPLL 0x08 1945#define ATOM_PPLL_SS_TYPE_V3_DCPLL 0x08
1946#define ATOM_PPLL_SS_TYPE_V3_P0PLL ATOM_PPLL_SS_TYPE_V3_DCPLL
1796#define ATOM_PPLL_SS_AMOUNT_V3_FBDIV_MASK 0x00FF 1947#define ATOM_PPLL_SS_AMOUNT_V3_FBDIV_MASK 0x00FF
1797#define ATOM_PPLL_SS_AMOUNT_V3_FBDIV_SHIFT 0 1948#define ATOM_PPLL_SS_AMOUNT_V3_FBDIV_SHIFT 0
1798#define ATOM_PPLL_SS_AMOUNT_V3_NFRAC_MASK 0x0F00 1949#define ATOM_PPLL_SS_AMOUNT_V3_NFRAC_MASK 0x0F00
@@ -2030,12 +2181,77 @@ typedef struct _SET_VOLTAGE_PARAMETERS_V2
2030 USHORT usVoltageLevel; // real voltage level 2181 USHORT usVoltageLevel; // real voltage level
2031}SET_VOLTAGE_PARAMETERS_V2; 2182}SET_VOLTAGE_PARAMETERS_V2;
2032 2183
2184
2185typedef struct _SET_VOLTAGE_PARAMETERS_V1_3
2186{
2187 UCHAR ucVoltageType; // To tell which voltage to set up, VDDC/MVDDC/MVDDQ/VDDCI
2188 UCHAR ucVoltageMode; // Indicate action: Set voltage level
2189 USHORT usVoltageLevel; // real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. )
2190}SET_VOLTAGE_PARAMETERS_V1_3;
2191
2192//ucVoltageType
2193#define VOLTAGE_TYPE_VDDC 1
2194#define VOLTAGE_TYPE_MVDDC 2
2195#define VOLTAGE_TYPE_MVDDQ 3
2196#define VOLTAGE_TYPE_VDDCI 4
2197
2198//SET_VOLTAGE_PARAMETERS_V3.ucVoltageMode
2199#define ATOM_SET_VOLTAGE 0 //Set voltage Level
2200#define ATOM_INIT_VOLTAGE_REGULATOR 3 //Init Regulator
2201#define ATOM_SET_VOLTAGE_PHASE 4 //Set Vregulator Phase
2202#define ATOM_GET_MAX_VOLTAGE 6 //Get Max Voltage, not used in SetVoltageTable v1.3
2203#define ATOM_GET_VOLTAGE_LEVEL 6 //Get Voltage level from vitual voltage ID
2204
2205// define vitual voltage id in usVoltageLevel
2206#define ATOM_VIRTUAL_VOLTAGE_ID0 0xff01
2207#define ATOM_VIRTUAL_VOLTAGE_ID1 0xff02
2208#define ATOM_VIRTUAL_VOLTAGE_ID2 0xff03
2209#define ATOM_VIRTUAL_VOLTAGE_ID3 0xff04
2210
2033typedef struct _SET_VOLTAGE_PS_ALLOCATION 2211typedef struct _SET_VOLTAGE_PS_ALLOCATION
2034{ 2212{
2035 SET_VOLTAGE_PARAMETERS sASICSetVoltage; 2213 SET_VOLTAGE_PARAMETERS sASICSetVoltage;
2036 WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved; 2214 WRITE_ONE_BYTE_HW_I2C_DATA_PS_ALLOCATION sReserved;
2037}SET_VOLTAGE_PS_ALLOCATION; 2215}SET_VOLTAGE_PS_ALLOCATION;
2038 2216
2217// New Added from SI for GetVoltageInfoTable, input parameter structure
2218typedef struct _GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_1
2219{
2220 UCHAR ucVoltageType; // Input: To tell which voltage to set up, VDDC/MVDDC/MVDDQ/VDDCI
2221 UCHAR ucVoltageMode; // Input: Indicate action: Get voltage info
2222 USHORT usVoltageLevel; // Input: real voltage level in unit of mv or Voltage Phase (0, 1, 2, .. ) or Leakage Id
2223 ULONG ulReserved;
2224}GET_VOLTAGE_INFO_INPUT_PARAMETER_V1_1;
2225
2226// New Added from SI for GetVoltageInfoTable, output parameter structure when ucVotlageMode == ATOM_GET_VOLTAGE_VID
2227typedef struct _GET_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_1
2228{
2229 ULONG ulVotlageGpioState;
2230 ULONG ulVoltageGPioMask;
2231}GET_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_1;
2232
2233// New Added from SI for GetVoltageInfoTable, output parameter structure when ucVotlageMode == ATOM_GET_VOLTAGE_STATEx_LEAKAGE_VID
2234typedef struct _GET_LEAKAGE_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_1
2235{
2236 USHORT usVoltageLevel;
2237 USHORT usVoltageId; // Voltage Id programmed in Voltage Regulator
2238 ULONG ulReseved;
2239}GET_LEAKAGE_VOLTAGE_INFO_OUTPUT_PARAMETER_V1_1;
2240
2241
2242// GetVoltageInfo v1.1 ucVoltageMode
2243#define ATOM_GET_VOLTAGE_VID 0x00
2244#define ATOM_GET_VOTLAGE_INIT_SEQ 0x03
2245#define ATOM_GET_VOLTTAGE_PHASE_PHASE_VID 0x04
2246// for SI, this state map to 0xff02 voltage state in Power Play table, which is power boost state
2247#define ATOM_GET_VOLTAGE_STATE0_LEAKAGE_VID 0x10
2248
2249// for SI, this state map to 0xff01 voltage state in Power Play table, which is performance state
2250#define ATOM_GET_VOLTAGE_STATE1_LEAKAGE_VID 0x11
2251// undefined power state
2252#define ATOM_GET_VOLTAGE_STATE2_LEAKAGE_VID 0x12
2253#define ATOM_GET_VOLTAGE_STATE3_LEAKAGE_VID 0x13
2254
2039/****************************************************************************/ 2255/****************************************************************************/
2040// Structures used by TVEncoderControlTable 2256// Structures used by TVEncoderControlTable
2041/****************************************************************************/ 2257/****************************************************************************/
@@ -2065,9 +2281,9 @@ typedef struct _ATOM_MASTER_LIST_OF_DATA_TABLES
2065 USHORT MultimediaConfigInfo; // Only used by MM Lib,latest version 2.1, not configuable from Bios, need to include the table to build Bios 2281 USHORT MultimediaConfigInfo; // Only used by MM Lib,latest version 2.1, not configuable from Bios, need to include the table to build Bios
2066 USHORT StandardVESA_Timing; // Only used by Bios 2282 USHORT StandardVESA_Timing; // Only used by Bios
2067 USHORT FirmwareInfo; // Shared by various SW components,latest version 1.4 2283 USHORT FirmwareInfo; // Shared by various SW components,latest version 1.4
2068 USHORT DAC_Info; // Will be obsolete from R600 2284 USHORT PaletteData; // Only used by BIOS
2069 USHORT LCD_Info; // Shared by various SW components,latest version 1.3, was called LVDS_Info 2285 USHORT LCD_Info; // Shared by various SW components,latest version 1.3, was called LVDS_Info
2070 USHORT TMDS_Info; // Will be obsolete from R600 2286 USHORT DIGTransmitterInfo; // Internal used by VBIOS only version 3.1
2071 USHORT AnalogTV_Info; // Shared by various SW components,latest version 1.1 2287 USHORT AnalogTV_Info; // Shared by various SW components,latest version 1.1
2072 USHORT SupportedDevicesInfo; // Will be obsolete from R600 2288 USHORT SupportedDevicesInfo; // Will be obsolete from R600
2073 USHORT GPIO_I2C_Info; // Shared by various SW components,latest version 1.2 will be used from R600 2289 USHORT GPIO_I2C_Info; // Shared by various SW components,latest version 1.2 will be used from R600
@@ -2096,15 +2312,16 @@ typedef struct _ATOM_MASTER_LIST_OF_DATA_TABLES
2096 USHORT PowerSourceInfo; // Shared by various SW components, latest versoin 1.1 2312 USHORT PowerSourceInfo; // Shared by various SW components, latest versoin 1.1
2097}ATOM_MASTER_LIST_OF_DATA_TABLES; 2313}ATOM_MASTER_LIST_OF_DATA_TABLES;
2098 2314
2099// For backward compatible
2100#define LVDS_Info LCD_Info
2101
2102typedef struct _ATOM_MASTER_DATA_TABLE 2315typedef struct _ATOM_MASTER_DATA_TABLE
2103{ 2316{
2104 ATOM_COMMON_TABLE_HEADER sHeader; 2317 ATOM_COMMON_TABLE_HEADER sHeader;
2105 ATOM_MASTER_LIST_OF_DATA_TABLES ListOfDataTables; 2318 ATOM_MASTER_LIST_OF_DATA_TABLES ListOfDataTables;
2106}ATOM_MASTER_DATA_TABLE; 2319}ATOM_MASTER_DATA_TABLE;
2107 2320
2321// For backward compatible
2322#define LVDS_Info LCD_Info
2323#define DAC_Info PaletteData
2324#define TMDS_Info DIGTransmitterInfo
2108 2325
2109/****************************************************************************/ 2326/****************************************************************************/
2110// Structure used in MultimediaCapabilityInfoTable 2327// Structure used in MultimediaCapabilityInfoTable
@@ -2171,7 +2388,9 @@ typedef struct _ATOM_MULTIMEDIA_CONFIG_INFO
2171typedef struct _ATOM_FIRMWARE_CAPABILITY 2388typedef struct _ATOM_FIRMWARE_CAPABILITY
2172{ 2389{
2173#if ATOM_BIG_ENDIAN 2390#if ATOM_BIG_ENDIAN
2174 USHORT Reserved:3; 2391 USHORT Reserved:1;
2392 USHORT SCL2Redefined:1;
2393 USHORT PostWithoutModeSet:1;
2175 USHORT HyperMemory_Size:4; 2394 USHORT HyperMemory_Size:4;
2176 USHORT HyperMemory_Support:1; 2395 USHORT HyperMemory_Support:1;
2177 USHORT PPMode_Assigned:1; 2396 USHORT PPMode_Assigned:1;
@@ -2193,7 +2412,9 @@ typedef struct _ATOM_FIRMWARE_CAPABILITY
2193 USHORT PPMode_Assigned:1; 2412 USHORT PPMode_Assigned:1;
2194 USHORT HyperMemory_Support:1; 2413 USHORT HyperMemory_Support:1;
2195 USHORT HyperMemory_Size:4; 2414 USHORT HyperMemory_Size:4;
2196 USHORT Reserved:3; 2415 USHORT PostWithoutModeSet:1;
2416 USHORT SCL2Redefined:1;
2417 USHORT Reserved:1;
2197#endif 2418#endif
2198}ATOM_FIRMWARE_CAPABILITY; 2419}ATOM_FIRMWARE_CAPABILITY;
2199 2420
@@ -2418,7 +2639,8 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_2
2418 USHORT usLcdMaxPixelClockPLL_Output; // In MHz unit 2639 USHORT usLcdMaxPixelClockPLL_Output; // In MHz unit
2419 ULONG ulReserved4; //Was ulAsicMaximumVoltage 2640 ULONG ulReserved4; //Was ulAsicMaximumVoltage
2420 ULONG ulMinPixelClockPLL_Output; //In 10Khz unit 2641 ULONG ulMinPixelClockPLL_Output; //In 10Khz unit
2421 ULONG ulReserved5; //Was usMinEngineClockPLL_Input and usMaxEngineClockPLL_Input 2642 UCHAR ucRemoteDisplayConfig;
2643 UCHAR ucReserved5[3]; //Was usMinEngineClockPLL_Input and usMaxEngineClockPLL_Input
2422 ULONG ulReserved6; //Was usMinEngineClockPLL_Output and usMinMemoryClockPLL_Input 2644 ULONG ulReserved6; //Was usMinEngineClockPLL_Output and usMinMemoryClockPLL_Input
2423 ULONG ulReserved7; //Was usMaxMemoryClockPLL_Input and usMinMemoryClockPLL_Output 2645 ULONG ulReserved7; //Was usMaxMemoryClockPLL_Input and usMinMemoryClockPLL_Output
2424 USHORT usReserved11; //Was usMaxPixelClock; //In 10Khz unit, Max. Pclk used only for DAC 2646 USHORT usReserved11; //Was usMaxPixelClock; //In 10Khz unit, Max. Pclk used only for DAC
@@ -2438,6 +2660,11 @@ typedef struct _ATOM_FIRMWARE_INFO_V2_2
2438 2660
2439#define ATOM_FIRMWARE_INFO_LAST ATOM_FIRMWARE_INFO_V2_2 2661#define ATOM_FIRMWARE_INFO_LAST ATOM_FIRMWARE_INFO_V2_2
2440 2662
2663
2664// definition of ucRemoteDisplayConfig
2665#define REMOTE_DISPLAY_DISABLE 0x00
2666#define REMOTE_DISPLAY_ENABLE 0x01
2667
2441/****************************************************************************/ 2668/****************************************************************************/
2442// Structures used in IntegratedSystemInfoTable 2669// Structures used in IntegratedSystemInfoTable
2443/****************************************************************************/ 2670/****************************************************************************/
@@ -2660,8 +2887,9 @@ usMinDownStreamHTLinkWidth: same as above.
2660#define INTEGRATED_SYSTEM_INFO__AMD_CPU__GREYHOUND 2 2887#define INTEGRATED_SYSTEM_INFO__AMD_CPU__GREYHOUND 2
2661#define INTEGRATED_SYSTEM_INFO__AMD_CPU__K8 3 2888#define INTEGRATED_SYSTEM_INFO__AMD_CPU__K8 3
2662#define INTEGRATED_SYSTEM_INFO__AMD_CPU__PHARAOH 4 2889#define INTEGRATED_SYSTEM_INFO__AMD_CPU__PHARAOH 4
2890#define INTEGRATED_SYSTEM_INFO__AMD_CPU__OROCHI 5
2663 2891
2664#define INTEGRATED_SYSTEM_INFO__AMD_CPU__MAX_CODE INTEGRATED_SYSTEM_INFO__AMD_CPU__PHARAOH // this deff reflects max defined CPU code 2892#define INTEGRATED_SYSTEM_INFO__AMD_CPU__MAX_CODE INTEGRATED_SYSTEM_INFO__AMD_CPU__OROCHI // this deff reflects max defined CPU code
2665 2893
2666#define SYSTEM_CONFIG_POWEREXPRESS_ENABLE 0x00000001 2894#define SYSTEM_CONFIG_POWEREXPRESS_ENABLE 0x00000001
2667#define SYSTEM_CONFIG_RUN_AT_OVERDRIVE_ENGINE 0x00000002 2895#define SYSTEM_CONFIG_RUN_AT_OVERDRIVE_ENGINE 0x00000002
@@ -2753,6 +2981,7 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V5
2753#define ASIC_INT_DIG4_ENCODER_ID 0x0b 2981#define ASIC_INT_DIG4_ENCODER_ID 0x0b
2754#define ASIC_INT_DIG5_ENCODER_ID 0x0c 2982#define ASIC_INT_DIG5_ENCODER_ID 0x0c
2755#define ASIC_INT_DIG6_ENCODER_ID 0x0d 2983#define ASIC_INT_DIG6_ENCODER_ID 0x0d
2984#define ASIC_INT_DIG7_ENCODER_ID 0x0e
2756 2985
2757//define Encoder attribute 2986//define Encoder attribute
2758#define ATOM_ANALOG_ENCODER 0 2987#define ATOM_ANALOG_ENCODER 0
@@ -3226,15 +3455,23 @@ typedef struct _ATOM_LCD_INFO_V13
3226 3455
3227 UCHAR ucPowerSequenceDIGONtoDE_in4Ms; 3456 UCHAR ucPowerSequenceDIGONtoDE_in4Ms;
3228 UCHAR ucPowerSequenceDEtoVARY_BL_in4Ms; 3457 UCHAR ucPowerSequenceDEtoVARY_BL_in4Ms;
3229 UCHAR ucPowerSequenceDEtoDIGON_in4Ms;
3230 UCHAR ucPowerSequenceVARY_BLtoDE_in4Ms; 3458 UCHAR ucPowerSequenceVARY_BLtoDE_in4Ms;
3459 UCHAR ucPowerSequenceDEtoDIGON_in4Ms;
3231 3460
3232 UCHAR ucOffDelay_in4Ms; 3461 UCHAR ucOffDelay_in4Ms;
3233 UCHAR ucPowerSequenceVARY_BLtoBLON_in4Ms; 3462 UCHAR ucPowerSequenceVARY_BLtoBLON_in4Ms;
3234 UCHAR ucPowerSequenceBLONtoVARY_BL_in4Ms; 3463 UCHAR ucPowerSequenceBLONtoVARY_BL_in4Ms;
3235 UCHAR ucReserved1; 3464 UCHAR ucReserved1;
3236 3465
3237 ULONG ulReserved[4]; 3466 UCHAR ucDPCD_eDP_CONFIGURATION_CAP; // dpcd 0dh
3467 UCHAR ucDPCD_MAX_LINK_RATE; // dpcd 01h
3468 UCHAR ucDPCD_MAX_LANE_COUNT; // dpcd 02h
3469 UCHAR ucDPCD_MAX_DOWNSPREAD; // dpcd 03h
3470
3471 USHORT usMaxPclkFreqInSingleLink; // Max PixelClock frequency in single link mode.
3472 UCHAR uceDPToLVDSRxId;
3473 UCHAR ucLcdReservd;
3474 ULONG ulReserved[2];
3238}ATOM_LCD_INFO_V13; 3475}ATOM_LCD_INFO_V13;
3239 3476
3240#define ATOM_LCD_INFO_LAST ATOM_LCD_INFO_V13 3477#define ATOM_LCD_INFO_LAST ATOM_LCD_INFO_V13
@@ -3273,6 +3510,11 @@ typedef struct _ATOM_LCD_INFO_V13
3273//Use this cap bit for a quick reference whether an embadded panel (LCD1 ) is LVDS or eDP. 3510//Use this cap bit for a quick reference whether an embadded panel (LCD1 ) is LVDS or eDP.
3274#define LCDPANEL_CAP_V13_eDP 0x4 // = LCDPANEL_CAP_eDP no change comparing to previous version 3511#define LCDPANEL_CAP_V13_eDP 0x4 // = LCDPANEL_CAP_eDP no change comparing to previous version
3275 3512
3513//uceDPToLVDSRxId
3514#define eDP_TO_LVDS_RX_DISABLE 0x00 // no eDP->LVDS translator chip
3515#define eDP_TO_LVDS_COMMON_ID 0x01 // common eDP->LVDS translator chip without AMD SW init
3516#define eDP_TO_LVDS_RT_ID 0x02 // RT tanslator which require AMD SW init
3517
3276typedef struct _ATOM_PATCH_RECORD_MODE 3518typedef struct _ATOM_PATCH_RECORD_MODE
3277{ 3519{
3278 UCHAR ucRecordType; 3520 UCHAR ucRecordType;
@@ -3317,6 +3559,7 @@ typedef struct _ATOM_PANEL_RESOLUTION_PATCH_RECORD
3317#define LCD_CAP_RECORD_TYPE 3 3559#define LCD_CAP_RECORD_TYPE 3
3318#define LCD_FAKE_EDID_PATCH_RECORD_TYPE 4 3560#define LCD_FAKE_EDID_PATCH_RECORD_TYPE 4
3319#define LCD_PANEL_RESOLUTION_RECORD_TYPE 5 3561#define LCD_PANEL_RESOLUTION_RECORD_TYPE 5
3562#define LCD_EDID_OFFSET_PATCH_RECORD_TYPE 6
3320#define ATOM_RECORD_END_TYPE 0xFF 3563#define ATOM_RECORD_END_TYPE 0xFF
3321 3564
3322/****************************Spread Spectrum Info Table Definitions **********************/ 3565/****************************Spread Spectrum Info Table Definitions **********************/
@@ -3528,6 +3771,7 @@ else //Non VGA case
3528 3771
3529CAIL needs to claim an reserved area defined by FBAccessAreaOffset and usFBUsedbyDrvInKB in non VGA case.*/ 3772CAIL needs to claim an reserved area defined by FBAccessAreaOffset and usFBUsedbyDrvInKB in non VGA case.*/
3530 3773
3774/***********************************************************************************/
3531#define ATOM_MAX_FIRMWARE_VRAM_USAGE_INFO 1 3775#define ATOM_MAX_FIRMWARE_VRAM_USAGE_INFO 1
3532 3776
3533typedef struct _ATOM_FIRMWARE_VRAM_RESERVE_INFO 3777typedef struct _ATOM_FIRMWARE_VRAM_RESERVE_INFO
@@ -3818,13 +4062,17 @@ typedef struct _EXT_DISPLAY_PATH
3818 ATOM_DP_CONN_CHANNEL_MAPPING asDPMapping; 4062 ATOM_DP_CONN_CHANNEL_MAPPING asDPMapping;
3819 ATOM_DVI_CONN_CHANNEL_MAPPING asDVIMapping; 4063 ATOM_DVI_CONN_CHANNEL_MAPPING asDVIMapping;
3820 }; 4064 };
3821 UCHAR ucReserved; 4065 UCHAR ucChPNInvert; // bit vector for up to 8 lanes, =0: P and N is not invert, =1 P and N is inverted
3822 USHORT usReserved[2]; 4066 USHORT usCaps;
4067 USHORT usReserved;
3823}EXT_DISPLAY_PATH; 4068}EXT_DISPLAY_PATH;
3824 4069
3825#define NUMBER_OF_UCHAR_FOR_GUID 16 4070#define NUMBER_OF_UCHAR_FOR_GUID 16
3826#define MAX_NUMBER_OF_EXT_DISPLAY_PATH 7 4071#define MAX_NUMBER_OF_EXT_DISPLAY_PATH 7
3827 4072
4073//usCaps
4074#define EXT_DISPLAY_PATH_CAPS__HBR2_DISABLE 0x01
4075
3828typedef struct _ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO 4076typedef struct _ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO
3829{ 4077{
3830 ATOM_COMMON_TABLE_HEADER sHeader; 4078 ATOM_COMMON_TABLE_HEADER sHeader;
@@ -3832,7 +4080,9 @@ typedef struct _ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO
3832 EXT_DISPLAY_PATH sPath[MAX_NUMBER_OF_EXT_DISPLAY_PATH]; // total of fixed 7 entries. 4080 EXT_DISPLAY_PATH sPath[MAX_NUMBER_OF_EXT_DISPLAY_PATH]; // total of fixed 7 entries.
3833 UCHAR ucChecksum; // a simple Checksum of the sum of whole structure equal to 0x0. 4081 UCHAR ucChecksum; // a simple Checksum of the sum of whole structure equal to 0x0.
3834 UCHAR uc3DStereoPinId; // use for eDP panel 4082 UCHAR uc3DStereoPinId; // use for eDP panel
3835 UCHAR Reserved [6]; // for potential expansion 4083 UCHAR ucRemoteDisplayConfig;
4084 UCHAR uceDPToLVDSRxId;
4085 UCHAR Reserved[4]; // for potential expansion
3836}ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO; 4086}ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO;
3837 4087
3838//Related definitions, all records are different but they have a commond header 4088//Related definitions, all records are different but they have a commond header
@@ -3977,6 +4227,7 @@ typedef struct _ATOM_OBJECT_GPIO_CNTL_RECORD
3977#define GPIO_PIN_STATE_ACTIVE_HIGH 0x1 4227#define GPIO_PIN_STATE_ACTIVE_HIGH 0x1
3978 4228
3979// Indexes to GPIO array in GLSync record 4229// Indexes to GPIO array in GLSync record
4230// GLSync record is for Frame Lock/Gen Lock feature.
3980#define ATOM_GPIO_INDEX_GLSYNC_REFCLK 0 4231#define ATOM_GPIO_INDEX_GLSYNC_REFCLK 0
3981#define ATOM_GPIO_INDEX_GLSYNC_HSYNC 1 4232#define ATOM_GPIO_INDEX_GLSYNC_HSYNC 1
3982#define ATOM_GPIO_INDEX_GLSYNC_VSYNC 2 4233#define ATOM_GPIO_INDEX_GLSYNC_VSYNC 2
@@ -3984,7 +4235,9 @@ typedef struct _ATOM_OBJECT_GPIO_CNTL_RECORD
3984#define ATOM_GPIO_INDEX_GLSYNC_SWAP_GNT 4 4235#define ATOM_GPIO_INDEX_GLSYNC_SWAP_GNT 4
3985#define ATOM_GPIO_INDEX_GLSYNC_INTERRUPT 5 4236#define ATOM_GPIO_INDEX_GLSYNC_INTERRUPT 5
3986#define ATOM_GPIO_INDEX_GLSYNC_V_RESET 6 4237#define ATOM_GPIO_INDEX_GLSYNC_V_RESET 6
3987#define ATOM_GPIO_INDEX_GLSYNC_MAX 7 4238#define ATOM_GPIO_INDEX_GLSYNC_SWAP_CNTL 7
4239#define ATOM_GPIO_INDEX_GLSYNC_SWAP_SEL 8
4240#define ATOM_GPIO_INDEX_GLSYNC_MAX 9
3988 4241
3989typedef struct _ATOM_ENCODER_DVO_CF_RECORD 4242typedef struct _ATOM_ENCODER_DVO_CF_RECORD
3990{ 4243{
@@ -3994,7 +4247,8 @@ typedef struct _ATOM_ENCODER_DVO_CF_RECORD
3994}ATOM_ENCODER_DVO_CF_RECORD; 4247}ATOM_ENCODER_DVO_CF_RECORD;
3995 4248
3996// Bit maps for ATOM_ENCODER_CAP_RECORD.ucEncoderCap 4249// Bit maps for ATOM_ENCODER_CAP_RECORD.ucEncoderCap
3997#define ATOM_ENCODER_CAP_RECORD_HBR2 0x01 // DP1.2 HBR2 is supported by this path 4250#define ATOM_ENCODER_CAP_RECORD_HBR2 0x01 // DP1.2 HBR2 is supported by HW encoder
4251#define ATOM_ENCODER_CAP_RECORD_HBR2_EN 0x02 // DP1.2 HBR2 setting is qualified and HBR2 can be enabled
3998 4252
3999typedef struct _ATOM_ENCODER_CAP_RECORD 4253typedef struct _ATOM_ENCODER_CAP_RECORD
4000{ 4254{
@@ -4003,11 +4257,13 @@ typedef struct _ATOM_ENCODER_CAP_RECORD
4003 USHORT usEncoderCap; 4257 USHORT usEncoderCap;
4004 struct { 4258 struct {
4005#if ATOM_BIG_ENDIAN 4259#if ATOM_BIG_ENDIAN
4006 USHORT usReserved:15; // Bit1-15 may be defined for other capability in future 4260 USHORT usReserved:14; // Bit1-15 may be defined for other capability in future
4261 USHORT usHBR2En:1; // Bit1 is for DP1.2 HBR2 enable
4007 USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. 4262 USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability.
4008#else 4263#else
4009 USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability. 4264 USHORT usHBR2Cap:1; // Bit0 is for DP1.2 HBR2 capability.
4010 USHORT usReserved:15; // Bit1-15 may be defined for other capability in future 4265 USHORT usHBR2En:1; // Bit1 is for DP1.2 HBR2 enable
4266 USHORT usReserved:14; // Bit1-15 may be defined for other capability in future
4011#endif 4267#endif
4012 }; 4268 };
4013 }; 4269 };
@@ -4157,6 +4413,7 @@ typedef struct _ATOM_VOLTAGE_CONTROL
4157#define VOLTAGE_CONTROL_ID_VT1556M 0x07 4413#define VOLTAGE_CONTROL_ID_VT1556M 0x07
4158#define VOLTAGE_CONTROL_ID_CHL822x 0x08 4414#define VOLTAGE_CONTROL_ID_CHL822x 0x08
4159#define VOLTAGE_CONTROL_ID_VT1586M 0x09 4415#define VOLTAGE_CONTROL_ID_VT1586M 0x09
4416#define VOLTAGE_CONTROL_ID_UP1637 0x0A
4160 4417
4161typedef struct _ATOM_VOLTAGE_OBJECT 4418typedef struct _ATOM_VOLTAGE_OBJECT
4162{ 4419{
@@ -4193,6 +4450,69 @@ typedef struct _ATOM_LEAKID_VOLTAGE
4193 USHORT usVoltage; 4450 USHORT usVoltage;
4194}ATOM_LEAKID_VOLTAGE; 4451}ATOM_LEAKID_VOLTAGE;
4195 4452
4453typedef struct _ATOM_VOLTAGE_OBJECT_HEADER_V3{
4454 UCHAR ucVoltageType; //Indicate Voltage Source: VDDC, MVDDC, MVDDQ or MVDDCI
4455 UCHAR ucVoltageMode; //Indicate voltage control mode: Init/Set/Leakage/Set phase
4456 USHORT usSize; //Size of Object
4457}ATOM_VOLTAGE_OBJECT_HEADER_V3;
4458
4459typedef struct _VOLTAGE_LUT_ENTRY_V2
4460{
4461 ULONG ulVoltageId; // The Voltage ID which is used to program GPIO register
4462 USHORT usVoltageValue; // The corresponding Voltage Value, in mV
4463}VOLTAGE_LUT_ENTRY_V2;
4464
4465typedef struct _LEAKAGE_VOLTAGE_LUT_ENTRY_V2
4466{
4467 USHORT usVoltageLevel; // The Voltage ID which is used to program GPIO register
4468 USHORT usVoltageId;
4469 USHORT usLeakageId; // The corresponding Voltage Value, in mV
4470}LEAKAGE_VOLTAGE_LUT_ENTRY_V2;
4471
4472typedef struct _ATOM_I2C_VOLTAGE_OBJECT_V3
4473{
4474 ATOM_VOLTAGE_OBJECT_HEADER_V3 sHeader;
4475 UCHAR ucVoltageRegulatorId; //Indicate Voltage Regulator Id
4476 UCHAR ucVoltageControlI2cLine;
4477 UCHAR ucVoltageControlAddress;
4478 UCHAR ucVoltageControlOffset;
4479 ULONG ulReserved;
4480 VOLTAGE_LUT_ENTRY asVolI2cLut[1]; // end with 0xff
4481}ATOM_I2C_VOLTAGE_OBJECT_V3;
4482
4483typedef struct _ATOM_GPIO_VOLTAGE_OBJECT_V3
4484{
4485 ATOM_VOLTAGE_OBJECT_HEADER_V3 sHeader;
4486 UCHAR ucVoltageGpioCntlId; // default is 0 which indicate control through CG VID mode
4487 UCHAR ucGpioEntryNum; // indiate the entry numbers of Votlage/Gpio value Look up table
4488 UCHAR ucPhaseDelay; // phase delay in unit of micro second
4489 UCHAR ucReserved;
4490 ULONG ulGpioMaskVal; // GPIO Mask value
4491 VOLTAGE_LUT_ENTRY_V2 asVolGpioLut[1];
4492}ATOM_GPIO_VOLTAGE_OBJECT_V3;
4493
4494typedef struct _ATOM_LEAKAGE_VOLTAGE_OBJECT_V3
4495{
4496 ATOM_VOLTAGE_OBJECT_HEADER_V3 sHeader;
4497 UCHAR ucLeakageCntlId; // default is 0
4498 UCHAR ucLeakageEntryNum; // indicate the entry number of LeakageId/Voltage Lut table
4499 UCHAR ucReserved[2];
4500 ULONG ulMaxVoltageLevel;
4501 LEAKAGE_VOLTAGE_LUT_ENTRY_V2 asLeakageIdLut[1];
4502}ATOM_LEAKAGE_VOLTAGE_OBJECT_V3;
4503
4504typedef union _ATOM_VOLTAGE_OBJECT_V3{
4505 ATOM_GPIO_VOLTAGE_OBJECT_V3 asGpioVoltageObj;
4506 ATOM_I2C_VOLTAGE_OBJECT_V3 asI2cVoltageObj;
4507 ATOM_LEAKAGE_VOLTAGE_OBJECT_V3 asLeakageObj;
4508}ATOM_VOLTAGE_OBJECT_V3;
4509
4510typedef struct _ATOM_VOLTAGE_OBJECT_INFO_V3_1
4511{
4512 ATOM_COMMON_TABLE_HEADER sHeader;
4513 ATOM_VOLTAGE_OBJECT_V3 asVoltageObj[3]; //Info for Voltage control
4514}ATOM_VOLTAGE_OBJECT_INFO_V3_1;
4515
4196typedef struct _ATOM_ASIC_PROFILE_VOLTAGE 4516typedef struct _ATOM_ASIC_PROFILE_VOLTAGE
4197{ 4517{
4198 UCHAR ucProfileId; 4518 UCHAR ucProfileId;
@@ -4305,7 +4625,18 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V6
4305 USHORT usHDMISSpreadRateIn10Hz; 4625 USHORT usHDMISSpreadRateIn10Hz;
4306 USHORT usDVISSPercentage; 4626 USHORT usDVISSPercentage;
4307 USHORT usDVISSpreadRateIn10Hz; 4627 USHORT usDVISSpreadRateIn10Hz;
4308 ULONG ulReserved3[21]; 4628 ULONG SclkDpmBoostMargin;
4629 ULONG SclkDpmThrottleMargin;
4630 USHORT SclkDpmTdpLimitPG;
4631 USHORT SclkDpmTdpLimitBoost;
4632 ULONG ulBoostEngineCLock;
4633 UCHAR ulBoostVid_2bit;
4634 UCHAR EnableBoost;
4635 USHORT GnbTdpLimit;
4636 USHORT usMaxLVDSPclkFreqInSingleLink;
4637 UCHAR ucLvdsMisc;
4638 UCHAR ucLVDSReserved;
4639 ULONG ulReserved3[15];
4309 ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo; 4640 ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo;
4310}ATOM_INTEGRATED_SYSTEM_INFO_V6; 4641}ATOM_INTEGRATED_SYSTEM_INFO_V6;
4311 4642
@@ -4313,9 +4644,16 @@ typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V6
4313#define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__TMDSHDMI_COHERENT_SINGLEPLL_MODE 0x01 4644#define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__TMDSHDMI_COHERENT_SINGLEPLL_MODE 0x01
4314#define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__DISABLE_AUX_HW_MODE_DETECTION 0x08 4645#define INTEGRATED_SYSTEM_INFO_V6_GPUCAPINFO__DISABLE_AUX_HW_MODE_DETECTION 0x08
4315 4646
4316// ulOtherDisplayMisc 4647//ucLVDSMisc:
4317#define INTEGRATED_SYSTEM_INFO__GET_EDID_CALLBACK_FUNC_SUPPORT 0x01 4648#define SYS_INFO_LVDSMISC__888_FPDI_MODE 0x01
4649#define SYS_INFO_LVDSMISC__DL_CH_SWAP 0x02
4650#define SYS_INFO_LVDSMISC__888_BPC 0x04
4651#define SYS_INFO_LVDSMISC__OVERRIDE_EN 0x08
4652#define SYS_INFO_LVDSMISC__BLON_ACTIVE_LOW 0x10
4318 4653
4654// not used any more
4655#define SYS_INFO_LVDSMISC__VSYNC_ACTIVE_LOW 0x04
4656#define SYS_INFO_LVDSMISC__HSYNC_ACTIVE_LOW 0x08
4319 4657
4320/********************************************************************************************************************** 4658/**********************************************************************************************************************
4321 ATOM_INTEGRATED_SYSTEM_INFO_V6 Description 4659 ATOM_INTEGRATED_SYSTEM_INFO_V6 Description
@@ -4384,7 +4722,208 @@ ucUMAChannelNumber: System memory channel numbers.
4384ulCSR_M3_ARB_CNTL_DEFAULT[10]: Arrays with values for CSR M3 arbiter for default 4722ulCSR_M3_ARB_CNTL_DEFAULT[10]: Arrays with values for CSR M3 arbiter for default
4385ulCSR_M3_ARB_CNTL_UVD[10]: Arrays with values for CSR M3 arbiter for UVD playback. 4723ulCSR_M3_ARB_CNTL_UVD[10]: Arrays with values for CSR M3 arbiter for UVD playback.
4386ulCSR_M3_ARB_CNTL_FS3D[10]: Arrays with values for CSR M3 arbiter for Full Screen 3D applications. 4724ulCSR_M3_ARB_CNTL_FS3D[10]: Arrays with values for CSR M3 arbiter for Full Screen 3D applications.
4387sAvail_SCLK[5]: Arrays to provide available list of SLCK and corresponding voltage, order from low to high 4725sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high
4726ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns.
4727ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz.
4728ulIdleNClk: NCLK speed while memory runs in self-refresh state. Unit in 10kHz.
4729ulDDR_DLL_PowerUpTime: DDR PHY DLL power up time. Unit in ns.
4730ulDDR_PLL_PowerUpTime: DDR PHY PLL power up time. Unit in ns.
4731usPCIEClkSSPercentage: PCIE Clock Spred Spectrum Percentage in unit 0.01%; 100 mean 1%.
4732usPCIEClkSSType: PCIE Clock Spred Spectrum Type. 0 for Down spread(default); 1 for Center spread.
4733usLvdsSSPercentage: LVDS panel ( not include eDP ) Spread Spectrum Percentage in unit of 0.01%, =0, use VBIOS default setting.
4734usLvdsSSpreadRateIn10Hz: LVDS panel ( not include eDP ) Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting.
4735usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting.
4736usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting.
4737usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting.
4738usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting.
4739usMaxLVDSPclkFreqInSingleLink: Max pixel clock LVDS panel single link, if=0 means VBIOS use default threhold, right now it is 85Mhz
4740ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 panel in LDI mode, =1: LVDS 888 panel in FPDI mode
4741 [bit1] LVDS panel lower and upper link mapping =0: lower link and upper link not swap, =1: lower link and upper link are swapped
4742 [bit2] LVDS 888bit per color mode =0: 666 bit per color =1:888 bit per color
4743 [bit3] LVDS parameter override enable =0: ucLvdsMisc parameter are not used =1: ucLvdsMisc parameter should be used
4744 [bit4] Polarity of signal sent to digital BLON output pin. =0: not inverted(active high) =1: inverted ( active low )
4745**********************************************************************************************************************/
4746
4747// this Table is used for Liano/Ontario APU
4748typedef struct _ATOM_FUSION_SYSTEM_INFO_V1
4749{
4750 ATOM_INTEGRATED_SYSTEM_INFO_V6 sIntegratedSysInfo;
4751 ULONG ulPowerplayTable[128];
4752}ATOM_FUSION_SYSTEM_INFO_V1;
4753/**********************************************************************************************************************
4754 ATOM_FUSION_SYSTEM_INFO_V1 Description
4755sIntegratedSysInfo: refer to ATOM_INTEGRATED_SYSTEM_INFO_V6 definition.
4756ulPowerplayTable[128]: This 512 bytes memory is used to save ATOM_PPLIB_POWERPLAYTABLE3, starting form ulPowerplayTable[0]
4757**********************************************************************************************************************/
4758
4759// this IntegrateSystemInfoTable is used for Trinity APU
4760typedef struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7
4761{
4762 ATOM_COMMON_TABLE_HEADER sHeader;
4763 ULONG ulBootUpEngineClock;
4764 ULONG ulDentistVCOFreq;
4765 ULONG ulBootUpUMAClock;
4766 ATOM_CLK_VOLT_CAPABILITY sDISPCLK_Voltage[4];
4767 ULONG ulBootUpReqDisplayVector;
4768 ULONG ulOtherDisplayMisc;
4769 ULONG ulGPUCapInfo;
4770 ULONG ulSB_MMIO_Base_Addr;
4771 USHORT usRequestedPWMFreqInHz;
4772 UCHAR ucHtcTmpLmt;
4773 UCHAR ucHtcHystLmt;
4774 ULONG ulMinEngineClock;
4775 ULONG ulSystemConfig;
4776 ULONG ulCPUCapInfo;
4777 USHORT usNBP0Voltage;
4778 USHORT usNBP1Voltage;
4779 USHORT usBootUpNBVoltage;
4780 USHORT usExtDispConnInfoOffset;
4781 USHORT usPanelRefreshRateRange;
4782 UCHAR ucMemoryType;
4783 UCHAR ucUMAChannelNumber;
4784 UCHAR strVBIOSMsg[40];
4785 ULONG ulReserved[20];
4786 ATOM_AVAILABLE_SCLK_LIST sAvail_SCLK[5];
4787 ULONG ulGMCRestoreResetTime;
4788 ULONG ulMinimumNClk;
4789 ULONG ulIdleNClk;
4790 ULONG ulDDR_DLL_PowerUpTime;
4791 ULONG ulDDR_PLL_PowerUpTime;
4792 USHORT usPCIEClkSSPercentage;
4793 USHORT usPCIEClkSSType;
4794 USHORT usLvdsSSPercentage;
4795 USHORT usLvdsSSpreadRateIn10Hz;
4796 USHORT usHDMISSPercentage;
4797 USHORT usHDMISSpreadRateIn10Hz;
4798 USHORT usDVISSPercentage;
4799 USHORT usDVISSpreadRateIn10Hz;
4800 ULONG SclkDpmBoostMargin;
4801 ULONG SclkDpmThrottleMargin;
4802 USHORT SclkDpmTdpLimitPG;
4803 USHORT SclkDpmTdpLimitBoost;
4804 ULONG ulBoostEngineCLock;
4805 UCHAR ulBoostVid_2bit;
4806 UCHAR EnableBoost;
4807 USHORT GnbTdpLimit;
4808 USHORT usMaxLVDSPclkFreqInSingleLink;
4809 UCHAR ucLvdsMisc;
4810 UCHAR ucLVDSReserved;
4811 UCHAR ucLVDSPwrOnSeqDIGONtoDE_in4Ms;
4812 UCHAR ucLVDSPwrOnSeqDEtoVARY_BL_in4Ms;
4813 UCHAR ucLVDSPwrOffSeqVARY_BLtoDE_in4Ms;
4814 UCHAR ucLVDSPwrOffSeqDEtoDIGON_in4Ms;
4815 UCHAR ucLVDSOffToOnDelay_in4Ms;
4816 UCHAR ucLVDSPwrOnSeqVARY_BLtoBLON_in4Ms;
4817 UCHAR ucLVDSPwrOffSeqBLONtoVARY_BL_in4Ms;
4818 UCHAR ucLVDSReserved1;
4819 ULONG ulLCDBitDepthControlVal;
4820 ULONG ulNbpStateMemclkFreq[4];
4821 USHORT usNBP2Voltage;
4822 USHORT usNBP3Voltage;
4823 ULONG ulNbpStateNClkFreq[4];
4824 UCHAR ucNBDPMEnable;
4825 UCHAR ucReserved[3];
4826 UCHAR ucDPMState0VclkFid;
4827 UCHAR ucDPMState0DclkFid;
4828 UCHAR ucDPMState1VclkFid;
4829 UCHAR ucDPMState1DclkFid;
4830 UCHAR ucDPMState2VclkFid;
4831 UCHAR ucDPMState2DclkFid;
4832 UCHAR ucDPMState3VclkFid;
4833 UCHAR ucDPMState3DclkFid;
4834 ATOM_EXTERNAL_DISPLAY_CONNECTION_INFO sExtDispConnInfo;
4835}ATOM_INTEGRATED_SYSTEM_INFO_V1_7;
4836
4837// ulOtherDisplayMisc
4838#define INTEGRATED_SYSTEM_INFO__GET_EDID_CALLBACK_FUNC_SUPPORT 0x01
4839#define INTEGRATED_SYSTEM_INFO__GET_BOOTUP_DISPLAY_CALLBACK_FUNC_SUPPORT 0x02
4840#define INTEGRATED_SYSTEM_INFO__GET_EXPANSION_CALLBACK_FUNC_SUPPORT 0x04
4841#define INTEGRATED_SYSTEM_INFO__FAST_BOOT_SUPPORT 0x08
4842
4843// ulGPUCapInfo
4844#define SYS_INFO_GPUCAPS__TMDSHDMI_COHERENT_SINGLEPLL_MODE 0x01
4845#define SYS_INFO_GPUCAPS__DP_SINGLEPLL_MODE 0x02
4846#define SYS_INFO_GPUCAPS__DISABLE_AUX_MODE_DETECT 0x08
4847
4848/**********************************************************************************************************************
4849 ATOM_INTEGRATED_SYSTEM_INFO_V1_7 Description
4850ulBootUpEngineClock: VBIOS bootup Engine clock frequency, in 10kHz unit. if it is equal 0, then VBIOS use pre-defined bootup engine clock
4851ulDentistVCOFreq: Dentist VCO clock in 10kHz unit.
4852ulBootUpUMAClock: System memory boot up clock frequency in 10Khz unit.
4853sDISPCLK_Voltage: Report Display clock voltage requirement.
4854
4855ulBootUpReqDisplayVector: VBIOS boot up display IDs, following are supported devices in Trinity projects:
4856 ATOM_DEVICE_CRT1_SUPPORT 0x0001
4857 ATOM_DEVICE_DFP1_SUPPORT 0x0008
4858 ATOM_DEVICE_DFP6_SUPPORT 0x0040
4859 ATOM_DEVICE_DFP2_SUPPORT 0x0080
4860 ATOM_DEVICE_DFP3_SUPPORT 0x0200
4861 ATOM_DEVICE_DFP4_SUPPORT 0x0400
4862 ATOM_DEVICE_DFP5_SUPPORT 0x0800
4863 ATOM_DEVICE_LCD1_SUPPORT 0x0002
4864ulOtherDisplayMisc: bit[0]=0: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is not supported by SBIOS.
4865 =1: INT15 callback function Get LCD EDID ( ax=4e08, bl=1b ) is supported by SBIOS.
4866 bit[1]=0: INT15 callback function Get boot display( ax=4e08, bl=01h) is not supported by SBIOS
4867 =1: INT15 callback function Get boot display( ax=4e08, bl=01h) is supported by SBIOS
4868 bit[2]=0: INT15 callback function Get panel Expansion ( ax=4e08, bl=02h) is not supported by SBIOS
4869 =1: INT15 callback function Get panel Expansion ( ax=4e08, bl=02h) is supported by SBIOS
4870 bit[3]=0: VBIOS fast boot is disable
4871 =1: VBIOS fast boot is enable. ( VBIOS skip display device detection in every set mode if LCD panel is connect and LID is open)
4872ulGPUCapInfo: bit[0]=0: TMDS/HDMI Coherent Mode use cascade PLL mode.
4873 =1: TMDS/HDMI Coherent Mode use signel PLL mode.
4874 bit[1]=0: DP mode use cascade PLL mode ( New for Trinity )
4875 =1: DP mode use single PLL mode
4876 bit[3]=0: Enable AUX HW mode detection logic
4877 =1: Disable AUX HW mode detection logic
4878
4879ulSB_MMIO_Base_Addr: Physical Base address to SB MMIO space. Driver needs to initialize it for SMU usage.
4880
4881usRequestedPWMFreqInHz: When it's set to 0x0 by SBIOS: the LCD BackLight is not controlled by GPU(SW).
4882 Any attempt to change BL using VBIOS function or enable VariBri from PP table is not effective since ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==0;
4883
4884 When it's set to a non-zero frequency, the BackLight is controlled by GPU (SW) in one of two ways below:
4885 1. SW uses the GPU BL PWM output to control the BL, in chis case, this non-zero frequency determines what freq GPU should use;
4886 VBIOS will set up proper PWM frequency and ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1,as the result,
4887 Changing BL using VBIOS function is functional in both driver and non-driver present environment;
4888 and enabling VariBri under the driver environment from PP table is optional.
4889
4890 2. SW uses other means to control BL (like DPCD),this non-zero frequency serves as a flag only indicating
4891 that BL control from GPU is expected.
4892 VBIOS will NOT set up PWM frequency but make ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU==1
4893 Changing BL using VBIOS function could be functional in both driver and non-driver present environment,but
4894 it's per platform
4895 and enabling VariBri under the driver environment from PP table is optional.
4896
4897ucHtcTmpLmt: Refer to D18F3x64 bit[22:16], HtcTmpLmt.
4898 Threshold on value to enter HTC_active state.
4899ucHtcHystLmt: Refer to D18F3x64 bit[27:24], HtcHystLmt.
4900 To calculate threshold off value to exit HTC_active state, which is Threshold on vlaue minus ucHtcHystLmt.
4901ulMinEngineClock: Minimum SCLK allowed in 10kHz unit. This is calculated based on WRCK Fuse settings.
4902ulSystemConfig: Bit[0]=0: PCIE Power Gating Disabled
4903 =1: PCIE Power Gating Enabled
4904 Bit[1]=0: DDR-DLL shut-down feature disabled.
4905 1: DDR-DLL shut-down feature enabled.
4906 Bit[2]=0: DDR-PLL Power down feature disabled.
4907 1: DDR-PLL Power down feature enabled.
4908ulCPUCapInfo: TBD
4909usNBP0Voltage: VID for voltage on NB P0 State
4910usNBP1Voltage: VID for voltage on NB P1 State
4911usNBP2Voltage: VID for voltage on NB P2 State
4912usNBP3Voltage: VID for voltage on NB P3 State
4913usBootUpNBVoltage: Voltage Index of GNB voltage configured by SBIOS, which is suffcient to support VBIOS DISPCLK requirement.
4914usExtDispConnInfoOffset: Offset to sExtDispConnInfo inside the structure
4915usPanelRefreshRateRange: Bit vector for LCD supported refresh rate range. If DRR is requestd by the platform, at least two bits need to be set
4916 to indicate a range.
4917 SUPPORTED_LCD_REFRESHRATE_30Hz 0x0004
4918 SUPPORTED_LCD_REFRESHRATE_40Hz 0x0008
4919 SUPPORTED_LCD_REFRESHRATE_50Hz 0x0010
4920 SUPPORTED_LCD_REFRESHRATE_60Hz 0x0020
4921ucMemoryType: [3:0]=1:DDR1;=2:DDR2;=3:DDR3.[7:4] is reserved.
4922ucUMAChannelNumber: System memory channel numbers.
4923ulCSR_M3_ARB_CNTL_DEFAULT[10]: Arrays with values for CSR M3 arbiter for default
4924ulCSR_M3_ARB_CNTL_UVD[10]: Arrays with values for CSR M3 arbiter for UVD playback.
4925ulCSR_M3_ARB_CNTL_FS3D[10]: Arrays with values for CSR M3 arbiter for Full Screen 3D applications.
4926sAvail_SCLK[5]: Arrays to provide availabe list of SLCK and corresponding voltage, order from low to high
4388ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns. 4927ulGMCRestoreResetTime: GMC power restore and GMC reset time to calculate data reconnection latency. Unit in ns.
4389ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz. 4928ulMinimumNClk: Minimum NCLK speed among all NB-Pstates to calcualte data reconnection latency. Unit in 10kHz.
4390ulIdleNClk: NCLK speed while memory runs in self-refresh state. Unit in 10kHz. 4929ulIdleNClk: NCLK speed while memory runs in self-refresh state. Unit in 10kHz.
@@ -4398,6 +4937,41 @@ usHDMISSPercentage: HDMI Spread Spectrum Percentage in unit 0.01%;
4398usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. 4937usHDMISSpreadRateIn10Hz: HDMI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting.
4399usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting. 4938usDVISSPercentage: DVI Spread Spectrum Percentage in unit 0.01%; 100 mean 1%, =0, use VBIOS default setting.
4400usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting. 4939usDVISSpreadRateIn10Hz: DVI Spread Spectrum frequency in unit of 10Hz, =0, use VBIOS default setting.
4940usMaxLVDSPclkFreqInSingleLink: Max pixel clock LVDS panel single link, if=0 means VBIOS use default threhold, right now it is 85Mhz
4941ucLVDSMisc: [bit0] LVDS 888bit panel mode =0: LVDS 888 panel in LDI mode, =1: LVDS 888 panel in FPDI mode
4942 [bit1] LVDS panel lower and upper link mapping =0: lower link and upper link not swap, =1: lower link and upper link are swapped
4943 [bit2] LVDS 888bit per color mode =0: 666 bit per color =1:888 bit per color
4944 [bit3] LVDS parameter override enable =0: ucLvdsMisc parameter are not used =1: ucLvdsMisc parameter should be used
4945 [bit4] Polarity of signal sent to digital BLON output pin. =0: not inverted(active high) =1: inverted ( active low )
4946ucLVDSPwrOnSeqDIGONtoDE_in4Ms: LVDS power up sequence time in unit of 4ms, time delay from DIGON signal active to data enable signal active( DE ).
4947 =0 mean use VBIOS default which is 8 ( 32ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON.
4948 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4949ucLVDSPwrOnDEtoVARY_BL_in4Ms: LVDS power up sequence time in unit of 4ms., time delay from DE( data enable ) active to Vary Brightness enable signal active( VARY_BL ).
4950 =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power up sequence is as following: DIGON->DE->VARY_BL->BLON.
4951 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4952
4953ucLVDSPwrOffVARY_BLtoDE_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from data enable ( DE ) signal off to LCDVCC (DIGON) off.
4954 =0 mean use VBIOS default delay which is 8 ( 32ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON
4955 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4956
4957ucLVDSPwrOffDEtoDIGON_in4Ms: LVDS power down sequence time in unit of 4ms, time delay from vary brightness enable signal( VARY_BL) off to data enable ( DE ) signal off.
4958 =0 mean use VBIOS default which is 90 ( 360ms ). The LVDS power down sequence is as following: BLON->VARY_BL->DE->DIGON
4959 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4960
4961ucLVDSOffToOnDelay_in4Ms: LVDS power down sequence time in unit of 4ms. Time delay from DIGON signal off to DIGON signal active.
4962 =0 means to use VBIOS default delay which is 125 ( 500ms ).
4963 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4964
4965ucLVDSPwrOnVARY_BLtoBLON_in4Ms: LVDS power up sequence time in unit of 4ms. Time delay from VARY_BL signal on to DLON signal active.
4966 =0 means to use VBIOS default delay which is 0 ( 0ms ).
4967 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4968
4969ucLVDSPwrOffBLONtoVARY_BL_in4Ms: LVDS power down sequence time in unit of 4ms. Time delay from BLON signal off to VARY_BL signal off.
4970 =0 means to use VBIOS default delay which is 0 ( 0ms ).
4971 This parameter is used by VBIOS only. VBIOS will patch LVDS_InfoTable.
4972
4973ulNbpStateMemclkFreq[4]: system memory clock frequncey in unit of 10Khz in different NB pstate.
4974
4401**********************************************************************************************************************/ 4975**********************************************************************************************************************/
4402 4976
4403/**************************************************************************/ 4977/**************************************************************************/
@@ -4459,6 +5033,7 @@ typedef struct _ATOM_ASIC_SS_ASSIGNMENT
4459#define ASIC_INTERNAL_SS_ON_DP 7 5033#define ASIC_INTERNAL_SS_ON_DP 7
4460#define ASIC_INTERNAL_SS_ON_DCPLL 8 5034#define ASIC_INTERNAL_SS_ON_DCPLL 8
4461#define ASIC_EXTERNAL_SS_ON_DP_CLOCK 9 5035#define ASIC_EXTERNAL_SS_ON_DP_CLOCK 9
5036#define ASIC_INTERNAL_VCE_SS 10
4462 5037
4463typedef struct _ATOM_ASIC_SS_ASSIGNMENT_V2 5038typedef struct _ATOM_ASIC_SS_ASSIGNMENT_V2
4464{ 5039{
@@ -4520,7 +5095,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3
4520#define ATOM_DOS_MODE_INFO_DEF 7 5095#define ATOM_DOS_MODE_INFO_DEF 7
4521#define ATOM_I2C_CHANNEL_STATUS_DEF 8 5096#define ATOM_I2C_CHANNEL_STATUS_DEF 8
4522#define ATOM_I2C_CHANNEL_STATUS1_DEF 9 5097#define ATOM_I2C_CHANNEL_STATUS1_DEF 9
4523 5098#define ATOM_INTERNAL_TIMER_DEF 10
4524 5099
4525// BIOS_0_SCRATCH Definition 5100// BIOS_0_SCRATCH Definition
4526#define ATOM_S0_CRT1_MONO 0x00000001L 5101#define ATOM_S0_CRT1_MONO 0x00000001L
@@ -4648,6 +5223,7 @@ typedef struct _ATOM_ASIC_INTERNAL_SS_INFO_V3
4648#define ATOM_S2_DEVICE_DPMS_MASKw1 0x3FF 5223#define ATOM_S2_DEVICE_DPMS_MASKw1 0x3FF
4649#define ATOM_S2_FORCEDLOWPWRMODE_STATE_MASKb3 0x0C 5224#define ATOM_S2_FORCEDLOWPWRMODE_STATE_MASKb3 0x0C
4650#define ATOM_S2_FORCEDLOWPWRMODE_STATE_CHANGEb3 0x10 5225#define ATOM_S2_FORCEDLOWPWRMODE_STATE_CHANGEb3 0x10
5226#define ATOM_S2_TMDS_COHERENT_MODEb3 0x10 // used by VBIOS code only, use coherent mode for TMDS/HDMI mode
4651#define ATOM_S2_VRI_BRIGHT_ENABLEb3 0x20 5227#define ATOM_S2_VRI_BRIGHT_ENABLEb3 0x20
4652#define ATOM_S2_ROTATION_STATE_MASKb3 0xC0 5228#define ATOM_S2_ROTATION_STATE_MASKb3 0xC0
4653 5229
@@ -5038,6 +5614,23 @@ typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS_V1_3
5038 USHORT usDeviceId; // Active Device Id for this surface. If no device, set to 0. 5614 USHORT usDeviceId; // Active Device Id for this surface. If no device, set to 0.
5039}ENABLE_GRAPH_SURFACE_PARAMETERS_V1_3; 5615}ENABLE_GRAPH_SURFACE_PARAMETERS_V1_3;
5040 5616
5617typedef struct _ENABLE_GRAPH_SURFACE_PARAMETERS_V1_4
5618{
5619 USHORT usHight; // Image Hight
5620 USHORT usWidth; // Image Width
5621 USHORT usGraphPitch;
5622 UCHAR ucColorDepth;
5623 UCHAR ucPixelFormat;
5624 UCHAR ucSurface; // Surface 1 or 2
5625 UCHAR ucEnable; // ATOM_ENABLE or ATOM_DISABLE
5626 UCHAR ucModeType;
5627 UCHAR ucReserved;
5628}ENABLE_GRAPH_SURFACE_PARAMETERS_V1_4;
5629
5630// ucEnable
5631#define ATOM_GRAPH_CONTROL_SET_PITCH 0x0f
5632#define ATOM_GRAPH_CONTROL_SET_DISP_START 0x10
5633
5041typedef struct _ENABLE_GRAPH_SURFACE_PS_ALLOCATION 5634typedef struct _ENABLE_GRAPH_SURFACE_PS_ALLOCATION
5042{ 5635{
5043 ENABLE_GRAPH_SURFACE_PARAMETERS sSetSurface; 5636 ENABLE_GRAPH_SURFACE_PARAMETERS sSetSurface;
@@ -5057,6 +5650,58 @@ typedef struct _GET_DISPLAY_SURFACE_SIZE_PARAMETERS
5057 USHORT usY_Size; 5650 USHORT usY_Size;
5058}GET_DISPLAY_SURFACE_SIZE_PARAMETERS; 5651}GET_DISPLAY_SURFACE_SIZE_PARAMETERS;
5059 5652
5653typedef struct _GET_DISPLAY_SURFACE_SIZE_PARAMETERS_V2
5654{
5655 union{
5656 USHORT usX_Size; //When use as input parameter, usX_Size indicates which CRTC
5657 USHORT usSurface;
5658 };
5659 USHORT usY_Size;
5660 USHORT usDispXStart;
5661 USHORT usDispYStart;
5662}GET_DISPLAY_SURFACE_SIZE_PARAMETERS_V2;
5663
5664
5665typedef struct _PALETTE_DATA_CONTROL_PARAMETERS_V3
5666{
5667 UCHAR ucLutId;
5668 UCHAR ucAction;
5669 USHORT usLutStartIndex;
5670 USHORT usLutLength;
5671 USHORT usLutOffsetInVram;
5672}PALETTE_DATA_CONTROL_PARAMETERS_V3;
5673
5674// ucAction:
5675#define PALETTE_DATA_AUTO_FILL 1
5676#define PALETTE_DATA_READ 2
5677#define PALETTE_DATA_WRITE 3
5678
5679
5680typedef struct _INTERRUPT_SERVICE_PARAMETERS_V2
5681{
5682 UCHAR ucInterruptId;
5683 UCHAR ucServiceId;
5684 UCHAR ucStatus;
5685 UCHAR ucReserved;
5686}INTERRUPT_SERVICE_PARAMETER_V2;
5687
5688// ucInterruptId
5689#define HDP1_INTERRUPT_ID 1
5690#define HDP2_INTERRUPT_ID 2
5691#define HDP3_INTERRUPT_ID 3
5692#define HDP4_INTERRUPT_ID 4
5693#define HDP5_INTERRUPT_ID 5
5694#define HDP6_INTERRUPT_ID 6
5695#define SW_INTERRUPT_ID 11
5696
5697// ucAction
5698#define INTERRUPT_SERVICE_GEN_SW_INT 1
5699#define INTERRUPT_SERVICE_GET_STATUS 2
5700
5701 // ucStatus
5702#define INTERRUPT_STATUS__INT_TRIGGER 1
5703#define INTERRUPT_STATUS__HPD_HIGH 2
5704
5060typedef struct _INDIRECT_IO_ACCESS 5705typedef struct _INDIRECT_IO_ACCESS
5061{ 5706{
5062 ATOM_COMMON_TABLE_HEADER sHeader; 5707 ATOM_COMMON_TABLE_HEADER sHeader;
@@ -5189,7 +5834,7 @@ typedef struct _ATOM_INIT_REG_BLOCK{
5189 5834
5190#define END_OF_REG_INDEX_BLOCK 0x0ffff 5835#define END_OF_REG_INDEX_BLOCK 0x0ffff
5191#define END_OF_REG_DATA_BLOCK 0x00000000 5836#define END_OF_REG_DATA_BLOCK 0x00000000
5192#define ATOM_INIT_REG_MASK_FLAG 0x80 5837#define ATOM_INIT_REG_MASK_FLAG 0x80 //Not used in BIOS
5193#define CLOCK_RANGE_HIGHEST 0x00ffffff 5838#define CLOCK_RANGE_HIGHEST 0x00ffffff
5194 5839
5195#define VALUE_DWORD SIZEOF ULONG 5840#define VALUE_DWORD SIZEOF ULONG
@@ -5229,6 +5874,7 @@ typedef struct _ATOM_MC_INIT_PARAM_TABLE
5229#define _128Mx8 0x51 5874#define _128Mx8 0x51
5230#define _128Mx16 0x52 5875#define _128Mx16 0x52
5231#define _256Mx8 0x61 5876#define _256Mx8 0x61
5877#define _256Mx16 0x62
5232 5878
5233#define SAMSUNG 0x1 5879#define SAMSUNG 0x1
5234#define INFINEON 0x2 5880#define INFINEON 0x2
@@ -5585,7 +6231,7 @@ typedef struct _ATOM_VRAM_MODULE_V7
5585 ULONG ulChannelMapCfg; // mmMC_SHARED_CHREMAP 6231 ULONG ulChannelMapCfg; // mmMC_SHARED_CHREMAP
5586 USHORT usModuleSize; // Size of ATOM_VRAM_MODULE_V7 6232 USHORT usModuleSize; // Size of ATOM_VRAM_MODULE_V7
5587 USHORT usPrivateReserved; // MC_ARB_RAMCFG (includes NOOFBANK,NOOFRANKS,NOOFROWS,NOOFCOLS) 6233 USHORT usPrivateReserved; // MC_ARB_RAMCFG (includes NOOFBANK,NOOFRANKS,NOOFROWS,NOOFCOLS)
5588 USHORT usReserved; 6234 USHORT usEnableChannels; // bit vector which indicate which channels are enabled
5589 UCHAR ucExtMemoryID; // Current memory module ID 6235 UCHAR ucExtMemoryID; // Current memory module ID
5590 UCHAR ucMemoryType; // MEM_TYPE_DDR2/DDR3/GDDR3/GDDR5 6236 UCHAR ucMemoryType; // MEM_TYPE_DDR2/DDR3/GDDR3/GDDR5
5591 UCHAR ucChannelNum; // Number of mem. channels supported in this module 6237 UCHAR ucChannelNum; // Number of mem. channels supported in this module
@@ -5597,7 +6243,8 @@ typedef struct _ATOM_VRAM_MODULE_V7
5597 UCHAR ucNPL_RT; // Round trip delay (MC_SEQ_CAS_TIMING [28:24]:TCL=CL+NPL_RT-2). Always 2. 6243 UCHAR ucNPL_RT; // Round trip delay (MC_SEQ_CAS_TIMING [28:24]:TCL=CL+NPL_RT-2). Always 2.
5598 UCHAR ucPreamble; // [7:4] Write Preamble, [3:0] Read Preamble 6244 UCHAR ucPreamble; // [7:4] Write Preamble, [3:0] Read Preamble
5599 UCHAR ucMemorySize; // Total memory size in unit of 16MB for CONFIG_MEMSIZE - bit[23:0] zeros 6245 UCHAR ucMemorySize; // Total memory size in unit of 16MB for CONFIG_MEMSIZE - bit[23:0] zeros
5600 UCHAR ucReserved[3]; 6246 USHORT usSEQSettingOffset;
6247 UCHAR ucReserved;
5601// Memory Module specific values 6248// Memory Module specific values
5602 USHORT usEMRS2Value; // EMRS2/MR2 Value. 6249 USHORT usEMRS2Value; // EMRS2/MR2 Value.
5603 USHORT usEMRS3Value; // EMRS3/MR3 Value. 6250 USHORT usEMRS3Value; // EMRS3/MR3 Value.
@@ -5633,10 +6280,10 @@ typedef struct _ATOM_VRAM_INFO_V3
5633typedef struct _ATOM_VRAM_INFO_V4 6280typedef struct _ATOM_VRAM_INFO_V4
5634{ 6281{
5635 ATOM_COMMON_TABLE_HEADER sHeader; 6282 ATOM_COMMON_TABLE_HEADER sHeader;
5636 USHORT usMemAdjustTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory vendor specific MC adjust setting 6283 USHORT usMemAdjustTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory vendor specific MC adjust setting
5637 USHORT usMemClkPatchTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory clock specific MC setting 6284 USHORT usMemClkPatchTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory clock specific MC setting
5638 USHORT usRerseved; 6285 USHORT usRerseved;
5639 UCHAR ucMemDQ7_0ByteRemap; // DQ line byte remap, =0: Memory Data line BYTE0, =1: BYTE1, =2: BYTE2, =3: BYTE3 6286 UCHAR ucMemDQ7_0ByteRemap; // DQ line byte remap, =0: Memory Data line BYTE0, =1: BYTE1, =2: BYTE2, =3: BYTE3
5640 ULONG ulMemDQ7_0BitRemap; // each DQ line ( 7~0) use 3bits, like: DQ0=Bit[2:0], DQ1:[5:3], ... DQ7:[23:21] 6287 ULONG ulMemDQ7_0BitRemap; // each DQ line ( 7~0) use 3bits, like: DQ0=Bit[2:0], DQ1:[5:3], ... DQ7:[23:21]
5641 UCHAR ucReservde[4]; 6288 UCHAR ucReservde[4];
5642 UCHAR ucNumOfVRAMModule; 6289 UCHAR ucNumOfVRAMModule;
@@ -5648,9 +6295,10 @@ typedef struct _ATOM_VRAM_INFO_V4
5648typedef struct _ATOM_VRAM_INFO_HEADER_V2_1 6295typedef struct _ATOM_VRAM_INFO_HEADER_V2_1
5649{ 6296{
5650 ATOM_COMMON_TABLE_HEADER sHeader; 6297 ATOM_COMMON_TABLE_HEADER sHeader;
5651 USHORT usMemAdjustTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory vendor specific MC adjust setting 6298 USHORT usMemAdjustTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory vendor specific MC adjust setting
5652 USHORT usMemClkPatchTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory clock specific MC setting 6299 USHORT usMemClkPatchTblOffset; // offset of ATOM_INIT_REG_BLOCK structure for memory clock specific MC setting
5653 USHORT usReserved[4]; 6300 USHORT usPerBytePresetOffset; // offset of ATOM_INIT_REG_BLOCK structure for Per Byte Offset Preset Settings
6301 USHORT usReserved[3];
5654 UCHAR ucNumOfVRAMModule; // indicate number of VRAM module 6302 UCHAR ucNumOfVRAMModule; // indicate number of VRAM module
5655 UCHAR ucMemoryClkPatchTblVer; // version of memory AC timing register list 6303 UCHAR ucMemoryClkPatchTblVer; // version of memory AC timing register list
5656 UCHAR ucVramModuleVer; // indicate ATOM_VRAM_MODUE version 6304 UCHAR ucVramModuleVer; // indicate ATOM_VRAM_MODUE version
@@ -5935,6 +6583,52 @@ typedef struct _ATOM_DISP_OUT_INFO_V2
5935 ASIC_ENCODER_INFO asEncoderInfo[1]; 6583 ASIC_ENCODER_INFO asEncoderInfo[1];
5936}ATOM_DISP_OUT_INFO_V2; 6584}ATOM_DISP_OUT_INFO_V2;
5937 6585
6586
6587typedef struct _ATOM_DISP_CLOCK_ID {
6588 UCHAR ucPpllId;
6589 UCHAR ucPpllAttribute;
6590}ATOM_DISP_CLOCK_ID;
6591
6592// ucPpllAttribute
6593#define CLOCK_SOURCE_SHAREABLE 0x01
6594#define CLOCK_SOURCE_DP_MODE 0x02
6595#define CLOCK_SOURCE_NONE_DP_MODE 0x04
6596
6597//DispOutInfoTable
6598typedef struct _ASIC_TRANSMITTER_INFO_V2
6599{
6600 USHORT usTransmitterObjId;
6601 USHORT usDispClkIdOffset; // point to clock source id list supported by Encoder Object
6602 UCHAR ucTransmitterCmdTblId;
6603 UCHAR ucConfig;
6604 UCHAR ucEncoderID; // available 1st encoder ( default )
6605 UCHAR ucOptionEncoderID; // available 2nd encoder ( optional )
6606 UCHAR uc2ndEncoderID;
6607 UCHAR ucReserved;
6608}ASIC_TRANSMITTER_INFO_V2;
6609
6610typedef struct _ATOM_DISP_OUT_INFO_V3
6611{
6612 ATOM_COMMON_TABLE_HEADER sHeader;
6613 USHORT ptrTransmitterInfo;
6614 USHORT ptrEncoderInfo;
6615 USHORT ptrMainCallParserFar; // direct address of main parser call in VBIOS binary.
6616 USHORT usReserved;
6617 UCHAR ucDCERevision;
6618 UCHAR ucMaxDispEngineNum;
6619 UCHAR ucMaxActiveDispEngineNum;
6620 UCHAR ucMaxPPLLNum;
6621 UCHAR ucCoreRefClkSource; // value of CORE_REF_CLK_SOURCE
6622 UCHAR ucReserved[3];
6623 ASIC_TRANSMITTER_INFO_V2 asTransmitterInfo[1]; // for alligment only
6624}ATOM_DISP_OUT_INFO_V3;
6625
6626typedef enum CORE_REF_CLK_SOURCE{
6627 CLOCK_SRC_XTALIN=0,
6628 CLOCK_SRC_XO_IN=1,
6629 CLOCK_SRC_XO_IN2=2,
6630}CORE_REF_CLK_SOURCE;
6631
5938// DispDevicePriorityInfo 6632// DispDevicePriorityInfo
5939typedef struct _ATOM_DISPLAY_DEVICE_PRIORITY_INFO 6633typedef struct _ATOM_DISPLAY_DEVICE_PRIORITY_INFO
5940{ 6634{
@@ -6070,6 +6764,39 @@ typedef struct _PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS
6070#define HW_I2C_READ 0 6764#define HW_I2C_READ 0
6071#define I2C_2BYTE_ADDR 0x02 6765#define I2C_2BYTE_ADDR 0x02
6072 6766
6767/****************************************************************************/
6768// Structures used by HW_Misc_OperationTable
6769/****************************************************************************/
6770typedef struct _ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1
6771{
6772 UCHAR ucCmd; // Input: To tell which action to take
6773 UCHAR ucReserved[3];
6774 ULONG ulReserved;
6775}ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1;
6776
6777typedef struct _ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1
6778{
6779 UCHAR ucReturnCode; // Output: Return value base on action was taken
6780 UCHAR ucReserved[3];
6781 ULONG ulReserved;
6782}ATOM_HW_MISC_OPERATION_OUTPUT_PARAMETER_V1_1;
6783
6784// Actions code
6785#define ATOM_GET_SDI_SUPPORT 0xF0
6786
6787// Return code
6788#define ATOM_UNKNOWN_CMD 0
6789#define ATOM_FEATURE_NOT_SUPPORTED 1
6790#define ATOM_FEATURE_SUPPORTED 2
6791
6792typedef struct _ATOM_HW_MISC_OPERATION_PS_ALLOCATION
6793{
6794 ATOM_HW_MISC_OPERATION_INPUT_PARAMETER_V1_1 sInput_Output;
6795 PROCESS_I2C_CHANNEL_TRANSACTION_PARAMETERS sReserved;
6796}ATOM_HW_MISC_OPERATION_PS_ALLOCATION;
6797
6798/****************************************************************************/
6799
6073typedef struct _SET_HWBLOCK_INSTANCE_PARAMETER_V2 6800typedef struct _SET_HWBLOCK_INSTANCE_PARAMETER_V2
6074{ 6801{
6075 UCHAR ucHWBlkInst; // HW block instance, 0, 1, 2, ... 6802 UCHAR ucHWBlkInst; // HW block instance, 0, 1, 2, ...
@@ -6090,6 +6817,52 @@ typedef struct _SET_HWBLOCK_INSTANCE_PARAMETER_V2
6090#define SELECT_CRTC_PIXEL_RATE 7 6817#define SELECT_CRTC_PIXEL_RATE 7
6091#define SELECT_VGA_BLK 8 6818#define SELECT_VGA_BLK 8
6092 6819
6820// DIGTransmitterInfoTable structure used to program UNIPHY settings
6821typedef struct _DIG_TRANSMITTER_INFO_HEADER_V3_1{
6822 ATOM_COMMON_TABLE_HEADER sHeader;
6823 USHORT usDPVsPreEmphSettingOffset; // offset of PHY_ANALOG_SETTING_INFO * with DP Voltage Swing and Pre-Emphasis for each Link clock
6824 USHORT usPhyAnalogRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with None-DP mode Analog Setting's register Info
6825 USHORT usPhyAnalogSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with None-DP mode Analog Setting for each link clock range
6826 USHORT usPhyPllRegListOffset; // offset of CLOCK_CONDITION_REGESTER_INFO* with Phy Pll register Info
6827 USHORT usPhyPllSettingOffset; // offset of CLOCK_CONDITION_SETTING_ENTRY* with Phy Pll Settings
6828}DIG_TRANSMITTER_INFO_HEADER_V3_1;
6829
6830typedef struct _CLOCK_CONDITION_REGESTER_INFO{
6831 USHORT usRegisterIndex;
6832 UCHAR ucStartBit;
6833 UCHAR ucEndBit;
6834}CLOCK_CONDITION_REGESTER_INFO;
6835
6836typedef struct _CLOCK_CONDITION_SETTING_ENTRY{
6837 USHORT usMaxClockFreq;
6838 UCHAR ucEncodeMode;
6839 UCHAR ucPhySel;
6840 ULONG ulAnalogSetting[1];
6841}CLOCK_CONDITION_SETTING_ENTRY;
6842
6843typedef struct _CLOCK_CONDITION_SETTING_INFO{
6844 USHORT usEntrySize;
6845 CLOCK_CONDITION_SETTING_ENTRY asClkCondSettingEntry[1];
6846}CLOCK_CONDITION_SETTING_INFO;
6847
6848typedef struct _PHY_CONDITION_REG_VAL{
6849 ULONG ulCondition;
6850 ULONG ulRegVal;
6851}PHY_CONDITION_REG_VAL;
6852
6853typedef struct _PHY_CONDITION_REG_INFO{
6854 USHORT usRegIndex;
6855 USHORT usSize;
6856 PHY_CONDITION_REG_VAL asRegVal[1];
6857}PHY_CONDITION_REG_INFO;
6858
6859typedef struct _PHY_ANALOG_SETTING_INFO{
6860 UCHAR ucEncodeMode;
6861 UCHAR ucPhySel;
6862 USHORT usSize;
6863 PHY_CONDITION_REG_INFO asAnalogSetting[1];
6864}PHY_ANALOG_SETTING_INFO;
6865
6093/****************************************************************************/ 6866/****************************************************************************/
6094//Portion VI: Definitinos for vbios MC scratch registers that driver used 6867//Portion VI: Definitinos for vbios MC scratch registers that driver used
6095/****************************************************************************/ 6868/****************************************************************************/
@@ -6497,6 +7270,8 @@ typedef struct _ATOM_PPLIB_THERMALCONTROLLER
6497#define ATOM_PP_THERMALCONTROLLER_EMC2103 13 /* 0x0D */ // Only fan control will be implemented, do NOT show this in PPGen. 7270#define ATOM_PP_THERMALCONTROLLER_EMC2103 13 /* 0x0D */ // Only fan control will be implemented, do NOT show this in PPGen.
6498#define ATOM_PP_THERMALCONTROLLER_SUMO 14 /* 0x0E */ // Sumo type, used internally 7271#define ATOM_PP_THERMALCONTROLLER_SUMO 14 /* 0x0E */ // Sumo type, used internally
6499#define ATOM_PP_THERMALCONTROLLER_NISLANDS 15 7272#define ATOM_PP_THERMALCONTROLLER_NISLANDS 15
7273#define ATOM_PP_THERMALCONTROLLER_SISLANDS 16
7274#define ATOM_PP_THERMALCONTROLLER_LM96163 17
6500 7275
6501// Thermal controller 'combo type' to use an external controller for Fan control and an internal controller for thermal. 7276// Thermal controller 'combo type' to use an external controller for Fan control and an internal controller for thermal.
6502// We probably should reserve the bit 0x80 for this use. 7277// We probably should reserve the bit 0x80 for this use.
@@ -6512,6 +7287,7 @@ typedef struct _ATOM_PPLIB_STATE
6512 UCHAR ucClockStateIndices[1]; // variable-sized 7287 UCHAR ucClockStateIndices[1]; // variable-sized
6513} ATOM_PPLIB_STATE; 7288} ATOM_PPLIB_STATE;
6514 7289
7290
6515typedef struct _ATOM_PPLIB_FANTABLE 7291typedef struct _ATOM_PPLIB_FANTABLE
6516{ 7292{
6517 UCHAR ucFanTableFormat; // Change this if the table format changes or version changes so that the other fields are not the same. 7293 UCHAR ucFanTableFormat; // Change this if the table format changes or version changes so that the other fields are not the same.
@@ -6524,12 +7300,20 @@ typedef struct _ATOM_PPLIB_FANTABLE
6524 USHORT usPWMHigh; // The PWM value at THigh. 7300 USHORT usPWMHigh; // The PWM value at THigh.
6525} ATOM_PPLIB_FANTABLE; 7301} ATOM_PPLIB_FANTABLE;
6526 7302
7303typedef struct _ATOM_PPLIB_FANTABLE2
7304{
7305 ATOM_PPLIB_FANTABLE basicTable;
7306 USHORT usTMax; // The max temperature
7307} ATOM_PPLIB_FANTABLE2;
7308
6527typedef struct _ATOM_PPLIB_EXTENDEDHEADER 7309typedef struct _ATOM_PPLIB_EXTENDEDHEADER
6528{ 7310{
6529 USHORT usSize; 7311 USHORT usSize;
6530 ULONG ulMaxEngineClock; // For Overdrive. 7312 ULONG ulMaxEngineClock; // For Overdrive.
6531 ULONG ulMaxMemoryClock; // For Overdrive. 7313 ULONG ulMaxMemoryClock; // For Overdrive.
6532 // Add extra system parameters here, always adjust size to include all fields. 7314 // Add extra system parameters here, always adjust size to include all fields.
7315 USHORT usVCETableOffset; //points to ATOM_PPLIB_VCE_Table
7316 USHORT usUVDTableOffset; //points to ATOM_PPLIB_UVD_Table
6533} ATOM_PPLIB_EXTENDEDHEADER; 7317} ATOM_PPLIB_EXTENDEDHEADER;
6534 7318
6535//// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps 7319//// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps
@@ -6552,6 +7336,7 @@ typedef struct _ATOM_PPLIB_EXTENDEDHEADER
6552#define ATOM_PP_PLATFORM_CAP_REGULATOR_HOT 0x00010000 // Enable the 'regulator hot' feature. 7336#define ATOM_PP_PLATFORM_CAP_REGULATOR_HOT 0x00010000 // Enable the 'regulator hot' feature.
6553#define ATOM_PP_PLATFORM_CAP_BACO 0x00020000 // Does the driver supports BACO state. 7337#define ATOM_PP_PLATFORM_CAP_BACO 0x00020000 // Does the driver supports BACO state.
6554 7338
7339
6555typedef struct _ATOM_PPLIB_POWERPLAYTABLE 7340typedef struct _ATOM_PPLIB_POWERPLAYTABLE
6556{ 7341{
6557 ATOM_COMMON_TABLE_HEADER sHeader; 7342 ATOM_COMMON_TABLE_HEADER sHeader;
@@ -6610,7 +7395,8 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE4
6610 USHORT usVddciDependencyOnMCLKOffset; 7395 USHORT usVddciDependencyOnMCLKOffset;
6611 USHORT usVddcDependencyOnMCLKOffset; 7396 USHORT usVddcDependencyOnMCLKOffset;
6612 USHORT usMaxClockVoltageOnDCOffset; 7397 USHORT usMaxClockVoltageOnDCOffset;
6613 USHORT usReserved[2]; 7398 USHORT usVddcPhaseShedLimitsTableOffset; // Points to ATOM_PPLIB_PhaseSheddingLimits_Table
7399 USHORT usReserved;
6614} ATOM_PPLIB_POWERPLAYTABLE4, *LPATOM_PPLIB_POWERPLAYTABLE4; 7400} ATOM_PPLIB_POWERPLAYTABLE4, *LPATOM_PPLIB_POWERPLAYTABLE4;
6615 7401
6616typedef struct _ATOM_PPLIB_POWERPLAYTABLE5 7402typedef struct _ATOM_PPLIB_POWERPLAYTABLE5
@@ -6620,8 +7406,9 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE5
6620 ULONG ulNearTDPLimit; 7406 ULONG ulNearTDPLimit;
6621 ULONG ulSQRampingThreshold; 7407 ULONG ulSQRampingThreshold;
6622 USHORT usCACLeakageTableOffset; // Points to ATOM_PPLIB_CAC_Leakage_Table 7408 USHORT usCACLeakageTableOffset; // Points to ATOM_PPLIB_CAC_Leakage_Table
6623 ULONG ulCACLeakage; // TBD, this parameter is still under discussion. Change to ulReserved if not needed. 7409 ULONG ulCACLeakage; // The iLeakage for driver calculated CAC leakage table
6624 ULONG ulReserved; 7410 USHORT usTDPODLimit;
7411 USHORT usLoadLineSlope; // in milliOhms * 100
6625} ATOM_PPLIB_POWERPLAYTABLE5, *LPATOM_PPLIB_POWERPLAYTABLE5; 7412} ATOM_PPLIB_POWERPLAYTABLE5, *LPATOM_PPLIB_POWERPLAYTABLE5;
6626 7413
6627//// ATOM_PPLIB_NONCLOCK_INFO::usClassification 7414//// ATOM_PPLIB_NONCLOCK_INFO::usClassification
@@ -6650,6 +7437,7 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE5
6650//// ATOM_PPLIB_NONCLOCK_INFO::usClassification2 7437//// ATOM_PPLIB_NONCLOCK_INFO::usClassification2
6651#define ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2 0x0001 7438#define ATOM_PPLIB_CLASSIFICATION2_LIMITEDPOWERSOURCE_2 0x0001
6652#define ATOM_PPLIB_CLASSIFICATION2_ULV 0x0002 7439#define ATOM_PPLIB_CLASSIFICATION2_ULV 0x0002
7440#define ATOM_PPLIB_CLASSIFICATION2_MVC 0x0004 //Multi-View Codec (BD-3D)
6653 7441
6654//// ATOM_PPLIB_NONCLOCK_INFO::ulCapsAndSettings 7442//// ATOM_PPLIB_NONCLOCK_INFO::ulCapsAndSettings
6655#define ATOM_PPLIB_SINGLE_DISPLAY_ONLY 0x00000001 7443#define ATOM_PPLIB_SINGLE_DISPLAY_ONLY 0x00000001
@@ -6673,7 +7461,9 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE5
6673 7461
6674#define ATOM_PPLIB_SOFTWARE_DISABLE_LOADBALANCING 0x00001000 7462#define ATOM_PPLIB_SOFTWARE_DISABLE_LOADBALANCING 0x00001000
6675#define ATOM_PPLIB_SOFTWARE_ENABLE_SLEEP_FOR_TIMESTAMPS 0x00002000 7463#define ATOM_PPLIB_SOFTWARE_ENABLE_SLEEP_FOR_TIMESTAMPS 0x00002000
6676#define ATOM_PPLIB_DISALLOW_ON_DC 0x00004000 7464
7465#define ATOM_PPLIB_DISALLOW_ON_DC 0x00004000
7466
6677#define ATOM_PPLIB_ENABLE_VARIBRIGHT 0x00008000 7467#define ATOM_PPLIB_ENABLE_VARIBRIGHT 0x00008000
6678 7468
6679//memory related flags 7469//memory related flags
@@ -6735,7 +7525,7 @@ typedef struct _ATOM_PPLIB_R600_CLOCK_INFO
6735#define ATOM_PPLIB_R600_FLAGS_UVDSAFE 2 7525#define ATOM_PPLIB_R600_FLAGS_UVDSAFE 2
6736#define ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE 4 7526#define ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE 4
6737#define ATOM_PPLIB_R600_FLAGS_MEMORY_ODT_OFF 8 7527#define ATOM_PPLIB_R600_FLAGS_MEMORY_ODT_OFF 8
6738#define ATOM_PPLIB_R600_FLAGS_MEMORY_DLL_OFF 16 7528#define ATOM_PPLIB_R600_FLAGS_MEMORY_DLL_OFF 16
6739#define ATOM_PPLIB_R600_FLAGS_LOWPOWER 32 // On the RV770 use 'low power' setting (sequencer S0). 7529#define ATOM_PPLIB_R600_FLAGS_LOWPOWER 32 // On the RV770 use 'low power' setting (sequencer S0).
6740 7530
6741typedef struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO 7531typedef struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO
@@ -6754,6 +7544,24 @@ typedef struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO
6754 7544
6755} ATOM_PPLIB_EVERGREEN_CLOCK_INFO; 7545} ATOM_PPLIB_EVERGREEN_CLOCK_INFO;
6756 7546
7547typedef struct _ATOM_PPLIB_SI_CLOCK_INFO
7548{
7549 USHORT usEngineClockLow;
7550 UCHAR ucEngineClockHigh;
7551
7552 USHORT usMemoryClockLow;
7553 UCHAR ucMemoryClockHigh;
7554
7555 USHORT usVDDC;
7556 USHORT usVDDCI;
7557 UCHAR ucPCIEGen;
7558 UCHAR ucUnused1;
7559
7560 ULONG ulFlags; // ATOM_PPLIB_SI_FLAGS_*, no flag is necessary for now
7561
7562} ATOM_PPLIB_SI_CLOCK_INFO;
7563
7564
6757typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO 7565typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO
6758 7566
6759{ 7567{
@@ -6766,7 +7574,7 @@ typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO
6766 UCHAR ucPadding; // For proper alignment and size. 7574 UCHAR ucPadding; // For proper alignment and size.
6767 USHORT usVDDC; // For the 780, use: None, Low, High, Variable 7575 USHORT usVDDC; // For the 780, use: None, Low, High, Variable
6768 UCHAR ucMaxHTLinkWidth; // From SBIOS - {2, 4, 8, 16} 7576 UCHAR ucMaxHTLinkWidth; // From SBIOS - {2, 4, 8, 16}
6769 UCHAR ucMinHTLinkWidth; // From SBIOS - {2, 4, 8, 16}. Effective only if CDLW enabled. Minimum down stream width could be bigger as display BW requirement. 7577 UCHAR ucMinHTLinkWidth; // From SBIOS - {2, 4, 8, 16}. Effective only if CDLW enabled. Minimum down stream width could be bigger as display BW requriement.
6770 USHORT usHTLinkFreq; // See definition ATOM_PPLIB_RS780_HTLINKFREQ_xxx or in MHz(>=200). 7578 USHORT usHTLinkFreq; // See definition ATOM_PPLIB_RS780_HTLINKFREQ_xxx or in MHz(>=200).
6771 ULONG ulFlags; 7579 ULONG ulFlags;
6772} ATOM_PPLIB_RS780_CLOCK_INFO; 7580} ATOM_PPLIB_RS780_CLOCK_INFO;
@@ -6788,9 +7596,7 @@ typedef struct _ATOM_PPLIB_SUMO_CLOCK_INFO{
6788 USHORT usEngineClockLow; //clockfrequency & 0xFFFF. The unit is in 10khz 7596 USHORT usEngineClockLow; //clockfrequency & 0xFFFF. The unit is in 10khz
6789 UCHAR ucEngineClockHigh; //clockfrequency >> 16. 7597 UCHAR ucEngineClockHigh; //clockfrequency >> 16.
6790 UCHAR vddcIndex; //2-bit vddc index; 7598 UCHAR vddcIndex; //2-bit vddc index;
6791 UCHAR leakage; //please use 8-bit absolute value, not the 6-bit % value 7599 USHORT tdpLimit;
6792 //please initalize to 0
6793 UCHAR rsv;
6794 //please initalize to 0 7600 //please initalize to 0
6795 USHORT rsv1; 7601 USHORT rsv1;
6796 //please initialize to 0s 7602 //please initialize to 0s
@@ -6813,7 +7619,7 @@ typedef struct _ATOM_PPLIB_STATE_V2
6813 UCHAR clockInfoIndex[1]; 7619 UCHAR clockInfoIndex[1];
6814} ATOM_PPLIB_STATE_V2; 7620} ATOM_PPLIB_STATE_V2;
6815 7621
6816typedef struct StateArray{ 7622typedef struct _StateArray{
6817 //how many states we have 7623 //how many states we have
6818 UCHAR ucNumEntries; 7624 UCHAR ucNumEntries;
6819 7625
@@ -6821,18 +7627,17 @@ typedef struct StateArray{
6821}StateArray; 7627}StateArray;
6822 7628
6823 7629
6824typedef struct ClockInfoArray{ 7630typedef struct _ClockInfoArray{
6825 //how many clock levels we have 7631 //how many clock levels we have
6826 UCHAR ucNumEntries; 7632 UCHAR ucNumEntries;
6827 7633
6828 //sizeof(ATOM_PPLIB_SUMO_CLOCK_INFO) 7634 //sizeof(ATOM_PPLIB_CLOCK_INFO)
6829 UCHAR ucEntrySize; 7635 UCHAR ucEntrySize;
6830 7636
6831 //this is for Sumo 7637 UCHAR clockInfo[1];
6832 ATOM_PPLIB_SUMO_CLOCK_INFO clockInfo[1];
6833}ClockInfoArray; 7638}ClockInfoArray;
6834 7639
6835typedef struct NonClockInfoArray{ 7640typedef struct _NonClockInfoArray{
6836 7641
6837 //how many non-clock levels we have. normally should be same as number of states 7642 //how many non-clock levels we have. normally should be same as number of states
6838 UCHAR ucNumEntries; 7643 UCHAR ucNumEntries;
@@ -6871,6 +7676,124 @@ typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Table
6871 ATOM_PPLIB_Clock_Voltage_Limit_Record entries[1]; // Dynamically allocate entries. 7676 ATOM_PPLIB_Clock_Voltage_Limit_Record entries[1]; // Dynamically allocate entries.
6872}ATOM_PPLIB_Clock_Voltage_Limit_Table; 7677}ATOM_PPLIB_Clock_Voltage_Limit_Table;
6873 7678
7679typedef struct _ATOM_PPLIB_CAC_Leakage_Record
7680{
7681 USHORT usVddc; // We use this field for the "fake" standardized VDDC for power calculations
7682 ULONG ulLeakageValue;
7683}ATOM_PPLIB_CAC_Leakage_Record;
7684
7685typedef struct _ATOM_PPLIB_CAC_Leakage_Table
7686{
7687 UCHAR ucNumEntries; // Number of entries.
7688 ATOM_PPLIB_CAC_Leakage_Record entries[1]; // Dynamically allocate entries.
7689}ATOM_PPLIB_CAC_Leakage_Table;
7690
7691typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Record
7692{
7693 USHORT usVoltage;
7694 USHORT usSclkLow;
7695 UCHAR ucSclkHigh;
7696 USHORT usMclkLow;
7697 UCHAR ucMclkHigh;
7698}ATOM_PPLIB_PhaseSheddingLimits_Record;
7699
7700typedef struct _ATOM_PPLIB_PhaseSheddingLimits_Table
7701{
7702 UCHAR ucNumEntries; // Number of entries.
7703 ATOM_PPLIB_PhaseSheddingLimits_Record entries[1]; // Dynamically allocate entries.
7704}ATOM_PPLIB_PhaseSheddingLimits_Table;
7705
7706typedef struct _VCEClockInfo{
7707 USHORT usEVClkLow;
7708 UCHAR ucEVClkHigh;
7709 USHORT usECClkLow;
7710 UCHAR ucECClkHigh;
7711}VCEClockInfo;
7712
7713typedef struct _VCEClockInfoArray{
7714 UCHAR ucNumEntries;
7715 VCEClockInfo entries[1];
7716}VCEClockInfoArray;
7717
7718typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record
7719{
7720 USHORT usVoltage;
7721 UCHAR ucVCEClockInfoIndex;
7722}ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record;
7723
7724typedef struct _ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table
7725{
7726 UCHAR numEntries;
7727 ATOM_PPLIB_VCE_Clock_Voltage_Limit_Record entries[1];
7728}ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table;
7729
7730typedef struct _ATOM_PPLIB_VCE_State_Record
7731{
7732 UCHAR ucVCEClockInfoIndex;
7733 UCHAR ucClockInfoIndex; //highest 2 bits indicates memory p-states, lower 6bits indicates index to ClockInfoArrary
7734}ATOM_PPLIB_VCE_State_Record;
7735
7736typedef struct _ATOM_PPLIB_VCE_State_Table
7737{
7738 UCHAR numEntries;
7739 ATOM_PPLIB_VCE_State_Record entries[1];
7740}ATOM_PPLIB_VCE_State_Table;
7741
7742
7743typedef struct _ATOM_PPLIB_VCE_Table
7744{
7745 UCHAR revid;
7746// VCEClockInfoArray array;
7747// ATOM_PPLIB_VCE_Clock_Voltage_Limit_Table limits;
7748// ATOM_PPLIB_VCE_State_Table states;
7749}ATOM_PPLIB_VCE_Table;
7750
7751
7752typedef struct _UVDClockInfo{
7753 USHORT usVClkLow;
7754 UCHAR ucVClkHigh;
7755 USHORT usDClkLow;
7756 UCHAR ucDClkHigh;
7757}UVDClockInfo;
7758
7759typedef struct _UVDClockInfoArray{
7760 UCHAR ucNumEntries;
7761 UVDClockInfo entries[1];
7762}UVDClockInfoArray;
7763
7764typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record
7765{
7766 USHORT usVoltage;
7767 UCHAR ucUVDClockInfoIndex;
7768}ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record;
7769
7770typedef struct _ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table
7771{
7772 UCHAR numEntries;
7773 ATOM_PPLIB_UVD_Clock_Voltage_Limit_Record entries[1];
7774}ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table;
7775
7776typedef struct _ATOM_PPLIB_UVD_State_Record
7777{
7778 UCHAR ucUVDClockInfoIndex;
7779 UCHAR ucClockInfoIndex; //highest 2 bits indicates memory p-states, lower 6bits indicates index to ClockInfoArrary
7780}ATOM_PPLIB_UVD_State_Record;
7781
7782typedef struct _ATOM_PPLIB_UVD_State_Table
7783{
7784 UCHAR numEntries;
7785 ATOM_PPLIB_UVD_State_Record entries[1];
7786}ATOM_PPLIB_UVD_State_Table;
7787
7788
7789typedef struct _ATOM_PPLIB_UVD_Table
7790{
7791 UCHAR revid;
7792// UVDClockInfoArray array;
7793// ATOM_PPLIB_UVD_Clock_Voltage_Limit_Table limits;
7794// ATOM_PPLIB_UVD_State_Table states;
7795}ATOM_PPLIB_UVD_Table;
7796
6874/**************************************************************************/ 7797/**************************************************************************/
6875 7798
6876 7799
@@ -7020,4 +7943,68 @@ typedef struct _ATOM_PPLIB_Clock_Voltage_Limit_Table
7020 7943
7021#pragma pack() // BIOS data must use byte aligment 7944#pragma pack() // BIOS data must use byte aligment
7022 7945
7946//
7947// AMD ACPI Table
7948//
7949#pragma pack(1)
7950
7951typedef struct {
7952 ULONG Signature;
7953 ULONG TableLength; //Length
7954 UCHAR Revision;
7955 UCHAR Checksum;
7956 UCHAR OemId[6];
7957 UCHAR OemTableId[8]; //UINT64 OemTableId;
7958 ULONG OemRevision;
7959 ULONG CreatorId;
7960 ULONG CreatorRevision;
7961} AMD_ACPI_DESCRIPTION_HEADER;
7962/*
7963//EFI_ACPI_DESCRIPTION_HEADER from AcpiCommon.h
7964typedef struct {
7965 UINT32 Signature; //0x0
7966 UINT32 Length; //0x4
7967 UINT8 Revision; //0x8
7968 UINT8 Checksum; //0x9
7969 UINT8 OemId[6]; //0xA
7970 UINT64 OemTableId; //0x10
7971 UINT32 OemRevision; //0x18
7972 UINT32 CreatorId; //0x1C
7973 UINT32 CreatorRevision; //0x20
7974}EFI_ACPI_DESCRIPTION_HEADER;
7975*/
7976typedef struct {
7977 AMD_ACPI_DESCRIPTION_HEADER SHeader;
7978 UCHAR TableUUID[16]; //0x24
7979 ULONG VBIOSImageOffset; //0x34. Offset to the first GOP_VBIOS_CONTENT block from the beginning of the stucture.
7980 ULONG Lib1ImageOffset; //0x38. Offset to the first GOP_LIB1_CONTENT block from the beginning of the stucture.
7981 ULONG Reserved[4]; //0x3C
7982}UEFI_ACPI_VFCT;
7983
7984typedef struct {
7985 ULONG PCIBus; //0x4C
7986 ULONG PCIDevice; //0x50
7987 ULONG PCIFunction; //0x54
7988 USHORT VendorID; //0x58
7989 USHORT DeviceID; //0x5A
7990 USHORT SSVID; //0x5C
7991 USHORT SSID; //0x5E
7992 ULONG Revision; //0x60
7993 ULONG ImageLength; //0x64
7994}VFCT_IMAGE_HEADER;
7995
7996
7997typedef struct {
7998 VFCT_IMAGE_HEADER VbiosHeader;
7999 UCHAR VbiosContent[1];
8000}GOP_VBIOS_CONTENT;
8001
8002typedef struct {
8003 VFCT_IMAGE_HEADER Lib1Header;
8004 UCHAR Lib1Content[1];
8005}GOP_LIB1_CONTENT;
8006
8007#pragma pack()
8008
8009
7023#endif /* _ATOMBIOS_H */ 8010#endif /* _ATOMBIOS_H */
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 72672ea3f6d3..083b3eada001 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -231,6 +231,22 @@ static void atombios_blank_crtc(struct drm_crtc *crtc, int state)
231 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 231 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
232} 232}
233 233
234static void atombios_powergate_crtc(struct drm_crtc *crtc, int state)
235{
236 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
237 struct drm_device *dev = crtc->dev;
238 struct radeon_device *rdev = dev->dev_private;
239 int index = GetIndexIntoMasterTable(COMMAND, EnableDispPowerGating);
240 ENABLE_DISP_POWER_GATING_PARAMETERS_V2_1 args;
241
242 memset(&args, 0, sizeof(args));
243
244 args.ucDispPipeId = radeon_crtc->crtc_id;
245 args.ucEnable = state;
246
247 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
248}
249
234void atombios_crtc_dpms(struct drm_crtc *crtc, int mode) 250void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
235{ 251{
236 struct drm_device *dev = crtc->dev; 252 struct drm_device *dev = crtc->dev;
@@ -242,8 +258,11 @@ void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
242 radeon_crtc->enabled = true; 258 radeon_crtc->enabled = true;
243 /* adjust pm to dpms changes BEFORE enabling crtcs */ 259 /* adjust pm to dpms changes BEFORE enabling crtcs */
244 radeon_pm_compute_clocks(rdev); 260 radeon_pm_compute_clocks(rdev);
261 /* disable crtc pair power gating before programming */
262 if (ASIC_IS_DCE6(rdev))
263 atombios_powergate_crtc(crtc, ATOM_DISABLE);
245 atombios_enable_crtc(crtc, ATOM_ENABLE); 264 atombios_enable_crtc(crtc, ATOM_ENABLE);
246 if (ASIC_IS_DCE3(rdev)) 265 if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
247 atombios_enable_crtc_memreq(crtc, ATOM_ENABLE); 266 atombios_enable_crtc_memreq(crtc, ATOM_ENABLE);
248 atombios_blank_crtc(crtc, ATOM_DISABLE); 267 atombios_blank_crtc(crtc, ATOM_DISABLE);
249 drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); 268 drm_vblank_post_modeset(dev, radeon_crtc->crtc_id);
@@ -255,10 +274,29 @@ void atombios_crtc_dpms(struct drm_crtc *crtc, int mode)
255 drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); 274 drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id);
256 if (radeon_crtc->enabled) 275 if (radeon_crtc->enabled)
257 atombios_blank_crtc(crtc, ATOM_ENABLE); 276 atombios_blank_crtc(crtc, ATOM_ENABLE);
258 if (ASIC_IS_DCE3(rdev)) 277 if (ASIC_IS_DCE3(rdev) && !ASIC_IS_DCE6(rdev))
259 atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); 278 atombios_enable_crtc_memreq(crtc, ATOM_DISABLE);
260 atombios_enable_crtc(crtc, ATOM_DISABLE); 279 atombios_enable_crtc(crtc, ATOM_DISABLE);
261 radeon_crtc->enabled = false; 280 radeon_crtc->enabled = false;
281 /* power gating is per-pair */
282 if (ASIC_IS_DCE6(rdev)) {
283 struct drm_crtc *other_crtc;
284 struct radeon_crtc *other_radeon_crtc;
285 list_for_each_entry(other_crtc, &rdev->ddev->mode_config.crtc_list, head) {
286 other_radeon_crtc = to_radeon_crtc(other_crtc);
287 if (((radeon_crtc->crtc_id == 0) && (other_radeon_crtc->crtc_id == 1)) ||
288 ((radeon_crtc->crtc_id == 1) && (other_radeon_crtc->crtc_id == 0)) ||
289 ((radeon_crtc->crtc_id == 2) && (other_radeon_crtc->crtc_id == 3)) ||
290 ((radeon_crtc->crtc_id == 3) && (other_radeon_crtc->crtc_id == 2)) ||
291 ((radeon_crtc->crtc_id == 4) && (other_radeon_crtc->crtc_id == 5)) ||
292 ((radeon_crtc->crtc_id == 5) && (other_radeon_crtc->crtc_id == 4))) {
293 /* if both crtcs in the pair are off, enable power gating */
294 if (other_radeon_crtc->enabled == false)
295 atombios_powergate_crtc(crtc, ATOM_ENABLE);
296 break;
297 }
298 }
299 }
262 /* adjust pm to dpms changes AFTER disabling crtcs */ 300 /* adjust pm to dpms changes AFTER disabling crtcs */
263 radeon_pm_compute_clocks(rdev); 301 radeon_pm_compute_clocks(rdev);
264 break; 302 break;
@@ -436,7 +474,7 @@ static void atombios_crtc_program_ss(struct radeon_device *rdev,
436 return; 474 return;
437 } 475 }
438 args.v3.ucEnable = enable; 476 args.v3.ucEnable = enable;
439 if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK)) 477 if ((ss->percentage == 0) || (ss->type & ATOM_EXTERNAL_SS_MASK) || ASIC_IS_DCE61(rdev))
440 args.v3.ucEnable = ATOM_DISABLE; 478 args.v3.ucEnable = ATOM_DISABLE;
441 } else if (ASIC_IS_DCE4(rdev)) { 479 } else if (ASIC_IS_DCE4(rdev)) {
442 args.v2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage); 480 args.v2.usSpreadSpectrumPercentage = cpu_to_le16(ss->percentage);
@@ -699,7 +737,7 @@ union set_pixel_clock {
699/* on DCE5, make sure the voltage is high enough to support the 737/* on DCE5, make sure the voltage is high enough to support the
700 * required disp clk. 738 * required disp clk.
701 */ 739 */
702static void atombios_crtc_set_dcpll(struct radeon_device *rdev, 740static void atombios_crtc_set_disp_eng_pll(struct radeon_device *rdev,
703 u32 dispclk) 741 u32 dispclk)
704{ 742{
705 u8 frev, crev; 743 u8 frev, crev;
@@ -729,7 +767,12 @@ static void atombios_crtc_set_dcpll(struct radeon_device *rdev,
729 * SetPixelClock provides the dividers 767 * SetPixelClock provides the dividers
730 */ 768 */
731 args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk); 769 args.v6.ulDispEngClkFreq = cpu_to_le32(dispclk);
732 args.v6.ucPpll = ATOM_DCPLL; 770 if (ASIC_IS_DCE61(rdev))
771 args.v6.ucPpll = ATOM_EXT_PLL1;
772 else if (ASIC_IS_DCE6(rdev))
773 args.v6.ucPpll = ATOM_PPLL0;
774 else
775 args.v6.ucPpll = ATOM_DCPLL;
733 break; 776 break;
734 default: 777 default:
735 DRM_ERROR("Unknown table version %d %d\n", frev, crev); 778 DRM_ERROR("Unknown table version %d %d\n", frev, crev);
@@ -1444,7 +1487,36 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1444 struct drm_crtc *test_crtc; 1487 struct drm_crtc *test_crtc;
1445 uint32_t pll_in_use = 0; 1488 uint32_t pll_in_use = 0;
1446 1489
1447 if (ASIC_IS_DCE4(rdev)) { 1490 if (ASIC_IS_DCE61(rdev)) {
1491 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
1492 if (test_encoder->crtc && (test_encoder->crtc == crtc)) {
1493 struct radeon_encoder *test_radeon_encoder =
1494 to_radeon_encoder(test_encoder);
1495 struct radeon_encoder_atom_dig *dig =
1496 test_radeon_encoder->enc_priv;
1497
1498 if ((test_radeon_encoder->encoder_id ==
1499 ENCODER_OBJECT_ID_INTERNAL_UNIPHY) &&
1500 (dig->linkb == false)) /* UNIPHY A uses PPLL2 */
1501 return ATOM_PPLL2;
1502 }
1503 }
1504 /* UNIPHY B/C/D/E/F */
1505 list_for_each_entry(test_crtc, &dev->mode_config.crtc_list, head) {
1506 struct radeon_crtc *radeon_test_crtc;
1507
1508 if (crtc == test_crtc)
1509 continue;
1510
1511 radeon_test_crtc = to_radeon_crtc(test_crtc);
1512 if ((radeon_test_crtc->pll_id == ATOM_PPLL0) ||
1513 (radeon_test_crtc->pll_id == ATOM_PPLL1))
1514 pll_in_use |= (1 << radeon_test_crtc->pll_id);
1515 }
1516 if (!(pll_in_use & 4))
1517 return ATOM_PPLL0;
1518 return ATOM_PPLL1;
1519 } else if (ASIC_IS_DCE4(rdev)) {
1448 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) { 1520 list_for_each_entry(test_encoder, &dev->mode_config.encoder_list, head) {
1449 if (test_encoder->crtc && (test_encoder->crtc == crtc)) { 1521 if (test_encoder->crtc && (test_encoder->crtc == crtc)) {
1450 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock, 1522 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock,
@@ -1483,10 +1555,12 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1483 1555
1484} 1556}
1485 1557
1486void radeon_atom_dcpll_init(struct radeon_device *rdev) 1558void radeon_atom_disp_eng_pll_init(struct radeon_device *rdev)
1487{ 1559{
1488 /* always set DCPLL */ 1560 /* always set DCPLL */
1489 if (ASIC_IS_DCE4(rdev)) { 1561 if (ASIC_IS_DCE6(rdev))
1562 atombios_crtc_set_disp_eng_pll(rdev, rdev->clock.default_dispclk);
1563 else if (ASIC_IS_DCE4(rdev)) {
1490 struct radeon_atom_ss ss; 1564 struct radeon_atom_ss ss;
1491 bool ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss, 1565 bool ss_enabled = radeon_atombios_get_asic_ss_info(rdev, &ss,
1492 ASIC_INTERNAL_SS_ON_DCPLL, 1566 ASIC_INTERNAL_SS_ON_DCPLL,
@@ -1494,7 +1568,7 @@ void radeon_atom_dcpll_init(struct radeon_device *rdev)
1494 if (ss_enabled) 1568 if (ss_enabled)
1495 atombios_crtc_program_ss(rdev, ATOM_DISABLE, ATOM_DCPLL, &ss); 1569 atombios_crtc_program_ss(rdev, ATOM_DISABLE, ATOM_DCPLL, &ss);
1496 /* XXX: DCE5, make sure voltage, dispclk is high enough */ 1570 /* XXX: DCE5, make sure voltage, dispclk is high enough */
1497 atombios_crtc_set_dcpll(rdev, rdev->clock.default_dispclk); 1571 atombios_crtc_set_disp_eng_pll(rdev, rdev->clock.default_dispclk);
1498 if (ss_enabled) 1572 if (ss_enabled)
1499 atombios_crtc_program_ss(rdev, ATOM_ENABLE, ATOM_DCPLL, &ss); 1573 atombios_crtc_program_ss(rdev, ATOM_ENABLE, ATOM_DCPLL, &ss);
1500 } 1574 }
@@ -1572,6 +1646,8 @@ static void atombios_crtc_commit(struct drm_crtc *crtc)
1572static void atombios_crtc_disable(struct drm_crtc *crtc) 1646static void atombios_crtc_disable(struct drm_crtc *crtc)
1573{ 1647{
1574 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 1648 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
1649 struct drm_device *dev = crtc->dev;
1650 struct radeon_device *rdev = dev->dev_private;
1575 struct radeon_atom_ss ss; 1651 struct radeon_atom_ss ss;
1576 1652
1577 atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); 1653 atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
@@ -1583,6 +1659,12 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
1583 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, 1659 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
1584 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss); 1660 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
1585 break; 1661 break;
1662 case ATOM_PPLL0:
1663 /* disable the ppll */
1664 if (ASIC_IS_DCE61(rdev))
1665 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
1666 0, 0, ATOM_DISABLE, 0, 0, 0, 0, 0, false, &ss);
1667 break;
1586 default: 1668 default:
1587 break; 1669 break;
1588 } 1670 }
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 191218ad92e7..6c62be226804 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -63,12 +63,12 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
63 63
64 memset(&args, 0, sizeof(args)); 64 memset(&args, 0, sizeof(args));
65 65
66 base = (unsigned char *)rdev->mode_info.atom_context->scratch; 66 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
67 67
68 memcpy(base, send, send_bytes); 68 memcpy(base, send, send_bytes);
69 69
70 args.v1.lpAuxRequest = 0; 70 args.v1.lpAuxRequest = 0 + 4;
71 args.v1.lpDataOut = 16; 71 args.v1.lpDataOut = 16 + 4;
72 args.v1.ucDataOutLen = 0; 72 args.v1.ucDataOutLen = 0;
73 args.v1.ucChannelID = chan->rec.i2c_id; 73 args.v1.ucChannelID = chan->rec.i2c_id;
74 args.v1.ucDelay = delay / 10; 74 args.v1.ucDelay = delay / 10;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index b88c4608731b..468b874336f9 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -479,7 +479,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
479 * - 2 DIG encoder blocks. 479 * - 2 DIG encoder blocks.
480 * DIG1/2 can drive UNIPHY0/1/2 link A or link B 480 * DIG1/2 can drive UNIPHY0/1/2 link A or link B
481 * 481 *
482 * DCE 4.0/5.0 482 * DCE 4.0/5.0/6.0
483 * - 3 DIG transmitter blocks UNIPHY0/1/2 (links A and B). 483 * - 3 DIG transmitter blocks UNIPHY0/1/2 (links A and B).
484 * Supports up to 6 digital outputs 484 * Supports up to 6 digital outputs
485 * - 6 DIG encoder blocks. 485 * - 6 DIG encoder blocks.
@@ -495,7 +495,11 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
495 * - 3 DIG transmitter blocks UNIPHY0/1/2 (links A and B). 495 * - 3 DIG transmitter blocks UNIPHY0/1/2 (links A and B).
496 * Supports up to 6 digital outputs 496 * Supports up to 6 digital outputs
497 * - 2 DIG encoder blocks. 497 * - 2 DIG encoder blocks.
498 * llano
498 * DIG1/2 can drive UNIPHY0/1/2 link A or link B 499 * DIG1/2 can drive UNIPHY0/1/2 link A or link B
500 * ontario
501 * DIG1 drives UNIPHY0/1/2 link A
502 * DIG2 drives UNIPHY0/1/2 link B
499 * 503 *
500 * Routing 504 * Routing
501 * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links) 505 * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links)
@@ -703,6 +707,7 @@ union dig_transmitter_control {
703 DIG_TRANSMITTER_CONTROL_PARAMETERS_V2 v2; 707 DIG_TRANSMITTER_CONTROL_PARAMETERS_V2 v2;
704 DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 v3; 708 DIG_TRANSMITTER_CONTROL_PARAMETERS_V3 v3;
705 DIG_TRANSMITTER_CONTROL_PARAMETERS_V4 v4; 709 DIG_TRANSMITTER_CONTROL_PARAMETERS_V4 v4;
710 DIG_TRANSMITTER_CONTROL_PARAMETERS_V1_5 v5;
706}; 711};
707 712
708void 713void
@@ -723,6 +728,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
723 int connector_object_id = 0; 728 int connector_object_id = 0;
724 int igp_lane_info = 0; 729 int igp_lane_info = 0;
725 int dig_encoder = dig->dig_encoder; 730 int dig_encoder = dig->dig_encoder;
731 int hpd_id = RADEON_HPD_NONE;
726 732
727 if (action == ATOM_TRANSMITTER_ACTION_INIT) { 733 if (action == ATOM_TRANSMITTER_ACTION_INIT) {
728 connector = radeon_get_connector_for_encoder_init(encoder); 734 connector = radeon_get_connector_for_encoder_init(encoder);
@@ -738,6 +744,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
738 struct radeon_connector_atom_dig *dig_connector = 744 struct radeon_connector_atom_dig *dig_connector =
739 radeon_connector->con_priv; 745 radeon_connector->con_priv;
740 746
747 hpd_id = radeon_connector->hpd.hpd;
741 dp_clock = dig_connector->dp_clock; 748 dp_clock = dig_connector->dp_clock;
742 dp_lane_count = dig_connector->dp_lane_count; 749 dp_lane_count = dig_connector->dp_lane_count;
743 connector_object_id = 750 connector_object_id =
@@ -1003,6 +1010,60 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
1003 args.v4.acConfig.fDualLinkConnector = 1; 1010 args.v4.acConfig.fDualLinkConnector = 1;
1004 } 1011 }
1005 break; 1012 break;
1013 case 5:
1014 args.v5.ucAction = action;
1015 if (is_dp)
1016 args.v5.usSymClock = cpu_to_le16(dp_clock / 10);
1017 else
1018 args.v5.usSymClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
1019
1020 switch (radeon_encoder->encoder_id) {
1021 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
1022 if (dig->linkb)
1023 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYB;
1024 else
1025 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYA;
1026 break;
1027 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
1028 if (dig->linkb)
1029 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYD;
1030 else
1031 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYC;
1032 break;
1033 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
1034 if (dig->linkb)
1035 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYF;
1036 else
1037 args.v5.ucPhyId = ATOM_PHY_ID_UNIPHYE;
1038 break;
1039 }
1040 if (is_dp)
1041 args.v5.ucLaneNum = dp_lane_count;
1042 else if (radeon_encoder->pixel_clock > 165000)
1043 args.v5.ucLaneNum = 8;
1044 else
1045 args.v5.ucLaneNum = 4;
1046 args.v5.ucConnObjId = connector_object_id;
1047 args.v5.ucDigMode = atombios_get_encoder_mode(encoder);
1048
1049 if (is_dp && rdev->clock.dp_extclk)
1050 args.v5.asConfig.ucPhyClkSrcId = ENCODER_REFCLK_SRC_EXTCLK;
1051 else
1052 args.v5.asConfig.ucPhyClkSrcId = pll_id;
1053
1054 if (is_dp)
1055 args.v5.asConfig.ucCoherentMode = 1; /* DP requires coherent */
1056 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
1057 if (dig->coherent_mode)
1058 args.v5.asConfig.ucCoherentMode = 1;
1059 }
1060 if (hpd_id == RADEON_HPD_NONE)
1061 args.v5.asConfig.ucHPDSel = 0;
1062 else
1063 args.v5.asConfig.ucHPDSel = hpd_id + 1;
1064 args.v5.ucDigEncoderSel = 1 << dig_encoder;
1065 args.v5.ucDPLaneSet = lane_set;
1066 break;
1006 default: 1067 default:
1007 DRM_ERROR("Unknown table version %d, %d\n", frev, crev); 1068 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
1008 break; 1069 break;
@@ -1377,7 +1438,7 @@ radeon_atom_encoder_dpms_ext(struct drm_encoder *encoder,
1377 switch (mode) { 1438 switch (mode) {
1378 case DRM_MODE_DPMS_ON: 1439 case DRM_MODE_DPMS_ON:
1379 default: 1440 default:
1380 if (ASIC_IS_DCE41(rdev)) { 1441 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev)) {
1381 atombios_external_encoder_setup(encoder, ext_encoder, 1442 atombios_external_encoder_setup(encoder, ext_encoder,
1382 EXTERNAL_ENCODER_ACTION_V3_ENABLE_OUTPUT); 1443 EXTERNAL_ENCODER_ACTION_V3_ENABLE_OUTPUT);
1383 atombios_external_encoder_setup(encoder, ext_encoder, 1444 atombios_external_encoder_setup(encoder, ext_encoder,
@@ -1388,7 +1449,7 @@ radeon_atom_encoder_dpms_ext(struct drm_encoder *encoder,
1388 case DRM_MODE_DPMS_STANDBY: 1449 case DRM_MODE_DPMS_STANDBY:
1389 case DRM_MODE_DPMS_SUSPEND: 1450 case DRM_MODE_DPMS_SUSPEND:
1390 case DRM_MODE_DPMS_OFF: 1451 case DRM_MODE_DPMS_OFF:
1391 if (ASIC_IS_DCE41(rdev)) { 1452 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev)) {
1392 atombios_external_encoder_setup(encoder, ext_encoder, 1453 atombios_external_encoder_setup(encoder, ext_encoder,
1393 EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING); 1454 EXTERNAL_ENCODER_ACTION_V3_ENCODER_BLANKING);
1394 atombios_external_encoder_setup(encoder, ext_encoder, 1455 atombios_external_encoder_setup(encoder, ext_encoder,
@@ -1761,7 +1822,7 @@ radeon_atom_encoder_init(struct radeon_device *rdev)
1761 break; 1822 break;
1762 } 1823 }
1763 1824
1764 if (ext_encoder && ASIC_IS_DCE41(rdev)) 1825 if (ext_encoder && (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev)))
1765 atombios_external_encoder_setup(encoder, ext_encoder, 1826 atombios_external_encoder_setup(encoder, ext_encoder,
1766 EXTERNAL_ENCODER_ACTION_V3_ENCODER_INIT); 1827 EXTERNAL_ENCODER_ACTION_V3_ENCODER_INIT);
1767 } 1828 }
@@ -1850,7 +1911,7 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1850 } 1911 }
1851 1912
1852 if (ext_encoder) { 1913 if (ext_encoder) {
1853 if (ASIC_IS_DCE41(rdev)) 1914 if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
1854 atombios_external_encoder_setup(encoder, ext_encoder, 1915 atombios_external_encoder_setup(encoder, ext_encoder,
1855 EXTERNAL_ENCODER_ACTION_V3_ENCODER_SETUP); 1916 EXTERNAL_ENCODER_ACTION_V3_ENCODER_SETUP);
1856 else 1917 else
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 466db4115cd5..cfa372cb1cb3 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -581,7 +581,7 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev,
581 return 0; 581 return 0;
582} 582}
583 583
584static u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev) 584u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev)
585{ 585{
586 u32 tmp = RREG32(MC_SHARED_CHMAP); 586 u32 tmp = RREG32(MC_SHARED_CHMAP);
587 587
@@ -1328,7 +1328,10 @@ void evergreen_mc_program(struct radeon_device *rdev)
1328 rdev->mc.vram_end >> 12); 1328 rdev->mc.vram_end >> 12);
1329 } 1329 }
1330 WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr >> 12); 1330 WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr >> 12);
1331 if (rdev->flags & RADEON_IS_IGP) { 1331 /* llano/ontario only */
1332 if ((rdev->family == CHIP_PALM) ||
1333 (rdev->family == CHIP_SUMO) ||
1334 (rdev->family == CHIP_SUMO2)) {
1332 tmp = RREG32(MC_FUS_VM_FB_OFFSET) & 0x000FFFFF; 1335 tmp = RREG32(MC_FUS_VM_FB_OFFSET) & 0x000FFFFF;
1333 tmp |= ((rdev->mc.vram_end >> 20) & 0xF) << 24; 1336 tmp |= ((rdev->mc.vram_end >> 20) & 0xF) << 24;
1334 tmp |= ((rdev->mc.vram_start >> 20) & 0xF) << 20; 1337 tmp |= ((rdev->mc.vram_start >> 20) & 0xF) << 20;
@@ -1972,7 +1975,9 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
1972 1975
1973 1976
1974 mc_shared_chmap = RREG32(MC_SHARED_CHMAP); 1977 mc_shared_chmap = RREG32(MC_SHARED_CHMAP);
1975 if (rdev->flags & RADEON_IS_IGP) 1978 if ((rdev->family == CHIP_PALM) ||
1979 (rdev->family == CHIP_SUMO) ||
1980 (rdev->family == CHIP_SUMO2))
1976 mc_arb_ramcfg = RREG32(FUS_MC_ARB_RAMCFG); 1981 mc_arb_ramcfg = RREG32(FUS_MC_ARB_RAMCFG);
1977 else 1982 else
1978 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); 1983 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG);
@@ -2362,7 +2367,9 @@ int evergreen_mc_init(struct radeon_device *rdev)
2362 2367
2363 /* Get VRAM informations */ 2368 /* Get VRAM informations */
2364 rdev->mc.vram_is_ddr = true; 2369 rdev->mc.vram_is_ddr = true;
2365 if (rdev->flags & RADEON_IS_IGP) 2370 if ((rdev->family == CHIP_PALM) ||
2371 (rdev->family == CHIP_SUMO) ||
2372 (rdev->family == CHIP_SUMO2))
2366 tmp = RREG32(FUS_MC_ARB_RAMCFG); 2373 tmp = RREG32(FUS_MC_ARB_RAMCFG);
2367 else 2374 else
2368 tmp = RREG32(MC_ARB_RAMCFG); 2375 tmp = RREG32(MC_ARB_RAMCFG);
@@ -2394,12 +2401,14 @@ int evergreen_mc_init(struct radeon_device *rdev)
2394 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); 2401 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
2395 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); 2402 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
2396 /* Setup GPU memory space */ 2403 /* Setup GPU memory space */
2397 if (rdev->flags & RADEON_IS_IGP) { 2404 if ((rdev->family == CHIP_PALM) ||
2405 (rdev->family == CHIP_SUMO) ||
2406 (rdev->family == CHIP_SUMO2)) {
2398 /* size in bytes on fusion */ 2407 /* size in bytes on fusion */
2399 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); 2408 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE);
2400 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); 2409 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE);
2401 } else { 2410 } else {
2402 /* size in MB on evergreen */ 2411 /* size in MB on evergreen/cayman/tn */
2403 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; 2412 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
2404 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; 2413 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
2405 } 2414 }
@@ -2557,7 +2566,9 @@ void evergreen_disable_interrupt_state(struct radeon_device *rdev)
2557 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); 2566 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0);
2558 } 2567 }
2559 2568
2560 WREG32(DACA_AUTODETECT_INT_CONTROL, 0); 2569 /* only one DAC on DCE6 */
2570 if (!ASIC_IS_DCE6(rdev))
2571 WREG32(DACA_AUTODETECT_INT_CONTROL, 0);
2561 WREG32(DACB_AUTODETECT_INT_CONTROL, 0); 2572 WREG32(DACB_AUTODETECT_INT_CONTROL, 0);
2562 2573
2563 tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; 2574 tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY;
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
index 4e83fdcf4bc5..222acd2d33df 100644
--- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
+++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
@@ -226,7 +226,7 @@ set_scissors(struct radeon_device *rdev, int x1, int y1,
226 x1 = 1; 226 x1 = 1;
227 if (y2 == 0) 227 if (y2 == 0)
228 y1 = 1; 228 y1 = 1;
229 if (rdev->family == CHIP_CAYMAN) { 229 if (rdev->family >= CHIP_CAYMAN) {
230 if ((x2 == 1) && (y2 == 1)) 230 if ((x2 == 1) && (y2 == 1))
231 x2 = 2; 231 x2 = 2;
232 } 232 }
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 160799c14b91..a48ca53fcd6a 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -42,6 +42,8 @@ extern void evergreen_irq_suspend(struct radeon_device *rdev);
42extern int evergreen_mc_init(struct radeon_device *rdev); 42extern int evergreen_mc_init(struct radeon_device *rdev);
43extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev); 43extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
44extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev); 44extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
45extern void si_rlc_fini(struct radeon_device *rdev);
46extern int si_rlc_init(struct radeon_device *rdev);
45 47
46#define EVERGREEN_PFP_UCODE_SIZE 1120 48#define EVERGREEN_PFP_UCODE_SIZE 1120
47#define EVERGREEN_PM4_UCODE_SIZE 1376 49#define EVERGREEN_PM4_UCODE_SIZE 1376
@@ -53,6 +55,8 @@ extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
53#define CAYMAN_RLC_UCODE_SIZE 1024 55#define CAYMAN_RLC_UCODE_SIZE 1024
54#define CAYMAN_MC_UCODE_SIZE 6037 56#define CAYMAN_MC_UCODE_SIZE 6037
55 57
58#define ARUBA_RLC_UCODE_SIZE 1536
59
56/* Firmware Names */ 60/* Firmware Names */
57MODULE_FIRMWARE("radeon/BARTS_pfp.bin"); 61MODULE_FIRMWARE("radeon/BARTS_pfp.bin");
58MODULE_FIRMWARE("radeon/BARTS_me.bin"); 62MODULE_FIRMWARE("radeon/BARTS_me.bin");
@@ -68,6 +72,9 @@ MODULE_FIRMWARE("radeon/CAYMAN_pfp.bin");
68MODULE_FIRMWARE("radeon/CAYMAN_me.bin"); 72MODULE_FIRMWARE("radeon/CAYMAN_me.bin");
69MODULE_FIRMWARE("radeon/CAYMAN_mc.bin"); 73MODULE_FIRMWARE("radeon/CAYMAN_mc.bin");
70MODULE_FIRMWARE("radeon/CAYMAN_rlc.bin"); 74MODULE_FIRMWARE("radeon/CAYMAN_rlc.bin");
75MODULE_FIRMWARE("radeon/ARUBA_pfp.bin");
76MODULE_FIRMWARE("radeon/ARUBA_me.bin");
77MODULE_FIRMWARE("radeon/ARUBA_rlc.bin");
71 78
72#define BTC_IO_MC_REGS_SIZE 29 79#define BTC_IO_MC_REGS_SIZE 29
73 80
@@ -326,6 +333,15 @@ int ni_init_microcode(struct radeon_device *rdev)
326 rlc_req_size = CAYMAN_RLC_UCODE_SIZE * 4; 333 rlc_req_size = CAYMAN_RLC_UCODE_SIZE * 4;
327 mc_req_size = CAYMAN_MC_UCODE_SIZE * 4; 334 mc_req_size = CAYMAN_MC_UCODE_SIZE * 4;
328 break; 335 break;
336 case CHIP_ARUBA:
337 chip_name = "ARUBA";
338 rlc_chip_name = "ARUBA";
339 /* pfp/me same size as CAYMAN */
340 pfp_req_size = CAYMAN_PFP_UCODE_SIZE * 4;
341 me_req_size = CAYMAN_PM4_UCODE_SIZE * 4;
342 rlc_req_size = ARUBA_RLC_UCODE_SIZE * 4;
343 mc_req_size = 0;
344 break;
329 default: BUG(); 345 default: BUG();
330 } 346 }
331 347
@@ -365,15 +381,18 @@ int ni_init_microcode(struct radeon_device *rdev)
365 err = -EINVAL; 381 err = -EINVAL;
366 } 382 }
367 383
368 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name); 384 /* no MC ucode on TN */
369 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev); 385 if (!(rdev->flags & RADEON_IS_IGP)) {
370 if (err) 386 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
371 goto out; 387 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
372 if (rdev->mc_fw->size != mc_req_size) { 388 if (err)
373 printk(KERN_ERR 389 goto out;
374 "ni_mc: Bogus length %zu in firmware \"%s\"\n", 390 if (rdev->mc_fw->size != mc_req_size) {
375 rdev->mc_fw->size, fw_name); 391 printk(KERN_ERR
376 err = -EINVAL; 392 "ni_mc: Bogus length %zu in firmware \"%s\"\n",
393 rdev->mc_fw->size, fw_name);
394 err = -EINVAL;
395 }
377 } 396 }
378out: 397out:
379 platform_device_unregister(pdev); 398 platform_device_unregister(pdev);
@@ -478,6 +497,7 @@ static u32 cayman_get_tile_pipe_to_backend_map(struct radeon_device *rdev,
478 memset((uint8_t *)&swizzle_pipe[0], 0, sizeof(u32) * CAYMAN_MAX_PIPES); 497 memset((uint8_t *)&swizzle_pipe[0], 0, sizeof(u32) * CAYMAN_MAX_PIPES);
479 switch (rdev->family) { 498 switch (rdev->family) {
480 case CHIP_CAYMAN: 499 case CHIP_CAYMAN:
500 case CHIP_ARUBA:
481 force_no_swizzle = true; 501 force_no_swizzle = true;
482 break; 502 break;
483 default: 503 default:
@@ -610,7 +630,6 @@ static void cayman_gpu_init(struct radeon_device *rdev)
610 630
611 switch (rdev->family) { 631 switch (rdev->family) {
612 case CHIP_CAYMAN: 632 case CHIP_CAYMAN:
613 default:
614 rdev->config.cayman.max_shader_engines = 2; 633 rdev->config.cayman.max_shader_engines = 2;
615 rdev->config.cayman.max_pipes_per_simd = 4; 634 rdev->config.cayman.max_pipes_per_simd = 4;
616 rdev->config.cayman.max_tile_pipes = 8; 635 rdev->config.cayman.max_tile_pipes = 8;
@@ -632,6 +651,43 @@ static void cayman_gpu_init(struct radeon_device *rdev)
632 rdev->config.cayman.sc_hiz_tile_fifo_size = 0x30; 651 rdev->config.cayman.sc_hiz_tile_fifo_size = 0x30;
633 rdev->config.cayman.sc_earlyz_tile_fifo_size = 0x130; 652 rdev->config.cayman.sc_earlyz_tile_fifo_size = 0x130;
634 break; 653 break;
654 case CHIP_ARUBA:
655 default:
656 rdev->config.cayman.max_shader_engines = 1;
657 rdev->config.cayman.max_pipes_per_simd = 4;
658 rdev->config.cayman.max_tile_pipes = 2;
659 if ((rdev->pdev->device == 0x9900) ||
660 (rdev->pdev->device == 0x9901)) {
661 rdev->config.cayman.max_simds_per_se = 6;
662 rdev->config.cayman.max_backends_per_se = 2;
663 } else if ((rdev->pdev->device == 0x9903) ||
664 (rdev->pdev->device == 0x9904)) {
665 rdev->config.cayman.max_simds_per_se = 4;
666 rdev->config.cayman.max_backends_per_se = 2;
667 } else if ((rdev->pdev->device == 0x9990) ||
668 (rdev->pdev->device == 0x9991)) {
669 rdev->config.cayman.max_simds_per_se = 3;
670 rdev->config.cayman.max_backends_per_se = 1;
671 } else {
672 rdev->config.cayman.max_simds_per_se = 2;
673 rdev->config.cayman.max_backends_per_se = 1;
674 }
675 rdev->config.cayman.max_texture_channel_caches = 2;
676 rdev->config.cayman.max_gprs = 256;
677 rdev->config.cayman.max_threads = 256;
678 rdev->config.cayman.max_gs_threads = 32;
679 rdev->config.cayman.max_stack_entries = 512;
680 rdev->config.cayman.sx_num_of_sets = 8;
681 rdev->config.cayman.sx_max_export_size = 256;
682 rdev->config.cayman.sx_max_export_pos_size = 64;
683 rdev->config.cayman.sx_max_export_smx_size = 192;
684 rdev->config.cayman.max_hw_contexts = 8;
685 rdev->config.cayman.sq_num_cf_insts = 2;
686
687 rdev->config.cayman.sc_prim_fifo_size = 0x40;
688 rdev->config.cayman.sc_hiz_tile_fifo_size = 0x30;
689 rdev->config.cayman.sc_earlyz_tile_fifo_size = 0x130;
690 break;
635 } 691 }
636 692
637 /* Initialize HDP */ 693 /* Initialize HDP */
@@ -652,7 +708,9 @@ static void cayman_gpu_init(struct radeon_device *rdev)
652 708
653 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE); 709 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE);
654 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG); 710 cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG);
655 cgts_tcc_disable = 0xff000000; 711 cgts_tcc_disable = 0xffff0000;
712 for (i = 0; i < rdev->config.cayman.max_texture_channel_caches; i++)
713 cgts_tcc_disable &= ~(1 << (16 + i));
656 gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE); 714 gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE);
657 gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG); 715 gc_user_shader_pipe_config = RREG32(GC_USER_SHADER_PIPE_CONFIG);
658 cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE); 716 cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE);
@@ -804,8 +862,13 @@ static void cayman_gpu_init(struct radeon_device *rdev)
804 rdev->config.cayman.tile_config |= (3 << 0); 862 rdev->config.cayman.tile_config |= (3 << 0);
805 break; 863 break;
806 } 864 }
807 rdev->config.cayman.tile_config |= 865
808 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4; 866 /* num banks is 8 on all fusion asics. 0 = 4, 1 = 8, 2 = 16 */
867 if (rdev->flags & RADEON_IS_IGP)
868 rdev->config.evergreen.tile_config |= 1 << 4;
869 else
870 rdev->config.cayman.tile_config |=
871 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4;
809 rdev->config.cayman.tile_config |= 872 rdev->config.cayman.tile_config |=
810 ((gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT) << 8; 873 ((gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT) << 8;
811 rdev->config.cayman.tile_config |= 874 rdev->config.cayman.tile_config |=
@@ -1440,18 +1503,29 @@ static int cayman_startup(struct radeon_device *rdev)
1440 /* enable pcie gen2 link */ 1503 /* enable pcie gen2 link */
1441 evergreen_pcie_gen2_enable(rdev); 1504 evergreen_pcie_gen2_enable(rdev);
1442 1505
1443 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) { 1506 if (rdev->flags & RADEON_IS_IGP) {
1444 r = ni_init_microcode(rdev); 1507 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
1508 r = ni_init_microcode(rdev);
1509 if (r) {
1510 DRM_ERROR("Failed to load firmware!\n");
1511 return r;
1512 }
1513 }
1514 } else {
1515 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) {
1516 r = ni_init_microcode(rdev);
1517 if (r) {
1518 DRM_ERROR("Failed to load firmware!\n");
1519 return r;
1520 }
1521 }
1522
1523 r = ni_mc_load_microcode(rdev);
1445 if (r) { 1524 if (r) {
1446 DRM_ERROR("Failed to load firmware!\n"); 1525 DRM_ERROR("Failed to load MC firmware!\n");
1447 return r; 1526 return r;
1448 } 1527 }
1449 } 1528 }
1450 r = ni_mc_load_microcode(rdev);
1451 if (r) {
1452 DRM_ERROR("Failed to load MC firmware!\n");
1453 return r;
1454 }
1455 1529
1456 r = r600_vram_scratch_init(rdev); 1530 r = r600_vram_scratch_init(rdev);
1457 if (r) 1531 if (r)
@@ -1470,6 +1544,15 @@ static int cayman_startup(struct radeon_device *rdev)
1470 dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r); 1544 dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r);
1471 } 1545 }
1472 1546
1547 /* allocate rlc buffers */
1548 if (rdev->flags & RADEON_IS_IGP) {
1549 r = si_rlc_init(rdev);
1550 if (r) {
1551 DRM_ERROR("Failed to init rlc BOs!\n");
1552 return r;
1553 }
1554 }
1555
1473 /* allocate wb buffer */ 1556 /* allocate wb buffer */
1474 r = radeon_wb_init(rdev); 1557 r = radeon_wb_init(rdev);
1475 if (r) 1558 if (r)
@@ -1654,6 +1737,8 @@ int cayman_init(struct radeon_device *rdev)
1654 dev_err(rdev->dev, "disabling GPU acceleration\n"); 1737 dev_err(rdev->dev, "disabling GPU acceleration\n");
1655 cayman_cp_fini(rdev); 1738 cayman_cp_fini(rdev);
1656 r600_irq_fini(rdev); 1739 r600_irq_fini(rdev);
1740 if (rdev->flags & RADEON_IS_IGP)
1741 si_rlc_fini(rdev);
1657 radeon_wb_fini(rdev); 1742 radeon_wb_fini(rdev);
1658 r100_ib_fini(rdev); 1743 r100_ib_fini(rdev);
1659 radeon_vm_manager_fini(rdev); 1744 radeon_vm_manager_fini(rdev);
@@ -1665,8 +1750,11 @@ int cayman_init(struct radeon_device *rdev)
1665 /* Don't start up if the MC ucode is missing. 1750 /* Don't start up if the MC ucode is missing.
1666 * The default clocks and voltages before the MC ucode 1751 * The default clocks and voltages before the MC ucode
1667 * is loaded are not suffient for advanced operations. 1752 * is loaded are not suffient for advanced operations.
1753 *
1754 * We can skip this check for TN, because there is no MC
1755 * ucode.
1668 */ 1756 */
1669 if (!rdev->mc_fw) { 1757 if (!rdev->mc_fw && !(rdev->flags & RADEON_IS_IGP)) {
1670 DRM_ERROR("radeon: MC ucode required for NI+.\n"); 1758 DRM_ERROR("radeon: MC ucode required for NI+.\n");
1671 return -EINVAL; 1759 return -EINVAL;
1672 } 1760 }
@@ -1679,6 +1767,8 @@ void cayman_fini(struct radeon_device *rdev)
1679 r600_blit_fini(rdev); 1767 r600_blit_fini(rdev);
1680 cayman_cp_fini(rdev); 1768 cayman_cp_fini(rdev);
1681 r600_irq_fini(rdev); 1769 r600_irq_fini(rdev);
1770 if (rdev->flags & RADEON_IS_IGP)
1771 si_rlc_fini(rdev);
1682 radeon_wb_fini(rdev); 1772 radeon_wb_fini(rdev);
1683 radeon_vm_manager_fini(rdev); 1773 radeon_vm_manager_fini(rdev);
1684 r100_ib_fini(rdev); 1774 r100_ib_fini(rdev);
@@ -1702,7 +1792,12 @@ int cayman_vm_init(struct radeon_device *rdev)
1702 /* number of VMs */ 1792 /* number of VMs */
1703 rdev->vm_manager.nvm = 8; 1793 rdev->vm_manager.nvm = 8;
1704 /* base offset of vram pages */ 1794 /* base offset of vram pages */
1705 rdev->vm_manager.vram_base_offset = 0; 1795 if (rdev->flags & RADEON_IS_IGP) {
1796 u64 tmp = RREG32(FUS_MC_VM_FB_OFFSET);
1797 tmp <<= 22;
1798 rdev->vm_manager.vram_base_offset = tmp;
1799 } else
1800 rdev->vm_manager.vram_base_offset = 0;
1706 return 0; 1801 return 0;
1707} 1802}
1708 1803
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index 9a7f3b6e02de..2aa7046ada56 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -106,6 +106,7 @@
106#define SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 3) 106#define SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 3)
107#define SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5) 107#define SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5)
108#define ENABLE_ADVANCED_DRIVER_MODEL (1 << 6) 108#define ENABLE_ADVANCED_DRIVER_MODEL (1 << 6)
109#define FUS_MC_VM_FB_OFFSET 0x2068
109 110
110#define MC_SHARED_BLACKOUT_CNTL 0x20ac 111#define MC_SHARED_BLACKOUT_CNTL 0x20ac
111#define MC_ARB_RAMCFG 0x2760 112#define MC_ARB_RAMCFG 0x2760
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 5eb23829353f..391bd2636a80 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -49,6 +49,7 @@
49#define EVERGREEN_PM4_UCODE_SIZE 1376 49#define EVERGREEN_PM4_UCODE_SIZE 1376
50#define EVERGREEN_RLC_UCODE_SIZE 768 50#define EVERGREEN_RLC_UCODE_SIZE 768
51#define CAYMAN_RLC_UCODE_SIZE 1024 51#define CAYMAN_RLC_UCODE_SIZE 1024
52#define ARUBA_RLC_UCODE_SIZE 1536
52 53
53/* Firmware Names */ 54/* Firmware Names */
54MODULE_FIRMWARE("radeon/R600_pfp.bin"); 55MODULE_FIRMWARE("radeon/R600_pfp.bin");
@@ -2778,7 +2779,7 @@ void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size)
2778 rdev->ih.rptr = 0; 2779 rdev->ih.rptr = 0;
2779} 2780}
2780 2781
2781static int r600_ih_ring_alloc(struct radeon_device *rdev) 2782int r600_ih_ring_alloc(struct radeon_device *rdev)
2782{ 2783{
2783 int r; 2784 int r;
2784 2785
@@ -2814,7 +2815,7 @@ static int r600_ih_ring_alloc(struct radeon_device *rdev)
2814 return 0; 2815 return 0;
2815} 2816}
2816 2817
2817static void r600_ih_ring_fini(struct radeon_device *rdev) 2818void r600_ih_ring_fini(struct radeon_device *rdev)
2818{ 2819{
2819 int r; 2820 int r;
2820 if (rdev->ih.ring_obj) { 2821 if (rdev->ih.ring_obj) {
@@ -2861,10 +2862,17 @@ static int r600_rlc_init(struct radeon_device *rdev)
2861 2862
2862 r600_rlc_stop(rdev); 2863 r600_rlc_stop(rdev);
2863 2864
2864 WREG32(RLC_HB_BASE, 0);
2865 WREG32(RLC_HB_CNTL, 0); 2865 WREG32(RLC_HB_CNTL, 0);
2866 WREG32(RLC_HB_RPTR, 0); 2866
2867 WREG32(RLC_HB_WPTR, 0); 2867 if (rdev->family == CHIP_ARUBA) {
2868 WREG32(TN_RLC_SAVE_AND_RESTORE_BASE, rdev->rlc.save_restore_gpu_addr >> 8);
2869 WREG32(TN_RLC_CLEAR_STATE_RESTORE_BASE, rdev->rlc.clear_state_gpu_addr >> 8);
2870 }
2871 if (rdev->family <= CHIP_CAYMAN) {
2872 WREG32(RLC_HB_BASE, 0);
2873 WREG32(RLC_HB_RPTR, 0);
2874 WREG32(RLC_HB_WPTR, 0);
2875 }
2868 if (rdev->family <= CHIP_CAICOS) { 2876 if (rdev->family <= CHIP_CAICOS) {
2869 WREG32(RLC_HB_WPTR_LSB_ADDR, 0); 2877 WREG32(RLC_HB_WPTR_LSB_ADDR, 0);
2870 WREG32(RLC_HB_WPTR_MSB_ADDR, 0); 2878 WREG32(RLC_HB_WPTR_MSB_ADDR, 0);
@@ -2873,7 +2881,12 @@ static int r600_rlc_init(struct radeon_device *rdev)
2873 WREG32(RLC_UCODE_CNTL, 0); 2881 WREG32(RLC_UCODE_CNTL, 0);
2874 2882
2875 fw_data = (const __be32 *)rdev->rlc_fw->data; 2883 fw_data = (const __be32 *)rdev->rlc_fw->data;
2876 if (rdev->family >= CHIP_CAYMAN) { 2884 if (rdev->family >= CHIP_ARUBA) {
2885 for (i = 0; i < ARUBA_RLC_UCODE_SIZE; i++) {
2886 WREG32(RLC_UCODE_ADDR, i);
2887 WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++));
2888 }
2889 } else if (rdev->family >= CHIP_CAYMAN) {
2877 for (i = 0; i < CAYMAN_RLC_UCODE_SIZE; i++) { 2890 for (i = 0; i < CAYMAN_RLC_UCODE_SIZE; i++) {
2878 WREG32(RLC_UCODE_ADDR, i); 2891 WREG32(RLC_UCODE_ADDR, i);
2879 WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); 2892 WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++));
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 8ae328ff5fdd..3568a2e345fa 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -593,6 +593,10 @@
593#define RLC_UCODE_ADDR 0x3f2c 593#define RLC_UCODE_ADDR 0x3f2c
594#define RLC_UCODE_DATA 0x3f30 594#define RLC_UCODE_DATA 0x3f30
595 595
596/* new for TN */
597#define TN_RLC_SAVE_AND_RESTORE_BASE 0x3f10
598#define TN_RLC_CLEAR_STATE_RESTORE_BASE 0x3f20
599
596#define SRBM_SOFT_RESET 0xe60 600#define SRBM_SOFT_RESET 0xe60
597# define SOFT_RESET_RLC (1 << 13) 601# define SOFT_RESET_RLC (1 << 13)
598 602
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index d2870a014ec0..138b95216d8d 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -236,12 +236,12 @@ void radeon_pm_resume(struct radeon_device *rdev);
236void radeon_combios_get_power_modes(struct radeon_device *rdev); 236void radeon_combios_get_power_modes(struct radeon_device *rdev);
237void radeon_atombios_get_power_modes(struct radeon_device *rdev); 237void radeon_atombios_get_power_modes(struct radeon_device *rdev);
238void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type); 238void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
239int radeon_atom_get_max_vddc(struct radeon_device *rdev, u16 *voltage);
240void rs690_pm_info(struct radeon_device *rdev); 239void rs690_pm_info(struct radeon_device *rdev);
241extern int rv6xx_get_temp(struct radeon_device *rdev); 240extern int rv6xx_get_temp(struct radeon_device *rdev);
242extern int rv770_get_temp(struct radeon_device *rdev); 241extern int rv770_get_temp(struct radeon_device *rdev);
243extern int evergreen_get_temp(struct radeon_device *rdev); 242extern int evergreen_get_temp(struct radeon_device *rdev);
244extern int sumo_get_temp(struct radeon_device *rdev); 243extern int sumo_get_temp(struct radeon_device *rdev);
244extern int si_get_temp(struct radeon_device *rdev);
245extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw, 245extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
246 unsigned *bankh, unsigned *mtaspect, 246 unsigned *bankh, unsigned *mtaspect,
247 unsigned *tile_split); 247 unsigned *tile_split);
@@ -632,6 +632,7 @@ struct radeon_ib {
632 uint32_t *ptr; 632 uint32_t *ptr;
633 struct radeon_fence *fence; 633 struct radeon_fence *fence;
634 unsigned vm_id; 634 unsigned vm_id;
635 bool is_const_ib;
635}; 636};
636 637
637/* 638/*
@@ -771,6 +772,18 @@ struct r600_blit {
771 772
772void r600_blit_suspend(struct radeon_device *rdev); 773void r600_blit_suspend(struct radeon_device *rdev);
773 774
775/*
776 * SI RLC stuff
777 */
778struct si_rlc {
779 /* for power gating */
780 struct radeon_bo *save_restore_obj;
781 uint64_t save_restore_gpu_addr;
782 /* for clear state */
783 struct radeon_bo *clear_state_obj;
784 uint64_t clear_state_gpu_addr;
785};
786
774int radeon_ib_get(struct radeon_device *rdev, int ring, 787int radeon_ib_get(struct radeon_device *rdev, int ring,
775 struct radeon_ib **ib, unsigned size); 788 struct radeon_ib **ib, unsigned size);
776void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib); 789void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib **ib);
@@ -836,7 +849,9 @@ struct radeon_cs_parser {
836 int chunk_ib_idx; 849 int chunk_ib_idx;
837 int chunk_relocs_idx; 850 int chunk_relocs_idx;
838 int chunk_flags_idx; 851 int chunk_flags_idx;
852 int chunk_const_ib_idx;
839 struct radeon_ib *ib; 853 struct radeon_ib *ib;
854 struct radeon_ib *const_ib;
840 void *track; 855 void *track;
841 unsigned family; 856 unsigned family;
842 int parser_error; 857 int parser_error;
@@ -978,6 +993,7 @@ enum radeon_int_thermal_type {
978 THERMAL_TYPE_EVERGREEN, 993 THERMAL_TYPE_EVERGREEN,
979 THERMAL_TYPE_SUMO, 994 THERMAL_TYPE_SUMO,
980 THERMAL_TYPE_NI, 995 THERMAL_TYPE_NI,
996 THERMAL_TYPE_SI,
981}; 997};
982 998
983struct radeon_voltage { 999struct radeon_voltage {
@@ -1369,6 +1385,37 @@ struct cayman_asic {
1369 struct r100_gpu_lockup lockup; 1385 struct r100_gpu_lockup lockup;
1370}; 1386};
1371 1387
1388struct si_asic {
1389 unsigned max_shader_engines;
1390 unsigned max_pipes_per_simd;
1391 unsigned max_tile_pipes;
1392 unsigned max_simds_per_se;
1393 unsigned max_backends_per_se;
1394 unsigned max_texture_channel_caches;
1395 unsigned max_gprs;
1396 unsigned max_gs_threads;
1397 unsigned max_hw_contexts;
1398 unsigned sc_prim_fifo_size_frontend;
1399 unsigned sc_prim_fifo_size_backend;
1400 unsigned sc_hiz_tile_fifo_size;
1401 unsigned sc_earlyz_tile_fifo_size;
1402
1403 unsigned num_shader_engines;
1404 unsigned num_tile_pipes;
1405 unsigned num_backends_per_se;
1406 unsigned backend_disable_mask_per_asic;
1407 unsigned backend_map;
1408 unsigned num_texture_channel_caches;
1409 unsigned mem_max_burst_length_bytes;
1410 unsigned mem_row_size_in_kb;
1411 unsigned shader_engine_tile_size;
1412 unsigned num_gpus;
1413 unsigned multi_gpu_tile_size;
1414
1415 unsigned tile_config;
1416 struct r100_gpu_lockup lockup;
1417};
1418
1372union radeon_asic_config { 1419union radeon_asic_config {
1373 struct r300_asic r300; 1420 struct r300_asic r300;
1374 struct r100_asic r100; 1421 struct r100_asic r100;
@@ -1376,6 +1423,7 @@ union radeon_asic_config {
1376 struct rv770_asic rv770; 1423 struct rv770_asic rv770;
1377 struct evergreen_asic evergreen; 1424 struct evergreen_asic evergreen;
1378 struct cayman_asic cayman; 1425 struct cayman_asic cayman;
1426 struct si_asic si;
1379}; 1427};
1380 1428
1381/* 1429/*
@@ -1491,10 +1539,12 @@ struct radeon_device {
1491 const struct firmware *pfp_fw; /* r6/700 PFP firmware */ 1539 const struct firmware *pfp_fw; /* r6/700 PFP firmware */
1492 const struct firmware *rlc_fw; /* r6/700 RLC firmware */ 1540 const struct firmware *rlc_fw; /* r6/700 RLC firmware */
1493 const struct firmware *mc_fw; /* NI MC firmware */ 1541 const struct firmware *mc_fw; /* NI MC firmware */
1542 const struct firmware *ce_fw; /* SI CE firmware */
1494 struct r600_blit r600_blit; 1543 struct r600_blit r600_blit;
1495 struct r600_vram_scratch vram_scratch; 1544 struct r600_vram_scratch vram_scratch;
1496 int msi_enabled; /* msi enabled */ 1545 int msi_enabled; /* msi enabled */
1497 struct r600_ih ih; /* r6/700 interrupt ring */ 1546 struct r600_ih ih; /* r6/700 interrupt ring */
1547 struct si_rlc rlc;
1498 struct work_struct hotplug_work; 1548 struct work_struct hotplug_work;
1499 int num_crtc; /* number of crtcs */ 1549 int num_crtc; /* number of crtcs */
1500 struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */ 1550 struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
@@ -1638,6 +1688,9 @@ void r100_pll_errata_after_index(struct radeon_device *rdev);
1638#define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \ 1688#define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
1639 (rdev->flags & RADEON_IS_IGP)) 1689 (rdev->flags & RADEON_IS_IGP))
1640#define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS)) 1690#define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
1691#define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
1692#define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
1693 (rdev->flags & RADEON_IS_IGP))
1641 1694
1642/* 1695/*
1643 * BIOS helpers. 1696 * BIOS helpers.
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
index 479c89e0af17..be4dc2ff0e40 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -1408,6 +1408,200 @@ static struct radeon_asic cayman_asic = {
1408 }, 1408 },
1409}; 1409};
1410 1410
1411static struct radeon_asic trinity_asic = {
1412 .init = &cayman_init,
1413 .fini = &cayman_fini,
1414 .suspend = &cayman_suspend,
1415 .resume = &cayman_resume,
1416 .gpu_is_lockup = &cayman_gpu_is_lockup,
1417 .asic_reset = &cayman_asic_reset,
1418 .vga_set_state = &r600_vga_set_state,
1419 .ioctl_wait_idle = r600_ioctl_wait_idle,
1420 .gui_idle = &r600_gui_idle,
1421 .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
1422 .gart = {
1423 .tlb_flush = &cayman_pcie_gart_tlb_flush,
1424 .set_page = &rs600_gart_set_page,
1425 },
1426 .ring = {
1427 [RADEON_RING_TYPE_GFX_INDEX] = {
1428 .ib_execute = &cayman_ring_ib_execute,
1429 .ib_parse = &evergreen_ib_parse,
1430 .emit_fence = &cayman_fence_ring_emit,
1431 .emit_semaphore = &r600_semaphore_ring_emit,
1432 .cs_parse = &evergreen_cs_parse,
1433 .ring_test = &r600_ring_test,
1434 .ib_test = &r600_ib_test,
1435 },
1436 [CAYMAN_RING_TYPE_CP1_INDEX] = {
1437 .ib_execute = &cayman_ring_ib_execute,
1438 .ib_parse = &evergreen_ib_parse,
1439 .emit_fence = &cayman_fence_ring_emit,
1440 .emit_semaphore = &r600_semaphore_ring_emit,
1441 .cs_parse = &evergreen_cs_parse,
1442 .ring_test = &r600_ring_test,
1443 .ib_test = &r600_ib_test,
1444 },
1445 [CAYMAN_RING_TYPE_CP2_INDEX] = {
1446 .ib_execute = &cayman_ring_ib_execute,
1447 .ib_parse = &evergreen_ib_parse,
1448 .emit_fence = &cayman_fence_ring_emit,
1449 .emit_semaphore = &r600_semaphore_ring_emit,
1450 .cs_parse = &evergreen_cs_parse,
1451 .ring_test = &r600_ring_test,
1452 .ib_test = &r600_ib_test,
1453 }
1454 },
1455 .irq = {
1456 .set = &evergreen_irq_set,
1457 .process = &evergreen_irq_process,
1458 },
1459 .display = {
1460 .bandwidth_update = &dce6_bandwidth_update,
1461 .get_vblank_counter = &evergreen_get_vblank_counter,
1462 .wait_for_vblank = &dce4_wait_for_vblank,
1463 },
1464 .copy = {
1465 .blit = &r600_copy_blit,
1466 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1467 .dma = NULL,
1468 .dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1469 .copy = &r600_copy_blit,
1470 .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1471 },
1472 .surface = {
1473 .set_reg = r600_set_surface_reg,
1474 .clear_reg = r600_clear_surface_reg,
1475 },
1476 .hpd = {
1477 .init = &evergreen_hpd_init,
1478 .fini = &evergreen_hpd_fini,
1479 .sense = &evergreen_hpd_sense,
1480 .set_polarity = &evergreen_hpd_set_polarity,
1481 },
1482 .pm = {
1483 .misc = &evergreen_pm_misc,
1484 .prepare = &evergreen_pm_prepare,
1485 .finish = &evergreen_pm_finish,
1486 .init_profile = &sumo_pm_init_profile,
1487 .get_dynpm_state = &r600_pm_get_dynpm_state,
1488 .get_engine_clock = &radeon_atom_get_engine_clock,
1489 .set_engine_clock = &radeon_atom_set_engine_clock,
1490 .get_memory_clock = NULL,
1491 .set_memory_clock = NULL,
1492 .get_pcie_lanes = NULL,
1493 .set_pcie_lanes = NULL,
1494 .set_clock_gating = NULL,
1495 },
1496 .pflip = {
1497 .pre_page_flip = &evergreen_pre_page_flip,
1498 .page_flip = &evergreen_page_flip,
1499 .post_page_flip = &evergreen_post_page_flip,
1500 },
1501};
1502
1503static const struct radeon_vm_funcs si_vm_funcs = {
1504 .init = &si_vm_init,
1505 .fini = &si_vm_fini,
1506 .bind = &si_vm_bind,
1507 .unbind = &si_vm_unbind,
1508 .tlb_flush = &si_vm_tlb_flush,
1509 .page_flags = &cayman_vm_page_flags,
1510 .set_page = &cayman_vm_set_page,
1511};
1512
1513static struct radeon_asic si_asic = {
1514 .init = &si_init,
1515 .fini = &si_fini,
1516 .suspend = &si_suspend,
1517 .resume = &si_resume,
1518 .gpu_is_lockup = &si_gpu_is_lockup,
1519 .asic_reset = &si_asic_reset,
1520 .vga_set_state = &r600_vga_set_state,
1521 .ioctl_wait_idle = r600_ioctl_wait_idle,
1522 .gui_idle = &r600_gui_idle,
1523 .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
1524 .gart = {
1525 .tlb_flush = &si_pcie_gart_tlb_flush,
1526 .set_page = &rs600_gart_set_page,
1527 },
1528 .ring = {
1529 [RADEON_RING_TYPE_GFX_INDEX] = {
1530 .ib_execute = &si_ring_ib_execute,
1531 .ib_parse = &si_ib_parse,
1532 .emit_fence = &si_fence_ring_emit,
1533 .emit_semaphore = &r600_semaphore_ring_emit,
1534 .cs_parse = NULL,
1535 .ring_test = &r600_ring_test,
1536 .ib_test = &r600_ib_test,
1537 },
1538 [CAYMAN_RING_TYPE_CP1_INDEX] = {
1539 .ib_execute = &si_ring_ib_execute,
1540 .ib_parse = &si_ib_parse,
1541 .emit_fence = &si_fence_ring_emit,
1542 .emit_semaphore = &r600_semaphore_ring_emit,
1543 .cs_parse = NULL,
1544 .ring_test = &r600_ring_test,
1545 .ib_test = &r600_ib_test,
1546 },
1547 [CAYMAN_RING_TYPE_CP2_INDEX] = {
1548 .ib_execute = &si_ring_ib_execute,
1549 .ib_parse = &si_ib_parse,
1550 .emit_fence = &si_fence_ring_emit,
1551 .emit_semaphore = &r600_semaphore_ring_emit,
1552 .cs_parse = NULL,
1553 .ring_test = &r600_ring_test,
1554 .ib_test = &r600_ib_test,
1555 }
1556 },
1557 .irq = {
1558 .set = &si_irq_set,
1559 .process = &si_irq_process,
1560 },
1561 .display = {
1562 .bandwidth_update = &dce6_bandwidth_update,
1563 .get_vblank_counter = &evergreen_get_vblank_counter,
1564 .wait_for_vblank = &dce4_wait_for_vblank,
1565 },
1566 .copy = {
1567 .blit = NULL,
1568 .blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1569 .dma = NULL,
1570 .dma_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1571 .copy = NULL,
1572 .copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
1573 },
1574 .surface = {
1575 .set_reg = r600_set_surface_reg,
1576 .clear_reg = r600_clear_surface_reg,
1577 },
1578 .hpd = {
1579 .init = &evergreen_hpd_init,
1580 .fini = &evergreen_hpd_fini,
1581 .sense = &evergreen_hpd_sense,
1582 .set_polarity = &evergreen_hpd_set_polarity,
1583 },
1584 .pm = {
1585 .misc = &evergreen_pm_misc,
1586 .prepare = &evergreen_pm_prepare,
1587 .finish = &evergreen_pm_finish,
1588 .init_profile = &sumo_pm_init_profile,
1589 .get_dynpm_state = &r600_pm_get_dynpm_state,
1590 .get_engine_clock = &radeon_atom_get_engine_clock,
1591 .set_engine_clock = &radeon_atom_set_engine_clock,
1592 .get_memory_clock = &radeon_atom_get_memory_clock,
1593 .set_memory_clock = &radeon_atom_set_memory_clock,
1594 .get_pcie_lanes = NULL,
1595 .set_pcie_lanes = NULL,
1596 .set_clock_gating = NULL,
1597 },
1598 .pflip = {
1599 .pre_page_flip = &evergreen_pre_page_flip,
1600 .page_flip = &evergreen_page_flip,
1601 .post_page_flip = &evergreen_post_page_flip,
1602 },
1603};
1604
1411int radeon_asic_init(struct radeon_device *rdev) 1605int radeon_asic_init(struct radeon_device *rdev)
1412{ 1606{
1413 radeon_register_accessor_init(rdev); 1607 radeon_register_accessor_init(rdev);
@@ -1525,6 +1719,20 @@ int radeon_asic_init(struct radeon_device *rdev)
1525 rdev->num_crtc = 6; 1719 rdev->num_crtc = 6;
1526 rdev->vm_manager.funcs = &cayman_vm_funcs; 1720 rdev->vm_manager.funcs = &cayman_vm_funcs;
1527 break; 1721 break;
1722 case CHIP_ARUBA:
1723 rdev->asic = &trinity_asic;
1724 /* set num crtcs */
1725 rdev->num_crtc = 4;
1726 rdev->vm_manager.funcs = &cayman_vm_funcs;
1727 break;
1728 case CHIP_TAHITI:
1729 case CHIP_PITCAIRN:
1730 case CHIP_VERDE:
1731 rdev->asic = &si_asic;
1732 /* set num crtcs */
1733 rdev->num_crtc = 6;
1734 rdev->vm_manager.funcs = &si_vm_funcs;
1735 break;
1528 default: 1736 default:
1529 /* FIXME: not supported yet */ 1737 /* FIXME: not supported yet */
1530 return -EINVAL; 1738 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index b8f0a16bf65f..3d9f9f1d8f90 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -461,4 +461,29 @@ void cayman_vm_set_page(struct radeon_device *rdev, struct radeon_vm *vm,
461 unsigned pfn, uint64_t addr, uint32_t flags); 461 unsigned pfn, uint64_t addr, uint32_t flags);
462int evergreen_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib); 462int evergreen_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
463 463
464/* DCE6 - SI */
465void dce6_bandwidth_update(struct radeon_device *rdev);
466
467/*
468 * si
469 */
470void si_fence_ring_emit(struct radeon_device *rdev,
471 struct radeon_fence *fence);
472void si_pcie_gart_tlb_flush(struct radeon_device *rdev);
473int si_init(struct radeon_device *rdev);
474void si_fini(struct radeon_device *rdev);
475int si_suspend(struct radeon_device *rdev);
476int si_resume(struct radeon_device *rdev);
477bool si_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *cp);
478int si_asic_reset(struct radeon_device *rdev);
479void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
480int si_irq_set(struct radeon_device *rdev);
481int si_irq_process(struct radeon_device *rdev);
482int si_vm_init(struct radeon_device *rdev);
483void si_vm_fini(struct radeon_device *rdev);
484int si_vm_bind(struct radeon_device *rdev, struct radeon_vm *vm, int id);
485void si_vm_unbind(struct radeon_device *rdev, struct radeon_vm *vm);
486void si_vm_tlb_flush(struct radeon_device *rdev, struct radeon_vm *vm);
487int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
488
464#endif 489#endif
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 73541373bf56..f6e69b8c06c6 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -56,6 +56,10 @@ extern void
56radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum, 56radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum,
57 uint32_t supported_device); 57 uint32_t supported_device);
58 58
59/* local */
60static int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
61 u16 voltage_id, u16 *voltage);
62
59union atom_supported_devices { 63union atom_supported_devices {
60 struct _ATOM_SUPPORTED_DEVICES_INFO info; 64 struct _ATOM_SUPPORTED_DEVICES_INFO info;
61 struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; 65 struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
@@ -253,7 +257,9 @@ static struct radeon_hpd radeon_atom_get_hpd_info_from_gpio(struct radeon_device
253 257
254 memset(&hpd, 0, sizeof(struct radeon_hpd)); 258 memset(&hpd, 0, sizeof(struct radeon_hpd));
255 259
256 if (ASIC_IS_DCE4(rdev)) 260 if (ASIC_IS_DCE6(rdev))
261 reg = SI_DC_GPIO_HPD_A;
262 else if (ASIC_IS_DCE4(rdev))
257 reg = EVERGREEN_DC_GPIO_HPD_A; 263 reg = EVERGREEN_DC_GPIO_HPD_A;
258 else 264 else
259 reg = AVIVO_DC_GPIO_HPD_A; 265 reg = AVIVO_DC_GPIO_HPD_A;
@@ -1888,6 +1894,8 @@ static const char *pp_lib_thermal_controller_names[] = {
1888 "emc2103", 1894 "emc2103",
1889 "Sumo", 1895 "Sumo",
1890 "Northern Islands", 1896 "Northern Islands",
1897 "Southern Islands",
1898 "lm96163",
1891}; 1899};
1892 1900
1893union power_info { 1901union power_info {
@@ -1904,6 +1912,7 @@ union pplib_clock_info {
1904 struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780; 1912 struct _ATOM_PPLIB_RS780_CLOCK_INFO rs780;
1905 struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen; 1913 struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO evergreen;
1906 struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo; 1914 struct _ATOM_PPLIB_SUMO_CLOCK_INFO sumo;
1915 struct _ATOM_PPLIB_SI_CLOCK_INFO si;
1907}; 1916};
1908 1917
1909union pplib_power_state { 1918union pplib_power_state {
@@ -2161,6 +2170,11 @@ static void radeon_atombios_add_pplib_thermal_controller(struct radeon_device *r
2161 (controller->ucFanParameters & 2170 (controller->ucFanParameters &
2162 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); 2171 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
2163 rdev->pm.int_thermal_type = THERMAL_TYPE_NI; 2172 rdev->pm.int_thermal_type = THERMAL_TYPE_NI;
2173 } else if (controller->ucType == ATOM_PP_THERMALCONTROLLER_SISLANDS) {
2174 DRM_INFO("Internal thermal controller %s fan control\n",
2175 (controller->ucFanParameters &
2176 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
2177 rdev->pm.int_thermal_type = THERMAL_TYPE_SI;
2164 } else if ((controller->ucType == 2178 } else if ((controller->ucType ==
2165 ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) || 2179 ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) ||
2166 (controller->ucType == 2180 (controller->ucType ==
@@ -2281,6 +2295,7 @@ static bool radeon_atombios_parse_pplib_clock_info(struct radeon_device *rdev,
2281 union pplib_clock_info *clock_info) 2295 union pplib_clock_info *clock_info)
2282{ 2296{
2283 u32 sclk, mclk; 2297 u32 sclk, mclk;
2298 u16 vddc;
2284 2299
2285 if (rdev->flags & RADEON_IS_IGP) { 2300 if (rdev->flags & RADEON_IS_IGP) {
2286 if (rdev->family >= CHIP_PALM) { 2301 if (rdev->family >= CHIP_PALM) {
@@ -2292,6 +2307,19 @@ static bool radeon_atombios_parse_pplib_clock_info(struct radeon_device *rdev,
2292 sclk |= clock_info->rs780.ucLowEngineClockHigh << 16; 2307 sclk |= clock_info->rs780.ucLowEngineClockHigh << 16;
2293 rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; 2308 rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk;
2294 } 2309 }
2310 } else if (ASIC_IS_DCE6(rdev)) {
2311 sclk = le16_to_cpu(clock_info->si.usEngineClockLow);
2312 sclk |= clock_info->si.ucEngineClockHigh << 16;
2313 mclk = le16_to_cpu(clock_info->si.usMemoryClockLow);
2314 mclk |= clock_info->si.ucMemoryClockHigh << 16;
2315 rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk;
2316 rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk;
2317 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type =
2318 VOLTAGE_SW;
2319 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage =
2320 le16_to_cpu(clock_info->si.usVDDC);
2321 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.vddci =
2322 le16_to_cpu(clock_info->si.usVDDCI);
2295 } else if (ASIC_IS_DCE4(rdev)) { 2323 } else if (ASIC_IS_DCE4(rdev)) {
2296 sclk = le16_to_cpu(clock_info->evergreen.usEngineClockLow); 2324 sclk = le16_to_cpu(clock_info->evergreen.usEngineClockLow);
2297 sclk |= clock_info->evergreen.ucEngineClockHigh << 16; 2325 sclk |= clock_info->evergreen.ucEngineClockHigh << 16;
@@ -2319,11 +2347,18 @@ static bool radeon_atombios_parse_pplib_clock_info(struct radeon_device *rdev,
2319 } 2347 }
2320 2348
2321 /* patch up vddc if necessary */ 2349 /* patch up vddc if necessary */
2322 if (rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage == 0xff01) { 2350 switch (rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage) {
2323 u16 vddc; 2351 case ATOM_VIRTUAL_VOLTAGE_ID0:
2324 2352 case ATOM_VIRTUAL_VOLTAGE_ID1:
2325 if (radeon_atom_get_max_vddc(rdev, &vddc) == 0) 2353 case ATOM_VIRTUAL_VOLTAGE_ID2:
2354 case ATOM_VIRTUAL_VOLTAGE_ID3:
2355 if (radeon_atom_get_max_vddc(rdev, VOLTAGE_TYPE_VDDC,
2356 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage,
2357 &vddc) == 0)
2326 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = vddc; 2358 rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = vddc;
2359 break;
2360 default:
2361 break;
2327 } 2362 }
2328 2363
2329 if (rdev->flags & RADEON_IS_IGP) { 2364 if (rdev->flags & RADEON_IS_IGP) {
@@ -2433,9 +2468,9 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
2433 int i, j, non_clock_array_index, clock_array_index; 2468 int i, j, non_clock_array_index, clock_array_index;
2434 int state_index = 0, mode_index = 0; 2469 int state_index = 0, mode_index = 0;
2435 union pplib_clock_info *clock_info; 2470 union pplib_clock_info *clock_info;
2436 struct StateArray *state_array; 2471 struct _StateArray *state_array;
2437 struct ClockInfoArray *clock_info_array; 2472 struct _ClockInfoArray *clock_info_array;
2438 struct NonClockInfoArray *non_clock_info_array; 2473 struct _NonClockInfoArray *non_clock_info_array;
2439 bool valid; 2474 bool valid;
2440 union power_info *power_info; 2475 union power_info *power_info;
2441 int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo); 2476 int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
@@ -2448,13 +2483,13 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
2448 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); 2483 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
2449 2484
2450 radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController); 2485 radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController);
2451 state_array = (struct StateArray *) 2486 state_array = (struct _StateArray *)
2452 (mode_info->atom_context->bios + data_offset + 2487 (mode_info->atom_context->bios + data_offset +
2453 le16_to_cpu(power_info->pplib.usStateArrayOffset)); 2488 le16_to_cpu(power_info->pplib.usStateArrayOffset));
2454 clock_info_array = (struct ClockInfoArray *) 2489 clock_info_array = (struct _ClockInfoArray *)
2455 (mode_info->atom_context->bios + data_offset + 2490 (mode_info->atom_context->bios + data_offset +
2456 le16_to_cpu(power_info->pplib.usClockInfoArrayOffset)); 2491 le16_to_cpu(power_info->pplib.usClockInfoArrayOffset));
2457 non_clock_info_array = (struct NonClockInfoArray *) 2492 non_clock_info_array = (struct _NonClockInfoArray *)
2458 (mode_info->atom_context->bios + data_offset + 2493 (mode_info->atom_context->bios + data_offset +
2459 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); 2494 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
2460 rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2495 rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
@@ -2481,7 +2516,7 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
2481 if (clock_array_index >= clock_info_array->ucNumEntries) 2516 if (clock_array_index >= clock_info_array->ucNumEntries)
2482 continue; 2517 continue;
2483 clock_info = (union pplib_clock_info *) 2518 clock_info = (union pplib_clock_info *)
2484 &clock_info_array->clockInfo[clock_array_index]; 2519 &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
2485 valid = radeon_atombios_parse_pplib_clock_info(rdev, 2520 valid = radeon_atombios_parse_pplib_clock_info(rdev,
2486 state_index, mode_index, 2521 state_index, mode_index,
2487 clock_info); 2522 clock_info);
@@ -2638,6 +2673,7 @@ union set_voltage {
2638 struct _SET_VOLTAGE_PS_ALLOCATION alloc; 2673 struct _SET_VOLTAGE_PS_ALLOCATION alloc;
2639 struct _SET_VOLTAGE_PARAMETERS v1; 2674 struct _SET_VOLTAGE_PARAMETERS v1;
2640 struct _SET_VOLTAGE_PARAMETERS_V2 v2; 2675 struct _SET_VOLTAGE_PARAMETERS_V2 v2;
2676 struct _SET_VOLTAGE_PARAMETERS_V1_3 v3;
2641}; 2677};
2642 2678
2643void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type) 2679void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type)
@@ -2664,6 +2700,11 @@ void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 v
2664 args.v2.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_SET_VOLTAGE; 2700 args.v2.ucVoltageMode = SET_ASIC_VOLTAGE_MODE_SET_VOLTAGE;
2665 args.v2.usVoltageLevel = cpu_to_le16(voltage_level); 2701 args.v2.usVoltageLevel = cpu_to_le16(voltage_level);
2666 break; 2702 break;
2703 case 3:
2704 args.v3.ucVoltageType = voltage_type;
2705 args.v3.ucVoltageMode = ATOM_SET_VOLTAGE;
2706 args.v3.usVoltageLevel = cpu_to_le16(voltage_level);
2707 break;
2667 default: 2708 default:
2668 DRM_ERROR("Unknown table version %d, %d\n", frev, crev); 2709 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
2669 return; 2710 return;
@@ -2672,8 +2713,8 @@ void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 v
2672 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 2713 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2673} 2714}
2674 2715
2675int radeon_atom_get_max_vddc(struct radeon_device *rdev, 2716static int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
2676 u16 *voltage) 2717 u16 voltage_id, u16 *voltage)
2677{ 2718{
2678 union set_voltage args; 2719 union set_voltage args;
2679 int index = GetIndexIntoMasterTable(COMMAND, SetVoltage); 2720 int index = GetIndexIntoMasterTable(COMMAND, SetVoltage);
@@ -2694,6 +2735,15 @@ int radeon_atom_get_max_vddc(struct radeon_device *rdev,
2694 2735
2695 *voltage = le16_to_cpu(args.v2.usVoltageLevel); 2736 *voltage = le16_to_cpu(args.v2.usVoltageLevel);
2696 break; 2737 break;
2738 case 3:
2739 args.v3.ucVoltageType = voltage_type;
2740 args.v3.ucVoltageMode = ATOM_GET_VOLTAGE_LEVEL;
2741 args.v3.usVoltageLevel = cpu_to_le16(voltage_id);
2742
2743 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
2744
2745 *voltage = le16_to_cpu(args.v3.usVoltageLevel);
2746 break;
2697 default: 2747 default:
2698 DRM_ERROR("Unknown table version %d, %d\n", frev, crev); 2748 DRM_ERROR("Unknown table version %d, %d\n", frev, crev);
2699 return -EINVAL; 2749 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 64774ac94449..bd05156edbdb 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1085,7 +1085,7 @@ static int radeon_dvi_mode_valid(struct drm_connector *connector,
1085 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) 1085 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B))
1086 return MODE_OK; 1086 return MODE_OK;
1087 else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) { 1087 else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) {
1088 if (0) { 1088 if (ASIC_IS_DCE6(rdev)) {
1089 /* HDMI 1.3+ supports max clock of 340 Mhz */ 1089 /* HDMI 1.3+ supports max clock of 340 Mhz */
1090 if (mode->clock > 340000) 1090 if (mode->clock > 340000)
1091 return MODE_CLOCK_HIGH; 1091 return MODE_CLOCK_HIGH;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index d9d9f5a59c42..5cac83278338 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -103,8 +103,13 @@ static int radeon_cs_get_ring(struct radeon_cs_parser *p, u32 ring, s32 priority
103 p->ring = RADEON_RING_TYPE_GFX_INDEX; 103 p->ring = RADEON_RING_TYPE_GFX_INDEX;
104 break; 104 break;
105 case RADEON_CS_RING_COMPUTE: 105 case RADEON_CS_RING_COMPUTE:
106 /* for now */ 106 if (p->rdev->family >= CHIP_TAHITI) {
107 p->ring = RADEON_RING_TYPE_GFX_INDEX; 107 if (p->priority > 0)
108 p->ring = CAYMAN_RING_TYPE_CP1_INDEX;
109 else
110 p->ring = CAYMAN_RING_TYPE_CP2_INDEX;
111 } else
112 p->ring = RADEON_RING_TYPE_GFX_INDEX;
108 break; 113 break;
109 } 114 }
110 return 0; 115 return 0;
@@ -170,6 +175,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
170 p->chunk_ib_idx = -1; 175 p->chunk_ib_idx = -1;
171 p->chunk_relocs_idx = -1; 176 p->chunk_relocs_idx = -1;
172 p->chunk_flags_idx = -1; 177 p->chunk_flags_idx = -1;
178 p->chunk_const_ib_idx = -1;
173 p->chunks_array = kcalloc(cs->num_chunks, sizeof(uint64_t), GFP_KERNEL); 179 p->chunks_array = kcalloc(cs->num_chunks, sizeof(uint64_t), GFP_KERNEL);
174 if (p->chunks_array == NULL) { 180 if (p->chunks_array == NULL) {
175 return -ENOMEM; 181 return -ENOMEM;
@@ -208,6 +214,12 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
208 if (p->chunks[i].length_dw == 0) 214 if (p->chunks[i].length_dw == 0)
209 return -EINVAL; 215 return -EINVAL;
210 } 216 }
217 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_CONST_IB) {
218 p->chunk_const_ib_idx = i;
219 /* zero length CONST IB isn't useful */
220 if (p->chunks[i].length_dw == 0)
221 return -EINVAL;
222 }
211 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) { 223 if (p->chunks[i].chunk_id == RADEON_CHUNK_ID_FLAGS) {
212 p->chunk_flags_idx = i; 224 p->chunk_flags_idx = i;
213 /* zero length flags aren't useful */ 225 /* zero length flags aren't useful */
@@ -246,6 +258,13 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
246 return -EINVAL; 258 return -EINVAL;
247 } 259 }
248 260
261 /* we only support VM on SI+ */
262 if ((p->rdev->family >= CHIP_TAHITI) &&
263 ((p->cs_flags & RADEON_CS_USE_VM) == 0)) {
264 DRM_ERROR("VM required on SI+!\n");
265 return -EINVAL;
266 }
267
249 if (radeon_cs_get_ring(p, ring, priority)) 268 if (radeon_cs_get_ring(p, ring, priority))
250 return -EINVAL; 269 return -EINVAL;
251 270
@@ -389,6 +408,32 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
389 if ((parser->cs_flags & RADEON_CS_USE_VM) == 0) 408 if ((parser->cs_flags & RADEON_CS_USE_VM) == 0)
390 return 0; 409 return 0;
391 410
411 if ((rdev->family >= CHIP_TAHITI) &&
412 (parser->chunk_const_ib_idx != -1)) {
413 ib_chunk = &parser->chunks[parser->chunk_const_ib_idx];
414 if (ib_chunk->length_dw > RADEON_IB_VM_MAX_SIZE) {
415 DRM_ERROR("cs IB CONST too big: %d\n", ib_chunk->length_dw);
416 return -EINVAL;
417 }
418 r = radeon_ib_get(rdev, parser->ring, &parser->const_ib,
419 ib_chunk->length_dw * 4);
420 if (r) {
421 DRM_ERROR("Failed to get const ib !\n");
422 return r;
423 }
424 parser->const_ib->is_const_ib = true;
425 parser->const_ib->length_dw = ib_chunk->length_dw;
426 /* Copy the packet into the IB */
427 if (DRM_COPY_FROM_USER(parser->const_ib->ptr, ib_chunk->user_ptr,
428 ib_chunk->length_dw * 4)) {
429 return -EFAULT;
430 }
431 r = radeon_ring_ib_parse(rdev, parser->ring, parser->const_ib);
432 if (r) {
433 return r;
434 }
435 }
436
392 ib_chunk = &parser->chunks[parser->chunk_ib_idx]; 437 ib_chunk = &parser->chunks[parser->chunk_ib_idx];
393 if (ib_chunk->length_dw > RADEON_IB_VM_MAX_SIZE) { 438 if (ib_chunk->length_dw > RADEON_IB_VM_MAX_SIZE) {
394 DRM_ERROR("cs IB too big: %d\n", ib_chunk->length_dw); 439 DRM_ERROR("cs IB too big: %d\n", ib_chunk->length_dw);
@@ -424,11 +469,25 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
424 if (r) { 469 if (r) {
425 DRM_ERROR("Failed to synchronize rings !\n"); 470 DRM_ERROR("Failed to synchronize rings !\n");
426 } 471 }
472
473 if ((rdev->family >= CHIP_TAHITI) &&
474 (parser->chunk_const_ib_idx != -1)) {
475 parser->const_ib->vm_id = vm->id;
476 /* ib pool is bind at 0 in virtual address space to gpu_addr is the
477 * offset inside the pool bo
478 */
479 parser->const_ib->gpu_addr = parser->const_ib->sa_bo.offset;
480 r = radeon_ib_schedule(rdev, parser->const_ib);
481 if (r)
482 goto out;
483 }
484
427 parser->ib->vm_id = vm->id; 485 parser->ib->vm_id = vm->id;
428 /* ib pool is bind at 0 in virtual address space to gpu_addr is the 486 /* ib pool is bind at 0 in virtual address space to gpu_addr is the
429 * offset inside the pool bo 487 * offset inside the pool bo
430 */ 488 */
431 parser->ib->gpu_addr = parser->ib->sa_bo.offset; 489 parser->ib->gpu_addr = parser->ib->sa_bo.offset;
490 parser->ib->is_const_ib = false;
432 r = radeon_ib_schedule(rdev, parser->ib); 491 r = radeon_ib_schedule(rdev, parser->ib);
433out: 492out:
434 if (!r) { 493 if (!r) {
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 49f7cb7e226b..ea7df16e2f84 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -89,6 +89,10 @@ static const char radeon_family_name[][16] = {
89 "TURKS", 89 "TURKS",
90 "CAICOS", 90 "CAICOS",
91 "CAYMAN", 91 "CAYMAN",
92 "ARUBA",
93 "TAHITI",
94 "PITCAIRN",
95 "VERDE",
92 "LAST", 96 "LAST",
93}; 97};
94 98
@@ -964,7 +968,7 @@ int radeon_resume_kms(struct drm_device *dev)
964 /* init dig PHYs, disp eng pll */ 968 /* init dig PHYs, disp eng pll */
965 if (rdev->is_atom_bios) { 969 if (rdev->is_atom_bios) {
966 radeon_atom_encoder_init(rdev); 970 radeon_atom_encoder_init(rdev);
967 radeon_atom_dcpll_init(rdev); 971 radeon_atom_disp_eng_pll_init(rdev);
968 } 972 }
969 /* reset hpd state */ 973 /* reset hpd state */
970 radeon_hpd_init(rdev); 974 radeon_hpd_init(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 1ebcef25b915..8086c96e0b06 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1296,7 +1296,7 @@ int radeon_modeset_init(struct radeon_device *rdev)
1296 /* init dig PHYs, disp eng pll */ 1296 /* init dig PHYs, disp eng pll */
1297 if (rdev->is_atom_bios) { 1297 if (rdev->is_atom_bios) {
1298 radeon_atom_encoder_init(rdev); 1298 radeon_atom_encoder_init(rdev);
1299 radeon_atom_dcpll_init(rdev); 1299 radeon_atom_disp_eng_pll_init(rdev);
1300 } 1300 }
1301 1301
1302 /* initialize hpd */ 1302 /* initialize hpd */
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 498d21d50ba3..ef7bb3f6ecae 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -56,9 +56,10 @@
56 * 2.12.0 - RADEON_CS_KEEP_TILING_FLAGS 56 * 2.12.0 - RADEON_CS_KEEP_TILING_FLAGS
57 * 2.13.0 - virtual memory support, streamout 57 * 2.13.0 - virtual memory support, streamout
58 * 2.14.0 - add evergreen tiling informations 58 * 2.14.0 - add evergreen tiling informations
59 * 2.15.0 - add max_pipes query
59 */ 60 */
60#define KMS_DRIVER_MAJOR 2 61#define KMS_DRIVER_MAJOR 2
61#define KMS_DRIVER_MINOR 14 62#define KMS_DRIVER_MINOR 15
62#define KMS_DRIVER_PATCHLEVEL 0 63#define KMS_DRIVER_PATCHLEVEL 0
63int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); 64int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
64int radeon_driver_unload_kms(struct drm_device *dev); 65int radeon_driver_unload_kms(struct drm_device *dev);
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 26e92708d114..74670696277d 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -307,6 +307,8 @@ void radeon_panel_mode_fixup(struct drm_encoder *encoder,
307bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder, 307bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,
308 u32 pixel_clock) 308 u32 pixel_clock)
309{ 309{
310 struct drm_device *dev = encoder->dev;
311 struct radeon_device *rdev = dev->dev_private;
310 struct drm_connector *connector; 312 struct drm_connector *connector;
311 struct radeon_connector *radeon_connector; 313 struct radeon_connector *radeon_connector;
312 struct radeon_connector_atom_dig *dig_connector; 314 struct radeon_connector_atom_dig *dig_connector;
@@ -324,7 +326,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,
324 case DRM_MODE_CONNECTOR_HDMIB: 326 case DRM_MODE_CONNECTOR_HDMIB:
325 if (radeon_connector->use_digital) { 327 if (radeon_connector->use_digital) {
326 /* HDMI 1.3 supports up to 340 Mhz over single link */ 328 /* HDMI 1.3 supports up to 340 Mhz over single link */
327 if (0 && drm_detect_hdmi_monitor(radeon_connector->edid)) { 329 if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
328 if (pixel_clock > 340000) 330 if (pixel_clock > 340000)
329 return true; 331 return true;
330 else 332 else
@@ -346,7 +348,7 @@ bool radeon_dig_monitor_is_duallink(struct drm_encoder *encoder,
346 return false; 348 return false;
347 else { 349 else {
348 /* HDMI 1.3 supports up to 340 Mhz over single link */ 350 /* HDMI 1.3 supports up to 340 Mhz over single link */
349 if (0 && drm_detect_hdmi_monitor(radeon_connector->edid)) { 351 if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
350 if (pixel_clock > 340000) 352 if (pixel_clock > 340000)
351 return true; 353 return true;
352 else 354 else
diff --git a/drivers/gpu/drm/radeon/radeon_family.h b/drivers/gpu/drm/radeon/radeon_family.h
index ec2f1ea84f81..d1fafeabea09 100644
--- a/drivers/gpu/drm/radeon/radeon_family.h
+++ b/drivers/gpu/drm/radeon/radeon_family.h
@@ -87,6 +87,10 @@ enum radeon_family {
87 CHIP_TURKS, 87 CHIP_TURKS,
88 CHIP_CAICOS, 88 CHIP_CAICOS,
89 CHIP_CAYMAN, 89 CHIP_CAYMAN,
90 CHIP_ARUBA,
91 CHIP_TAHITI,
92 CHIP_PITCAIRN,
93 CHIP_VERDE,
90 CHIP_LAST, 94 CHIP_LAST,
91}; 95};
92 96
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 1986ebae1ef2..3c2628b14d56 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -171,7 +171,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
171 value = rdev->accel_working; 171 value = rdev->accel_working;
172 break; 172 break;
173 case RADEON_INFO_TILING_CONFIG: 173 case RADEON_INFO_TILING_CONFIG:
174 if (rdev->family >= CHIP_CAYMAN) 174 if (rdev->family >= CHIP_TAHITI)
175 value = rdev->config.si.tile_config;
176 else if (rdev->family >= CHIP_CAYMAN)
175 value = rdev->config.cayman.tile_config; 177 value = rdev->config.cayman.tile_config;
176 else if (rdev->family >= CHIP_CEDAR) 178 else if (rdev->family >= CHIP_CEDAR)
177 value = rdev->config.evergreen.tile_config; 179 value = rdev->config.evergreen.tile_config;
@@ -210,7 +212,10 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
210 value = rdev->clock.spll.reference_freq * 10; 212 value = rdev->clock.spll.reference_freq * 10;
211 break; 213 break;
212 case RADEON_INFO_NUM_BACKENDS: 214 case RADEON_INFO_NUM_BACKENDS:
213 if (rdev->family >= CHIP_CAYMAN) 215 if (rdev->family >= CHIP_TAHITI)
216 value = rdev->config.si.max_backends_per_se *
217 rdev->config.si.max_shader_engines;
218 else if (rdev->family >= CHIP_CAYMAN)
214 value = rdev->config.cayman.max_backends_per_se * 219 value = rdev->config.cayman.max_backends_per_se *
215 rdev->config.cayman.max_shader_engines; 220 rdev->config.cayman.max_shader_engines;
216 else if (rdev->family >= CHIP_CEDAR) 221 else if (rdev->family >= CHIP_CEDAR)
@@ -224,7 +229,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
224 } 229 }
225 break; 230 break;
226 case RADEON_INFO_NUM_TILE_PIPES: 231 case RADEON_INFO_NUM_TILE_PIPES:
227 if (rdev->family >= CHIP_CAYMAN) 232 if (rdev->family >= CHIP_TAHITI)
233 value = rdev->config.si.max_tile_pipes;
234 else if (rdev->family >= CHIP_CAYMAN)
228 value = rdev->config.cayman.max_tile_pipes; 235 value = rdev->config.cayman.max_tile_pipes;
229 else if (rdev->family >= CHIP_CEDAR) 236 else if (rdev->family >= CHIP_CEDAR)
230 value = rdev->config.evergreen.max_tile_pipes; 237 value = rdev->config.evergreen.max_tile_pipes;
@@ -240,7 +247,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
240 value = 1; 247 value = 1;
241 break; 248 break;
242 case RADEON_INFO_BACKEND_MAP: 249 case RADEON_INFO_BACKEND_MAP:
243 if (rdev->family >= CHIP_CAYMAN) 250 if (rdev->family >= CHIP_TAHITI)
251 value = rdev->config.si.backend_map;
252 else if (rdev->family >= CHIP_CAYMAN)
244 value = rdev->config.cayman.backend_map; 253 value = rdev->config.cayman.backend_map;
245 else if (rdev->family >= CHIP_CEDAR) 254 else if (rdev->family >= CHIP_CEDAR)
246 value = rdev->config.evergreen.backend_map; 255 value = rdev->config.evergreen.backend_map;
@@ -264,6 +273,21 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
264 return -EINVAL; 273 return -EINVAL;
265 value = RADEON_IB_VM_MAX_SIZE; 274 value = RADEON_IB_VM_MAX_SIZE;
266 break; 275 break;
276 case RADEON_INFO_MAX_PIPES:
277 if (rdev->family >= CHIP_TAHITI)
278 value = rdev->config.si.max_pipes_per_simd;
279 else if (rdev->family >= CHIP_CAYMAN)
280 value = rdev->config.cayman.max_pipes_per_simd;
281 else if (rdev->family >= CHIP_CEDAR)
282 value = rdev->config.evergreen.max_pipes;
283 else if (rdev->family >= CHIP_RV770)
284 value = rdev->config.rv770.max_pipes;
285 else if (rdev->family >= CHIP_R600)
286 value = rdev->config.r600.max_pipes;
287 else {
288 return -EINVAL;
289 }
290 break;
267 default: 291 default:
268 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 292 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
269 return -EINVAL; 293 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 8a85598fb242..f7eb5d8b9fd3 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -491,7 +491,7 @@ extern int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
491 struct drm_connector *connector); 491 struct drm_connector *connector);
492extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode); 492extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode);
493extern void radeon_atom_encoder_init(struct radeon_device *rdev); 493extern void radeon_atom_encoder_init(struct radeon_device *rdev);
494extern void radeon_atom_dcpll_init(struct radeon_device *rdev); 494extern void radeon_atom_disp_eng_pll_init(struct radeon_device *rdev);
495extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder, 495extern void atombios_dig_transmitter_setup(struct drm_encoder *encoder,
496 int action, uint8_t lane_num, 496 int action, uint8_t lane_num,
497 uint8_t lane_set); 497 uint8_t lane_set);
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 3575129c1940..caa55d68f319 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -474,6 +474,9 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev,
474 case THERMAL_TYPE_SUMO: 474 case THERMAL_TYPE_SUMO:
475 temp = sumo_get_temp(rdev); 475 temp = sumo_get_temp(rdev);
476 break; 476 break;
477 case THERMAL_TYPE_SI:
478 temp = si_get_temp(rdev);
479 break;
477 default: 480 default:
478 temp = 0; 481 temp = 0;
479 break; 482 break;
@@ -514,6 +517,10 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
514 case THERMAL_TYPE_EVERGREEN: 517 case THERMAL_TYPE_EVERGREEN:
515 case THERMAL_TYPE_NI: 518 case THERMAL_TYPE_NI:
516 case THERMAL_TYPE_SUMO: 519 case THERMAL_TYPE_SUMO:
520 case THERMAL_TYPE_SI:
521 /* No support for TN yet */
522 if (rdev->family == CHIP_ARUBA)
523 return err;
517 rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); 524 rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev);
518 if (IS_ERR(rdev->pm.int_hwmon_dev)) { 525 if (IS_ERR(rdev->pm.int_hwmon_dev)) {
519 err = PTR_ERR(rdev->pm.int_hwmon_dev); 526 err = PTR_ERR(rdev->pm.int_hwmon_dev);
diff --git a/drivers/gpu/drm/radeon/radeon_reg.h b/drivers/gpu/drm/radeon/radeon_reg.h
index 509863411285..5d8f735d6aaf 100644
--- a/drivers/gpu/drm/radeon/radeon_reg.h
+++ b/drivers/gpu/drm/radeon/radeon_reg.h
@@ -56,6 +56,7 @@
56#include "r600_reg.h" 56#include "r600_reg.h"
57#include "evergreen_reg.h" 57#include "evergreen_reg.h"
58#include "ni_reg.h" 58#include "ni_reg.h"
59#include "si_reg.h"
59 60
60#define RADEON_MC_AGP_LOCATION 0x014c 61#define RADEON_MC_AGP_LOCATION 0x014c
61#define RADEON_MC_AGP_START_MASK 0x0000FFFF 62#define RADEON_MC_AGP_START_MASK 0x0000FFFF
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 30566201dffb..cc33b3d7c33b 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -133,6 +133,7 @@ retry:
133 (*ib)->gpu_addr += (*ib)->sa_bo.offset; 133 (*ib)->gpu_addr += (*ib)->sa_bo.offset;
134 (*ib)->fence = fence; 134 (*ib)->fence = fence;
135 (*ib)->vm_id = 0; 135 (*ib)->vm_id = 0;
136 (*ib)->is_const_ib = false;
136 /* ib are most likely to be allocated in a ring fashion 137 /* ib are most likely to be allocated in a ring fashion
137 * thus rdev->ib_pool.head_id should be the id of the 138 * thus rdev->ib_pool.head_id should be the id of the
138 * oldest ib 139 * oldest ib
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
new file mode 100644
index 000000000000..ac7a199ffece
--- /dev/null
+++ b/drivers/gpu/drm/radeon/si.c
@@ -0,0 +1,4128 @@
1/*
2 * Copyright 2011 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Alex Deucher
23 */
24#include <linux/firmware.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h>
27#include <linux/module.h>
28#include "drmP.h"
29#include "radeon.h"
30#include "radeon_asic.h"
31#include "radeon_drm.h"
32#include "sid.h"
33#include "atom.h"
34#include "si_blit_shaders.h"
35
36#define SI_PFP_UCODE_SIZE 2144
37#define SI_PM4_UCODE_SIZE 2144
38#define SI_CE_UCODE_SIZE 2144
39#define SI_RLC_UCODE_SIZE 2048
40#define SI_MC_UCODE_SIZE 7769
41
42MODULE_FIRMWARE("radeon/TAHITI_pfp.bin");
43MODULE_FIRMWARE("radeon/TAHITI_me.bin");
44MODULE_FIRMWARE("radeon/TAHITI_ce.bin");
45MODULE_FIRMWARE("radeon/TAHITI_mc.bin");
46MODULE_FIRMWARE("radeon/TAHITI_rlc.bin");
47MODULE_FIRMWARE("radeon/PITCAIRN_pfp.bin");
48MODULE_FIRMWARE("radeon/PITCAIRN_me.bin");
49MODULE_FIRMWARE("radeon/PITCAIRN_ce.bin");
50MODULE_FIRMWARE("radeon/PITCAIRN_mc.bin");
51MODULE_FIRMWARE("radeon/PITCAIRN_rlc.bin");
52MODULE_FIRMWARE("radeon/VERDE_pfp.bin");
53MODULE_FIRMWARE("radeon/VERDE_me.bin");
54MODULE_FIRMWARE("radeon/VERDE_ce.bin");
55MODULE_FIRMWARE("radeon/VERDE_mc.bin");
56MODULE_FIRMWARE("radeon/VERDE_rlc.bin");
57
58extern int r600_ih_ring_alloc(struct radeon_device *rdev);
59extern void r600_ih_ring_fini(struct radeon_device *rdev);
60extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
61extern void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save);
62extern void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save);
63extern u32 evergreen_get_number_of_dram_channels(struct radeon_device *rdev);
64
65/* get temperature in millidegrees */
66int si_get_temp(struct radeon_device *rdev)
67{
68 u32 temp;
69 int actual_temp = 0;
70
71 temp = (RREG32(CG_MULT_THERMAL_STATUS) & CTF_TEMP_MASK) >>
72 CTF_TEMP_SHIFT;
73
74 if (temp & 0x200)
75 actual_temp = 255;
76 else
77 actual_temp = temp & 0x1ff;
78
79 actual_temp = (actual_temp * 1000);
80
81 return actual_temp;
82}
83
84#define TAHITI_IO_MC_REGS_SIZE 36
85
86static const u32 tahiti_io_mc_regs[TAHITI_IO_MC_REGS_SIZE][2] = {
87 {0x0000006f, 0x03044000},
88 {0x00000070, 0x0480c018},
89 {0x00000071, 0x00000040},
90 {0x00000072, 0x01000000},
91 {0x00000074, 0x000000ff},
92 {0x00000075, 0x00143400},
93 {0x00000076, 0x08ec0800},
94 {0x00000077, 0x040000cc},
95 {0x00000079, 0x00000000},
96 {0x0000007a, 0x21000409},
97 {0x0000007c, 0x00000000},
98 {0x0000007d, 0xe8000000},
99 {0x0000007e, 0x044408a8},
100 {0x0000007f, 0x00000003},
101 {0x00000080, 0x00000000},
102 {0x00000081, 0x01000000},
103 {0x00000082, 0x02000000},
104 {0x00000083, 0x00000000},
105 {0x00000084, 0xe3f3e4f4},
106 {0x00000085, 0x00052024},
107 {0x00000087, 0x00000000},
108 {0x00000088, 0x66036603},
109 {0x00000089, 0x01000000},
110 {0x0000008b, 0x1c0a0000},
111 {0x0000008c, 0xff010000},
112 {0x0000008e, 0xffffefff},
113 {0x0000008f, 0xfff3efff},
114 {0x00000090, 0xfff3efbf},
115 {0x00000094, 0x00101101},
116 {0x00000095, 0x00000fff},
117 {0x00000096, 0x00116fff},
118 {0x00000097, 0x60010000},
119 {0x00000098, 0x10010000},
120 {0x00000099, 0x00006000},
121 {0x0000009a, 0x00001000},
122 {0x0000009f, 0x00a77400}
123};
124
125static const u32 pitcairn_io_mc_regs[TAHITI_IO_MC_REGS_SIZE][2] = {
126 {0x0000006f, 0x03044000},
127 {0x00000070, 0x0480c018},
128 {0x00000071, 0x00000040},
129 {0x00000072, 0x01000000},
130 {0x00000074, 0x000000ff},
131 {0x00000075, 0x00143400},
132 {0x00000076, 0x08ec0800},
133 {0x00000077, 0x040000cc},
134 {0x00000079, 0x00000000},
135 {0x0000007a, 0x21000409},
136 {0x0000007c, 0x00000000},
137 {0x0000007d, 0xe8000000},
138 {0x0000007e, 0x044408a8},
139 {0x0000007f, 0x00000003},
140 {0x00000080, 0x00000000},
141 {0x00000081, 0x01000000},
142 {0x00000082, 0x02000000},
143 {0x00000083, 0x00000000},
144 {0x00000084, 0xe3f3e4f4},
145 {0x00000085, 0x00052024},
146 {0x00000087, 0x00000000},
147 {0x00000088, 0x66036603},
148 {0x00000089, 0x01000000},
149 {0x0000008b, 0x1c0a0000},
150 {0x0000008c, 0xff010000},
151 {0x0000008e, 0xffffefff},
152 {0x0000008f, 0xfff3efff},
153 {0x00000090, 0xfff3efbf},
154 {0x00000094, 0x00101101},
155 {0x00000095, 0x00000fff},
156 {0x00000096, 0x00116fff},
157 {0x00000097, 0x60010000},
158 {0x00000098, 0x10010000},
159 {0x00000099, 0x00006000},
160 {0x0000009a, 0x00001000},
161 {0x0000009f, 0x00a47400}
162};
163
164static const u32 verde_io_mc_regs[TAHITI_IO_MC_REGS_SIZE][2] = {
165 {0x0000006f, 0x03044000},
166 {0x00000070, 0x0480c018},
167 {0x00000071, 0x00000040},
168 {0x00000072, 0x01000000},
169 {0x00000074, 0x000000ff},
170 {0x00000075, 0x00143400},
171 {0x00000076, 0x08ec0800},
172 {0x00000077, 0x040000cc},
173 {0x00000079, 0x00000000},
174 {0x0000007a, 0x21000409},
175 {0x0000007c, 0x00000000},
176 {0x0000007d, 0xe8000000},
177 {0x0000007e, 0x044408a8},
178 {0x0000007f, 0x00000003},
179 {0x00000080, 0x00000000},
180 {0x00000081, 0x01000000},
181 {0x00000082, 0x02000000},
182 {0x00000083, 0x00000000},
183 {0x00000084, 0xe3f3e4f4},
184 {0x00000085, 0x00052024},
185 {0x00000087, 0x00000000},
186 {0x00000088, 0x66036603},
187 {0x00000089, 0x01000000},
188 {0x0000008b, 0x1c0a0000},
189 {0x0000008c, 0xff010000},
190 {0x0000008e, 0xffffefff},
191 {0x0000008f, 0xfff3efff},
192 {0x00000090, 0xfff3efbf},
193 {0x00000094, 0x00101101},
194 {0x00000095, 0x00000fff},
195 {0x00000096, 0x00116fff},
196 {0x00000097, 0x60010000},
197 {0x00000098, 0x10010000},
198 {0x00000099, 0x00006000},
199 {0x0000009a, 0x00001000},
200 {0x0000009f, 0x00a37400}
201};
202
203/* ucode loading */
204static int si_mc_load_microcode(struct radeon_device *rdev)
205{
206 const __be32 *fw_data;
207 u32 running, blackout = 0;
208 u32 *io_mc_regs;
209 int i, ucode_size, regs_size;
210
211 if (!rdev->mc_fw)
212 return -EINVAL;
213
214 switch (rdev->family) {
215 case CHIP_TAHITI:
216 io_mc_regs = (u32 *)&tahiti_io_mc_regs;
217 ucode_size = SI_MC_UCODE_SIZE;
218 regs_size = TAHITI_IO_MC_REGS_SIZE;
219 break;
220 case CHIP_PITCAIRN:
221 io_mc_regs = (u32 *)&pitcairn_io_mc_regs;
222 ucode_size = SI_MC_UCODE_SIZE;
223 regs_size = TAHITI_IO_MC_REGS_SIZE;
224 break;
225 case CHIP_VERDE:
226 default:
227 io_mc_regs = (u32 *)&verde_io_mc_regs;
228 ucode_size = SI_MC_UCODE_SIZE;
229 regs_size = TAHITI_IO_MC_REGS_SIZE;
230 break;
231 }
232
233 running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;
234
235 if (running == 0) {
236 if (running) {
237 blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
238 WREG32(MC_SHARED_BLACKOUT_CNTL, blackout | 1);
239 }
240
241 /* reset the engine and set to writable */
242 WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
243 WREG32(MC_SEQ_SUP_CNTL, 0x00000010);
244
245 /* load mc io regs */
246 for (i = 0; i < regs_size; i++) {
247 WREG32(MC_SEQ_IO_DEBUG_INDEX, io_mc_regs[(i << 1)]);
248 WREG32(MC_SEQ_IO_DEBUG_DATA, io_mc_regs[(i << 1) + 1]);
249 }
250 /* load the MC ucode */
251 fw_data = (const __be32 *)rdev->mc_fw->data;
252 for (i = 0; i < ucode_size; i++)
253 WREG32(MC_SEQ_SUP_PGM, be32_to_cpup(fw_data++));
254
255 /* put the engine back into the active state */
256 WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
257 WREG32(MC_SEQ_SUP_CNTL, 0x00000004);
258 WREG32(MC_SEQ_SUP_CNTL, 0x00000001);
259
260 /* wait for training to complete */
261 for (i = 0; i < rdev->usec_timeout; i++) {
262 if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D0)
263 break;
264 udelay(1);
265 }
266 for (i = 0; i < rdev->usec_timeout; i++) {
267 if (RREG32(MC_SEQ_TRAIN_WAKEUP_CNTL) & TRAIN_DONE_D1)
268 break;
269 udelay(1);
270 }
271
272 if (running)
273 WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
274 }
275
276 return 0;
277}
278
279static int si_init_microcode(struct radeon_device *rdev)
280{
281 struct platform_device *pdev;
282 const char *chip_name;
283 const char *rlc_chip_name;
284 size_t pfp_req_size, me_req_size, ce_req_size, rlc_req_size, mc_req_size;
285 char fw_name[30];
286 int err;
287
288 DRM_DEBUG("\n");
289
290 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
291 err = IS_ERR(pdev);
292 if (err) {
293 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
294 return -EINVAL;
295 }
296
297 switch (rdev->family) {
298 case CHIP_TAHITI:
299 chip_name = "TAHITI";
300 rlc_chip_name = "TAHITI";
301 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
302 me_req_size = SI_PM4_UCODE_SIZE * 4;
303 ce_req_size = SI_CE_UCODE_SIZE * 4;
304 rlc_req_size = SI_RLC_UCODE_SIZE * 4;
305 mc_req_size = SI_MC_UCODE_SIZE * 4;
306 break;
307 case CHIP_PITCAIRN:
308 chip_name = "PITCAIRN";
309 rlc_chip_name = "PITCAIRN";
310 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
311 me_req_size = SI_PM4_UCODE_SIZE * 4;
312 ce_req_size = SI_CE_UCODE_SIZE * 4;
313 rlc_req_size = SI_RLC_UCODE_SIZE * 4;
314 mc_req_size = SI_MC_UCODE_SIZE * 4;
315 break;
316 case CHIP_VERDE:
317 chip_name = "VERDE";
318 rlc_chip_name = "VERDE";
319 pfp_req_size = SI_PFP_UCODE_SIZE * 4;
320 me_req_size = SI_PM4_UCODE_SIZE * 4;
321 ce_req_size = SI_CE_UCODE_SIZE * 4;
322 rlc_req_size = SI_RLC_UCODE_SIZE * 4;
323 mc_req_size = SI_MC_UCODE_SIZE * 4;
324 break;
325 default: BUG();
326 }
327
328 DRM_INFO("Loading %s Microcode\n", chip_name);
329
330 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
331 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
332 if (err)
333 goto out;
334 if (rdev->pfp_fw->size != pfp_req_size) {
335 printk(KERN_ERR
336 "si_cp: Bogus length %zu in firmware \"%s\"\n",
337 rdev->pfp_fw->size, fw_name);
338 err = -EINVAL;
339 goto out;
340 }
341
342 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
343 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
344 if (err)
345 goto out;
346 if (rdev->me_fw->size != me_req_size) {
347 printk(KERN_ERR
348 "si_cp: Bogus length %zu in firmware \"%s\"\n",
349 rdev->me_fw->size, fw_name);
350 err = -EINVAL;
351 }
352
353 snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
354 err = request_firmware(&rdev->ce_fw, fw_name, &pdev->dev);
355 if (err)
356 goto out;
357 if (rdev->ce_fw->size != ce_req_size) {
358 printk(KERN_ERR
359 "si_cp: Bogus length %zu in firmware \"%s\"\n",
360 rdev->ce_fw->size, fw_name);
361 err = -EINVAL;
362 }
363
364 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
365 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
366 if (err)
367 goto out;
368 if (rdev->rlc_fw->size != rlc_req_size) {
369 printk(KERN_ERR
370 "si_rlc: Bogus length %zu in firmware \"%s\"\n",
371 rdev->rlc_fw->size, fw_name);
372 err = -EINVAL;
373 }
374
375 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
376 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
377 if (err)
378 goto out;
379 if (rdev->mc_fw->size != mc_req_size) {
380 printk(KERN_ERR
381 "si_mc: Bogus length %zu in firmware \"%s\"\n",
382 rdev->mc_fw->size, fw_name);
383 err = -EINVAL;
384 }
385
386out:
387 platform_device_unregister(pdev);
388
389 if (err) {
390 if (err != -EINVAL)
391 printk(KERN_ERR
392 "si_cp: Failed to load firmware \"%s\"\n",
393 fw_name);
394 release_firmware(rdev->pfp_fw);
395 rdev->pfp_fw = NULL;
396 release_firmware(rdev->me_fw);
397 rdev->me_fw = NULL;
398 release_firmware(rdev->ce_fw);
399 rdev->ce_fw = NULL;
400 release_firmware(rdev->rlc_fw);
401 rdev->rlc_fw = NULL;
402 release_firmware(rdev->mc_fw);
403 rdev->mc_fw = NULL;
404 }
405 return err;
406}
407
408/* watermark setup */
409static u32 dce6_line_buffer_adjust(struct radeon_device *rdev,
410 struct radeon_crtc *radeon_crtc,
411 struct drm_display_mode *mode,
412 struct drm_display_mode *other_mode)
413{
414 u32 tmp;
415 /*
416 * Line Buffer Setup
417 * There are 3 line buffers, each one shared by 2 display controllers.
418 * DC_LB_MEMORY_SPLIT controls how that line buffer is shared between
419 * the display controllers. The paritioning is done via one of four
420 * preset allocations specified in bits 21:20:
421 * 0 - half lb
422 * 2 - whole lb, other crtc must be disabled
423 */
424 /* this can get tricky if we have two large displays on a paired group
425 * of crtcs. Ideally for multiple large displays we'd assign them to
426 * non-linked crtcs for maximum line buffer allocation.
427 */
428 if (radeon_crtc->base.enabled && mode) {
429 if (other_mode)
430 tmp = 0; /* 1/2 */
431 else
432 tmp = 2; /* whole */
433 } else
434 tmp = 0;
435
436 WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset,
437 DC_LB_MEMORY_CONFIG(tmp));
438
439 if (radeon_crtc->base.enabled && mode) {
440 switch (tmp) {
441 case 0:
442 default:
443 return 4096 * 2;
444 case 2:
445 return 8192 * 2;
446 }
447 }
448
449 /* controller not enabled, so no lb used */
450 return 0;
451}
452
453static u32 si_get_number_of_dram_channels(struct radeon_device *rdev)
454{
455 u32 tmp = RREG32(MC_SHARED_CHMAP);
456
457 switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) {
458 case 0:
459 default:
460 return 1;
461 case 1:
462 return 2;
463 case 2:
464 return 4;
465 case 3:
466 return 8;
467 case 4:
468 return 3;
469 case 5:
470 return 6;
471 case 6:
472 return 10;
473 case 7:
474 return 12;
475 case 8:
476 return 16;
477 }
478}
479
480struct dce6_wm_params {
481 u32 dram_channels; /* number of dram channels */
482 u32 yclk; /* bandwidth per dram data pin in kHz */
483 u32 sclk; /* engine clock in kHz */
484 u32 disp_clk; /* display clock in kHz */
485 u32 src_width; /* viewport width */
486 u32 active_time; /* active display time in ns */
487 u32 blank_time; /* blank time in ns */
488 bool interlaced; /* mode is interlaced */
489 fixed20_12 vsc; /* vertical scale ratio */
490 u32 num_heads; /* number of active crtcs */
491 u32 bytes_per_pixel; /* bytes per pixel display + overlay */
492 u32 lb_size; /* line buffer allocated to pipe */
493 u32 vtaps; /* vertical scaler taps */
494};
495
496static u32 dce6_dram_bandwidth(struct dce6_wm_params *wm)
497{
498 /* Calculate raw DRAM Bandwidth */
499 fixed20_12 dram_efficiency; /* 0.7 */
500 fixed20_12 yclk, dram_channels, bandwidth;
501 fixed20_12 a;
502
503 a.full = dfixed_const(1000);
504 yclk.full = dfixed_const(wm->yclk);
505 yclk.full = dfixed_div(yclk, a);
506 dram_channels.full = dfixed_const(wm->dram_channels * 4);
507 a.full = dfixed_const(10);
508 dram_efficiency.full = dfixed_const(7);
509 dram_efficiency.full = dfixed_div(dram_efficiency, a);
510 bandwidth.full = dfixed_mul(dram_channels, yclk);
511 bandwidth.full = dfixed_mul(bandwidth, dram_efficiency);
512
513 return dfixed_trunc(bandwidth);
514}
515
516static u32 dce6_dram_bandwidth_for_display(struct dce6_wm_params *wm)
517{
518 /* Calculate DRAM Bandwidth and the part allocated to display. */
519 fixed20_12 disp_dram_allocation; /* 0.3 to 0.7 */
520 fixed20_12 yclk, dram_channels, bandwidth;
521 fixed20_12 a;
522
523 a.full = dfixed_const(1000);
524 yclk.full = dfixed_const(wm->yclk);
525 yclk.full = dfixed_div(yclk, a);
526 dram_channels.full = dfixed_const(wm->dram_channels * 4);
527 a.full = dfixed_const(10);
528 disp_dram_allocation.full = dfixed_const(3); /* XXX worse case value 0.3 */
529 disp_dram_allocation.full = dfixed_div(disp_dram_allocation, a);
530 bandwidth.full = dfixed_mul(dram_channels, yclk);
531 bandwidth.full = dfixed_mul(bandwidth, disp_dram_allocation);
532
533 return dfixed_trunc(bandwidth);
534}
535
536static u32 dce6_data_return_bandwidth(struct dce6_wm_params *wm)
537{
538 /* Calculate the display Data return Bandwidth */
539 fixed20_12 return_efficiency; /* 0.8 */
540 fixed20_12 sclk, bandwidth;
541 fixed20_12 a;
542
543 a.full = dfixed_const(1000);
544 sclk.full = dfixed_const(wm->sclk);
545 sclk.full = dfixed_div(sclk, a);
546 a.full = dfixed_const(10);
547 return_efficiency.full = dfixed_const(8);
548 return_efficiency.full = dfixed_div(return_efficiency, a);
549 a.full = dfixed_const(32);
550 bandwidth.full = dfixed_mul(a, sclk);
551 bandwidth.full = dfixed_mul(bandwidth, return_efficiency);
552
553 return dfixed_trunc(bandwidth);
554}
555
556static u32 dce6_get_dmif_bytes_per_request(struct dce6_wm_params *wm)
557{
558 return 32;
559}
560
561static u32 dce6_dmif_request_bandwidth(struct dce6_wm_params *wm)
562{
563 /* Calculate the DMIF Request Bandwidth */
564 fixed20_12 disp_clk_request_efficiency; /* 0.8 */
565 fixed20_12 disp_clk, sclk, bandwidth;
566 fixed20_12 a, b1, b2;
567 u32 min_bandwidth;
568
569 a.full = dfixed_const(1000);
570 disp_clk.full = dfixed_const(wm->disp_clk);
571 disp_clk.full = dfixed_div(disp_clk, a);
572 a.full = dfixed_const(dce6_get_dmif_bytes_per_request(wm) / 2);
573 b1.full = dfixed_mul(a, disp_clk);
574
575 a.full = dfixed_const(1000);
576 sclk.full = dfixed_const(wm->sclk);
577 sclk.full = dfixed_div(sclk, a);
578 a.full = dfixed_const(dce6_get_dmif_bytes_per_request(wm));
579 b2.full = dfixed_mul(a, sclk);
580
581 a.full = dfixed_const(10);
582 disp_clk_request_efficiency.full = dfixed_const(8);
583 disp_clk_request_efficiency.full = dfixed_div(disp_clk_request_efficiency, a);
584
585 min_bandwidth = min(dfixed_trunc(b1), dfixed_trunc(b2));
586
587 a.full = dfixed_const(min_bandwidth);
588 bandwidth.full = dfixed_mul(a, disp_clk_request_efficiency);
589
590 return dfixed_trunc(bandwidth);
591}
592
593static u32 dce6_available_bandwidth(struct dce6_wm_params *wm)
594{
595 /* Calculate the Available bandwidth. Display can use this temporarily but not in average. */
596 u32 dram_bandwidth = dce6_dram_bandwidth(wm);
597 u32 data_return_bandwidth = dce6_data_return_bandwidth(wm);
598 u32 dmif_req_bandwidth = dce6_dmif_request_bandwidth(wm);
599
600 return min(dram_bandwidth, min(data_return_bandwidth, dmif_req_bandwidth));
601}
602
603static u32 dce6_average_bandwidth(struct dce6_wm_params *wm)
604{
605 /* Calculate the display mode Average Bandwidth
606 * DisplayMode should contain the source and destination dimensions,
607 * timing, etc.
608 */
609 fixed20_12 bpp;
610 fixed20_12 line_time;
611 fixed20_12 src_width;
612 fixed20_12 bandwidth;
613 fixed20_12 a;
614
615 a.full = dfixed_const(1000);
616 line_time.full = dfixed_const(wm->active_time + wm->blank_time);
617 line_time.full = dfixed_div(line_time, a);
618 bpp.full = dfixed_const(wm->bytes_per_pixel);
619 src_width.full = dfixed_const(wm->src_width);
620 bandwidth.full = dfixed_mul(src_width, bpp);
621 bandwidth.full = dfixed_mul(bandwidth, wm->vsc);
622 bandwidth.full = dfixed_div(bandwidth, line_time);
623
624 return dfixed_trunc(bandwidth);
625}
626
627static u32 dce6_latency_watermark(struct dce6_wm_params *wm)
628{
629 /* First calcualte the latency in ns */
630 u32 mc_latency = 2000; /* 2000 ns. */
631 u32 available_bandwidth = dce6_available_bandwidth(wm);
632 u32 worst_chunk_return_time = (512 * 8 * 1000) / available_bandwidth;
633 u32 cursor_line_pair_return_time = (128 * 4 * 1000) / available_bandwidth;
634 u32 dc_latency = 40000000 / wm->disp_clk; /* dc pipe latency */
635 u32 other_heads_data_return_time = ((wm->num_heads + 1) * worst_chunk_return_time) +
636 (wm->num_heads * cursor_line_pair_return_time);
637 u32 latency = mc_latency + other_heads_data_return_time + dc_latency;
638 u32 max_src_lines_per_dst_line, lb_fill_bw, line_fill_time;
639 u32 tmp, dmif_size = 12288;
640 fixed20_12 a, b, c;
641
642 if (wm->num_heads == 0)
643 return 0;
644
645 a.full = dfixed_const(2);
646 b.full = dfixed_const(1);
647 if ((wm->vsc.full > a.full) ||
648 ((wm->vsc.full > b.full) && (wm->vtaps >= 3)) ||
649 (wm->vtaps >= 5) ||
650 ((wm->vsc.full >= a.full) && wm->interlaced))
651 max_src_lines_per_dst_line = 4;
652 else
653 max_src_lines_per_dst_line = 2;
654
655 a.full = dfixed_const(available_bandwidth);
656 b.full = dfixed_const(wm->num_heads);
657 a.full = dfixed_div(a, b);
658
659 b.full = dfixed_const(mc_latency + 512);
660 c.full = dfixed_const(wm->disp_clk);
661 b.full = dfixed_div(b, c);
662
663 c.full = dfixed_const(dmif_size);
664 b.full = dfixed_div(c, b);
665
666 tmp = min(dfixed_trunc(a), dfixed_trunc(b));
667
668 b.full = dfixed_const(1000);
669 c.full = dfixed_const(wm->disp_clk);
670 b.full = dfixed_div(c, b);
671 c.full = dfixed_const(wm->bytes_per_pixel);
672 b.full = dfixed_mul(b, c);
673
674 lb_fill_bw = min(tmp, dfixed_trunc(b));
675
676 a.full = dfixed_const(max_src_lines_per_dst_line * wm->src_width * wm->bytes_per_pixel);
677 b.full = dfixed_const(1000);
678 c.full = dfixed_const(lb_fill_bw);
679 b.full = dfixed_div(c, b);
680 a.full = dfixed_div(a, b);
681 line_fill_time = dfixed_trunc(a);
682
683 if (line_fill_time < wm->active_time)
684 return latency;
685 else
686 return latency + (line_fill_time - wm->active_time);
687
688}
689
690static bool dce6_average_bandwidth_vs_dram_bandwidth_for_display(struct dce6_wm_params *wm)
691{
692 if (dce6_average_bandwidth(wm) <=
693 (dce6_dram_bandwidth_for_display(wm) / wm->num_heads))
694 return true;
695 else
696 return false;
697};
698
699static bool dce6_average_bandwidth_vs_available_bandwidth(struct dce6_wm_params *wm)
700{
701 if (dce6_average_bandwidth(wm) <=
702 (dce6_available_bandwidth(wm) / wm->num_heads))
703 return true;
704 else
705 return false;
706};
707
708static bool dce6_check_latency_hiding(struct dce6_wm_params *wm)
709{
710 u32 lb_partitions = wm->lb_size / wm->src_width;
711 u32 line_time = wm->active_time + wm->blank_time;
712 u32 latency_tolerant_lines;
713 u32 latency_hiding;
714 fixed20_12 a;
715
716 a.full = dfixed_const(1);
717 if (wm->vsc.full > a.full)
718 latency_tolerant_lines = 1;
719 else {
720 if (lb_partitions <= (wm->vtaps + 1))
721 latency_tolerant_lines = 1;
722 else
723 latency_tolerant_lines = 2;
724 }
725
726 latency_hiding = (latency_tolerant_lines * line_time + wm->blank_time);
727
728 if (dce6_latency_watermark(wm) <= latency_hiding)
729 return true;
730 else
731 return false;
732}
733
734static void dce6_program_watermarks(struct radeon_device *rdev,
735 struct radeon_crtc *radeon_crtc,
736 u32 lb_size, u32 num_heads)
737{
738 struct drm_display_mode *mode = &radeon_crtc->base.mode;
739 struct dce6_wm_params wm;
740 u32 pixel_period;
741 u32 line_time = 0;
742 u32 latency_watermark_a = 0, latency_watermark_b = 0;
743 u32 priority_a_mark = 0, priority_b_mark = 0;
744 u32 priority_a_cnt = PRIORITY_OFF;
745 u32 priority_b_cnt = PRIORITY_OFF;
746 u32 tmp, arb_control3;
747 fixed20_12 a, b, c;
748
749 if (radeon_crtc->base.enabled && num_heads && mode) {
750 pixel_period = 1000000 / (u32)mode->clock;
751 line_time = min((u32)mode->crtc_htotal * pixel_period, (u32)65535);
752 priority_a_cnt = 0;
753 priority_b_cnt = 0;
754
755 wm.yclk = rdev->pm.current_mclk * 10;
756 wm.sclk = rdev->pm.current_sclk * 10;
757 wm.disp_clk = mode->clock;
758 wm.src_width = mode->crtc_hdisplay;
759 wm.active_time = mode->crtc_hdisplay * pixel_period;
760 wm.blank_time = line_time - wm.active_time;
761 wm.interlaced = false;
762 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
763 wm.interlaced = true;
764 wm.vsc = radeon_crtc->vsc;
765 wm.vtaps = 1;
766 if (radeon_crtc->rmx_type != RMX_OFF)
767 wm.vtaps = 2;
768 wm.bytes_per_pixel = 4; /* XXX: get this from fb config */
769 wm.lb_size = lb_size;
770 if (rdev->family == CHIP_ARUBA)
771 wm.dram_channels = evergreen_get_number_of_dram_channels(rdev);
772 else
773 wm.dram_channels = si_get_number_of_dram_channels(rdev);
774 wm.num_heads = num_heads;
775
776 /* set for high clocks */
777 latency_watermark_a = min(dce6_latency_watermark(&wm), (u32)65535);
778 /* set for low clocks */
779 /* wm.yclk = low clk; wm.sclk = low clk */
780 latency_watermark_b = min(dce6_latency_watermark(&wm), (u32)65535);
781
782 /* possibly force display priority to high */
783 /* should really do this at mode validation time... */
784 if (!dce6_average_bandwidth_vs_dram_bandwidth_for_display(&wm) ||
785 !dce6_average_bandwidth_vs_available_bandwidth(&wm) ||
786 !dce6_check_latency_hiding(&wm) ||
787 (rdev->disp_priority == 2)) {
788 DRM_DEBUG_KMS("force priority to high\n");
789 priority_a_cnt |= PRIORITY_ALWAYS_ON;
790 priority_b_cnt |= PRIORITY_ALWAYS_ON;
791 }
792
793 a.full = dfixed_const(1000);
794 b.full = dfixed_const(mode->clock);
795 b.full = dfixed_div(b, a);
796 c.full = dfixed_const(latency_watermark_a);
797 c.full = dfixed_mul(c, b);
798 c.full = dfixed_mul(c, radeon_crtc->hsc);
799 c.full = dfixed_div(c, a);
800 a.full = dfixed_const(16);
801 c.full = dfixed_div(c, a);
802 priority_a_mark = dfixed_trunc(c);
803 priority_a_cnt |= priority_a_mark & PRIORITY_MARK_MASK;
804
805 a.full = dfixed_const(1000);
806 b.full = dfixed_const(mode->clock);
807 b.full = dfixed_div(b, a);
808 c.full = dfixed_const(latency_watermark_b);
809 c.full = dfixed_mul(c, b);
810 c.full = dfixed_mul(c, radeon_crtc->hsc);
811 c.full = dfixed_div(c, a);
812 a.full = dfixed_const(16);
813 c.full = dfixed_div(c, a);
814 priority_b_mark = dfixed_trunc(c);
815 priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK;
816 }
817
818 /* select wm A */
819 arb_control3 = RREG32(DPG_PIPE_ARBITRATION_CONTROL3 + radeon_crtc->crtc_offset);
820 tmp = arb_control3;
821 tmp &= ~LATENCY_WATERMARK_MASK(3);
822 tmp |= LATENCY_WATERMARK_MASK(1);
823 WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + radeon_crtc->crtc_offset, tmp);
824 WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset,
825 (LATENCY_LOW_WATERMARK(latency_watermark_a) |
826 LATENCY_HIGH_WATERMARK(line_time)));
827 /* select wm B */
828 tmp = RREG32(DPG_PIPE_ARBITRATION_CONTROL3 + radeon_crtc->crtc_offset);
829 tmp &= ~LATENCY_WATERMARK_MASK(3);
830 tmp |= LATENCY_WATERMARK_MASK(2);
831 WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + radeon_crtc->crtc_offset, tmp);
832 WREG32(DPG_PIPE_LATENCY_CONTROL + radeon_crtc->crtc_offset,
833 (LATENCY_LOW_WATERMARK(latency_watermark_b) |
834 LATENCY_HIGH_WATERMARK(line_time)));
835 /* restore original selection */
836 WREG32(DPG_PIPE_ARBITRATION_CONTROL3 + radeon_crtc->crtc_offset, arb_control3);
837
838 /* write the priority marks */
839 WREG32(PRIORITY_A_CNT + radeon_crtc->crtc_offset, priority_a_cnt);
840 WREG32(PRIORITY_B_CNT + radeon_crtc->crtc_offset, priority_b_cnt);
841
842}
843
844void dce6_bandwidth_update(struct radeon_device *rdev)
845{
846 struct drm_display_mode *mode0 = NULL;
847 struct drm_display_mode *mode1 = NULL;
848 u32 num_heads = 0, lb_size;
849 int i;
850
851 radeon_update_display_priority(rdev);
852
853 for (i = 0; i < rdev->num_crtc; i++) {
854 if (rdev->mode_info.crtcs[i]->base.enabled)
855 num_heads++;
856 }
857 for (i = 0; i < rdev->num_crtc; i += 2) {
858 mode0 = &rdev->mode_info.crtcs[i]->base.mode;
859 mode1 = &rdev->mode_info.crtcs[i+1]->base.mode;
860 lb_size = dce6_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i], mode0, mode1);
861 dce6_program_watermarks(rdev, rdev->mode_info.crtcs[i], lb_size, num_heads);
862 lb_size = dce6_line_buffer_adjust(rdev, rdev->mode_info.crtcs[i+1], mode1, mode0);
863 dce6_program_watermarks(rdev, rdev->mode_info.crtcs[i+1], lb_size, num_heads);
864 }
865}
866
867/*
868 * Core functions
869 */
870static u32 si_get_tile_pipe_to_backend_map(struct radeon_device *rdev,
871 u32 num_tile_pipes,
872 u32 num_backends_per_asic,
873 u32 *backend_disable_mask_per_asic,
874 u32 num_shader_engines)
875{
876 u32 backend_map = 0;
877 u32 enabled_backends_mask = 0;
878 u32 enabled_backends_count = 0;
879 u32 num_backends_per_se;
880 u32 cur_pipe;
881 u32 swizzle_pipe[SI_MAX_PIPES];
882 u32 cur_backend = 0;
883 u32 i;
884 bool force_no_swizzle;
885
886 /* force legal values */
887 if (num_tile_pipes < 1)
888 num_tile_pipes = 1;
889 if (num_tile_pipes > rdev->config.si.max_tile_pipes)
890 num_tile_pipes = rdev->config.si.max_tile_pipes;
891 if (num_shader_engines < 1)
892 num_shader_engines = 1;
893 if (num_shader_engines > rdev->config.si.max_shader_engines)
894 num_shader_engines = rdev->config.si.max_shader_engines;
895 if (num_backends_per_asic < num_shader_engines)
896 num_backends_per_asic = num_shader_engines;
897 if (num_backends_per_asic > (rdev->config.si.max_backends_per_se * num_shader_engines))
898 num_backends_per_asic = rdev->config.si.max_backends_per_se * num_shader_engines;
899
900 /* make sure we have the same number of backends per se */
901 num_backends_per_asic = ALIGN(num_backends_per_asic, num_shader_engines);
902 /* set up the number of backends per se */
903 num_backends_per_se = num_backends_per_asic / num_shader_engines;
904 if (num_backends_per_se > rdev->config.si.max_backends_per_se) {
905 num_backends_per_se = rdev->config.si.max_backends_per_se;
906 num_backends_per_asic = num_backends_per_se * num_shader_engines;
907 }
908
909 /* create enable mask and count for enabled backends */
910 for (i = 0; i < SI_MAX_BACKENDS; ++i) {
911 if (((*backend_disable_mask_per_asic >> i) & 1) == 0) {
912 enabled_backends_mask |= (1 << i);
913 ++enabled_backends_count;
914 }
915 if (enabled_backends_count == num_backends_per_asic)
916 break;
917 }
918
919 /* force the backends mask to match the current number of backends */
920 if (enabled_backends_count != num_backends_per_asic) {
921 u32 this_backend_enabled;
922 u32 shader_engine;
923 u32 backend_per_se;
924
925 enabled_backends_mask = 0;
926 enabled_backends_count = 0;
927 *backend_disable_mask_per_asic = SI_MAX_BACKENDS_MASK;
928 for (i = 0; i < SI_MAX_BACKENDS; ++i) {
929 /* calc the current se */
930 shader_engine = i / rdev->config.si.max_backends_per_se;
931 /* calc the backend per se */
932 backend_per_se = i % rdev->config.si.max_backends_per_se;
933 /* default to not enabled */
934 this_backend_enabled = 0;
935 if ((shader_engine < num_shader_engines) &&
936 (backend_per_se < num_backends_per_se))
937 this_backend_enabled = 1;
938 if (this_backend_enabled) {
939 enabled_backends_mask |= (1 << i);
940 *backend_disable_mask_per_asic &= ~(1 << i);
941 ++enabled_backends_count;
942 }
943 }
944 }
945
946
947 memset((uint8_t *)&swizzle_pipe[0], 0, sizeof(u32) * SI_MAX_PIPES);
948 switch (rdev->family) {
949 case CHIP_TAHITI:
950 case CHIP_PITCAIRN:
951 case CHIP_VERDE:
952 force_no_swizzle = true;
953 break;
954 default:
955 force_no_swizzle = false;
956 break;
957 }
958 if (force_no_swizzle) {
959 bool last_backend_enabled = false;
960
961 force_no_swizzle = false;
962 for (i = 0; i < SI_MAX_BACKENDS; ++i) {
963 if (((enabled_backends_mask >> i) & 1) == 1) {
964 if (last_backend_enabled)
965 force_no_swizzle = true;
966 last_backend_enabled = true;
967 } else
968 last_backend_enabled = false;
969 }
970 }
971
972 switch (num_tile_pipes) {
973 case 1:
974 case 3:
975 case 5:
976 case 7:
977 DRM_ERROR("odd number of pipes!\n");
978 break;
979 case 2:
980 swizzle_pipe[0] = 0;
981 swizzle_pipe[1] = 1;
982 break;
983 case 4:
984 if (force_no_swizzle) {
985 swizzle_pipe[0] = 0;
986 swizzle_pipe[1] = 1;
987 swizzle_pipe[2] = 2;
988 swizzle_pipe[3] = 3;
989 } else {
990 swizzle_pipe[0] = 0;
991 swizzle_pipe[1] = 2;
992 swizzle_pipe[2] = 1;
993 swizzle_pipe[3] = 3;
994 }
995 break;
996 case 6:
997 if (force_no_swizzle) {
998 swizzle_pipe[0] = 0;
999 swizzle_pipe[1] = 1;
1000 swizzle_pipe[2] = 2;
1001 swizzle_pipe[3] = 3;
1002 swizzle_pipe[4] = 4;
1003 swizzle_pipe[5] = 5;
1004 } else {
1005 swizzle_pipe[0] = 0;
1006 swizzle_pipe[1] = 2;
1007 swizzle_pipe[2] = 4;
1008 swizzle_pipe[3] = 1;
1009 swizzle_pipe[4] = 3;
1010 swizzle_pipe[5] = 5;
1011 }
1012 break;
1013 case 8:
1014 if (force_no_swizzle) {
1015 swizzle_pipe[0] = 0;
1016 swizzle_pipe[1] = 1;
1017 swizzle_pipe[2] = 2;
1018 swizzle_pipe[3] = 3;
1019 swizzle_pipe[4] = 4;
1020 swizzle_pipe[5] = 5;
1021 swizzle_pipe[6] = 6;
1022 swizzle_pipe[7] = 7;
1023 } else {
1024 swizzle_pipe[0] = 0;
1025 swizzle_pipe[1] = 2;
1026 swizzle_pipe[2] = 4;
1027 swizzle_pipe[3] = 6;
1028 swizzle_pipe[4] = 1;
1029 swizzle_pipe[5] = 3;
1030 swizzle_pipe[6] = 5;
1031 swizzle_pipe[7] = 7;
1032 }
1033 break;
1034 }
1035
1036 for (cur_pipe = 0; cur_pipe < num_tile_pipes; ++cur_pipe) {
1037 while (((1 << cur_backend) & enabled_backends_mask) == 0)
1038 cur_backend = (cur_backend + 1) % SI_MAX_BACKENDS;
1039
1040 backend_map |= (((cur_backend & 0xf) << (swizzle_pipe[cur_pipe] * 4)));
1041
1042 cur_backend = (cur_backend + 1) % SI_MAX_BACKENDS;
1043 }
1044
1045 return backend_map;
1046}
1047
1048static u32 si_get_disable_mask_per_asic(struct radeon_device *rdev,
1049 u32 disable_mask_per_se,
1050 u32 max_disable_mask_per_se,
1051 u32 num_shader_engines)
1052{
1053 u32 disable_field_width_per_se = r600_count_pipe_bits(disable_mask_per_se);
1054 u32 disable_mask_per_asic = disable_mask_per_se & max_disable_mask_per_se;
1055
1056 if (num_shader_engines == 1)
1057 return disable_mask_per_asic;
1058 else if (num_shader_engines == 2)
1059 return disable_mask_per_asic | (disable_mask_per_asic << disable_field_width_per_se);
1060 else
1061 return 0xffffffff;
1062}
1063
1064static void si_tiling_mode_table_init(struct radeon_device *rdev)
1065{
1066 const u32 num_tile_mode_states = 32;
1067 u32 reg_offset, gb_tile_moden, split_equal_to_row_size;
1068
1069 switch (rdev->config.si.mem_row_size_in_kb) {
1070 case 1:
1071 split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB;
1072 break;
1073 case 2:
1074 default:
1075 split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB;
1076 break;
1077 case 4:
1078 split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB;
1079 break;
1080 }
1081
1082 if ((rdev->family == CHIP_TAHITI) ||
1083 (rdev->family == CHIP_PITCAIRN)) {
1084 for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
1085 switch (reg_offset) {
1086 case 0: /* non-AA compressed depth or any compressed stencil */
1087 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1088 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1089 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1090 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1091 NUM_BANKS(ADDR_SURF_16_BANK) |
1092 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1093 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1094 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1095 break;
1096 case 1: /* 2xAA/4xAA compressed depth only */
1097 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1098 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1099 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1100 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
1101 NUM_BANKS(ADDR_SURF_16_BANK) |
1102 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1103 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1104 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1105 break;
1106 case 2: /* 8xAA compressed depth only */
1107 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1108 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1109 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1110 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1111 NUM_BANKS(ADDR_SURF_16_BANK) |
1112 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1113 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1114 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1115 break;
1116 case 3: /* 2xAA/4xAA compressed depth with stencil (for depth buffer) */
1117 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1118 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1119 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1120 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
1121 NUM_BANKS(ADDR_SURF_16_BANK) |
1122 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1123 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1124 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1125 break;
1126 case 4: /* Maps w/ a dimension less than the 2D macro-tile dimensions (for mipmapped depth textures) */
1127 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1128 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1129 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1130 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1131 NUM_BANKS(ADDR_SURF_16_BANK) |
1132 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1133 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1134 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1135 break;
1136 case 5: /* Uncompressed 16bpp depth - and stencil buffer allocated with it */
1137 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1138 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1139 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1140 TILE_SPLIT(split_equal_to_row_size) |
1141 NUM_BANKS(ADDR_SURF_16_BANK) |
1142 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1143 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1144 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1145 break;
1146 case 6: /* Uncompressed 32bpp depth - and stencil buffer allocated with it */
1147 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1148 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1149 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1150 TILE_SPLIT(split_equal_to_row_size) |
1151 NUM_BANKS(ADDR_SURF_16_BANK) |
1152 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1153 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1154 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1155 break;
1156 case 7: /* Uncompressed 8bpp stencil without depth (drivers typically do not use) */
1157 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1158 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1159 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1160 TILE_SPLIT(split_equal_to_row_size) |
1161 NUM_BANKS(ADDR_SURF_16_BANK) |
1162 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1163 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1164 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1165 break;
1166 case 8: /* 1D and 1D Array Surfaces */
1167 gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
1168 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1169 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1170 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1171 NUM_BANKS(ADDR_SURF_16_BANK) |
1172 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1173 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1174 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1175 break;
1176 case 9: /* Displayable maps. */
1177 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1178 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1179 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1180 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1181 NUM_BANKS(ADDR_SURF_16_BANK) |
1182 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1183 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1184 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1185 break;
1186 case 10: /* Display 8bpp. */
1187 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1188 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1189 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1190 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1191 NUM_BANKS(ADDR_SURF_16_BANK) |
1192 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1193 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1194 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1195 break;
1196 case 11: /* Display 16bpp. */
1197 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1198 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1199 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1200 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1201 NUM_BANKS(ADDR_SURF_16_BANK) |
1202 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1203 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1204 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1205 break;
1206 case 12: /* Display 32bpp. */
1207 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1208 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1209 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1210 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1211 NUM_BANKS(ADDR_SURF_16_BANK) |
1212 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1213 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1214 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1215 break;
1216 case 13: /* Thin. */
1217 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1218 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1219 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1220 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1221 NUM_BANKS(ADDR_SURF_16_BANK) |
1222 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1223 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1224 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1225 break;
1226 case 14: /* Thin 8 bpp. */
1227 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1228 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1229 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1230 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1231 NUM_BANKS(ADDR_SURF_16_BANK) |
1232 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1233 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1234 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1235 break;
1236 case 15: /* Thin 16 bpp. */
1237 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1238 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1239 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1240 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1241 NUM_BANKS(ADDR_SURF_16_BANK) |
1242 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1243 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1244 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1245 break;
1246 case 16: /* Thin 32 bpp. */
1247 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1248 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1249 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1250 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1251 NUM_BANKS(ADDR_SURF_16_BANK) |
1252 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1253 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1254 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1255 break;
1256 case 17: /* Thin 64 bpp. */
1257 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1258 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1259 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1260 TILE_SPLIT(split_equal_to_row_size) |
1261 NUM_BANKS(ADDR_SURF_16_BANK) |
1262 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1263 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1264 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1265 break;
1266 case 21: /* 8 bpp PRT. */
1267 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1268 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1269 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1270 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1271 NUM_BANKS(ADDR_SURF_16_BANK) |
1272 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
1273 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1274 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1275 break;
1276 case 22: /* 16 bpp PRT */
1277 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1278 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1279 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1280 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1281 NUM_BANKS(ADDR_SURF_16_BANK) |
1282 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1283 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1284 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1285 break;
1286 case 23: /* 32 bpp PRT */
1287 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1288 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1289 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1290 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1291 NUM_BANKS(ADDR_SURF_16_BANK) |
1292 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1293 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1294 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1295 break;
1296 case 24: /* 64 bpp PRT */
1297 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1298 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1299 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1300 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1301 NUM_BANKS(ADDR_SURF_16_BANK) |
1302 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1303 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1304 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1305 break;
1306 case 25: /* 128 bpp PRT */
1307 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1308 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1309 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1310 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
1311 NUM_BANKS(ADDR_SURF_8_BANK) |
1312 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1313 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1314 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1315 break;
1316 default:
1317 gb_tile_moden = 0;
1318 break;
1319 }
1320 WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden);
1321 }
1322 } else if (rdev->family == CHIP_VERDE) {
1323 for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
1324 switch (reg_offset) {
1325 case 0: /* non-AA compressed depth or any compressed stencil */
1326 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1327 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1328 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1329 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1330 NUM_BANKS(ADDR_SURF_16_BANK) |
1331 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1332 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1333 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1334 break;
1335 case 1: /* 2xAA/4xAA compressed depth only */
1336 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1337 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1338 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1339 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
1340 NUM_BANKS(ADDR_SURF_16_BANK) |
1341 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1342 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1343 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1344 break;
1345 case 2: /* 8xAA compressed depth only */
1346 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1347 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1348 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1349 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1350 NUM_BANKS(ADDR_SURF_16_BANK) |
1351 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1352 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1353 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1354 break;
1355 case 3: /* 2xAA/4xAA compressed depth with stencil (for depth buffer) */
1356 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1357 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1358 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1359 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
1360 NUM_BANKS(ADDR_SURF_16_BANK) |
1361 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1362 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1363 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1364 break;
1365 case 4: /* Maps w/ a dimension less than the 2D macro-tile dimensions (for mipmapped depth textures) */
1366 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1367 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1368 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1369 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1370 NUM_BANKS(ADDR_SURF_16_BANK) |
1371 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1372 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1373 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1374 break;
1375 case 5: /* Uncompressed 16bpp depth - and stencil buffer allocated with it */
1376 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1377 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1378 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1379 TILE_SPLIT(split_equal_to_row_size) |
1380 NUM_BANKS(ADDR_SURF_16_BANK) |
1381 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1382 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1383 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1384 break;
1385 case 6: /* Uncompressed 32bpp depth - and stencil buffer allocated with it */
1386 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1387 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1388 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1389 TILE_SPLIT(split_equal_to_row_size) |
1390 NUM_BANKS(ADDR_SURF_16_BANK) |
1391 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1392 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1393 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1394 break;
1395 case 7: /* Uncompressed 8bpp stencil without depth (drivers typically do not use) */
1396 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1397 MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
1398 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1399 TILE_SPLIT(split_equal_to_row_size) |
1400 NUM_BANKS(ADDR_SURF_16_BANK) |
1401 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1402 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1403 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1404 break;
1405 case 8: /* 1D and 1D Array Surfaces */
1406 gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
1407 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1408 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1409 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1410 NUM_BANKS(ADDR_SURF_16_BANK) |
1411 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1412 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1413 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1414 break;
1415 case 9: /* Displayable maps. */
1416 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1417 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1418 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1419 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1420 NUM_BANKS(ADDR_SURF_16_BANK) |
1421 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1422 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1423 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1424 break;
1425 case 10: /* Display 8bpp. */
1426 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1427 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1428 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1429 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1430 NUM_BANKS(ADDR_SURF_16_BANK) |
1431 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1432 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1433 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1434 break;
1435 case 11: /* Display 16bpp. */
1436 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1437 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1438 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1439 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1440 NUM_BANKS(ADDR_SURF_16_BANK) |
1441 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1442 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1443 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1444 break;
1445 case 12: /* Display 32bpp. */
1446 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1447 MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
1448 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1449 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1450 NUM_BANKS(ADDR_SURF_16_BANK) |
1451 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1452 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1453 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1454 break;
1455 case 13: /* Thin. */
1456 gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
1457 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1458 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1459 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
1460 NUM_BANKS(ADDR_SURF_16_BANK) |
1461 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1462 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1463 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1464 break;
1465 case 14: /* Thin 8 bpp. */
1466 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1467 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1468 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1469 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1470 NUM_BANKS(ADDR_SURF_16_BANK) |
1471 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1472 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1473 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1474 break;
1475 case 15: /* Thin 16 bpp. */
1476 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1477 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1478 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1479 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1480 NUM_BANKS(ADDR_SURF_16_BANK) |
1481 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1482 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1483 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1484 break;
1485 case 16: /* Thin 32 bpp. */
1486 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1487 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1488 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1489 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1490 NUM_BANKS(ADDR_SURF_16_BANK) |
1491 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1492 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1493 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1494 break;
1495 case 17: /* Thin 64 bpp. */
1496 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1497 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1498 PIPE_CONFIG(ADDR_SURF_P4_8x16) |
1499 TILE_SPLIT(split_equal_to_row_size) |
1500 NUM_BANKS(ADDR_SURF_16_BANK) |
1501 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1502 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1503 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1504 break;
1505 case 21: /* 8 bpp PRT. */
1506 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1507 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1508 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1509 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1510 NUM_BANKS(ADDR_SURF_16_BANK) |
1511 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
1512 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1513 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1514 break;
1515 case 22: /* 16 bpp PRT */
1516 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1517 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1518 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1519 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1520 NUM_BANKS(ADDR_SURF_16_BANK) |
1521 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1522 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
1523 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4));
1524 break;
1525 case 23: /* 32 bpp PRT */
1526 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1527 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1528 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1529 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
1530 NUM_BANKS(ADDR_SURF_16_BANK) |
1531 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1532 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
1533 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1534 break;
1535 case 24: /* 64 bpp PRT */
1536 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1537 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1538 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1539 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
1540 NUM_BANKS(ADDR_SURF_16_BANK) |
1541 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1542 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1543 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2));
1544 break;
1545 case 25: /* 128 bpp PRT */
1546 gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
1547 MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
1548 PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
1549 TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
1550 NUM_BANKS(ADDR_SURF_8_BANK) |
1551 BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
1552 BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
1553 MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1));
1554 break;
1555 default:
1556 gb_tile_moden = 0;
1557 break;
1558 }
1559 WREG32(GB_TILE_MODE0 + (reg_offset * 4), gb_tile_moden);
1560 }
1561 } else
1562 DRM_ERROR("unknown asic: 0x%x\n", rdev->family);
1563}
1564
1565static void si_gpu_init(struct radeon_device *rdev)
1566{
1567 u32 cc_rb_backend_disable = 0;
1568 u32 cc_gc_shader_array_config;
1569 u32 gb_addr_config = 0;
1570 u32 mc_shared_chmap, mc_arb_ramcfg;
1571 u32 gb_backend_map;
1572 u32 cgts_tcc_disable;
1573 u32 sx_debug_1;
1574 u32 gc_user_shader_array_config;
1575 u32 gc_user_rb_backend_disable;
1576 u32 cgts_user_tcc_disable;
1577 u32 hdp_host_path_cntl;
1578 u32 tmp;
1579 int i, j;
1580
1581 switch (rdev->family) {
1582 case CHIP_TAHITI:
1583 rdev->config.si.max_shader_engines = 2;
1584 rdev->config.si.max_pipes_per_simd = 4;
1585 rdev->config.si.max_tile_pipes = 12;
1586 rdev->config.si.max_simds_per_se = 8;
1587 rdev->config.si.max_backends_per_se = 4;
1588 rdev->config.si.max_texture_channel_caches = 12;
1589 rdev->config.si.max_gprs = 256;
1590 rdev->config.si.max_gs_threads = 32;
1591 rdev->config.si.max_hw_contexts = 8;
1592
1593 rdev->config.si.sc_prim_fifo_size_frontend = 0x20;
1594 rdev->config.si.sc_prim_fifo_size_backend = 0x100;
1595 rdev->config.si.sc_hiz_tile_fifo_size = 0x30;
1596 rdev->config.si.sc_earlyz_tile_fifo_size = 0x130;
1597 break;
1598 case CHIP_PITCAIRN:
1599 rdev->config.si.max_shader_engines = 2;
1600 rdev->config.si.max_pipes_per_simd = 4;
1601 rdev->config.si.max_tile_pipes = 8;
1602 rdev->config.si.max_simds_per_se = 5;
1603 rdev->config.si.max_backends_per_se = 4;
1604 rdev->config.si.max_texture_channel_caches = 8;
1605 rdev->config.si.max_gprs = 256;
1606 rdev->config.si.max_gs_threads = 32;
1607 rdev->config.si.max_hw_contexts = 8;
1608
1609 rdev->config.si.sc_prim_fifo_size_frontend = 0x20;
1610 rdev->config.si.sc_prim_fifo_size_backend = 0x100;
1611 rdev->config.si.sc_hiz_tile_fifo_size = 0x30;
1612 rdev->config.si.sc_earlyz_tile_fifo_size = 0x130;
1613 break;
1614 case CHIP_VERDE:
1615 default:
1616 rdev->config.si.max_shader_engines = 1;
1617 rdev->config.si.max_pipes_per_simd = 4;
1618 rdev->config.si.max_tile_pipes = 4;
1619 rdev->config.si.max_simds_per_se = 2;
1620 rdev->config.si.max_backends_per_se = 4;
1621 rdev->config.si.max_texture_channel_caches = 4;
1622 rdev->config.si.max_gprs = 256;
1623 rdev->config.si.max_gs_threads = 32;
1624 rdev->config.si.max_hw_contexts = 8;
1625
1626 rdev->config.si.sc_prim_fifo_size_frontend = 0x20;
1627 rdev->config.si.sc_prim_fifo_size_backend = 0x40;
1628 rdev->config.si.sc_hiz_tile_fifo_size = 0x30;
1629 rdev->config.si.sc_earlyz_tile_fifo_size = 0x130;
1630 break;
1631 }
1632
1633 /* Initialize HDP */
1634 for (i = 0, j = 0; i < 32; i++, j += 0x18) {
1635 WREG32((0x2c14 + j), 0x00000000);
1636 WREG32((0x2c18 + j), 0x00000000);
1637 WREG32((0x2c1c + j), 0x00000000);
1638 WREG32((0x2c20 + j), 0x00000000);
1639 WREG32((0x2c24 + j), 0x00000000);
1640 }
1641
1642 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
1643
1644 evergreen_fix_pci_max_read_req_size(rdev);
1645
1646 WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN);
1647
1648 mc_shared_chmap = RREG32(MC_SHARED_CHMAP);
1649 mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG);
1650
1651 cc_rb_backend_disable = RREG32(CC_RB_BACKEND_DISABLE);
1652 cc_gc_shader_array_config = RREG32(CC_GC_SHADER_ARRAY_CONFIG);
1653 cgts_tcc_disable = 0xffff0000;
1654 for (i = 0; i < rdev->config.si.max_texture_channel_caches; i++)
1655 cgts_tcc_disable &= ~(1 << (16 + i));
1656 gc_user_rb_backend_disable = RREG32(GC_USER_RB_BACKEND_DISABLE);
1657 gc_user_shader_array_config = RREG32(GC_USER_SHADER_ARRAY_CONFIG);
1658 cgts_user_tcc_disable = RREG32(CGTS_USER_TCC_DISABLE);
1659
1660 rdev->config.si.num_shader_engines = rdev->config.si.max_shader_engines;
1661 rdev->config.si.num_tile_pipes = rdev->config.si.max_tile_pipes;
1662 tmp = ((~gc_user_rb_backend_disable) & BACKEND_DISABLE_MASK) >> BACKEND_DISABLE_SHIFT;
1663 rdev->config.si.num_backends_per_se = r600_count_pipe_bits(tmp);
1664 tmp = (gc_user_rb_backend_disable & BACKEND_DISABLE_MASK) >> BACKEND_DISABLE_SHIFT;
1665 rdev->config.si.backend_disable_mask_per_asic =
1666 si_get_disable_mask_per_asic(rdev, tmp, SI_MAX_BACKENDS_PER_SE_MASK,
1667 rdev->config.si.num_shader_engines);
1668 rdev->config.si.backend_map =
1669 si_get_tile_pipe_to_backend_map(rdev, rdev->config.si.num_tile_pipes,
1670 rdev->config.si.num_backends_per_se *
1671 rdev->config.si.num_shader_engines,
1672 &rdev->config.si.backend_disable_mask_per_asic,
1673 rdev->config.si.num_shader_engines);
1674 tmp = ((~cgts_user_tcc_disable) & TCC_DISABLE_MASK) >> TCC_DISABLE_SHIFT;
1675 rdev->config.si.num_texture_channel_caches = r600_count_pipe_bits(tmp);
1676 rdev->config.si.mem_max_burst_length_bytes = 256;
1677 tmp = (mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT;
1678 rdev->config.si.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024;
1679 if (rdev->config.si.mem_row_size_in_kb > 4)
1680 rdev->config.si.mem_row_size_in_kb = 4;
1681 /* XXX use MC settings? */
1682 rdev->config.si.shader_engine_tile_size = 32;
1683 rdev->config.si.num_gpus = 1;
1684 rdev->config.si.multi_gpu_tile_size = 64;
1685
1686 gb_addr_config = 0;
1687 switch (rdev->config.si.num_tile_pipes) {
1688 case 1:
1689 gb_addr_config |= NUM_PIPES(0);
1690 break;
1691 case 2:
1692 gb_addr_config |= NUM_PIPES(1);
1693 break;
1694 case 4:
1695 gb_addr_config |= NUM_PIPES(2);
1696 break;
1697 case 8:
1698 default:
1699 gb_addr_config |= NUM_PIPES(3);
1700 break;
1701 }
1702
1703 tmp = (rdev->config.si.mem_max_burst_length_bytes / 256) - 1;
1704 gb_addr_config |= PIPE_INTERLEAVE_SIZE(tmp);
1705 gb_addr_config |= NUM_SHADER_ENGINES(rdev->config.si.num_shader_engines - 1);
1706 tmp = (rdev->config.si.shader_engine_tile_size / 16) - 1;
1707 gb_addr_config |= SHADER_ENGINE_TILE_SIZE(tmp);
1708 switch (rdev->config.si.num_gpus) {
1709 case 1:
1710 default:
1711 gb_addr_config |= NUM_GPUS(0);
1712 break;
1713 case 2:
1714 gb_addr_config |= NUM_GPUS(1);
1715 break;
1716 case 4:
1717 gb_addr_config |= NUM_GPUS(2);
1718 break;
1719 }
1720 switch (rdev->config.si.multi_gpu_tile_size) {
1721 case 16:
1722 gb_addr_config |= MULTI_GPU_TILE_SIZE(0);
1723 break;
1724 case 32:
1725 default:
1726 gb_addr_config |= MULTI_GPU_TILE_SIZE(1);
1727 break;
1728 case 64:
1729 gb_addr_config |= MULTI_GPU_TILE_SIZE(2);
1730 break;
1731 case 128:
1732 gb_addr_config |= MULTI_GPU_TILE_SIZE(3);
1733 break;
1734 }
1735 switch (rdev->config.si.mem_row_size_in_kb) {
1736 case 1:
1737 default:
1738 gb_addr_config |= ROW_SIZE(0);
1739 break;
1740 case 2:
1741 gb_addr_config |= ROW_SIZE(1);
1742 break;
1743 case 4:
1744 gb_addr_config |= ROW_SIZE(2);
1745 break;
1746 }
1747
1748 tmp = (gb_addr_config & NUM_PIPES_MASK) >> NUM_PIPES_SHIFT;
1749 rdev->config.si.num_tile_pipes = (1 << tmp);
1750 tmp = (gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT;
1751 rdev->config.si.mem_max_burst_length_bytes = (tmp + 1) * 256;
1752 tmp = (gb_addr_config & NUM_SHADER_ENGINES_MASK) >> NUM_SHADER_ENGINES_SHIFT;
1753 rdev->config.si.num_shader_engines = tmp + 1;
1754 tmp = (gb_addr_config & NUM_GPUS_MASK) >> NUM_GPUS_SHIFT;
1755 rdev->config.si.num_gpus = tmp + 1;
1756 tmp = (gb_addr_config & MULTI_GPU_TILE_SIZE_MASK) >> MULTI_GPU_TILE_SIZE_SHIFT;
1757 rdev->config.si.multi_gpu_tile_size = 1 << tmp;
1758 tmp = (gb_addr_config & ROW_SIZE_MASK) >> ROW_SIZE_SHIFT;
1759 rdev->config.si.mem_row_size_in_kb = 1 << tmp;
1760
1761 gb_backend_map =
1762 si_get_tile_pipe_to_backend_map(rdev, rdev->config.si.num_tile_pipes,
1763 rdev->config.si.num_backends_per_se *
1764 rdev->config.si.num_shader_engines,
1765 &rdev->config.si.backend_disable_mask_per_asic,
1766 rdev->config.si.num_shader_engines);
1767
1768 /* setup tiling info dword. gb_addr_config is not adequate since it does
1769 * not have bank info, so create a custom tiling dword.
1770 * bits 3:0 num_pipes
1771 * bits 7:4 num_banks
1772 * bits 11:8 group_size
1773 * bits 15:12 row_size
1774 */
1775 rdev->config.si.tile_config = 0;
1776 switch (rdev->config.si.num_tile_pipes) {
1777 case 1:
1778 rdev->config.si.tile_config |= (0 << 0);
1779 break;
1780 case 2:
1781 rdev->config.si.tile_config |= (1 << 0);
1782 break;
1783 case 4:
1784 rdev->config.si.tile_config |= (2 << 0);
1785 break;
1786 case 8:
1787 default:
1788 /* XXX what about 12? */
1789 rdev->config.si.tile_config |= (3 << 0);
1790 break;
1791 }
1792 rdev->config.si.tile_config |=
1793 ((mc_arb_ramcfg & NOOFBANK_MASK) >> NOOFBANK_SHIFT) << 4;
1794 rdev->config.si.tile_config |=
1795 ((gb_addr_config & PIPE_INTERLEAVE_SIZE_MASK) >> PIPE_INTERLEAVE_SIZE_SHIFT) << 8;
1796 rdev->config.si.tile_config |=
1797 ((gb_addr_config & ROW_SIZE_MASK) >> ROW_SIZE_SHIFT) << 12;
1798
1799 rdev->config.si.backend_map = gb_backend_map;
1800 WREG32(GB_ADDR_CONFIG, gb_addr_config);
1801 WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
1802 WREG32(HDP_ADDR_CONFIG, gb_addr_config);
1803
1804 /* primary versions */
1805 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1806 WREG32(CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1807 WREG32(CC_GC_SHADER_ARRAY_CONFIG, cc_gc_shader_array_config);
1808
1809 WREG32(CGTS_TCC_DISABLE, cgts_tcc_disable);
1810
1811 /* user versions */
1812 WREG32(GC_USER_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1813 WREG32(GC_USER_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1814 WREG32(GC_USER_SHADER_ARRAY_CONFIG, cc_gc_shader_array_config);
1815
1816 WREG32(CGTS_USER_TCC_DISABLE, cgts_tcc_disable);
1817
1818 si_tiling_mode_table_init(rdev);
1819
1820 /* set HW defaults for 3D engine */
1821 WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) |
1822 ROQ_IB2_START(0x2b)));
1823 WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60));
1824
1825 sx_debug_1 = RREG32(SX_DEBUG_1);
1826 WREG32(SX_DEBUG_1, sx_debug_1);
1827
1828 WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4));
1829
1830 WREG32(PA_SC_FIFO_SIZE, (SC_FRONTEND_PRIM_FIFO_SIZE(rdev->config.si.sc_prim_fifo_size_frontend) |
1831 SC_BACKEND_PRIM_FIFO_SIZE(rdev->config.si.sc_prim_fifo_size_backend) |
1832 SC_HIZ_TILE_FIFO_SIZE(rdev->config.si.sc_hiz_tile_fifo_size) |
1833 SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.si.sc_earlyz_tile_fifo_size)));
1834
1835 WREG32(VGT_NUM_INSTANCES, 1);
1836
1837 WREG32(CP_PERFMON_CNTL, 0);
1838
1839 WREG32(SQ_CONFIG, 0);
1840
1841 WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) |
1842 FORCE_EOV_MAX_REZ_CNT(255)));
1843
1844 WREG32(VGT_CACHE_INVALIDATION, CACHE_INVALIDATION(VC_AND_TC) |
1845 AUTO_INVLD_EN(ES_AND_GS_AUTO));
1846
1847 WREG32(VGT_GS_VERTEX_REUSE, 16);
1848 WREG32(PA_SC_LINE_STIPPLE_STATE, 0);
1849
1850 WREG32(CB_PERFCOUNTER0_SELECT0, 0);
1851 WREG32(CB_PERFCOUNTER0_SELECT1, 0);
1852 WREG32(CB_PERFCOUNTER1_SELECT0, 0);
1853 WREG32(CB_PERFCOUNTER1_SELECT1, 0);
1854 WREG32(CB_PERFCOUNTER2_SELECT0, 0);
1855 WREG32(CB_PERFCOUNTER2_SELECT1, 0);
1856 WREG32(CB_PERFCOUNTER3_SELECT0, 0);
1857 WREG32(CB_PERFCOUNTER3_SELECT1, 0);
1858
1859 tmp = RREG32(HDP_MISC_CNTL);
1860 tmp |= HDP_FLUSH_INVALIDATE_CACHE;
1861 WREG32(HDP_MISC_CNTL, tmp);
1862
1863 hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL);
1864 WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl);
1865
1866 WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3));
1867
1868 udelay(50);
1869}
1870
1871/*
1872 * GPU scratch registers helpers function.
1873 */
1874static void si_scratch_init(struct radeon_device *rdev)
1875{
1876 int i;
1877
1878 rdev->scratch.num_reg = 7;
1879 rdev->scratch.reg_base = SCRATCH_REG0;
1880 for (i = 0; i < rdev->scratch.num_reg; i++) {
1881 rdev->scratch.free[i] = true;
1882 rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4);
1883 }
1884}
1885
1886void si_fence_ring_emit(struct radeon_device *rdev,
1887 struct radeon_fence *fence)
1888{
1889 struct radeon_ring *ring = &rdev->ring[fence->ring];
1890 u64 addr = rdev->fence_drv[fence->ring].gpu_addr;
1891
1892 /* flush read cache over gart */
1893 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
1894 radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2);
1895 radeon_ring_write(ring, 0);
1896 radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
1897 radeon_ring_write(ring, PACKET3_TCL1_ACTION_ENA |
1898 PACKET3_TC_ACTION_ENA |
1899 PACKET3_SH_KCACHE_ACTION_ENA |
1900 PACKET3_SH_ICACHE_ACTION_ENA);
1901 radeon_ring_write(ring, 0xFFFFFFFF);
1902 radeon_ring_write(ring, 0);
1903 radeon_ring_write(ring, 10); /* poll interval */
1904 /* EVENT_WRITE_EOP - flush caches, send int */
1905 radeon_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
1906 radeon_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5));
1907 radeon_ring_write(ring, addr & 0xffffffff);
1908 radeon_ring_write(ring, (upper_32_bits(addr) & 0xff) | DATA_SEL(1) | INT_SEL(2));
1909 radeon_ring_write(ring, fence->seq);
1910 radeon_ring_write(ring, 0);
1911}
1912
1913/*
1914 * IB stuff
1915 */
1916void si_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
1917{
1918 struct radeon_ring *ring = &rdev->ring[ib->fence->ring];
1919 u32 header;
1920
1921 if (ib->is_const_ib)
1922 header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2);
1923 else
1924 header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
1925
1926 radeon_ring_write(ring, header);
1927 radeon_ring_write(ring,
1928#ifdef __BIG_ENDIAN
1929 (2 << 0) |
1930#endif
1931 (ib->gpu_addr & 0xFFFFFFFC));
1932 radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
1933 radeon_ring_write(ring, ib->length_dw | (ib->vm_id << 24));
1934
1935 /* flush read cache over gart for this vmid */
1936 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
1937 radeon_ring_write(ring, (CP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START) >> 2);
1938 radeon_ring_write(ring, ib->vm_id);
1939 radeon_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
1940 radeon_ring_write(ring, PACKET3_TCL1_ACTION_ENA |
1941 PACKET3_TC_ACTION_ENA |
1942 PACKET3_SH_KCACHE_ACTION_ENA |
1943 PACKET3_SH_ICACHE_ACTION_ENA);
1944 radeon_ring_write(ring, 0xFFFFFFFF);
1945 radeon_ring_write(ring, 0);
1946 radeon_ring_write(ring, 10); /* poll interval */
1947}
1948
1949/*
1950 * CP.
1951 */
1952static void si_cp_enable(struct radeon_device *rdev, bool enable)
1953{
1954 if (enable)
1955 WREG32(CP_ME_CNTL, 0);
1956 else {
1957 radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size);
1958 WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT));
1959 WREG32(SCRATCH_UMSK, 0);
1960 }
1961 udelay(50);
1962}
1963
1964static int si_cp_load_microcode(struct radeon_device *rdev)
1965{
1966 const __be32 *fw_data;
1967 int i;
1968
1969 if (!rdev->me_fw || !rdev->pfp_fw)
1970 return -EINVAL;
1971
1972 si_cp_enable(rdev, false);
1973
1974 /* PFP */
1975 fw_data = (const __be32 *)rdev->pfp_fw->data;
1976 WREG32(CP_PFP_UCODE_ADDR, 0);
1977 for (i = 0; i < SI_PFP_UCODE_SIZE; i++)
1978 WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++));
1979 WREG32(CP_PFP_UCODE_ADDR, 0);
1980
1981 /* CE */
1982 fw_data = (const __be32 *)rdev->ce_fw->data;
1983 WREG32(CP_CE_UCODE_ADDR, 0);
1984 for (i = 0; i < SI_CE_UCODE_SIZE; i++)
1985 WREG32(CP_CE_UCODE_DATA, be32_to_cpup(fw_data++));
1986 WREG32(CP_CE_UCODE_ADDR, 0);
1987
1988 /* ME */
1989 fw_data = (const __be32 *)rdev->me_fw->data;
1990 WREG32(CP_ME_RAM_WADDR, 0);
1991 for (i = 0; i < SI_PM4_UCODE_SIZE; i++)
1992 WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++));
1993 WREG32(CP_ME_RAM_WADDR, 0);
1994
1995 WREG32(CP_PFP_UCODE_ADDR, 0);
1996 WREG32(CP_CE_UCODE_ADDR, 0);
1997 WREG32(CP_ME_RAM_WADDR, 0);
1998 WREG32(CP_ME_RAM_RADDR, 0);
1999 return 0;
2000}
2001
2002static int si_cp_start(struct radeon_device *rdev)
2003{
2004 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
2005 int r, i;
2006
2007 r = radeon_ring_lock(rdev, ring, 7 + 4);
2008 if (r) {
2009 DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r);
2010 return r;
2011 }
2012 /* init the CP */
2013 radeon_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5));
2014 radeon_ring_write(ring, 0x1);
2015 radeon_ring_write(ring, 0x0);
2016 radeon_ring_write(ring, rdev->config.si.max_hw_contexts - 1);
2017 radeon_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1));
2018 radeon_ring_write(ring, 0);
2019 radeon_ring_write(ring, 0);
2020
2021 /* init the CE partitions */
2022 radeon_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2));
2023 radeon_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE));
2024 radeon_ring_write(ring, 0xc000);
2025 radeon_ring_write(ring, 0xe000);
2026 radeon_ring_unlock_commit(rdev, ring);
2027
2028 si_cp_enable(rdev, true);
2029
2030 r = radeon_ring_lock(rdev, ring, si_default_size + 10);
2031 if (r) {
2032 DRM_ERROR("radeon: cp failed to lock ring (%d).\n", r);
2033 return r;
2034 }
2035
2036 /* setup clear context state */
2037 radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
2038 radeon_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
2039
2040 for (i = 0; i < si_default_size; i++)
2041 radeon_ring_write(ring, si_default_state[i]);
2042
2043 radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
2044 radeon_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE);
2045
2046 /* set clear context state */
2047 radeon_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
2048 radeon_ring_write(ring, 0);
2049
2050 radeon_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2));
2051 radeon_ring_write(ring, 0x00000316);
2052 radeon_ring_write(ring, 0x0000000e); /* VGT_VERTEX_REUSE_BLOCK_CNTL */
2053 radeon_ring_write(ring, 0x00000010); /* VGT_OUT_DEALLOC_CNTL */
2054
2055 radeon_ring_unlock_commit(rdev, ring);
2056
2057 for (i = RADEON_RING_TYPE_GFX_INDEX; i <= CAYMAN_RING_TYPE_CP2_INDEX; ++i) {
2058 ring = &rdev->ring[i];
2059 r = radeon_ring_lock(rdev, ring, 2);
2060
2061 /* clear the compute context state */
2062 radeon_ring_write(ring, PACKET3_COMPUTE(PACKET3_CLEAR_STATE, 0));
2063 radeon_ring_write(ring, 0);
2064
2065 radeon_ring_unlock_commit(rdev, ring);
2066 }
2067
2068 return 0;
2069}
2070
2071static void si_cp_fini(struct radeon_device *rdev)
2072{
2073 si_cp_enable(rdev, false);
2074 radeon_ring_fini(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
2075 radeon_ring_fini(rdev, &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]);
2076 radeon_ring_fini(rdev, &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]);
2077}
2078
2079static int si_cp_resume(struct radeon_device *rdev)
2080{
2081 struct radeon_ring *ring;
2082 u32 tmp;
2083 u32 rb_bufsz;
2084 int r;
2085
2086 /* Reset cp; if cp is reset, then PA, SH, VGT also need to be reset */
2087 WREG32(GRBM_SOFT_RESET, (SOFT_RESET_CP |
2088 SOFT_RESET_PA |
2089 SOFT_RESET_VGT |
2090 SOFT_RESET_SPI |
2091 SOFT_RESET_SX));
2092 RREG32(GRBM_SOFT_RESET);
2093 mdelay(15);
2094 WREG32(GRBM_SOFT_RESET, 0);
2095 RREG32(GRBM_SOFT_RESET);
2096
2097 WREG32(CP_SEM_WAIT_TIMER, 0x0);
2098 WREG32(CP_SEM_INCOMPLETE_TIMER_CNTL, 0x0);
2099
2100 /* Set the write pointer delay */
2101 WREG32(CP_RB_WPTR_DELAY, 0);
2102
2103 WREG32(CP_DEBUG, 0);
2104 WREG32(SCRATCH_ADDR, ((rdev->wb.gpu_addr + RADEON_WB_SCRATCH_OFFSET) >> 8) & 0xFFFFFFFF);
2105
2106 /* ring 0 - compute and gfx */
2107 /* Set ring buffer size */
2108 ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
2109 rb_bufsz = drm_order(ring->ring_size / 8);
2110 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
2111#ifdef __BIG_ENDIAN
2112 tmp |= BUF_SWAP_32BIT;
2113#endif
2114 WREG32(CP_RB0_CNTL, tmp);
2115
2116 /* Initialize the ring buffer's read and write pointers */
2117 WREG32(CP_RB0_CNTL, tmp | RB_RPTR_WR_ENA);
2118 ring->wptr = 0;
2119 WREG32(CP_RB0_WPTR, ring->wptr);
2120
2121 /* set the wb address wether it's enabled or not */
2122 WREG32(CP_RB0_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFFFFFFFC);
2123 WREG32(CP_RB0_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP_RPTR_OFFSET) & 0xFF);
2124
2125 if (rdev->wb.enabled)
2126 WREG32(SCRATCH_UMSK, 0xff);
2127 else {
2128 tmp |= RB_NO_UPDATE;
2129 WREG32(SCRATCH_UMSK, 0);
2130 }
2131
2132 mdelay(1);
2133 WREG32(CP_RB0_CNTL, tmp);
2134
2135 WREG32(CP_RB0_BASE, ring->gpu_addr >> 8);
2136
2137 ring->rptr = RREG32(CP_RB0_RPTR);
2138
2139 /* ring1 - compute only */
2140 /* Set ring buffer size */
2141 ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
2142 rb_bufsz = drm_order(ring->ring_size / 8);
2143 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
2144#ifdef __BIG_ENDIAN
2145 tmp |= BUF_SWAP_32BIT;
2146#endif
2147 WREG32(CP_RB1_CNTL, tmp);
2148
2149 /* Initialize the ring buffer's read and write pointers */
2150 WREG32(CP_RB1_CNTL, tmp | RB_RPTR_WR_ENA);
2151 ring->wptr = 0;
2152 WREG32(CP_RB1_WPTR, ring->wptr);
2153
2154 /* set the wb address wether it's enabled or not */
2155 WREG32(CP_RB1_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFFFFFFFC);
2156 WREG32(CP_RB1_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP1_RPTR_OFFSET) & 0xFF);
2157
2158 mdelay(1);
2159 WREG32(CP_RB1_CNTL, tmp);
2160
2161 WREG32(CP_RB1_BASE, ring->gpu_addr >> 8);
2162
2163 ring->rptr = RREG32(CP_RB1_RPTR);
2164
2165 /* ring2 - compute only */
2166 /* Set ring buffer size */
2167 ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
2168 rb_bufsz = drm_order(ring->ring_size / 8);
2169 tmp = (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
2170#ifdef __BIG_ENDIAN
2171 tmp |= BUF_SWAP_32BIT;
2172#endif
2173 WREG32(CP_RB2_CNTL, tmp);
2174
2175 /* Initialize the ring buffer's read and write pointers */
2176 WREG32(CP_RB2_CNTL, tmp | RB_RPTR_WR_ENA);
2177 ring->wptr = 0;
2178 WREG32(CP_RB2_WPTR, ring->wptr);
2179
2180 /* set the wb address wether it's enabled or not */
2181 WREG32(CP_RB2_RPTR_ADDR, (rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFFFFFFFC);
2182 WREG32(CP_RB2_RPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + RADEON_WB_CP2_RPTR_OFFSET) & 0xFF);
2183
2184 mdelay(1);
2185 WREG32(CP_RB2_CNTL, tmp);
2186
2187 WREG32(CP_RB2_BASE, ring->gpu_addr >> 8);
2188
2189 ring->rptr = RREG32(CP_RB2_RPTR);
2190
2191 /* start the rings */
2192 si_cp_start(rdev);
2193 rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = true;
2194 rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = true;
2195 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = true;
2196 r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
2197 if (r) {
2198 rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false;
2199 rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
2200 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
2201 return r;
2202 }
2203 r = radeon_ring_test(rdev, CAYMAN_RING_TYPE_CP1_INDEX, &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]);
2204 if (r) {
2205 rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
2206 }
2207 r = radeon_ring_test(rdev, CAYMAN_RING_TYPE_CP2_INDEX, &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]);
2208 if (r) {
2209 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
2210 }
2211
2212 return 0;
2213}
2214
2215bool si_gpu_is_lockup(struct radeon_device *rdev, struct radeon_ring *ring)
2216{
2217 u32 srbm_status;
2218 u32 grbm_status, grbm_status2;
2219 u32 grbm_status_se0, grbm_status_se1;
2220 struct r100_gpu_lockup *lockup = &rdev->config.si.lockup;
2221 int r;
2222
2223 srbm_status = RREG32(SRBM_STATUS);
2224 grbm_status = RREG32(GRBM_STATUS);
2225 grbm_status2 = RREG32(GRBM_STATUS2);
2226 grbm_status_se0 = RREG32(GRBM_STATUS_SE0);
2227 grbm_status_se1 = RREG32(GRBM_STATUS_SE1);
2228 if (!(grbm_status & GUI_ACTIVE)) {
2229 r100_gpu_lockup_update(lockup, ring);
2230 return false;
2231 }
2232 /* force CP activities */
2233 r = radeon_ring_lock(rdev, ring, 2);
2234 if (!r) {
2235 /* PACKET2 NOP */
2236 radeon_ring_write(ring, 0x80000000);
2237 radeon_ring_write(ring, 0x80000000);
2238 radeon_ring_unlock_commit(rdev, ring);
2239 }
2240 /* XXX deal with CP0,1,2 */
2241 ring->rptr = RREG32(ring->rptr_reg);
2242 return r100_gpu_cp_is_lockup(rdev, lockup, ring);
2243}
2244
2245static int si_gpu_soft_reset(struct radeon_device *rdev)
2246{
2247 struct evergreen_mc_save save;
2248 u32 grbm_reset = 0;
2249
2250 if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))
2251 return 0;
2252
2253 dev_info(rdev->dev, "GPU softreset \n");
2254 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n",
2255 RREG32(GRBM_STATUS));
2256 dev_info(rdev->dev, " GRBM_STATUS2=0x%08X\n",
2257 RREG32(GRBM_STATUS2));
2258 dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n",
2259 RREG32(GRBM_STATUS_SE0));
2260 dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n",
2261 RREG32(GRBM_STATUS_SE1));
2262 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n",
2263 RREG32(SRBM_STATUS));
2264 evergreen_mc_stop(rdev, &save);
2265 if (radeon_mc_wait_for_idle(rdev)) {
2266 dev_warn(rdev->dev, "Wait for MC idle timedout !\n");
2267 }
2268 /* Disable CP parsing/prefetching */
2269 WREG32(CP_ME_CNTL, CP_ME_HALT | CP_PFP_HALT | CP_CE_HALT);
2270
2271 /* reset all the gfx blocks */
2272 grbm_reset = (SOFT_RESET_CP |
2273 SOFT_RESET_CB |
2274 SOFT_RESET_DB |
2275 SOFT_RESET_GDS |
2276 SOFT_RESET_PA |
2277 SOFT_RESET_SC |
2278 SOFT_RESET_SPI |
2279 SOFT_RESET_SX |
2280 SOFT_RESET_TC |
2281 SOFT_RESET_TA |
2282 SOFT_RESET_VGT |
2283 SOFT_RESET_IA);
2284
2285 dev_info(rdev->dev, " GRBM_SOFT_RESET=0x%08X\n", grbm_reset);
2286 WREG32(GRBM_SOFT_RESET, grbm_reset);
2287 (void)RREG32(GRBM_SOFT_RESET);
2288 udelay(50);
2289 WREG32(GRBM_SOFT_RESET, 0);
2290 (void)RREG32(GRBM_SOFT_RESET);
2291 /* Wait a little for things to settle down */
2292 udelay(50);
2293 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n",
2294 RREG32(GRBM_STATUS));
2295 dev_info(rdev->dev, " GRBM_STATUS2=0x%08X\n",
2296 RREG32(GRBM_STATUS2));
2297 dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n",
2298 RREG32(GRBM_STATUS_SE0));
2299 dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n",
2300 RREG32(GRBM_STATUS_SE1));
2301 dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n",
2302 RREG32(SRBM_STATUS));
2303 evergreen_mc_resume(rdev, &save);
2304 return 0;
2305}
2306
2307int si_asic_reset(struct radeon_device *rdev)
2308{
2309 return si_gpu_soft_reset(rdev);
2310}
2311
2312/* MC */
2313static void si_mc_program(struct radeon_device *rdev)
2314{
2315 struct evergreen_mc_save save;
2316 u32 tmp;
2317 int i, j;
2318
2319 /* Initialize HDP */
2320 for (i = 0, j = 0; i < 32; i++, j += 0x18) {
2321 WREG32((0x2c14 + j), 0x00000000);
2322 WREG32((0x2c18 + j), 0x00000000);
2323 WREG32((0x2c1c + j), 0x00000000);
2324 WREG32((0x2c20 + j), 0x00000000);
2325 WREG32((0x2c24 + j), 0x00000000);
2326 }
2327 WREG32(HDP_REG_COHERENCY_FLUSH_CNTL, 0);
2328
2329 evergreen_mc_stop(rdev, &save);
2330 if (radeon_mc_wait_for_idle(rdev)) {
2331 dev_warn(rdev->dev, "Wait for MC idle timedout !\n");
2332 }
2333 /* Lockout access through VGA aperture*/
2334 WREG32(VGA_HDP_CONTROL, VGA_MEMORY_DISABLE);
2335 /* Update configuration */
2336 WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR,
2337 rdev->mc.vram_start >> 12);
2338 WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR,
2339 rdev->mc.vram_end >> 12);
2340 WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR,
2341 rdev->vram_scratch.gpu_addr >> 12);
2342 tmp = ((rdev->mc.vram_end >> 24) & 0xFFFF) << 16;
2343 tmp |= ((rdev->mc.vram_start >> 24) & 0xFFFF);
2344 WREG32(MC_VM_FB_LOCATION, tmp);
2345 /* XXX double check these! */
2346 WREG32(HDP_NONSURFACE_BASE, (rdev->mc.vram_start >> 8));
2347 WREG32(HDP_NONSURFACE_INFO, (2 << 7) | (1 << 30));
2348 WREG32(HDP_NONSURFACE_SIZE, 0x3FFFFFFF);
2349 WREG32(MC_VM_AGP_BASE, 0);
2350 WREG32(MC_VM_AGP_TOP, 0x0FFFFFFF);
2351 WREG32(MC_VM_AGP_BOT, 0x0FFFFFFF);
2352 if (radeon_mc_wait_for_idle(rdev)) {
2353 dev_warn(rdev->dev, "Wait for MC idle timedout !\n");
2354 }
2355 evergreen_mc_resume(rdev, &save);
2356 /* we need to own VRAM, so turn off the VGA renderer here
2357 * to stop it overwriting our objects */
2358 rv515_vga_render_disable(rdev);
2359}
2360
2361/* SI MC address space is 40 bits */
2362static void si_vram_location(struct radeon_device *rdev,
2363 struct radeon_mc *mc, u64 base)
2364{
2365 mc->vram_start = base;
2366 if (mc->mc_vram_size > (0xFFFFFFFFFFULL - base + 1)) {
2367 dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n");
2368 mc->real_vram_size = mc->aper_size;
2369 mc->mc_vram_size = mc->aper_size;
2370 }
2371 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
2372 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
2373 mc->mc_vram_size >> 20, mc->vram_start,
2374 mc->vram_end, mc->real_vram_size >> 20);
2375}
2376
2377static void si_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
2378{
2379 u64 size_af, size_bf;
2380
2381 size_af = ((0xFFFFFFFFFFULL - mc->vram_end) + mc->gtt_base_align) & ~mc->gtt_base_align;
2382 size_bf = mc->vram_start & ~mc->gtt_base_align;
2383 if (size_bf > size_af) {
2384 if (mc->gtt_size > size_bf) {
2385 dev_warn(rdev->dev, "limiting GTT\n");
2386 mc->gtt_size = size_bf;
2387 }
2388 mc->gtt_start = (mc->vram_start & ~mc->gtt_base_align) - mc->gtt_size;
2389 } else {
2390 if (mc->gtt_size > size_af) {
2391 dev_warn(rdev->dev, "limiting GTT\n");
2392 mc->gtt_size = size_af;
2393 }
2394 mc->gtt_start = (mc->vram_end + 1 + mc->gtt_base_align) & ~mc->gtt_base_align;
2395 }
2396 mc->gtt_end = mc->gtt_start + mc->gtt_size - 1;
2397 dev_info(rdev->dev, "GTT: %lluM 0x%016llX - 0x%016llX\n",
2398 mc->gtt_size >> 20, mc->gtt_start, mc->gtt_end);
2399}
2400
2401static void si_vram_gtt_location(struct radeon_device *rdev,
2402 struct radeon_mc *mc)
2403{
2404 if (mc->mc_vram_size > 0xFFC0000000ULL) {
2405 /* leave room for at least 1024M GTT */
2406 dev_warn(rdev->dev, "limiting VRAM\n");
2407 mc->real_vram_size = 0xFFC0000000ULL;
2408 mc->mc_vram_size = 0xFFC0000000ULL;
2409 }
2410 si_vram_location(rdev, &rdev->mc, 0);
2411 rdev->mc.gtt_base_align = 0;
2412 si_gtt_location(rdev, mc);
2413}
2414
2415static int si_mc_init(struct radeon_device *rdev)
2416{
2417 u32 tmp;
2418 int chansize, numchan;
2419
2420 /* Get VRAM informations */
2421 rdev->mc.vram_is_ddr = true;
2422 tmp = RREG32(MC_ARB_RAMCFG);
2423 if (tmp & CHANSIZE_OVERRIDE) {
2424 chansize = 16;
2425 } else if (tmp & CHANSIZE_MASK) {
2426 chansize = 64;
2427 } else {
2428 chansize = 32;
2429 }
2430 tmp = RREG32(MC_SHARED_CHMAP);
2431 switch ((tmp & NOOFCHAN_MASK) >> NOOFCHAN_SHIFT) {
2432 case 0:
2433 default:
2434 numchan = 1;
2435 break;
2436 case 1:
2437 numchan = 2;
2438 break;
2439 case 2:
2440 numchan = 4;
2441 break;
2442 case 3:
2443 numchan = 8;
2444 break;
2445 case 4:
2446 numchan = 3;
2447 break;
2448 case 5:
2449 numchan = 6;
2450 break;
2451 case 6:
2452 numchan = 10;
2453 break;
2454 case 7:
2455 numchan = 12;
2456 break;
2457 case 8:
2458 numchan = 16;
2459 break;
2460 }
2461 rdev->mc.vram_width = numchan * chansize;
2462 /* Could aper size report 0 ? */
2463 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
2464 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
2465 /* size in MB on si */
2466 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
2467 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024;
2468 rdev->mc.visible_vram_size = rdev->mc.aper_size;
2469 si_vram_gtt_location(rdev, &rdev->mc);
2470 radeon_update_bandwidth_info(rdev);
2471
2472 return 0;
2473}
2474
2475/*
2476 * GART
2477 */
2478void si_pcie_gart_tlb_flush(struct radeon_device *rdev)
2479{
2480 /* flush hdp cache */
2481 WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
2482
2483 /* bits 0-15 are the VM contexts0-15 */
2484 WREG32(VM_INVALIDATE_REQUEST, 1);
2485}
2486
2487int si_pcie_gart_enable(struct radeon_device *rdev)
2488{
2489 int r, i;
2490
2491 if (rdev->gart.robj == NULL) {
2492 dev_err(rdev->dev, "No VRAM object for PCIE GART.\n");
2493 return -EINVAL;
2494 }
2495 r = radeon_gart_table_vram_pin(rdev);
2496 if (r)
2497 return r;
2498 radeon_gart_restore(rdev);
2499 /* Setup TLB control */
2500 WREG32(MC_VM_MX_L1_TLB_CNTL,
2501 (0xA << 7) |
2502 ENABLE_L1_TLB |
2503 SYSTEM_ACCESS_MODE_NOT_IN_SYS |
2504 ENABLE_ADVANCED_DRIVER_MODEL |
2505 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU);
2506 /* Setup L2 cache */
2507 WREG32(VM_L2_CNTL, ENABLE_L2_CACHE |
2508 ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE |
2509 ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE |
2510 EFFECTIVE_L2_QUEUE_SIZE(7) |
2511 CONTEXT1_IDENTITY_ACCESS_MODE(1));
2512 WREG32(VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS | INVALIDATE_L2_CACHE);
2513 WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY |
2514 L2_CACHE_BIGK_FRAGMENT_SIZE(0));
2515 /* setup context0 */
2516 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR, rdev->mc.gtt_start >> 12);
2517 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR, rdev->mc.gtt_end >> 12);
2518 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, rdev->gart.table_addr >> 12);
2519 WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR,
2520 (u32)(rdev->dummy_page.addr >> 12));
2521 WREG32(VM_CONTEXT0_CNTL2, 0);
2522 WREG32(VM_CONTEXT0_CNTL, (ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) |
2523 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT));
2524
2525 WREG32(0x15D4, 0);
2526 WREG32(0x15D8, 0);
2527 WREG32(0x15DC, 0);
2528
2529 /* empty context1-15 */
2530 /* FIXME start with 1G, once using 2 level pt switch to full
2531 * vm size space
2532 */
2533 /* set vm size, must be a multiple of 4 */
2534 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
2535 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, (1 << 30) / RADEON_GPU_PAGE_SIZE);
2536 for (i = 1; i < 16; i++) {
2537 if (i < 8)
2538 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
2539 rdev->gart.table_addr >> 12);
2540 else
2541 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((i - 8) << 2),
2542 rdev->gart.table_addr >> 12);
2543 }
2544
2545 /* enable context1-15 */
2546 WREG32(VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR,
2547 (u32)(rdev->dummy_page.addr >> 12));
2548 WREG32(VM_CONTEXT1_CNTL2, 0);
2549 WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(0) |
2550 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT);
2551
2552 si_pcie_gart_tlb_flush(rdev);
2553 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
2554 (unsigned)(rdev->mc.gtt_size >> 20),
2555 (unsigned long long)rdev->gart.table_addr);
2556 rdev->gart.ready = true;
2557 return 0;
2558}
2559
2560void si_pcie_gart_disable(struct radeon_device *rdev)
2561{
2562 /* Disable all tables */
2563 WREG32(VM_CONTEXT0_CNTL, 0);
2564 WREG32(VM_CONTEXT1_CNTL, 0);
2565 /* Setup TLB control */
2566 WREG32(MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE_NOT_IN_SYS |
2567 SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU);
2568 /* Setup L2 cache */
2569 WREG32(VM_L2_CNTL, ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE |
2570 ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE |
2571 EFFECTIVE_L2_QUEUE_SIZE(7) |
2572 CONTEXT1_IDENTITY_ACCESS_MODE(1));
2573 WREG32(VM_L2_CNTL2, 0);
2574 WREG32(VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY |
2575 L2_CACHE_BIGK_FRAGMENT_SIZE(0));
2576 radeon_gart_table_vram_unpin(rdev);
2577}
2578
2579void si_pcie_gart_fini(struct radeon_device *rdev)
2580{
2581 si_pcie_gart_disable(rdev);
2582 radeon_gart_table_vram_free(rdev);
2583 radeon_gart_fini(rdev);
2584}
2585
2586/* vm parser */
2587static bool si_vm_reg_valid(u32 reg)
2588{
2589 /* context regs are fine */
2590 if (reg >= 0x28000)
2591 return true;
2592
2593 /* check config regs */
2594 switch (reg) {
2595 case GRBM_GFX_INDEX:
2596 case VGT_VTX_VECT_EJECT_REG:
2597 case VGT_CACHE_INVALIDATION:
2598 case VGT_ESGS_RING_SIZE:
2599 case VGT_GSVS_RING_SIZE:
2600 case VGT_GS_VERTEX_REUSE:
2601 case VGT_PRIMITIVE_TYPE:
2602 case VGT_INDEX_TYPE:
2603 case VGT_NUM_INDICES:
2604 case VGT_NUM_INSTANCES:
2605 case VGT_TF_RING_SIZE:
2606 case VGT_HS_OFFCHIP_PARAM:
2607 case VGT_TF_MEMORY_BASE:
2608 case PA_CL_ENHANCE:
2609 case PA_SU_LINE_STIPPLE_VALUE:
2610 case PA_SC_LINE_STIPPLE_STATE:
2611 case PA_SC_ENHANCE:
2612 case SQC_CACHES:
2613 case SPI_STATIC_THREAD_MGMT_1:
2614 case SPI_STATIC_THREAD_MGMT_2:
2615 case SPI_STATIC_THREAD_MGMT_3:
2616 case SPI_PS_MAX_WAVE_ID:
2617 case SPI_CONFIG_CNTL:
2618 case SPI_CONFIG_CNTL_1:
2619 case TA_CNTL_AUX:
2620 return true;
2621 default:
2622 DRM_ERROR("Invalid register 0x%x in CS\n", reg);
2623 return false;
2624 }
2625}
2626
2627static int si_vm_packet3_ce_check(struct radeon_device *rdev,
2628 u32 *ib, struct radeon_cs_packet *pkt)
2629{
2630 switch (pkt->opcode) {
2631 case PACKET3_NOP:
2632 case PACKET3_SET_BASE:
2633 case PACKET3_SET_CE_DE_COUNTERS:
2634 case PACKET3_LOAD_CONST_RAM:
2635 case PACKET3_WRITE_CONST_RAM:
2636 case PACKET3_WRITE_CONST_RAM_OFFSET:
2637 case PACKET3_DUMP_CONST_RAM:
2638 case PACKET3_INCREMENT_CE_COUNTER:
2639 case PACKET3_WAIT_ON_DE_COUNTER:
2640 case PACKET3_CE_WRITE:
2641 break;
2642 default:
2643 DRM_ERROR("Invalid CE packet3: 0x%x\n", pkt->opcode);
2644 return -EINVAL;
2645 }
2646 return 0;
2647}
2648
2649static int si_vm_packet3_gfx_check(struct radeon_device *rdev,
2650 u32 *ib, struct radeon_cs_packet *pkt)
2651{
2652 u32 idx = pkt->idx + 1;
2653 u32 idx_value = ib[idx];
2654 u32 start_reg, end_reg, reg, i;
2655
2656 switch (pkt->opcode) {
2657 case PACKET3_NOP:
2658 case PACKET3_SET_BASE:
2659 case PACKET3_CLEAR_STATE:
2660 case PACKET3_INDEX_BUFFER_SIZE:
2661 case PACKET3_DISPATCH_DIRECT:
2662 case PACKET3_DISPATCH_INDIRECT:
2663 case PACKET3_ALLOC_GDS:
2664 case PACKET3_WRITE_GDS_RAM:
2665 case PACKET3_ATOMIC_GDS:
2666 case PACKET3_ATOMIC:
2667 case PACKET3_OCCLUSION_QUERY:
2668 case PACKET3_SET_PREDICATION:
2669 case PACKET3_COND_EXEC:
2670 case PACKET3_PRED_EXEC:
2671 case PACKET3_DRAW_INDIRECT:
2672 case PACKET3_DRAW_INDEX_INDIRECT:
2673 case PACKET3_INDEX_BASE:
2674 case PACKET3_DRAW_INDEX_2:
2675 case PACKET3_CONTEXT_CONTROL:
2676 case PACKET3_INDEX_TYPE:
2677 case PACKET3_DRAW_INDIRECT_MULTI:
2678 case PACKET3_DRAW_INDEX_AUTO:
2679 case PACKET3_DRAW_INDEX_IMMD:
2680 case PACKET3_NUM_INSTANCES:
2681 case PACKET3_DRAW_INDEX_MULTI_AUTO:
2682 case PACKET3_STRMOUT_BUFFER_UPDATE:
2683 case PACKET3_DRAW_INDEX_OFFSET_2:
2684 case PACKET3_DRAW_INDEX_MULTI_ELEMENT:
2685 case PACKET3_DRAW_INDEX_INDIRECT_MULTI:
2686 case PACKET3_MPEG_INDEX:
2687 case PACKET3_WAIT_REG_MEM:
2688 case PACKET3_MEM_WRITE:
2689 case PACKET3_PFP_SYNC_ME:
2690 case PACKET3_SURFACE_SYNC:
2691 case PACKET3_EVENT_WRITE:
2692 case PACKET3_EVENT_WRITE_EOP:
2693 case PACKET3_EVENT_WRITE_EOS:
2694 case PACKET3_SET_CONTEXT_REG:
2695 case PACKET3_SET_CONTEXT_REG_INDIRECT:
2696 case PACKET3_SET_SH_REG:
2697 case PACKET3_SET_SH_REG_OFFSET:
2698 case PACKET3_INCREMENT_DE_COUNTER:
2699 case PACKET3_WAIT_ON_CE_COUNTER:
2700 case PACKET3_WAIT_ON_AVAIL_BUFFER:
2701 case PACKET3_ME_WRITE:
2702 break;
2703 case PACKET3_COPY_DATA:
2704 if ((idx_value & 0xf00) == 0) {
2705 reg = ib[idx + 3] * 4;
2706 if (!si_vm_reg_valid(reg))
2707 return -EINVAL;
2708 }
2709 break;
2710 case PACKET3_WRITE_DATA:
2711 if ((idx_value & 0xf00) == 0) {
2712 start_reg = ib[idx + 1] * 4;
2713 if (idx_value & 0x10000) {
2714 if (!si_vm_reg_valid(start_reg))
2715 return -EINVAL;
2716 } else {
2717 for (i = 0; i < (pkt->count - 2); i++) {
2718 reg = start_reg + (4 * i);
2719 if (!si_vm_reg_valid(reg))
2720 return -EINVAL;
2721 }
2722 }
2723 }
2724 break;
2725 case PACKET3_COND_WRITE:
2726 if (idx_value & 0x100) {
2727 reg = ib[idx + 5] * 4;
2728 if (!si_vm_reg_valid(reg))
2729 return -EINVAL;
2730 }
2731 break;
2732 case PACKET3_COPY_DW:
2733 if (idx_value & 0x2) {
2734 reg = ib[idx + 3] * 4;
2735 if (!si_vm_reg_valid(reg))
2736 return -EINVAL;
2737 }
2738 break;
2739 case PACKET3_SET_CONFIG_REG:
2740 start_reg = (idx_value << 2) + PACKET3_SET_CONFIG_REG_START;
2741 end_reg = 4 * pkt->count + start_reg - 4;
2742 if ((start_reg < PACKET3_SET_CONFIG_REG_START) ||
2743 (start_reg >= PACKET3_SET_CONFIG_REG_END) ||
2744 (end_reg >= PACKET3_SET_CONFIG_REG_END)) {
2745 DRM_ERROR("bad PACKET3_SET_CONFIG_REG\n");
2746 return -EINVAL;
2747 }
2748 for (i = 0; i < pkt->count; i++) {
2749 reg = start_reg + (4 * i);
2750 if (!si_vm_reg_valid(reg))
2751 return -EINVAL;
2752 }
2753 break;
2754 default:
2755 DRM_ERROR("Invalid GFX packet3: 0x%x\n", pkt->opcode);
2756 return -EINVAL;
2757 }
2758 return 0;
2759}
2760
2761static int si_vm_packet3_compute_check(struct radeon_device *rdev,
2762 u32 *ib, struct radeon_cs_packet *pkt)
2763{
2764 u32 idx = pkt->idx + 1;
2765 u32 idx_value = ib[idx];
2766 u32 start_reg, reg, i;
2767
2768 switch (pkt->opcode) {
2769 case PACKET3_NOP:
2770 case PACKET3_SET_BASE:
2771 case PACKET3_CLEAR_STATE:
2772 case PACKET3_DISPATCH_DIRECT:
2773 case PACKET3_DISPATCH_INDIRECT:
2774 case PACKET3_ALLOC_GDS:
2775 case PACKET3_WRITE_GDS_RAM:
2776 case PACKET3_ATOMIC_GDS:
2777 case PACKET3_ATOMIC:
2778 case PACKET3_OCCLUSION_QUERY:
2779 case PACKET3_SET_PREDICATION:
2780 case PACKET3_COND_EXEC:
2781 case PACKET3_PRED_EXEC:
2782 case PACKET3_CONTEXT_CONTROL:
2783 case PACKET3_STRMOUT_BUFFER_UPDATE:
2784 case PACKET3_WAIT_REG_MEM:
2785 case PACKET3_MEM_WRITE:
2786 case PACKET3_PFP_SYNC_ME:
2787 case PACKET3_SURFACE_SYNC:
2788 case PACKET3_EVENT_WRITE:
2789 case PACKET3_EVENT_WRITE_EOP:
2790 case PACKET3_EVENT_WRITE_EOS:
2791 case PACKET3_SET_CONTEXT_REG:
2792 case PACKET3_SET_CONTEXT_REG_INDIRECT:
2793 case PACKET3_SET_SH_REG:
2794 case PACKET3_SET_SH_REG_OFFSET:
2795 case PACKET3_INCREMENT_DE_COUNTER:
2796 case PACKET3_WAIT_ON_CE_COUNTER:
2797 case PACKET3_WAIT_ON_AVAIL_BUFFER:
2798 case PACKET3_ME_WRITE:
2799 break;
2800 case PACKET3_COPY_DATA:
2801 if ((idx_value & 0xf00) == 0) {
2802 reg = ib[idx + 3] * 4;
2803 if (!si_vm_reg_valid(reg))
2804 return -EINVAL;
2805 }
2806 break;
2807 case PACKET3_WRITE_DATA:
2808 if ((idx_value & 0xf00) == 0) {
2809 start_reg = ib[idx + 1] * 4;
2810 if (idx_value & 0x10000) {
2811 if (!si_vm_reg_valid(start_reg))
2812 return -EINVAL;
2813 } else {
2814 for (i = 0; i < (pkt->count - 2); i++) {
2815 reg = start_reg + (4 * i);
2816 if (!si_vm_reg_valid(reg))
2817 return -EINVAL;
2818 }
2819 }
2820 }
2821 break;
2822 case PACKET3_COND_WRITE:
2823 if (idx_value & 0x100) {
2824 reg = ib[idx + 5] * 4;
2825 if (!si_vm_reg_valid(reg))
2826 return -EINVAL;
2827 }
2828 break;
2829 case PACKET3_COPY_DW:
2830 if (idx_value & 0x2) {
2831 reg = ib[idx + 3] * 4;
2832 if (!si_vm_reg_valid(reg))
2833 return -EINVAL;
2834 }
2835 break;
2836 default:
2837 DRM_ERROR("Invalid Compute packet3: 0x%x\n", pkt->opcode);
2838 return -EINVAL;
2839 }
2840 return 0;
2841}
2842
2843int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
2844{
2845 int ret = 0;
2846 u32 idx = 0;
2847 struct radeon_cs_packet pkt;
2848
2849 do {
2850 pkt.idx = idx;
2851 pkt.type = CP_PACKET_GET_TYPE(ib->ptr[idx]);
2852 pkt.count = CP_PACKET_GET_COUNT(ib->ptr[idx]);
2853 pkt.one_reg_wr = 0;
2854 switch (pkt.type) {
2855 case PACKET_TYPE0:
2856 dev_err(rdev->dev, "Packet0 not allowed!\n");
2857 ret = -EINVAL;
2858 break;
2859 case PACKET_TYPE2:
2860 idx += 1;
2861 break;
2862 case PACKET_TYPE3:
2863 pkt.opcode = CP_PACKET3_GET_OPCODE(ib->ptr[idx]);
2864 if (ib->is_const_ib)
2865 ret = si_vm_packet3_ce_check(rdev, ib->ptr, &pkt);
2866 else {
2867 switch (ib->fence->ring) {
2868 case RADEON_RING_TYPE_GFX_INDEX:
2869 ret = si_vm_packet3_gfx_check(rdev, ib->ptr, &pkt);
2870 break;
2871 case CAYMAN_RING_TYPE_CP1_INDEX:
2872 case CAYMAN_RING_TYPE_CP2_INDEX:
2873 ret = si_vm_packet3_compute_check(rdev, ib->ptr, &pkt);
2874 break;
2875 default:
2876 dev_err(rdev->dev, "Non-PM4 ring %d !\n", ib->fence->ring);
2877 ret = -EINVAL;
2878 break;
2879 }
2880 }
2881 idx += pkt.count + 2;
2882 break;
2883 default:
2884 dev_err(rdev->dev, "Unknown packet type %d !\n", pkt.type);
2885 ret = -EINVAL;
2886 break;
2887 }
2888 if (ret)
2889 break;
2890 } while (idx < ib->length_dw);
2891
2892 return ret;
2893}
2894
2895/*
2896 * vm
2897 */
2898int si_vm_init(struct radeon_device *rdev)
2899{
2900 /* number of VMs */
2901 rdev->vm_manager.nvm = 16;
2902 /* base offset of vram pages */
2903 rdev->vm_manager.vram_base_offset = 0;
2904
2905 return 0;
2906}
2907
2908void si_vm_fini(struct radeon_device *rdev)
2909{
2910}
2911
2912int si_vm_bind(struct radeon_device *rdev, struct radeon_vm *vm, int id)
2913{
2914 if (id < 8)
2915 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (id << 2), vm->pt_gpu_addr >> 12);
2916 else
2917 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((id - 8) << 2),
2918 vm->pt_gpu_addr >> 12);
2919 /* flush hdp cache */
2920 WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
2921 /* bits 0-15 are the VM contexts0-15 */
2922 WREG32(VM_INVALIDATE_REQUEST, 1 << id);
2923 return 0;
2924}
2925
2926void si_vm_unbind(struct radeon_device *rdev, struct radeon_vm *vm)
2927{
2928 if (vm->id < 8)
2929 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (vm->id << 2), 0);
2930 else
2931 WREG32(VM_CONTEXT8_PAGE_TABLE_BASE_ADDR + ((vm->id - 8) << 2), 0);
2932 /* flush hdp cache */
2933 WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
2934 /* bits 0-15 are the VM contexts0-15 */
2935 WREG32(VM_INVALIDATE_REQUEST, 1 << vm->id);
2936}
2937
2938void si_vm_tlb_flush(struct radeon_device *rdev, struct radeon_vm *vm)
2939{
2940 if (vm->id == -1)
2941 return;
2942
2943 /* flush hdp cache */
2944 WREG32(HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
2945 /* bits 0-15 are the VM contexts0-15 */
2946 WREG32(VM_INVALIDATE_REQUEST, 1 << vm->id);
2947}
2948
2949/*
2950 * RLC
2951 */
2952void si_rlc_fini(struct radeon_device *rdev)
2953{
2954 int r;
2955
2956 /* save restore block */
2957 if (rdev->rlc.save_restore_obj) {
2958 r = radeon_bo_reserve(rdev->rlc.save_restore_obj, false);
2959 if (unlikely(r != 0))
2960 dev_warn(rdev->dev, "(%d) reserve RLC sr bo failed\n", r);
2961 radeon_bo_unpin(rdev->rlc.save_restore_obj);
2962 radeon_bo_unreserve(rdev->rlc.save_restore_obj);
2963
2964 radeon_bo_unref(&rdev->rlc.save_restore_obj);
2965 rdev->rlc.save_restore_obj = NULL;
2966 }
2967
2968 /* clear state block */
2969 if (rdev->rlc.clear_state_obj) {
2970 r = radeon_bo_reserve(rdev->rlc.clear_state_obj, false);
2971 if (unlikely(r != 0))
2972 dev_warn(rdev->dev, "(%d) reserve RLC c bo failed\n", r);
2973 radeon_bo_unpin(rdev->rlc.clear_state_obj);
2974 radeon_bo_unreserve(rdev->rlc.clear_state_obj);
2975
2976 radeon_bo_unref(&rdev->rlc.clear_state_obj);
2977 rdev->rlc.clear_state_obj = NULL;
2978 }
2979}
2980
2981int si_rlc_init(struct radeon_device *rdev)
2982{
2983 int r;
2984
2985 /* save restore block */
2986 if (rdev->rlc.save_restore_obj == NULL) {
2987 r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
2988 RADEON_GEM_DOMAIN_VRAM, &rdev->rlc.save_restore_obj);
2989 if (r) {
2990 dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r);
2991 return r;
2992 }
2993 }
2994
2995 r = radeon_bo_reserve(rdev->rlc.save_restore_obj, false);
2996 if (unlikely(r != 0)) {
2997 si_rlc_fini(rdev);
2998 return r;
2999 }
3000 r = radeon_bo_pin(rdev->rlc.save_restore_obj, RADEON_GEM_DOMAIN_VRAM,
3001 &rdev->rlc.save_restore_gpu_addr);
3002 if (r) {
3003 radeon_bo_unreserve(rdev->rlc.save_restore_obj);
3004 dev_warn(rdev->dev, "(%d) pin RLC sr bo failed\n", r);
3005 si_rlc_fini(rdev);
3006 return r;
3007 }
3008
3009 /* clear state block */
3010 if (rdev->rlc.clear_state_obj == NULL) {
3011 r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
3012 RADEON_GEM_DOMAIN_VRAM, &rdev->rlc.clear_state_obj);
3013 if (r) {
3014 dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r);
3015 si_rlc_fini(rdev);
3016 return r;
3017 }
3018 }
3019 r = radeon_bo_reserve(rdev->rlc.clear_state_obj, false);
3020 if (unlikely(r != 0)) {
3021 si_rlc_fini(rdev);
3022 return r;
3023 }
3024 r = radeon_bo_pin(rdev->rlc.clear_state_obj, RADEON_GEM_DOMAIN_VRAM,
3025 &rdev->rlc.clear_state_gpu_addr);
3026 if (r) {
3027
3028 radeon_bo_unreserve(rdev->rlc.clear_state_obj);
3029 dev_warn(rdev->dev, "(%d) pin RLC c bo failed\n", r);
3030 si_rlc_fini(rdev);
3031 return r;
3032 }
3033
3034 return 0;
3035}
3036
3037static void si_rlc_stop(struct radeon_device *rdev)
3038{
3039 WREG32(RLC_CNTL, 0);
3040}
3041
3042static void si_rlc_start(struct radeon_device *rdev)
3043{
3044 WREG32(RLC_CNTL, RLC_ENABLE);
3045}
3046
3047static int si_rlc_resume(struct radeon_device *rdev)
3048{
3049 u32 i;
3050 const __be32 *fw_data;
3051
3052 if (!rdev->rlc_fw)
3053 return -EINVAL;
3054
3055 si_rlc_stop(rdev);
3056
3057 WREG32(RLC_RL_BASE, 0);
3058 WREG32(RLC_RL_SIZE, 0);
3059 WREG32(RLC_LB_CNTL, 0);
3060 WREG32(RLC_LB_CNTR_MAX, 0xffffffff);
3061 WREG32(RLC_LB_CNTR_INIT, 0);
3062
3063 WREG32(RLC_SAVE_AND_RESTORE_BASE, rdev->rlc.save_restore_gpu_addr >> 8);
3064 WREG32(RLC_CLEAR_STATE_RESTORE_BASE, rdev->rlc.clear_state_gpu_addr >> 8);
3065
3066 WREG32(RLC_MC_CNTL, 0);
3067 WREG32(RLC_UCODE_CNTL, 0);
3068
3069 fw_data = (const __be32 *)rdev->rlc_fw->data;
3070 for (i = 0; i < SI_RLC_UCODE_SIZE; i++) {
3071 WREG32(RLC_UCODE_ADDR, i);
3072 WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++));
3073 }
3074 WREG32(RLC_UCODE_ADDR, 0);
3075
3076 si_rlc_start(rdev);
3077
3078 return 0;
3079}
3080
3081static void si_enable_interrupts(struct radeon_device *rdev)
3082{
3083 u32 ih_cntl = RREG32(IH_CNTL);
3084 u32 ih_rb_cntl = RREG32(IH_RB_CNTL);
3085
3086 ih_cntl |= ENABLE_INTR;
3087 ih_rb_cntl |= IH_RB_ENABLE;
3088 WREG32(IH_CNTL, ih_cntl);
3089 WREG32(IH_RB_CNTL, ih_rb_cntl);
3090 rdev->ih.enabled = true;
3091}
3092
3093static void si_disable_interrupts(struct radeon_device *rdev)
3094{
3095 u32 ih_rb_cntl = RREG32(IH_RB_CNTL);
3096 u32 ih_cntl = RREG32(IH_CNTL);
3097
3098 ih_rb_cntl &= ~IH_RB_ENABLE;
3099 ih_cntl &= ~ENABLE_INTR;
3100 WREG32(IH_RB_CNTL, ih_rb_cntl);
3101 WREG32(IH_CNTL, ih_cntl);
3102 /* set rptr, wptr to 0 */
3103 WREG32(IH_RB_RPTR, 0);
3104 WREG32(IH_RB_WPTR, 0);
3105 rdev->ih.enabled = false;
3106 rdev->ih.wptr = 0;
3107 rdev->ih.rptr = 0;
3108}
3109
3110static void si_disable_interrupt_state(struct radeon_device *rdev)
3111{
3112 u32 tmp;
3113
3114 WREG32(CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE);
3115 WREG32(CP_INT_CNTL_RING1, 0);
3116 WREG32(CP_INT_CNTL_RING2, 0);
3117 WREG32(GRBM_INT_CNTL, 0);
3118 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0);
3119 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0);
3120 if (rdev->num_crtc >= 4) {
3121 WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0);
3122 WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0);
3123 }
3124 if (rdev->num_crtc >= 6) {
3125 WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0);
3126 WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0);
3127 }
3128
3129 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0);
3130 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0);
3131 if (rdev->num_crtc >= 4) {
3132 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0);
3133 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0);
3134 }
3135 if (rdev->num_crtc >= 6) {
3136 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0);
3137 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0);
3138 }
3139
3140 WREG32(DACA_AUTODETECT_INT_CONTROL, 0);
3141
3142 tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3143 WREG32(DC_HPD1_INT_CONTROL, tmp);
3144 tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3145 WREG32(DC_HPD2_INT_CONTROL, tmp);
3146 tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3147 WREG32(DC_HPD3_INT_CONTROL, tmp);
3148 tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3149 WREG32(DC_HPD4_INT_CONTROL, tmp);
3150 tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3151 WREG32(DC_HPD5_INT_CONTROL, tmp);
3152 tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY;
3153 WREG32(DC_HPD6_INT_CONTROL, tmp);
3154
3155}
3156
3157static int si_irq_init(struct radeon_device *rdev)
3158{
3159 int ret = 0;
3160 int rb_bufsz;
3161 u32 interrupt_cntl, ih_cntl, ih_rb_cntl;
3162
3163 /* allocate ring */
3164 ret = r600_ih_ring_alloc(rdev);
3165 if (ret)
3166 return ret;
3167
3168 /* disable irqs */
3169 si_disable_interrupts(rdev);
3170
3171 /* init rlc */
3172 ret = si_rlc_resume(rdev);
3173 if (ret) {
3174 r600_ih_ring_fini(rdev);
3175 return ret;
3176 }
3177
3178 /* setup interrupt control */
3179 /* set dummy read address to ring address */
3180 WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8);
3181 interrupt_cntl = RREG32(INTERRUPT_CNTL);
3182 /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi
3183 * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN
3184 */
3185 interrupt_cntl &= ~IH_DUMMY_RD_OVERRIDE;
3186 /* IH_REQ_NONSNOOP_EN=1 if ring is in non-cacheable memory, e.g., vram */
3187 interrupt_cntl &= ~IH_REQ_NONSNOOP_EN;
3188 WREG32(INTERRUPT_CNTL, interrupt_cntl);
3189
3190 WREG32(IH_RB_BASE, rdev->ih.gpu_addr >> 8);
3191 rb_bufsz = drm_order(rdev->ih.ring_size / 4);
3192
3193 ih_rb_cntl = (IH_WPTR_OVERFLOW_ENABLE |
3194 IH_WPTR_OVERFLOW_CLEAR |
3195 (rb_bufsz << 1));
3196
3197 if (rdev->wb.enabled)
3198 ih_rb_cntl |= IH_WPTR_WRITEBACK_ENABLE;
3199
3200 /* set the writeback address whether it's enabled or not */
3201 WREG32(IH_RB_WPTR_ADDR_LO, (rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFFFFFFFC);
3202 WREG32(IH_RB_WPTR_ADDR_HI, upper_32_bits(rdev->wb.gpu_addr + R600_WB_IH_WPTR_OFFSET) & 0xFF);
3203
3204 WREG32(IH_RB_CNTL, ih_rb_cntl);
3205
3206 /* set rptr, wptr to 0 */
3207 WREG32(IH_RB_RPTR, 0);
3208 WREG32(IH_RB_WPTR, 0);
3209
3210 /* Default settings for IH_CNTL (disabled at first) */
3211 ih_cntl = MC_WRREQ_CREDIT(0x10) | MC_WR_CLEAN_CNT(0x10) | MC_VMID(0);
3212 /* RPTR_REARM only works if msi's are enabled */
3213 if (rdev->msi_enabled)
3214 ih_cntl |= RPTR_REARM;
3215 WREG32(IH_CNTL, ih_cntl);
3216
3217 /* force the active interrupt state to all disabled */
3218 si_disable_interrupt_state(rdev);
3219
3220 /* enable irqs */
3221 si_enable_interrupts(rdev);
3222
3223 return ret;
3224}
3225
3226int si_irq_set(struct radeon_device *rdev)
3227{
3228 u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE;
3229 u32 cp_int_cntl1 = 0, cp_int_cntl2 = 0;
3230 u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0;
3231 u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6;
3232 u32 grbm_int_cntl = 0;
3233 u32 grph1 = 0, grph2 = 0, grph3 = 0, grph4 = 0, grph5 = 0, grph6 = 0;
3234
3235 if (!rdev->irq.installed) {
3236 WARN(1, "Can't enable IRQ/MSI because no handler is installed\n");
3237 return -EINVAL;
3238 }
3239 /* don't enable anything if the ih is disabled */
3240 if (!rdev->ih.enabled) {
3241 si_disable_interrupts(rdev);
3242 /* force the active interrupt state to all disabled */
3243 si_disable_interrupt_state(rdev);
3244 return 0;
3245 }
3246
3247 hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN;
3248 hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN;
3249 hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN;
3250 hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN;
3251 hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN;
3252 hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN;
3253
3254 /* enable CP interrupts on all rings */
3255 if (rdev->irq.sw_int[RADEON_RING_TYPE_GFX_INDEX]) {
3256 DRM_DEBUG("si_irq_set: sw int gfx\n");
3257 cp_int_cntl |= TIME_STAMP_INT_ENABLE;
3258 }
3259 if (rdev->irq.sw_int[CAYMAN_RING_TYPE_CP1_INDEX]) {
3260 DRM_DEBUG("si_irq_set: sw int cp1\n");
3261 cp_int_cntl1 |= TIME_STAMP_INT_ENABLE;
3262 }
3263 if (rdev->irq.sw_int[CAYMAN_RING_TYPE_CP2_INDEX]) {
3264 DRM_DEBUG("si_irq_set: sw int cp2\n");
3265 cp_int_cntl2 |= TIME_STAMP_INT_ENABLE;
3266 }
3267 if (rdev->irq.crtc_vblank_int[0] ||
3268 rdev->irq.pflip[0]) {
3269 DRM_DEBUG("si_irq_set: vblank 0\n");
3270 crtc1 |= VBLANK_INT_MASK;
3271 }
3272 if (rdev->irq.crtc_vblank_int[1] ||
3273 rdev->irq.pflip[1]) {
3274 DRM_DEBUG("si_irq_set: vblank 1\n");
3275 crtc2 |= VBLANK_INT_MASK;
3276 }
3277 if (rdev->irq.crtc_vblank_int[2] ||
3278 rdev->irq.pflip[2]) {
3279 DRM_DEBUG("si_irq_set: vblank 2\n");
3280 crtc3 |= VBLANK_INT_MASK;
3281 }
3282 if (rdev->irq.crtc_vblank_int[3] ||
3283 rdev->irq.pflip[3]) {
3284 DRM_DEBUG("si_irq_set: vblank 3\n");
3285 crtc4 |= VBLANK_INT_MASK;
3286 }
3287 if (rdev->irq.crtc_vblank_int[4] ||
3288 rdev->irq.pflip[4]) {
3289 DRM_DEBUG("si_irq_set: vblank 4\n");
3290 crtc5 |= VBLANK_INT_MASK;
3291 }
3292 if (rdev->irq.crtc_vblank_int[5] ||
3293 rdev->irq.pflip[5]) {
3294 DRM_DEBUG("si_irq_set: vblank 5\n");
3295 crtc6 |= VBLANK_INT_MASK;
3296 }
3297 if (rdev->irq.hpd[0]) {
3298 DRM_DEBUG("si_irq_set: hpd 1\n");
3299 hpd1 |= DC_HPDx_INT_EN;
3300 }
3301 if (rdev->irq.hpd[1]) {
3302 DRM_DEBUG("si_irq_set: hpd 2\n");
3303 hpd2 |= DC_HPDx_INT_EN;
3304 }
3305 if (rdev->irq.hpd[2]) {
3306 DRM_DEBUG("si_irq_set: hpd 3\n");
3307 hpd3 |= DC_HPDx_INT_EN;
3308 }
3309 if (rdev->irq.hpd[3]) {
3310 DRM_DEBUG("si_irq_set: hpd 4\n");
3311 hpd4 |= DC_HPDx_INT_EN;
3312 }
3313 if (rdev->irq.hpd[4]) {
3314 DRM_DEBUG("si_irq_set: hpd 5\n");
3315 hpd5 |= DC_HPDx_INT_EN;
3316 }
3317 if (rdev->irq.hpd[5]) {
3318 DRM_DEBUG("si_irq_set: hpd 6\n");
3319 hpd6 |= DC_HPDx_INT_EN;
3320 }
3321 if (rdev->irq.gui_idle) {
3322 DRM_DEBUG("gui idle\n");
3323 grbm_int_cntl |= GUI_IDLE_INT_ENABLE;
3324 }
3325
3326 WREG32(CP_INT_CNTL_RING0, cp_int_cntl);
3327 WREG32(CP_INT_CNTL_RING1, cp_int_cntl1);
3328 WREG32(CP_INT_CNTL_RING2, cp_int_cntl2);
3329
3330 WREG32(GRBM_INT_CNTL, grbm_int_cntl);
3331
3332 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1);
3333 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2);
3334 if (rdev->num_crtc >= 4) {
3335 WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3);
3336 WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4);
3337 }
3338 if (rdev->num_crtc >= 6) {
3339 WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5);
3340 WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6);
3341 }
3342
3343 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, grph1);
3344 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, grph2);
3345 if (rdev->num_crtc >= 4) {
3346 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, grph3);
3347 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, grph4);
3348 }
3349 if (rdev->num_crtc >= 6) {
3350 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, grph5);
3351 WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, grph6);
3352 }
3353
3354 WREG32(DC_HPD1_INT_CONTROL, hpd1);
3355 WREG32(DC_HPD2_INT_CONTROL, hpd2);
3356 WREG32(DC_HPD3_INT_CONTROL, hpd3);
3357 WREG32(DC_HPD4_INT_CONTROL, hpd4);
3358 WREG32(DC_HPD5_INT_CONTROL, hpd5);
3359 WREG32(DC_HPD6_INT_CONTROL, hpd6);
3360
3361 return 0;
3362}
3363
3364static inline void si_irq_ack(struct radeon_device *rdev)
3365{
3366 u32 tmp;
3367
3368 rdev->irq.stat_regs.evergreen.disp_int = RREG32(DISP_INTERRUPT_STATUS);
3369 rdev->irq.stat_regs.evergreen.disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE);
3370 rdev->irq.stat_regs.evergreen.disp_int_cont2 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE2);
3371 rdev->irq.stat_regs.evergreen.disp_int_cont3 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE3);
3372 rdev->irq.stat_regs.evergreen.disp_int_cont4 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE4);
3373 rdev->irq.stat_regs.evergreen.disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5);
3374 rdev->irq.stat_regs.evergreen.d1grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET);
3375 rdev->irq.stat_regs.evergreen.d2grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET);
3376 if (rdev->num_crtc >= 4) {
3377 rdev->irq.stat_regs.evergreen.d3grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET);
3378 rdev->irq.stat_regs.evergreen.d4grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET);
3379 }
3380 if (rdev->num_crtc >= 6) {
3381 rdev->irq.stat_regs.evergreen.d5grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET);
3382 rdev->irq.stat_regs.evergreen.d6grph_int = RREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET);
3383 }
3384
3385 if (rdev->irq.stat_regs.evergreen.d1grph_int & GRPH_PFLIP_INT_OCCURRED)
3386 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3387 if (rdev->irq.stat_regs.evergreen.d2grph_int & GRPH_PFLIP_INT_OCCURRED)
3388 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3389 if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT)
3390 WREG32(VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK);
3391 if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT)
3392 WREG32(VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK);
3393 if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT)
3394 WREG32(VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK);
3395 if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT)
3396 WREG32(VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK);
3397
3398 if (rdev->num_crtc >= 4) {
3399 if (rdev->irq.stat_regs.evergreen.d3grph_int & GRPH_PFLIP_INT_OCCURRED)
3400 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3401 if (rdev->irq.stat_regs.evergreen.d4grph_int & GRPH_PFLIP_INT_OCCURRED)
3402 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3403 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT)
3404 WREG32(VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK);
3405 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT)
3406 WREG32(VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK);
3407 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT)
3408 WREG32(VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK);
3409 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT)
3410 WREG32(VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK);
3411 }
3412
3413 if (rdev->num_crtc >= 6) {
3414 if (rdev->irq.stat_regs.evergreen.d5grph_int & GRPH_PFLIP_INT_OCCURRED)
3415 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3416 if (rdev->irq.stat_regs.evergreen.d6grph_int & GRPH_PFLIP_INT_OCCURRED)
3417 WREG32(GRPH_INT_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, GRPH_PFLIP_INT_CLEAR);
3418 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT)
3419 WREG32(VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK);
3420 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT)
3421 WREG32(VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK);
3422 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT)
3423 WREG32(VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK);
3424 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT)
3425 WREG32(VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK);
3426 }
3427
3428 if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) {
3429 tmp = RREG32(DC_HPD1_INT_CONTROL);
3430 tmp |= DC_HPDx_INT_ACK;
3431 WREG32(DC_HPD1_INT_CONTROL, tmp);
3432 }
3433 if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) {
3434 tmp = RREG32(DC_HPD2_INT_CONTROL);
3435 tmp |= DC_HPDx_INT_ACK;
3436 WREG32(DC_HPD2_INT_CONTROL, tmp);
3437 }
3438 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) {
3439 tmp = RREG32(DC_HPD3_INT_CONTROL);
3440 tmp |= DC_HPDx_INT_ACK;
3441 WREG32(DC_HPD3_INT_CONTROL, tmp);
3442 }
3443 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) {
3444 tmp = RREG32(DC_HPD4_INT_CONTROL);
3445 tmp |= DC_HPDx_INT_ACK;
3446 WREG32(DC_HPD4_INT_CONTROL, tmp);
3447 }
3448 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) {
3449 tmp = RREG32(DC_HPD5_INT_CONTROL);
3450 tmp |= DC_HPDx_INT_ACK;
3451 WREG32(DC_HPD5_INT_CONTROL, tmp);
3452 }
3453 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) {
3454 tmp = RREG32(DC_HPD5_INT_CONTROL);
3455 tmp |= DC_HPDx_INT_ACK;
3456 WREG32(DC_HPD6_INT_CONTROL, tmp);
3457 }
3458}
3459
3460static void si_irq_disable(struct radeon_device *rdev)
3461{
3462 si_disable_interrupts(rdev);
3463 /* Wait and acknowledge irq */
3464 mdelay(1);
3465 si_irq_ack(rdev);
3466 si_disable_interrupt_state(rdev);
3467}
3468
3469static void si_irq_suspend(struct radeon_device *rdev)
3470{
3471 si_irq_disable(rdev);
3472 si_rlc_stop(rdev);
3473}
3474
3475static void si_irq_fini(struct radeon_device *rdev)
3476{
3477 si_irq_suspend(rdev);
3478 r600_ih_ring_fini(rdev);
3479}
3480
3481static inline u32 si_get_ih_wptr(struct radeon_device *rdev)
3482{
3483 u32 wptr, tmp;
3484
3485 if (rdev->wb.enabled)
3486 wptr = le32_to_cpu(rdev->wb.wb[R600_WB_IH_WPTR_OFFSET/4]);
3487 else
3488 wptr = RREG32(IH_RB_WPTR);
3489
3490 if (wptr & RB_OVERFLOW) {
3491 /* When a ring buffer overflow happen start parsing interrupt
3492 * from the last not overwritten vector (wptr + 16). Hopefully
3493 * this should allow us to catchup.
3494 */
3495 dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n",
3496 wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask);
3497 rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask;
3498 tmp = RREG32(IH_RB_CNTL);
3499 tmp |= IH_WPTR_OVERFLOW_CLEAR;
3500 WREG32(IH_RB_CNTL, tmp);
3501 }
3502 return (wptr & rdev->ih.ptr_mask);
3503}
3504
3505/* SI IV Ring
3506 * Each IV ring entry is 128 bits:
3507 * [7:0] - interrupt source id
3508 * [31:8] - reserved
3509 * [59:32] - interrupt source data
3510 * [63:60] - reserved
3511 * [71:64] - RINGID
3512 * [79:72] - VMID
3513 * [127:80] - reserved
3514 */
3515int si_irq_process(struct radeon_device *rdev)
3516{
3517 u32 wptr;
3518 u32 rptr;
3519 u32 src_id, src_data, ring_id;
3520 u32 ring_index;
3521 unsigned long flags;
3522 bool queue_hotplug = false;
3523
3524 if (!rdev->ih.enabled || rdev->shutdown)
3525 return IRQ_NONE;
3526
3527 wptr = si_get_ih_wptr(rdev);
3528 rptr = rdev->ih.rptr;
3529 DRM_DEBUG("si_irq_process start: rptr %d, wptr %d\n", rptr, wptr);
3530
3531 spin_lock_irqsave(&rdev->ih.lock, flags);
3532 if (rptr == wptr) {
3533 spin_unlock_irqrestore(&rdev->ih.lock, flags);
3534 return IRQ_NONE;
3535 }
3536restart_ih:
3537 /* Order reading of wptr vs. reading of IH ring data */
3538 rmb();
3539
3540 /* display interrupts */
3541 si_irq_ack(rdev);
3542
3543 rdev->ih.wptr = wptr;
3544 while (rptr != wptr) {
3545 /* wptr/rptr are in bytes! */
3546 ring_index = rptr / 4;
3547 src_id = le32_to_cpu(rdev->ih.ring[ring_index]) & 0xff;
3548 src_data = le32_to_cpu(rdev->ih.ring[ring_index + 1]) & 0xfffffff;
3549 ring_id = le32_to_cpu(rdev->ih.ring[ring_index + 2]) & 0xff;
3550
3551 switch (src_id) {
3552 case 1: /* D1 vblank/vline */
3553 switch (src_data) {
3554 case 0: /* D1 vblank */
3555 if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VBLANK_INTERRUPT) {
3556 if (rdev->irq.crtc_vblank_int[0]) {
3557 drm_handle_vblank(rdev->ddev, 0);
3558 rdev->pm.vblank_sync = true;
3559 wake_up(&rdev->irq.vblank_queue);
3560 }
3561 if (rdev->irq.pflip[0])
3562 radeon_crtc_handle_flip(rdev, 0);
3563 rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VBLANK_INTERRUPT;
3564 DRM_DEBUG("IH: D1 vblank\n");
3565 }
3566 break;
3567 case 1: /* D1 vline */
3568 if (rdev->irq.stat_regs.evergreen.disp_int & LB_D1_VLINE_INTERRUPT) {
3569 rdev->irq.stat_regs.evergreen.disp_int &= ~LB_D1_VLINE_INTERRUPT;
3570 DRM_DEBUG("IH: D1 vline\n");
3571 }
3572 break;
3573 default:
3574 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3575 break;
3576 }
3577 break;
3578 case 2: /* D2 vblank/vline */
3579 switch (src_data) {
3580 case 0: /* D2 vblank */
3581 if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VBLANK_INTERRUPT) {
3582 if (rdev->irq.crtc_vblank_int[1]) {
3583 drm_handle_vblank(rdev->ddev, 1);
3584 rdev->pm.vblank_sync = true;
3585 wake_up(&rdev->irq.vblank_queue);
3586 }
3587 if (rdev->irq.pflip[1])
3588 radeon_crtc_handle_flip(rdev, 1);
3589 rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT;
3590 DRM_DEBUG("IH: D2 vblank\n");
3591 }
3592 break;
3593 case 1: /* D2 vline */
3594 if (rdev->irq.stat_regs.evergreen.disp_int_cont & LB_D2_VLINE_INTERRUPT) {
3595 rdev->irq.stat_regs.evergreen.disp_int_cont &= ~LB_D2_VLINE_INTERRUPT;
3596 DRM_DEBUG("IH: D2 vline\n");
3597 }
3598 break;
3599 default:
3600 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3601 break;
3602 }
3603 break;
3604 case 3: /* D3 vblank/vline */
3605 switch (src_data) {
3606 case 0: /* D3 vblank */
3607 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) {
3608 if (rdev->irq.crtc_vblank_int[2]) {
3609 drm_handle_vblank(rdev->ddev, 2);
3610 rdev->pm.vblank_sync = true;
3611 wake_up(&rdev->irq.vblank_queue);
3612 }
3613 if (rdev->irq.pflip[2])
3614 radeon_crtc_handle_flip(rdev, 2);
3615 rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT;
3616 DRM_DEBUG("IH: D3 vblank\n");
3617 }
3618 break;
3619 case 1: /* D3 vline */
3620 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & LB_D3_VLINE_INTERRUPT) {
3621 rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT;
3622 DRM_DEBUG("IH: D3 vline\n");
3623 }
3624 break;
3625 default:
3626 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3627 break;
3628 }
3629 break;
3630 case 4: /* D4 vblank/vline */
3631 switch (src_data) {
3632 case 0: /* D4 vblank */
3633 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) {
3634 if (rdev->irq.crtc_vblank_int[3]) {
3635 drm_handle_vblank(rdev->ddev, 3);
3636 rdev->pm.vblank_sync = true;
3637 wake_up(&rdev->irq.vblank_queue);
3638 }
3639 if (rdev->irq.pflip[3])
3640 radeon_crtc_handle_flip(rdev, 3);
3641 rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT;
3642 DRM_DEBUG("IH: D4 vblank\n");
3643 }
3644 break;
3645 case 1: /* D4 vline */
3646 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & LB_D4_VLINE_INTERRUPT) {
3647 rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT;
3648 DRM_DEBUG("IH: D4 vline\n");
3649 }
3650 break;
3651 default:
3652 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3653 break;
3654 }
3655 break;
3656 case 5: /* D5 vblank/vline */
3657 switch (src_data) {
3658 case 0: /* D5 vblank */
3659 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) {
3660 if (rdev->irq.crtc_vblank_int[4]) {
3661 drm_handle_vblank(rdev->ddev, 4);
3662 rdev->pm.vblank_sync = true;
3663 wake_up(&rdev->irq.vblank_queue);
3664 }
3665 if (rdev->irq.pflip[4])
3666 radeon_crtc_handle_flip(rdev, 4);
3667 rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT;
3668 DRM_DEBUG("IH: D5 vblank\n");
3669 }
3670 break;
3671 case 1: /* D5 vline */
3672 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & LB_D5_VLINE_INTERRUPT) {
3673 rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT;
3674 DRM_DEBUG("IH: D5 vline\n");
3675 }
3676 break;
3677 default:
3678 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3679 break;
3680 }
3681 break;
3682 case 6: /* D6 vblank/vline */
3683 switch (src_data) {
3684 case 0: /* D6 vblank */
3685 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) {
3686 if (rdev->irq.crtc_vblank_int[5]) {
3687 drm_handle_vblank(rdev->ddev, 5);
3688 rdev->pm.vblank_sync = true;
3689 wake_up(&rdev->irq.vblank_queue);
3690 }
3691 if (rdev->irq.pflip[5])
3692 radeon_crtc_handle_flip(rdev, 5);
3693 rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT;
3694 DRM_DEBUG("IH: D6 vblank\n");
3695 }
3696 break;
3697 case 1: /* D6 vline */
3698 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & LB_D6_VLINE_INTERRUPT) {
3699 rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT;
3700 DRM_DEBUG("IH: D6 vline\n");
3701 }
3702 break;
3703 default:
3704 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3705 break;
3706 }
3707 break;
3708 case 42: /* HPD hotplug */
3709 switch (src_data) {
3710 case 0:
3711 if (rdev->irq.stat_regs.evergreen.disp_int & DC_HPD1_INTERRUPT) {
3712 rdev->irq.stat_regs.evergreen.disp_int &= ~DC_HPD1_INTERRUPT;
3713 queue_hotplug = true;
3714 DRM_DEBUG("IH: HPD1\n");
3715 }
3716 break;
3717 case 1:
3718 if (rdev->irq.stat_regs.evergreen.disp_int_cont & DC_HPD2_INTERRUPT) {
3719 rdev->irq.stat_regs.evergreen.disp_int_cont &= ~DC_HPD2_INTERRUPT;
3720 queue_hotplug = true;
3721 DRM_DEBUG("IH: HPD2\n");
3722 }
3723 break;
3724 case 2:
3725 if (rdev->irq.stat_regs.evergreen.disp_int_cont2 & DC_HPD3_INTERRUPT) {
3726 rdev->irq.stat_regs.evergreen.disp_int_cont2 &= ~DC_HPD3_INTERRUPT;
3727 queue_hotplug = true;
3728 DRM_DEBUG("IH: HPD3\n");
3729 }
3730 break;
3731 case 3:
3732 if (rdev->irq.stat_regs.evergreen.disp_int_cont3 & DC_HPD4_INTERRUPT) {
3733 rdev->irq.stat_regs.evergreen.disp_int_cont3 &= ~DC_HPD4_INTERRUPT;
3734 queue_hotplug = true;
3735 DRM_DEBUG("IH: HPD4\n");
3736 }
3737 break;
3738 case 4:
3739 if (rdev->irq.stat_regs.evergreen.disp_int_cont4 & DC_HPD5_INTERRUPT) {
3740 rdev->irq.stat_regs.evergreen.disp_int_cont4 &= ~DC_HPD5_INTERRUPT;
3741 queue_hotplug = true;
3742 DRM_DEBUG("IH: HPD5\n");
3743 }
3744 break;
3745 case 5:
3746 if (rdev->irq.stat_regs.evergreen.disp_int_cont5 & DC_HPD6_INTERRUPT) {
3747 rdev->irq.stat_regs.evergreen.disp_int_cont5 &= ~DC_HPD6_INTERRUPT;
3748 queue_hotplug = true;
3749 DRM_DEBUG("IH: HPD6\n");
3750 }
3751 break;
3752 default:
3753 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3754 break;
3755 }
3756 break;
3757 case 176: /* RINGID0 CP_INT */
3758 radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX);
3759 break;
3760 case 177: /* RINGID1 CP_INT */
3761 radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP1_INDEX);
3762 break;
3763 case 178: /* RINGID2 CP_INT */
3764 radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP2_INDEX);
3765 break;
3766 case 181: /* CP EOP event */
3767 DRM_DEBUG("IH: CP EOP\n");
3768 switch (ring_id) {
3769 case 0:
3770 radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX);
3771 break;
3772 case 1:
3773 radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP1_INDEX);
3774 break;
3775 case 2:
3776 radeon_fence_process(rdev, CAYMAN_RING_TYPE_CP2_INDEX);
3777 break;
3778 }
3779 break;
3780 case 233: /* GUI IDLE */
3781 DRM_DEBUG("IH: GUI idle\n");
3782 rdev->pm.gui_idle = true;
3783 wake_up(&rdev->irq.idle_queue);
3784 break;
3785 default:
3786 DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data);
3787 break;
3788 }
3789
3790 /* wptr/rptr are in bytes! */
3791 rptr += 16;
3792 rptr &= rdev->ih.ptr_mask;
3793 }
3794 /* make sure wptr hasn't changed while processing */
3795 wptr = si_get_ih_wptr(rdev);
3796 if (wptr != rdev->ih.wptr)
3797 goto restart_ih;
3798 if (queue_hotplug)
3799 schedule_work(&rdev->hotplug_work);
3800 rdev->ih.rptr = rptr;
3801 WREG32(IH_RB_RPTR, rdev->ih.rptr);
3802 spin_unlock_irqrestore(&rdev->ih.lock, flags);
3803 return IRQ_HANDLED;
3804}
3805
3806/*
3807 * startup/shutdown callbacks
3808 */
3809static int si_startup(struct radeon_device *rdev)
3810{
3811 struct radeon_ring *ring;
3812 int r;
3813
3814 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
3815 !rdev->rlc_fw || !rdev->mc_fw) {
3816 r = si_init_microcode(rdev);
3817 if (r) {
3818 DRM_ERROR("Failed to load firmware!\n");
3819 return r;
3820 }
3821 }
3822
3823 r = si_mc_load_microcode(rdev);
3824 if (r) {
3825 DRM_ERROR("Failed to load MC firmware!\n");
3826 return r;
3827 }
3828
3829 r = r600_vram_scratch_init(rdev);
3830 if (r)
3831 return r;
3832
3833 si_mc_program(rdev);
3834 r = si_pcie_gart_enable(rdev);
3835 if (r)
3836 return r;
3837 si_gpu_init(rdev);
3838
3839#if 0
3840 r = evergreen_blit_init(rdev);
3841 if (r) {
3842 r600_blit_fini(rdev);
3843 rdev->asic->copy = NULL;
3844 dev_warn(rdev->dev, "failed blitter (%d) falling back to memcpy\n", r);
3845 }
3846#endif
3847 /* allocate rlc buffers */
3848 r = si_rlc_init(rdev);
3849 if (r) {
3850 DRM_ERROR("Failed to init rlc BOs!\n");
3851 return r;
3852 }
3853
3854 /* allocate wb buffer */
3855 r = radeon_wb_init(rdev);
3856 if (r)
3857 return r;
3858
3859 r = radeon_fence_driver_start_ring(rdev, RADEON_RING_TYPE_GFX_INDEX);
3860 if (r) {
3861 dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r);
3862 return r;
3863 }
3864
3865 r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP1_INDEX);
3866 if (r) {
3867 dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r);
3868 return r;
3869 }
3870
3871 r = radeon_fence_driver_start_ring(rdev, CAYMAN_RING_TYPE_CP2_INDEX);
3872 if (r) {
3873 dev_err(rdev->dev, "failed initializing CP fences (%d).\n", r);
3874 return r;
3875 }
3876
3877 /* Enable IRQ */
3878 r = si_irq_init(rdev);
3879 if (r) {
3880 DRM_ERROR("radeon: IH init failed (%d).\n", r);
3881 radeon_irq_kms_fini(rdev);
3882 return r;
3883 }
3884 si_irq_set(rdev);
3885
3886 ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
3887 r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP_RPTR_OFFSET,
3888 CP_RB0_RPTR, CP_RB0_WPTR,
3889 0, 0xfffff, RADEON_CP_PACKET2);
3890 if (r)
3891 return r;
3892
3893 ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
3894 r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP1_RPTR_OFFSET,
3895 CP_RB1_RPTR, CP_RB1_WPTR,
3896 0, 0xfffff, RADEON_CP_PACKET2);
3897 if (r)
3898 return r;
3899
3900 ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
3901 r = radeon_ring_init(rdev, ring, ring->ring_size, RADEON_WB_CP2_RPTR_OFFSET,
3902 CP_RB2_RPTR, CP_RB2_WPTR,
3903 0, 0xfffff, RADEON_CP_PACKET2);
3904 if (r)
3905 return r;
3906
3907 r = si_cp_load_microcode(rdev);
3908 if (r)
3909 return r;
3910 r = si_cp_resume(rdev);
3911 if (r)
3912 return r;
3913
3914 r = radeon_ib_pool_start(rdev);
3915 if (r)
3916 return r;
3917
3918 r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
3919 if (r) {
3920 DRM_ERROR("radeon: failed testing IB (%d) on CP ring 0\n", r);
3921 rdev->accel_working = false;
3922 return r;
3923 }
3924
3925 r = radeon_ib_test(rdev, CAYMAN_RING_TYPE_CP1_INDEX, &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX]);
3926 if (r) {
3927 DRM_ERROR("radeon: failed testing IB (%d) on CP ring 1\n", r);
3928 rdev->accel_working = false;
3929 return r;
3930 }
3931
3932 r = radeon_ib_test(rdev, CAYMAN_RING_TYPE_CP2_INDEX, &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX]);
3933 if (r) {
3934 DRM_ERROR("radeon: failed testing IB (%d) on CP ring 2\n", r);
3935 rdev->accel_working = false;
3936 return r;
3937 }
3938
3939 r = radeon_vm_manager_start(rdev);
3940 if (r)
3941 return r;
3942
3943 return 0;
3944}
3945
3946int si_resume(struct radeon_device *rdev)
3947{
3948 int r;
3949
3950 /* Do not reset GPU before posting, on rv770 hw unlike on r500 hw,
3951 * posting will perform necessary task to bring back GPU into good
3952 * shape.
3953 */
3954 /* post card */
3955 atom_asic_init(rdev->mode_info.atom_context);
3956
3957 rdev->accel_working = true;
3958 r = si_startup(rdev);
3959 if (r) {
3960 DRM_ERROR("si startup failed on resume\n");
3961 rdev->accel_working = false;
3962 return r;
3963 }
3964
3965 return r;
3966
3967}
3968
3969int si_suspend(struct radeon_device *rdev)
3970{
3971 /* FIXME: we should wait for ring to be empty */
3972 radeon_ib_pool_suspend(rdev);
3973 radeon_vm_manager_suspend(rdev);
3974#if 0
3975 r600_blit_suspend(rdev);
3976#endif
3977 si_cp_enable(rdev, false);
3978 rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false;
3979 rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
3980 rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
3981 si_irq_suspend(rdev);
3982 radeon_wb_disable(rdev);
3983 si_pcie_gart_disable(rdev);
3984 return 0;
3985}
3986
3987/* Plan is to move initialization in that function and use
3988 * helper function so that radeon_device_init pretty much
3989 * do nothing more than calling asic specific function. This
3990 * should also allow to remove a bunch of callback function
3991 * like vram_info.
3992 */
3993int si_init(struct radeon_device *rdev)
3994{
3995 struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
3996 int r;
3997
3998 /* This don't do much */
3999 r = radeon_gem_init(rdev);
4000 if (r)
4001 return r;
4002 /* Read BIOS */
4003 if (!radeon_get_bios(rdev)) {
4004 if (ASIC_IS_AVIVO(rdev))
4005 return -EINVAL;
4006 }
4007 /* Must be an ATOMBIOS */
4008 if (!rdev->is_atom_bios) {
4009 dev_err(rdev->dev, "Expecting atombios for cayman GPU\n");
4010 return -EINVAL;
4011 }
4012 r = radeon_atombios_init(rdev);
4013 if (r)
4014 return r;
4015
4016 /* Post card if necessary */
4017 if (!radeon_card_posted(rdev)) {
4018 if (!rdev->bios) {
4019 dev_err(rdev->dev, "Card not posted and no BIOS - ignoring\n");
4020 return -EINVAL;
4021 }
4022 DRM_INFO("GPU not posted. posting now...\n");
4023 atom_asic_init(rdev->mode_info.atom_context);
4024 }
4025 /* Initialize scratch registers */
4026 si_scratch_init(rdev);
4027 /* Initialize surface registers */
4028 radeon_surface_init(rdev);
4029 /* Initialize clocks */
4030 radeon_get_clock_info(rdev->ddev);
4031
4032 /* Fence driver */
4033 r = radeon_fence_driver_init(rdev);
4034 if (r)
4035 return r;
4036
4037 /* initialize memory controller */
4038 r = si_mc_init(rdev);
4039 if (r)
4040 return r;
4041 /* Memory manager */
4042 r = radeon_bo_init(rdev);
4043 if (r)
4044 return r;
4045
4046 r = radeon_irq_kms_init(rdev);
4047 if (r)
4048 return r;
4049
4050 ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
4051 ring->ring_obj = NULL;
4052 r600_ring_init(rdev, ring, 1024 * 1024);
4053
4054 ring = &rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX];
4055 ring->ring_obj = NULL;
4056 r600_ring_init(rdev, ring, 1024 * 1024);
4057
4058 ring = &rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX];
4059 ring->ring_obj = NULL;
4060 r600_ring_init(rdev, ring, 1024 * 1024);
4061
4062 rdev->ih.ring_obj = NULL;
4063 r600_ih_ring_init(rdev, 64 * 1024);
4064
4065 r = r600_pcie_gart_init(rdev);
4066 if (r)
4067 return r;
4068
4069 r = radeon_ib_pool_init(rdev);
4070 rdev->accel_working = true;
4071 if (r) {
4072 dev_err(rdev->dev, "IB initialization failed (%d).\n", r);
4073 rdev->accel_working = false;
4074 }
4075 r = radeon_vm_manager_init(rdev);
4076 if (r) {
4077 dev_err(rdev->dev, "vm manager initialization failed (%d).\n", r);
4078 }
4079
4080 r = si_startup(rdev);
4081 if (r) {
4082 dev_err(rdev->dev, "disabling GPU acceleration\n");
4083 si_cp_fini(rdev);
4084 si_irq_fini(rdev);
4085 si_rlc_fini(rdev);
4086 radeon_wb_fini(rdev);
4087 r100_ib_fini(rdev);
4088 radeon_vm_manager_fini(rdev);
4089 radeon_irq_kms_fini(rdev);
4090 si_pcie_gart_fini(rdev);
4091 rdev->accel_working = false;
4092 }
4093
4094 /* Don't start up if the MC ucode is missing.
4095 * The default clocks and voltages before the MC ucode
4096 * is loaded are not suffient for advanced operations.
4097 */
4098 if (!rdev->mc_fw) {
4099 DRM_ERROR("radeon: MC ucode required for NI+.\n");
4100 return -EINVAL;
4101 }
4102
4103 return 0;
4104}
4105
4106void si_fini(struct radeon_device *rdev)
4107{
4108#if 0
4109 r600_blit_fini(rdev);
4110#endif
4111 si_cp_fini(rdev);
4112 si_irq_fini(rdev);
4113 si_rlc_fini(rdev);
4114 radeon_wb_fini(rdev);
4115 radeon_vm_manager_fini(rdev);
4116 r100_ib_fini(rdev);
4117 radeon_irq_kms_fini(rdev);
4118 si_pcie_gart_fini(rdev);
4119 r600_vram_scratch_fini(rdev);
4120 radeon_gem_fini(rdev);
4121 radeon_semaphore_driver_fini(rdev);
4122 radeon_fence_driver_fini(rdev);
4123 radeon_bo_fini(rdev);
4124 radeon_atombios_fini(rdev);
4125 kfree(rdev->bios);
4126 rdev->bios = NULL;
4127}
4128
diff --git a/drivers/gpu/drm/radeon/si_blit_shaders.c b/drivers/gpu/drm/radeon/si_blit_shaders.c
new file mode 100644
index 000000000000..a7124b483adf
--- /dev/null
+++ b/drivers/gpu/drm/radeon/si_blit_shaders.c
@@ -0,0 +1,252 @@
1/*
2 * Copyright 2011 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Alex Deucher <alexander.deucher@amd.com>
25 */
26
27#include <linux/types.h>
28#include <linux/kernel.h>
29
30const u32 si_default_state[] =
31{
32 0xc0066900,
33 0x00000000,
34 0x00000060, /* DB_RENDER_CONTROL */
35 0x00000000, /* DB_COUNT_CONTROL */
36 0x00000000, /* DB_DEPTH_VIEW */
37 0x0000002a, /* DB_RENDER_OVERRIDE */
38 0x00000000, /* DB_RENDER_OVERRIDE2 */
39 0x00000000, /* DB_HTILE_DATA_BASE */
40
41 0xc0046900,
42 0x00000008,
43 0x00000000, /* DB_DEPTH_BOUNDS_MIN */
44 0x00000000, /* DB_DEPTH_BOUNDS_MAX */
45 0x00000000, /* DB_STENCIL_CLEAR */
46 0x00000000, /* DB_DEPTH_CLEAR */
47
48 0xc0036900,
49 0x0000000f,
50 0x00000000, /* DB_DEPTH_INFO */
51 0x00000000, /* DB_Z_INFO */
52 0x00000000, /* DB_STENCIL_INFO */
53
54 0xc0016900,
55 0x00000080,
56 0x00000000, /* PA_SC_WINDOW_OFFSET */
57
58 0xc00d6900,
59 0x00000083,
60 0x0000ffff, /* PA_SC_CLIPRECT_RULE */
61 0x00000000, /* PA_SC_CLIPRECT_0_TL */
62 0x20002000, /* PA_SC_CLIPRECT_0_BR */
63 0x00000000,
64 0x20002000,
65 0x00000000,
66 0x20002000,
67 0x00000000,
68 0x20002000,
69 0xaaaaaaaa, /* PA_SC_EDGERULE */
70 0x00000000, /* PA_SU_HARDWARE_SCREEN_OFFSET */
71 0x0000000f, /* CB_TARGET_MASK */
72 0x0000000f, /* CB_SHADER_MASK */
73
74 0xc0226900,
75 0x00000094,
76 0x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */
77 0x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */
78 0x80000000,
79 0x20002000,
80 0x80000000,
81 0x20002000,
82 0x80000000,
83 0x20002000,
84 0x80000000,
85 0x20002000,
86 0x80000000,
87 0x20002000,
88 0x80000000,
89 0x20002000,
90 0x80000000,
91 0x20002000,
92 0x80000000,
93 0x20002000,
94 0x80000000,
95 0x20002000,
96 0x80000000,
97 0x20002000,
98 0x80000000,
99 0x20002000,
100 0x80000000,
101 0x20002000,
102 0x80000000,
103 0x20002000,
104 0x80000000,
105 0x20002000,
106 0x80000000,
107 0x20002000,
108 0x00000000, /* PA_SC_VPORT_ZMIN_0 */
109 0x3f800000, /* PA_SC_VPORT_ZMAX_0 */
110
111 0xc0026900,
112 0x000000d9,
113 0x00000000, /* CP_RINGID */
114 0x00000000, /* CP_VMID */
115
116 0xc0046900,
117 0x00000100,
118 0xffffffff, /* VGT_MAX_VTX_INDX */
119 0x00000000, /* VGT_MIN_VTX_INDX */
120 0x00000000, /* VGT_INDX_OFFSET */
121 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */
122
123 0xc0046900,
124 0x00000105,
125 0x00000000, /* CB_BLEND_RED */
126 0x00000000, /* CB_BLEND_GREEN */
127 0x00000000, /* CB_BLEND_BLUE */
128 0x00000000, /* CB_BLEND_ALPHA */
129
130 0xc0016900,
131 0x000001e0,
132 0x00000000, /* CB_BLEND0_CONTROL */
133
134 0xc00e6900,
135 0x00000200,
136 0x00000000, /* DB_DEPTH_CONTROL */
137 0x00000000, /* DB_EQAA */
138 0x00cc0010, /* CB_COLOR_CONTROL */
139 0x00000210, /* DB_SHADER_CONTROL */
140 0x00010000, /* PA_CL_CLIP_CNTL */
141 0x00000004, /* PA_SU_SC_MODE_CNTL */
142 0x00000100, /* PA_CL_VTE_CNTL */
143 0x00000000, /* PA_CL_VS_OUT_CNTL */
144 0x00000000, /* PA_CL_NANINF_CNTL */
145 0x00000000, /* PA_SU_LINE_STIPPLE_CNTL */
146 0x00000000, /* PA_SU_LINE_STIPPLE_SCALE */
147 0x00000000, /* PA_SU_PRIM_FILTER_CNTL */
148 0x00000000, /* */
149 0x00000000, /* */
150
151 0xc0116900,
152 0x00000280,
153 0x00000000, /* PA_SU_POINT_SIZE */
154 0x00000000, /* PA_SU_POINT_MINMAX */
155 0x00000008, /* PA_SU_LINE_CNTL */
156 0x00000000, /* PA_SC_LINE_STIPPLE */
157 0x00000000, /* VGT_OUTPUT_PATH_CNTL */
158 0x00000000, /* VGT_HOS_CNTL */
159 0x00000000,
160 0x00000000,
161 0x00000000,
162 0x00000000,
163 0x00000000,
164 0x00000000,
165 0x00000000,
166 0x00000000,
167 0x00000000,
168 0x00000000,
169 0x00000000, /* VGT_GS_MODE */
170
171 0xc0026900,
172 0x00000292,
173 0x00000000, /* PA_SC_MODE_CNTL_0 */
174 0x00000000, /* PA_SC_MODE_CNTL_1 */
175
176 0xc0016900,
177 0x000002a1,
178 0x00000000, /* VGT_PRIMITIVEID_EN */
179
180 0xc0016900,
181 0x000002a5,
182 0x00000000, /* VGT_MULTI_PRIM_IB_RESET_EN */
183
184 0xc0026900,
185 0x000002a8,
186 0x00000000, /* VGT_INSTANCE_STEP_RATE_0 */
187 0x00000000,
188
189 0xc0026900,
190 0x000002ad,
191 0x00000000, /* VGT_REUSE_OFF */
192 0x00000000,
193
194 0xc0016900,
195 0x000002d5,
196 0x00000000, /* VGT_SHADER_STAGES_EN */
197
198 0xc0016900,
199 0x000002dc,
200 0x0000aa00, /* DB_ALPHA_TO_MASK */
201
202 0xc0066900,
203 0x000002de,
204 0x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */
205 0x00000000,
206 0x00000000,
207 0x00000000,
208 0x00000000,
209 0x00000000,
210
211 0xc0026900,
212 0x000002e5,
213 0x00000000, /* VGT_STRMOUT_CONFIG */
214 0x00000000,
215
216 0xc01b6900,
217 0x000002f5,
218 0x76543210, /* PA_SC_CENTROID_PRIORITY_0 */
219 0xfedcba98, /* PA_SC_CENTROID_PRIORITY_1 */
220 0x00000000, /* PA_SC_LINE_CNTL */
221 0x00000000, /* PA_SC_AA_CONFIG */
222 0x00000005, /* PA_SU_VTX_CNTL */
223 0x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */
224 0x3f800000, /* PA_CL_GB_VERT_DISC_ADJ */
225 0x3f800000, /* PA_CL_GB_HORZ_CLIP_ADJ */
226 0x3f800000, /* PA_CL_GB_HORZ_DISC_ADJ */
227 0x00000000, /* PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0 */
228 0x00000000,
229 0x00000000,
230 0x00000000,
231 0x00000000,
232 0x00000000,
233 0x00000000,
234 0x00000000,
235 0x00000000,
236 0x00000000,
237 0x00000000,
238 0x00000000,
239 0x00000000,
240 0x00000000,
241 0x00000000,
242 0x00000000,
243 0xffffffff, /* PA_SC_AA_MASK_X0Y0_X1Y0 */
244 0xffffffff,
245
246 0xc0026900,
247 0x00000316,
248 0x0000000e, /* VGT_VERTEX_REUSE_BLOCK_CNTL */
249 0x00000010, /* */
250};
251
252const u32 si_default_size = ARRAY_SIZE(si_default_state);
diff --git a/drivers/gpu/drm/radeon/si_blit_shaders.h b/drivers/gpu/drm/radeon/si_blit_shaders.h
new file mode 100644
index 000000000000..c739e51e3961
--- /dev/null
+++ b/drivers/gpu/drm/radeon/si_blit_shaders.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2011 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 */
24
25#ifndef SI_BLIT_SHADERS_H
26#define SI_BLIT_SHADERS_H
27
28extern const u32 si_default_state[];
29
30extern const u32 si_default_size;
31
32#endif
diff --git a/drivers/gpu/drm/radeon/si_reg.h b/drivers/gpu/drm/radeon/si_reg.h
new file mode 100644
index 000000000000..eda938a7cb6e
--- /dev/null
+++ b/drivers/gpu/drm/radeon/si_reg.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright 2010 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Alex Deucher
23 */
24#ifndef __SI_REG_H__
25#define __SI_REG_H__
26
27/* SI */
28#define SI_DC_GPIO_HPD_MASK 0x65b0
29#define SI_DC_GPIO_HPD_A 0x65b4
30#define SI_DC_GPIO_HPD_EN 0x65b8
31#define SI_DC_GPIO_HPD_Y 0x65bc
32
33#endif
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
new file mode 100644
index 000000000000..53ea2c42dbd6
--- /dev/null
+++ b/drivers/gpu/drm/radeon/sid.h
@@ -0,0 +1,886 @@
1/*
2 * Copyright 2011 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Alex Deucher
23 */
24#ifndef SI_H
25#define SI_H
26
27#define CG_MULT_THERMAL_STATUS 0x714
28#define ASIC_MAX_TEMP(x) ((x) << 0)
29#define ASIC_MAX_TEMP_MASK 0x000001ff
30#define ASIC_MAX_TEMP_SHIFT 0
31#define CTF_TEMP(x) ((x) << 9)
32#define CTF_TEMP_MASK 0x0003fe00
33#define CTF_TEMP_SHIFT 9
34
35#define SI_MAX_SH_GPRS 256
36#define SI_MAX_TEMP_GPRS 16
37#define SI_MAX_SH_THREADS 256
38#define SI_MAX_SH_STACK_ENTRIES 4096
39#define SI_MAX_FRC_EOV_CNT 16384
40#define SI_MAX_BACKENDS 8
41#define SI_MAX_BACKENDS_MASK 0xFF
42#define SI_MAX_BACKENDS_PER_SE_MASK 0x0F
43#define SI_MAX_SIMDS 12
44#define SI_MAX_SIMDS_MASK 0x0FFF
45#define SI_MAX_SIMDS_PER_SE_MASK 0x00FF
46#define SI_MAX_PIPES 8
47#define SI_MAX_PIPES_MASK 0xFF
48#define SI_MAX_PIPES_PER_SIMD_MASK 0x3F
49#define SI_MAX_LDS_NUM 0xFFFF
50#define SI_MAX_TCC 16
51#define SI_MAX_TCC_MASK 0xFFFF
52
53#define VGA_HDP_CONTROL 0x328
54#define VGA_MEMORY_DISABLE (1 << 4)
55
56#define DMIF_ADDR_CONFIG 0xBD4
57
58#define SRBM_STATUS 0xE50
59
60#define CC_SYS_RB_BACKEND_DISABLE 0xe80
61#define GC_USER_SYS_RB_BACKEND_DISABLE 0xe84
62
63#define VM_L2_CNTL 0x1400
64#define ENABLE_L2_CACHE (1 << 0)
65#define ENABLE_L2_FRAGMENT_PROCESSING (1 << 1)
66#define L2_CACHE_PTE_ENDIAN_SWAP_MODE(x) ((x) << 2)
67#define L2_CACHE_PDE_ENDIAN_SWAP_MODE(x) ((x) << 4)
68#define ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE (1 << 9)
69#define ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE (1 << 10)
70#define EFFECTIVE_L2_QUEUE_SIZE(x) (((x) & 7) << 15)
71#define CONTEXT1_IDENTITY_ACCESS_MODE(x) (((x) & 3) << 19)
72#define VM_L2_CNTL2 0x1404
73#define INVALIDATE_ALL_L1_TLBS (1 << 0)
74#define INVALIDATE_L2_CACHE (1 << 1)
75#define INVALIDATE_CACHE_MODE(x) ((x) << 26)
76#define INVALIDATE_PTE_AND_PDE_CACHES 0
77#define INVALIDATE_ONLY_PTE_CACHES 1
78#define INVALIDATE_ONLY_PDE_CACHES 2
79#define VM_L2_CNTL3 0x1408
80#define BANK_SELECT(x) ((x) << 0)
81#define L2_CACHE_UPDATE_MODE(x) ((x) << 6)
82#define L2_CACHE_BIGK_FRAGMENT_SIZE(x) ((x) << 15)
83#define L2_CACHE_BIGK_ASSOCIATIVITY (1 << 20)
84#define VM_L2_STATUS 0x140C
85#define L2_BUSY (1 << 0)
86#define VM_CONTEXT0_CNTL 0x1410
87#define ENABLE_CONTEXT (1 << 0)
88#define PAGE_TABLE_DEPTH(x) (((x) & 3) << 1)
89#define RANGE_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 4)
90#define VM_CONTEXT1_CNTL 0x1414
91#define VM_CONTEXT0_CNTL2 0x1430
92#define VM_CONTEXT1_CNTL2 0x1434
93#define VM_CONTEXT8_PAGE_TABLE_BASE_ADDR 0x1438
94#define VM_CONTEXT9_PAGE_TABLE_BASE_ADDR 0x143c
95#define VM_CONTEXT10_PAGE_TABLE_BASE_ADDR 0x1440
96#define VM_CONTEXT11_PAGE_TABLE_BASE_ADDR 0x1444
97#define VM_CONTEXT12_PAGE_TABLE_BASE_ADDR 0x1448
98#define VM_CONTEXT13_PAGE_TABLE_BASE_ADDR 0x144c
99#define VM_CONTEXT14_PAGE_TABLE_BASE_ADDR 0x1450
100#define VM_CONTEXT15_PAGE_TABLE_BASE_ADDR 0x1454
101
102#define VM_INVALIDATE_REQUEST 0x1478
103#define VM_INVALIDATE_RESPONSE 0x147c
104
105#define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x1518
106#define VM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR 0x151c
107
108#define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153c
109#define VM_CONTEXT1_PAGE_TABLE_BASE_ADDR 0x1540
110#define VM_CONTEXT2_PAGE_TABLE_BASE_ADDR 0x1544
111#define VM_CONTEXT3_PAGE_TABLE_BASE_ADDR 0x1548
112#define VM_CONTEXT4_PAGE_TABLE_BASE_ADDR 0x154c
113#define VM_CONTEXT5_PAGE_TABLE_BASE_ADDR 0x1550
114#define VM_CONTEXT6_PAGE_TABLE_BASE_ADDR 0x1554
115#define VM_CONTEXT7_PAGE_TABLE_BASE_ADDR 0x1558
116#define VM_CONTEXT0_PAGE_TABLE_START_ADDR 0x155c
117#define VM_CONTEXT1_PAGE_TABLE_START_ADDR 0x1560
118
119#define VM_CONTEXT0_PAGE_TABLE_END_ADDR 0x157C
120#define VM_CONTEXT1_PAGE_TABLE_END_ADDR 0x1580
121
122#define MC_SHARED_CHMAP 0x2004
123#define NOOFCHAN_SHIFT 12
124#define NOOFCHAN_MASK 0x0000f000
125#define MC_SHARED_CHREMAP 0x2008
126
127#define MC_VM_FB_LOCATION 0x2024
128#define MC_VM_AGP_TOP 0x2028
129#define MC_VM_AGP_BOT 0x202C
130#define MC_VM_AGP_BASE 0x2030
131#define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034
132#define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038
133#define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C
134
135#define MC_VM_MX_L1_TLB_CNTL 0x2064
136#define ENABLE_L1_TLB (1 << 0)
137#define ENABLE_L1_FRAGMENT_PROCESSING (1 << 1)
138#define SYSTEM_ACCESS_MODE_PA_ONLY (0 << 3)
139#define SYSTEM_ACCESS_MODE_USE_SYS_MAP (1 << 3)
140#define SYSTEM_ACCESS_MODE_IN_SYS (2 << 3)
141#define SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 3)
142#define SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5)
143#define ENABLE_ADVANCED_DRIVER_MODEL (1 << 6)
144
145#define MC_SHARED_BLACKOUT_CNTL 0x20ac
146
147#define MC_ARB_RAMCFG 0x2760
148#define NOOFBANK_SHIFT 0
149#define NOOFBANK_MASK 0x00000003
150#define NOOFRANK_SHIFT 2
151#define NOOFRANK_MASK 0x00000004
152#define NOOFROWS_SHIFT 3
153#define NOOFROWS_MASK 0x00000038
154#define NOOFCOLS_SHIFT 6
155#define NOOFCOLS_MASK 0x000000C0
156#define CHANSIZE_SHIFT 8
157#define CHANSIZE_MASK 0x00000100
158#define CHANSIZE_OVERRIDE (1 << 11)
159#define NOOFGROUPS_SHIFT 12
160#define NOOFGROUPS_MASK 0x00001000
161
162#define MC_SEQ_TRAIN_WAKEUP_CNTL 0x2808
163#define TRAIN_DONE_D0 (1 << 30)
164#define TRAIN_DONE_D1 (1 << 31)
165
166#define MC_SEQ_SUP_CNTL 0x28c8
167#define RUN_MASK (1 << 0)
168#define MC_SEQ_SUP_PGM 0x28cc
169
170#define MC_IO_PAD_CNTL_D0 0x29d0
171#define MEM_FALL_OUT_CMD (1 << 8)
172
173#define MC_SEQ_IO_DEBUG_INDEX 0x2a44
174#define MC_SEQ_IO_DEBUG_DATA 0x2a48
175
176#define HDP_HOST_PATH_CNTL 0x2C00
177#define HDP_NONSURFACE_BASE 0x2C04
178#define HDP_NONSURFACE_INFO 0x2C08
179#define HDP_NONSURFACE_SIZE 0x2C0C
180
181#define HDP_ADDR_CONFIG 0x2F48
182#define HDP_MISC_CNTL 0x2F4C
183#define HDP_FLUSH_INVALIDATE_CACHE (1 << 0)
184
185#define IH_RB_CNTL 0x3e00
186# define IH_RB_ENABLE (1 << 0)
187# define IH_IB_SIZE(x) ((x) << 1) /* log2 */
188# define IH_RB_FULL_DRAIN_ENABLE (1 << 6)
189# define IH_WPTR_WRITEBACK_ENABLE (1 << 8)
190# define IH_WPTR_WRITEBACK_TIMER(x) ((x) << 9) /* log2 */
191# define IH_WPTR_OVERFLOW_ENABLE (1 << 16)
192# define IH_WPTR_OVERFLOW_CLEAR (1 << 31)
193#define IH_RB_BASE 0x3e04
194#define IH_RB_RPTR 0x3e08
195#define IH_RB_WPTR 0x3e0c
196# define RB_OVERFLOW (1 << 0)
197# define WPTR_OFFSET_MASK 0x3fffc
198#define IH_RB_WPTR_ADDR_HI 0x3e10
199#define IH_RB_WPTR_ADDR_LO 0x3e14
200#define IH_CNTL 0x3e18
201# define ENABLE_INTR (1 << 0)
202# define IH_MC_SWAP(x) ((x) << 1)
203# define IH_MC_SWAP_NONE 0
204# define IH_MC_SWAP_16BIT 1
205# define IH_MC_SWAP_32BIT 2
206# define IH_MC_SWAP_64BIT 3
207# define RPTR_REARM (1 << 4)
208# define MC_WRREQ_CREDIT(x) ((x) << 15)
209# define MC_WR_CLEAN_CNT(x) ((x) << 20)
210# define MC_VMID(x) ((x) << 25)
211
212#define CONFIG_MEMSIZE 0x5428
213
214#define INTERRUPT_CNTL 0x5468
215# define IH_DUMMY_RD_OVERRIDE (1 << 0)
216# define IH_DUMMY_RD_EN (1 << 1)
217# define IH_REQ_NONSNOOP_EN (1 << 3)
218# define GEN_IH_INT_EN (1 << 8)
219#define INTERRUPT_CNTL2 0x546c
220
221#define HDP_MEM_COHERENCY_FLUSH_CNTL 0x5480
222
223#define BIF_FB_EN 0x5490
224#define FB_READ_EN (1 << 0)
225#define FB_WRITE_EN (1 << 1)
226
227#define HDP_REG_COHERENCY_FLUSH_CNTL 0x54A0
228
229#define DC_LB_MEMORY_SPLIT 0x6b0c
230#define DC_LB_MEMORY_CONFIG(x) ((x) << 20)
231
232#define PRIORITY_A_CNT 0x6b18
233#define PRIORITY_MARK_MASK 0x7fff
234#define PRIORITY_OFF (1 << 16)
235#define PRIORITY_ALWAYS_ON (1 << 20)
236#define PRIORITY_B_CNT 0x6b1c
237
238#define DPG_PIPE_ARBITRATION_CONTROL3 0x6cc8
239# define LATENCY_WATERMARK_MASK(x) ((x) << 16)
240#define DPG_PIPE_LATENCY_CONTROL 0x6ccc
241# define LATENCY_LOW_WATERMARK(x) ((x) << 0)
242# define LATENCY_HIGH_WATERMARK(x) ((x) << 16)
243
244/* 0x6bb8, 0x77b8, 0x103b8, 0x10fb8, 0x11bb8, 0x127b8 */
245#define VLINE_STATUS 0x6bb8
246# define VLINE_OCCURRED (1 << 0)
247# define VLINE_ACK (1 << 4)
248# define VLINE_STAT (1 << 12)
249# define VLINE_INTERRUPT (1 << 16)
250# define VLINE_INTERRUPT_TYPE (1 << 17)
251/* 0x6bbc, 0x77bc, 0x103bc, 0x10fbc, 0x11bbc, 0x127bc */
252#define VBLANK_STATUS 0x6bbc
253# define VBLANK_OCCURRED (1 << 0)
254# define VBLANK_ACK (1 << 4)
255# define VBLANK_STAT (1 << 12)
256# define VBLANK_INTERRUPT (1 << 16)
257# define VBLANK_INTERRUPT_TYPE (1 << 17)
258
259/* 0x6b40, 0x7740, 0x10340, 0x10f40, 0x11b40, 0x12740 */
260#define INT_MASK 0x6b40
261# define VBLANK_INT_MASK (1 << 0)
262# define VLINE_INT_MASK (1 << 4)
263
264#define DISP_INTERRUPT_STATUS 0x60f4
265# define LB_D1_VLINE_INTERRUPT (1 << 2)
266# define LB_D1_VBLANK_INTERRUPT (1 << 3)
267# define DC_HPD1_INTERRUPT (1 << 17)
268# define DC_HPD1_RX_INTERRUPT (1 << 18)
269# define DACA_AUTODETECT_INTERRUPT (1 << 22)
270# define DACB_AUTODETECT_INTERRUPT (1 << 23)
271# define DC_I2C_SW_DONE_INTERRUPT (1 << 24)
272# define DC_I2C_HW_DONE_INTERRUPT (1 << 25)
273#define DISP_INTERRUPT_STATUS_CONTINUE 0x60f8
274# define LB_D2_VLINE_INTERRUPT (1 << 2)
275# define LB_D2_VBLANK_INTERRUPT (1 << 3)
276# define DC_HPD2_INTERRUPT (1 << 17)
277# define DC_HPD2_RX_INTERRUPT (1 << 18)
278# define DISP_TIMER_INTERRUPT (1 << 24)
279#define DISP_INTERRUPT_STATUS_CONTINUE2 0x60fc
280# define LB_D3_VLINE_INTERRUPT (1 << 2)
281# define LB_D3_VBLANK_INTERRUPT (1 << 3)
282# define DC_HPD3_INTERRUPT (1 << 17)
283# define DC_HPD3_RX_INTERRUPT (1 << 18)
284#define DISP_INTERRUPT_STATUS_CONTINUE3 0x6100
285# define LB_D4_VLINE_INTERRUPT (1 << 2)
286# define LB_D4_VBLANK_INTERRUPT (1 << 3)
287# define DC_HPD4_INTERRUPT (1 << 17)
288# define DC_HPD4_RX_INTERRUPT (1 << 18)
289#define DISP_INTERRUPT_STATUS_CONTINUE4 0x614c
290# define LB_D5_VLINE_INTERRUPT (1 << 2)
291# define LB_D5_VBLANK_INTERRUPT (1 << 3)
292# define DC_HPD5_INTERRUPT (1 << 17)
293# define DC_HPD5_RX_INTERRUPT (1 << 18)
294#define DISP_INTERRUPT_STATUS_CONTINUE5 0x6150
295# define LB_D6_VLINE_INTERRUPT (1 << 2)
296# define LB_D6_VBLANK_INTERRUPT (1 << 3)
297# define DC_HPD6_INTERRUPT (1 << 17)
298# define DC_HPD6_RX_INTERRUPT (1 << 18)
299
300/* 0x6858, 0x7458, 0x10058, 0x10c58, 0x11858, 0x12458 */
301#define GRPH_INT_STATUS 0x6858
302# define GRPH_PFLIP_INT_OCCURRED (1 << 0)
303# define GRPH_PFLIP_INT_CLEAR (1 << 8)
304/* 0x685c, 0x745c, 0x1005c, 0x10c5c, 0x1185c, 0x1245c */
305#define GRPH_INT_CONTROL 0x685c
306# define GRPH_PFLIP_INT_MASK (1 << 0)
307# define GRPH_PFLIP_INT_TYPE (1 << 8)
308
309#define DACA_AUTODETECT_INT_CONTROL 0x66c8
310
311#define DC_HPD1_INT_STATUS 0x601c
312#define DC_HPD2_INT_STATUS 0x6028
313#define DC_HPD3_INT_STATUS 0x6034
314#define DC_HPD4_INT_STATUS 0x6040
315#define DC_HPD5_INT_STATUS 0x604c
316#define DC_HPD6_INT_STATUS 0x6058
317# define DC_HPDx_INT_STATUS (1 << 0)
318# define DC_HPDx_SENSE (1 << 1)
319# define DC_HPDx_RX_INT_STATUS (1 << 8)
320
321#define DC_HPD1_INT_CONTROL 0x6020
322#define DC_HPD2_INT_CONTROL 0x602c
323#define DC_HPD3_INT_CONTROL 0x6038
324#define DC_HPD4_INT_CONTROL 0x6044
325#define DC_HPD5_INT_CONTROL 0x6050
326#define DC_HPD6_INT_CONTROL 0x605c
327# define DC_HPDx_INT_ACK (1 << 0)
328# define DC_HPDx_INT_POLARITY (1 << 8)
329# define DC_HPDx_INT_EN (1 << 16)
330# define DC_HPDx_RX_INT_ACK (1 << 20)
331# define DC_HPDx_RX_INT_EN (1 << 24)
332
333#define DC_HPD1_CONTROL 0x6024
334#define DC_HPD2_CONTROL 0x6030
335#define DC_HPD3_CONTROL 0x603c
336#define DC_HPD4_CONTROL 0x6048
337#define DC_HPD5_CONTROL 0x6054
338#define DC_HPD6_CONTROL 0x6060
339# define DC_HPDx_CONNECTION_TIMER(x) ((x) << 0)
340# define DC_HPDx_RX_INT_TIMER(x) ((x) << 16)
341# define DC_HPDx_EN (1 << 28)
342
343/* 0x6e98, 0x7a98, 0x10698, 0x11298, 0x11e98, 0x12a98 */
344#define CRTC_STATUS_FRAME_COUNT 0x6e98
345
346#define GRBM_CNTL 0x8000
347#define GRBM_READ_TIMEOUT(x) ((x) << 0)
348
349#define GRBM_STATUS2 0x8008
350#define RLC_RQ_PENDING (1 << 0)
351#define RLC_BUSY (1 << 8)
352#define TC_BUSY (1 << 9)
353
354#define GRBM_STATUS 0x8010
355#define CMDFIFO_AVAIL_MASK 0x0000000F
356#define RING2_RQ_PENDING (1 << 4)
357#define SRBM_RQ_PENDING (1 << 5)
358#define RING1_RQ_PENDING (1 << 6)
359#define CF_RQ_PENDING (1 << 7)
360#define PF_RQ_PENDING (1 << 8)
361#define GDS_DMA_RQ_PENDING (1 << 9)
362#define GRBM_EE_BUSY (1 << 10)
363#define DB_CLEAN (1 << 12)
364#define CB_CLEAN (1 << 13)
365#define TA_BUSY (1 << 14)
366#define GDS_BUSY (1 << 15)
367#define VGT_BUSY (1 << 17)
368#define IA_BUSY_NO_DMA (1 << 18)
369#define IA_BUSY (1 << 19)
370#define SX_BUSY (1 << 20)
371#define SPI_BUSY (1 << 22)
372#define BCI_BUSY (1 << 23)
373#define SC_BUSY (1 << 24)
374#define PA_BUSY (1 << 25)
375#define DB_BUSY (1 << 26)
376#define CP_COHERENCY_BUSY (1 << 28)
377#define CP_BUSY (1 << 29)
378#define CB_BUSY (1 << 30)
379#define GUI_ACTIVE (1 << 31)
380#define GRBM_STATUS_SE0 0x8014
381#define GRBM_STATUS_SE1 0x8018
382#define SE_DB_CLEAN (1 << 1)
383#define SE_CB_CLEAN (1 << 2)
384#define SE_BCI_BUSY (1 << 22)
385#define SE_VGT_BUSY (1 << 23)
386#define SE_PA_BUSY (1 << 24)
387#define SE_TA_BUSY (1 << 25)
388#define SE_SX_BUSY (1 << 26)
389#define SE_SPI_BUSY (1 << 27)
390#define SE_SC_BUSY (1 << 29)
391#define SE_DB_BUSY (1 << 30)
392#define SE_CB_BUSY (1 << 31)
393
394#define GRBM_SOFT_RESET 0x8020
395#define SOFT_RESET_CP (1 << 0)
396#define SOFT_RESET_CB (1 << 1)
397#define SOFT_RESET_RLC (1 << 2)
398#define SOFT_RESET_DB (1 << 3)
399#define SOFT_RESET_GDS (1 << 4)
400#define SOFT_RESET_PA (1 << 5)
401#define SOFT_RESET_SC (1 << 6)
402#define SOFT_RESET_BCI (1 << 7)
403#define SOFT_RESET_SPI (1 << 8)
404#define SOFT_RESET_SX (1 << 10)
405#define SOFT_RESET_TC (1 << 11)
406#define SOFT_RESET_TA (1 << 12)
407#define SOFT_RESET_VGT (1 << 14)
408#define SOFT_RESET_IA (1 << 15)
409
410#define GRBM_GFX_INDEX 0x802C
411
412#define GRBM_INT_CNTL 0x8060
413# define RDERR_INT_ENABLE (1 << 0)
414# define GUI_IDLE_INT_ENABLE (1 << 19)
415
416#define SCRATCH_REG0 0x8500
417#define SCRATCH_REG1 0x8504
418#define SCRATCH_REG2 0x8508
419#define SCRATCH_REG3 0x850C
420#define SCRATCH_REG4 0x8510
421#define SCRATCH_REG5 0x8514
422#define SCRATCH_REG6 0x8518
423#define SCRATCH_REG7 0x851C
424
425#define SCRATCH_UMSK 0x8540
426#define SCRATCH_ADDR 0x8544
427
428#define CP_SEM_WAIT_TIMER 0x85BC
429
430#define CP_SEM_INCOMPLETE_TIMER_CNTL 0x85C8
431
432#define CP_ME_CNTL 0x86D8
433#define CP_CE_HALT (1 << 24)
434#define CP_PFP_HALT (1 << 26)
435#define CP_ME_HALT (1 << 28)
436
437#define CP_COHER_CNTL2 0x85E8
438
439#define CP_RB2_RPTR 0x86f8
440#define CP_RB1_RPTR 0x86fc
441#define CP_RB0_RPTR 0x8700
442#define CP_RB_WPTR_DELAY 0x8704
443
444#define CP_QUEUE_THRESHOLDS 0x8760
445#define ROQ_IB1_START(x) ((x) << 0)
446#define ROQ_IB2_START(x) ((x) << 8)
447#define CP_MEQ_THRESHOLDS 0x8764
448#define MEQ1_START(x) ((x) << 0)
449#define MEQ2_START(x) ((x) << 8)
450
451#define CP_PERFMON_CNTL 0x87FC
452
453#define VGT_VTX_VECT_EJECT_REG 0x88B0
454
455#define VGT_CACHE_INVALIDATION 0x88C4
456#define CACHE_INVALIDATION(x) ((x) << 0)
457#define VC_ONLY 0
458#define TC_ONLY 1
459#define VC_AND_TC 2
460#define AUTO_INVLD_EN(x) ((x) << 6)
461#define NO_AUTO 0
462#define ES_AUTO 1
463#define GS_AUTO 2
464#define ES_AND_GS_AUTO 3
465#define VGT_ESGS_RING_SIZE 0x88C8
466#define VGT_GSVS_RING_SIZE 0x88CC
467
468#define VGT_GS_VERTEX_REUSE 0x88D4
469
470#define VGT_PRIMITIVE_TYPE 0x8958
471#define VGT_INDEX_TYPE 0x895C
472
473#define VGT_NUM_INDICES 0x8970
474#define VGT_NUM_INSTANCES 0x8974
475
476#define VGT_TF_RING_SIZE 0x8988
477
478#define VGT_HS_OFFCHIP_PARAM 0x89B0
479
480#define VGT_TF_MEMORY_BASE 0x89B8
481
482#define CC_GC_SHADER_ARRAY_CONFIG 0x89bc
483#define GC_USER_SHADER_ARRAY_CONFIG 0x89c0
484
485#define PA_CL_ENHANCE 0x8A14
486#define CLIP_VTX_REORDER_ENA (1 << 0)
487#define NUM_CLIP_SEQ(x) ((x) << 1)
488
489#define PA_SU_LINE_STIPPLE_VALUE 0x8A60
490
491#define PA_SC_LINE_STIPPLE_STATE 0x8B10
492
493#define PA_SC_FORCE_EOV_MAX_CNTS 0x8B24
494#define FORCE_EOV_MAX_CLK_CNT(x) ((x) << 0)
495#define FORCE_EOV_MAX_REZ_CNT(x) ((x) << 16)
496
497#define PA_SC_FIFO_SIZE 0x8BCC
498#define SC_FRONTEND_PRIM_FIFO_SIZE(x) ((x) << 0)
499#define SC_BACKEND_PRIM_FIFO_SIZE(x) ((x) << 6)
500#define SC_HIZ_TILE_FIFO_SIZE(x) ((x) << 15)
501#define SC_EARLYZ_TILE_FIFO_SIZE(x) ((x) << 23)
502
503#define PA_SC_ENHANCE 0x8BF0
504
505#define SQ_CONFIG 0x8C00
506
507#define SQC_CACHES 0x8C08
508
509#define SX_DEBUG_1 0x9060
510
511#define SPI_STATIC_THREAD_MGMT_1 0x90E0
512#define SPI_STATIC_THREAD_MGMT_2 0x90E4
513#define SPI_STATIC_THREAD_MGMT_3 0x90E8
514#define SPI_PS_MAX_WAVE_ID 0x90EC
515
516#define SPI_CONFIG_CNTL 0x9100
517
518#define SPI_CONFIG_CNTL_1 0x913C
519#define VTX_DONE_DELAY(x) ((x) << 0)
520#define INTERP_ONE_PRIM_PER_ROW (1 << 4)
521
522#define CGTS_TCC_DISABLE 0x9148
523#define CGTS_USER_TCC_DISABLE 0x914C
524#define TCC_DISABLE_MASK 0xFFFF0000
525#define TCC_DISABLE_SHIFT 16
526
527#define TA_CNTL_AUX 0x9508
528
529#define CC_RB_BACKEND_DISABLE 0x98F4
530#define BACKEND_DISABLE(x) ((x) << 16)
531#define GB_ADDR_CONFIG 0x98F8
532#define NUM_PIPES(x) ((x) << 0)
533#define NUM_PIPES_MASK 0x00000007
534#define NUM_PIPES_SHIFT 0
535#define PIPE_INTERLEAVE_SIZE(x) ((x) << 4)
536#define PIPE_INTERLEAVE_SIZE_MASK 0x00000070
537#define PIPE_INTERLEAVE_SIZE_SHIFT 4
538#define NUM_SHADER_ENGINES(x) ((x) << 12)
539#define NUM_SHADER_ENGINES_MASK 0x00003000
540#define NUM_SHADER_ENGINES_SHIFT 12
541#define SHADER_ENGINE_TILE_SIZE(x) ((x) << 16)
542#define SHADER_ENGINE_TILE_SIZE_MASK 0x00070000
543#define SHADER_ENGINE_TILE_SIZE_SHIFT 16
544#define NUM_GPUS(x) ((x) << 20)
545#define NUM_GPUS_MASK 0x00700000
546#define NUM_GPUS_SHIFT 20
547#define MULTI_GPU_TILE_SIZE(x) ((x) << 24)
548#define MULTI_GPU_TILE_SIZE_MASK 0x03000000
549#define MULTI_GPU_TILE_SIZE_SHIFT 24
550#define ROW_SIZE(x) ((x) << 28)
551#define ROW_SIZE_MASK 0x30000000
552#define ROW_SIZE_SHIFT 28
553
554#define GB_TILE_MODE0 0x9910
555# define MICRO_TILE_MODE(x) ((x) << 0)
556# define ADDR_SURF_DISPLAY_MICRO_TILING 0
557# define ADDR_SURF_THIN_MICRO_TILING 1
558# define ADDR_SURF_DEPTH_MICRO_TILING 2
559# define ARRAY_MODE(x) ((x) << 2)
560# define ARRAY_LINEAR_GENERAL 0
561# define ARRAY_LINEAR_ALIGNED 1
562# define ARRAY_1D_TILED_THIN1 2
563# define ARRAY_2D_TILED_THIN1 4
564# define PIPE_CONFIG(x) ((x) << 6)
565# define ADDR_SURF_P2 0
566# define ADDR_SURF_P4_8x16 4
567# define ADDR_SURF_P4_16x16 5
568# define ADDR_SURF_P4_16x32 6
569# define ADDR_SURF_P4_32x32 7
570# define ADDR_SURF_P8_16x16_8x16 8
571# define ADDR_SURF_P8_16x32_8x16 9
572# define ADDR_SURF_P8_32x32_8x16 10
573# define ADDR_SURF_P8_16x32_16x16 11
574# define ADDR_SURF_P8_32x32_16x16 12
575# define ADDR_SURF_P8_32x32_16x32 13
576# define ADDR_SURF_P8_32x64_32x32 14
577# define TILE_SPLIT(x) ((x) << 11)
578# define ADDR_SURF_TILE_SPLIT_64B 0
579# define ADDR_SURF_TILE_SPLIT_128B 1
580# define ADDR_SURF_TILE_SPLIT_256B 2
581# define ADDR_SURF_TILE_SPLIT_512B 3
582# define ADDR_SURF_TILE_SPLIT_1KB 4
583# define ADDR_SURF_TILE_SPLIT_2KB 5
584# define ADDR_SURF_TILE_SPLIT_4KB 6
585# define BANK_WIDTH(x) ((x) << 14)
586# define ADDR_SURF_BANK_WIDTH_1 0
587# define ADDR_SURF_BANK_WIDTH_2 1
588# define ADDR_SURF_BANK_WIDTH_4 2
589# define ADDR_SURF_BANK_WIDTH_8 3
590# define BANK_HEIGHT(x) ((x) << 16)
591# define ADDR_SURF_BANK_HEIGHT_1 0
592# define ADDR_SURF_BANK_HEIGHT_2 1
593# define ADDR_SURF_BANK_HEIGHT_4 2
594# define ADDR_SURF_BANK_HEIGHT_8 3
595# define MACRO_TILE_ASPECT(x) ((x) << 18)
596# define ADDR_SURF_MACRO_ASPECT_1 0
597# define ADDR_SURF_MACRO_ASPECT_2 1
598# define ADDR_SURF_MACRO_ASPECT_4 2
599# define ADDR_SURF_MACRO_ASPECT_8 3
600# define NUM_BANKS(x) ((x) << 20)
601# define ADDR_SURF_2_BANK 0
602# define ADDR_SURF_4_BANK 1
603# define ADDR_SURF_8_BANK 2
604# define ADDR_SURF_16_BANK 3
605
606#define CB_PERFCOUNTER0_SELECT0 0x9a20
607#define CB_PERFCOUNTER0_SELECT1 0x9a24
608#define CB_PERFCOUNTER1_SELECT0 0x9a28
609#define CB_PERFCOUNTER1_SELECT1 0x9a2c
610#define CB_PERFCOUNTER2_SELECT0 0x9a30
611#define CB_PERFCOUNTER2_SELECT1 0x9a34
612#define CB_PERFCOUNTER3_SELECT0 0x9a38
613#define CB_PERFCOUNTER3_SELECT1 0x9a3c
614
615#define GC_USER_RB_BACKEND_DISABLE 0x9B7C
616#define BACKEND_DISABLE_MASK 0x00FF0000
617#define BACKEND_DISABLE_SHIFT 16
618
619#define TCP_CHAN_STEER_LO 0xac0c
620#define TCP_CHAN_STEER_HI 0xac10
621
622#define CP_RB0_BASE 0xC100
623#define CP_RB0_CNTL 0xC104
624#define RB_BUFSZ(x) ((x) << 0)
625#define RB_BLKSZ(x) ((x) << 8)
626#define BUF_SWAP_32BIT (2 << 16)
627#define RB_NO_UPDATE (1 << 27)
628#define RB_RPTR_WR_ENA (1 << 31)
629
630#define CP_RB0_RPTR_ADDR 0xC10C
631#define CP_RB0_RPTR_ADDR_HI 0xC110
632#define CP_RB0_WPTR 0xC114
633
634#define CP_PFP_UCODE_ADDR 0xC150
635#define CP_PFP_UCODE_DATA 0xC154
636#define CP_ME_RAM_RADDR 0xC158
637#define CP_ME_RAM_WADDR 0xC15C
638#define CP_ME_RAM_DATA 0xC160
639
640#define CP_CE_UCODE_ADDR 0xC168
641#define CP_CE_UCODE_DATA 0xC16C
642
643#define CP_RB1_BASE 0xC180
644#define CP_RB1_CNTL 0xC184
645#define CP_RB1_RPTR_ADDR 0xC188
646#define CP_RB1_RPTR_ADDR_HI 0xC18C
647#define CP_RB1_WPTR 0xC190
648#define CP_RB2_BASE 0xC194
649#define CP_RB2_CNTL 0xC198
650#define CP_RB2_RPTR_ADDR 0xC19C
651#define CP_RB2_RPTR_ADDR_HI 0xC1A0
652#define CP_RB2_WPTR 0xC1A4
653#define CP_INT_CNTL_RING0 0xC1A8
654#define CP_INT_CNTL_RING1 0xC1AC
655#define CP_INT_CNTL_RING2 0xC1B0
656# define CNTX_BUSY_INT_ENABLE (1 << 19)
657# define CNTX_EMPTY_INT_ENABLE (1 << 20)
658# define WAIT_MEM_SEM_INT_ENABLE (1 << 21)
659# define TIME_STAMP_INT_ENABLE (1 << 26)
660# define CP_RINGID2_INT_ENABLE (1 << 29)
661# define CP_RINGID1_INT_ENABLE (1 << 30)
662# define CP_RINGID0_INT_ENABLE (1 << 31)
663#define CP_INT_STATUS_RING0 0xC1B4
664#define CP_INT_STATUS_RING1 0xC1B8
665#define CP_INT_STATUS_RING2 0xC1BC
666# define WAIT_MEM_SEM_INT_STAT (1 << 21)
667# define TIME_STAMP_INT_STAT (1 << 26)
668# define CP_RINGID2_INT_STAT (1 << 29)
669# define CP_RINGID1_INT_STAT (1 << 30)
670# define CP_RINGID0_INT_STAT (1 << 31)
671
672#define CP_DEBUG 0xC1FC
673
674#define RLC_CNTL 0xC300
675# define RLC_ENABLE (1 << 0)
676#define RLC_RL_BASE 0xC304
677#define RLC_RL_SIZE 0xC308
678#define RLC_LB_CNTL 0xC30C
679#define RLC_SAVE_AND_RESTORE_BASE 0xC310
680#define RLC_LB_CNTR_MAX 0xC314
681#define RLC_LB_CNTR_INIT 0xC318
682
683#define RLC_CLEAR_STATE_RESTORE_BASE 0xC320
684
685#define RLC_UCODE_ADDR 0xC32C
686#define RLC_UCODE_DATA 0xC330
687
688#define RLC_MC_CNTL 0xC344
689#define RLC_UCODE_CNTL 0xC348
690
691#define VGT_EVENT_INITIATOR 0x28a90
692# define SAMPLE_STREAMOUTSTATS1 (1 << 0)
693# define SAMPLE_STREAMOUTSTATS2 (2 << 0)
694# define SAMPLE_STREAMOUTSTATS3 (3 << 0)
695# define CACHE_FLUSH_TS (4 << 0)
696# define CACHE_FLUSH (6 << 0)
697# define CS_PARTIAL_FLUSH (7 << 0)
698# define VGT_STREAMOUT_RESET (10 << 0)
699# define END_OF_PIPE_INCR_DE (11 << 0)
700# define END_OF_PIPE_IB_END (12 << 0)
701# define RST_PIX_CNT (13 << 0)
702# define VS_PARTIAL_FLUSH (15 << 0)
703# define PS_PARTIAL_FLUSH (16 << 0)
704# define CACHE_FLUSH_AND_INV_TS_EVENT (20 << 0)
705# define ZPASS_DONE (21 << 0)
706# define CACHE_FLUSH_AND_INV_EVENT (22 << 0)
707# define PERFCOUNTER_START (23 << 0)
708# define PERFCOUNTER_STOP (24 << 0)
709# define PIPELINESTAT_START (25 << 0)
710# define PIPELINESTAT_STOP (26 << 0)
711# define PERFCOUNTER_SAMPLE (27 << 0)
712# define SAMPLE_PIPELINESTAT (30 << 0)
713# define SAMPLE_STREAMOUTSTATS (32 << 0)
714# define RESET_VTX_CNT (33 << 0)
715# define VGT_FLUSH (36 << 0)
716# define BOTTOM_OF_PIPE_TS (40 << 0)
717# define DB_CACHE_FLUSH_AND_INV (42 << 0)
718# define FLUSH_AND_INV_DB_DATA_TS (43 << 0)
719# define FLUSH_AND_INV_DB_META (44 << 0)
720# define FLUSH_AND_INV_CB_DATA_TS (45 << 0)
721# define FLUSH_AND_INV_CB_META (46 << 0)
722# define CS_DONE (47 << 0)
723# define PS_DONE (48 << 0)
724# define FLUSH_AND_INV_CB_PIXEL_DATA (49 << 0)
725# define THREAD_TRACE_START (51 << 0)
726# define THREAD_TRACE_STOP (52 << 0)
727# define THREAD_TRACE_FLUSH (54 << 0)
728# define THREAD_TRACE_FINISH (55 << 0)
729
730/*
731 * PM4
732 */
733#define PACKET_TYPE0 0
734#define PACKET_TYPE1 1
735#define PACKET_TYPE2 2
736#define PACKET_TYPE3 3
737
738#define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3)
739#define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF)
740#define CP_PACKET0_GET_REG(h) (((h) & 0xFFFF) << 2)
741#define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF)
742#define PACKET0(reg, n) ((PACKET_TYPE0 << 30) | \
743 (((reg) >> 2) & 0xFFFF) | \
744 ((n) & 0x3FFF) << 16)
745#define CP_PACKET2 0x80000000
746#define PACKET2_PAD_SHIFT 0
747#define PACKET2_PAD_MASK (0x3fffffff << 0)
748
749#define PACKET2(v) (CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
750
751#define PACKET3(op, n) ((PACKET_TYPE3 << 30) | \
752 (((op) & 0xFF) << 8) | \
753 ((n) & 0x3FFF) << 16)
754
755#define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1)
756
757/* Packet 3 types */
758#define PACKET3_NOP 0x10
759#define PACKET3_SET_BASE 0x11
760#define PACKET3_BASE_INDEX(x) ((x) << 0)
761#define GDS_PARTITION_BASE 2
762#define CE_PARTITION_BASE 3
763#define PACKET3_CLEAR_STATE 0x12
764#define PACKET3_INDEX_BUFFER_SIZE 0x13
765#define PACKET3_DISPATCH_DIRECT 0x15
766#define PACKET3_DISPATCH_INDIRECT 0x16
767#define PACKET3_ALLOC_GDS 0x1B
768#define PACKET3_WRITE_GDS_RAM 0x1C
769#define PACKET3_ATOMIC_GDS 0x1D
770#define PACKET3_ATOMIC 0x1E
771#define PACKET3_OCCLUSION_QUERY 0x1F
772#define PACKET3_SET_PREDICATION 0x20
773#define PACKET3_REG_RMW 0x21
774#define PACKET3_COND_EXEC 0x22
775#define PACKET3_PRED_EXEC 0x23
776#define PACKET3_DRAW_INDIRECT 0x24
777#define PACKET3_DRAW_INDEX_INDIRECT 0x25
778#define PACKET3_INDEX_BASE 0x26
779#define PACKET3_DRAW_INDEX_2 0x27
780#define PACKET3_CONTEXT_CONTROL 0x28
781#define PACKET3_INDEX_TYPE 0x2A
782#define PACKET3_DRAW_INDIRECT_MULTI 0x2C
783#define PACKET3_DRAW_INDEX_AUTO 0x2D
784#define PACKET3_DRAW_INDEX_IMMD 0x2E
785#define PACKET3_NUM_INSTANCES 0x2F
786#define PACKET3_DRAW_INDEX_MULTI_AUTO 0x30
787#define PACKET3_INDIRECT_BUFFER_CONST 0x31
788#define PACKET3_INDIRECT_BUFFER 0x32
789#define PACKET3_STRMOUT_BUFFER_UPDATE 0x34
790#define PACKET3_DRAW_INDEX_OFFSET_2 0x35
791#define PACKET3_DRAW_INDEX_MULTI_ELEMENT 0x36
792#define PACKET3_WRITE_DATA 0x37
793#define PACKET3_DRAW_INDEX_INDIRECT_MULTI 0x38
794#define PACKET3_MEM_SEMAPHORE 0x39
795#define PACKET3_MPEG_INDEX 0x3A
796#define PACKET3_COPY_DW 0x3B
797#define PACKET3_WAIT_REG_MEM 0x3C
798#define PACKET3_MEM_WRITE 0x3D
799#define PACKET3_COPY_DATA 0x40
800#define PACKET3_PFP_SYNC_ME 0x42
801#define PACKET3_SURFACE_SYNC 0x43
802# define PACKET3_DEST_BASE_0_ENA (1 << 0)
803# define PACKET3_DEST_BASE_1_ENA (1 << 1)
804# define PACKET3_CB0_DEST_BASE_ENA (1 << 6)
805# define PACKET3_CB1_DEST_BASE_ENA (1 << 7)
806# define PACKET3_CB2_DEST_BASE_ENA (1 << 8)
807# define PACKET3_CB3_DEST_BASE_ENA (1 << 9)
808# define PACKET3_CB4_DEST_BASE_ENA (1 << 10)
809# define PACKET3_CB5_DEST_BASE_ENA (1 << 11)
810# define PACKET3_CB6_DEST_BASE_ENA (1 << 12)
811# define PACKET3_CB7_DEST_BASE_ENA (1 << 13)
812# define PACKET3_DB_DEST_BASE_ENA (1 << 14)
813# define PACKET3_DEST_BASE_2_ENA (1 << 19)
814# define PACKET3_DEST_BASE_3_ENA (1 << 21)
815# define PACKET3_TCL1_ACTION_ENA (1 << 22)
816# define PACKET3_TC_ACTION_ENA (1 << 23)
817# define PACKET3_CB_ACTION_ENA (1 << 25)
818# define PACKET3_DB_ACTION_ENA (1 << 26)
819# define PACKET3_SH_KCACHE_ACTION_ENA (1 << 27)
820# define PACKET3_SH_ICACHE_ACTION_ENA (1 << 29)
821#define PACKET3_ME_INITIALIZE 0x44
822#define PACKET3_ME_INITIALIZE_DEVICE_ID(x) ((x) << 16)
823#define PACKET3_COND_WRITE 0x45
824#define PACKET3_EVENT_WRITE 0x46
825#define EVENT_TYPE(x) ((x) << 0)
826#define EVENT_INDEX(x) ((x) << 8)
827 /* 0 - any non-TS event
828 * 1 - ZPASS_DONE
829 * 2 - SAMPLE_PIPELINESTAT
830 * 3 - SAMPLE_STREAMOUTSTAT*
831 * 4 - *S_PARTIAL_FLUSH
832 * 5 - EOP events
833 * 6 - EOS events
834 * 7 - CACHE_FLUSH, CACHE_FLUSH_AND_INV_EVENT
835 */
836#define INV_L2 (1 << 20)
837 /* INV TC L2 cache when EVENT_INDEX = 7 */
838#define PACKET3_EVENT_WRITE_EOP 0x47
839#define DATA_SEL(x) ((x) << 29)
840 /* 0 - discard
841 * 1 - send low 32bit data
842 * 2 - send 64bit data
843 * 3 - send 64bit counter value
844 */
845#define INT_SEL(x) ((x) << 24)
846 /* 0 - none
847 * 1 - interrupt only (DATA_SEL = 0)
848 * 2 - interrupt when data write is confirmed
849 */
850#define PACKET3_EVENT_WRITE_EOS 0x48
851#define PACKET3_PREAMBLE_CNTL 0x4A
852# define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE (2 << 28)
853# define PACKET3_PREAMBLE_END_CLEAR_STATE (3 << 28)
854#define PACKET3_ONE_REG_WRITE 0x57
855#define PACKET3_LOAD_CONFIG_REG 0x5F
856#define PACKET3_LOAD_CONTEXT_REG 0x60
857#define PACKET3_LOAD_SH_REG 0x61
858#define PACKET3_SET_CONFIG_REG 0x68
859#define PACKET3_SET_CONFIG_REG_START 0x00008000
860#define PACKET3_SET_CONFIG_REG_END 0x0000b000
861#define PACKET3_SET_CONTEXT_REG 0x69
862#define PACKET3_SET_CONTEXT_REG_START 0x00028000
863#define PACKET3_SET_CONTEXT_REG_END 0x00029000
864#define PACKET3_SET_CONTEXT_REG_INDIRECT 0x73
865#define PACKET3_SET_RESOURCE_INDIRECT 0x74
866#define PACKET3_SET_SH_REG 0x76
867#define PACKET3_SET_SH_REG_START 0x0000b000
868#define PACKET3_SET_SH_REG_END 0x0000c000
869#define PACKET3_SET_SH_REG_OFFSET 0x77
870#define PACKET3_ME_WRITE 0x7A
871#define PACKET3_SCRATCH_RAM_WRITE 0x7D
872#define PACKET3_SCRATCH_RAM_READ 0x7E
873#define PACKET3_CE_WRITE 0x7F
874#define PACKET3_LOAD_CONST_RAM 0x80
875#define PACKET3_WRITE_CONST_RAM 0x81
876#define PACKET3_WRITE_CONST_RAM_OFFSET 0x82
877#define PACKET3_DUMP_CONST_RAM 0x83
878#define PACKET3_INCREMENT_CE_COUNTER 0x84
879#define PACKET3_INCREMENT_DE_COUNTER 0x85
880#define PACKET3_WAIT_ON_CE_COUNTER 0x86
881#define PACKET3_WAIT_ON_DE_COUNTER 0x87
882#define PACKET3_WAIT_ON_DE_COUNTER_DIFF 0x88
883#define PACKET3_SET_CE_DE_COUNTERS 0x89
884#define PACKET3_WAIT_ON_AVAIL_BUFFER 0x8A
885
886#endif