diff options
author | Dave Airlie <airlied@redhat.com> | 2010-04-19 23:16:50 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-04-19 23:16:50 -0400 |
commit | 153549b8b63d71a9c5d8cbde887097b995c32bd6 (patch) | |
tree | 306ece7479bb98172272013dd02b243e6677a3f4 | |
parent | 7fff400be6fbf64f10abca9939718aaf1d61c255 (diff) | |
parent | a7433742d62c6e0e1173bd144a4aef7724b48d60 (diff) |
Merge branch 'drm-radeon-evergreen-accel' into drm-core-next
* drm-radeon-evergreen-accel:
drm/radeon: fix cypress firmware typo.
drm/radeon/kms/evergreen: add hpd support
drm/radeon/kms/evergreen: implement irq support
drm/radeon/kms/evergreen: setup and enable the CP
drm/radeon/kms/evergreen: implement gfx init
drm/radeon/kms/evergreen: add soft reset function
drm/radeon/kms/evergreen: add gart support
drm/radeon/kms: add support for evergreen power tables
drm/radeon/kms: update atombios.h power tables for evergreen
-rw-r--r-- | drivers/gpu/drm/radeon/atombios.h | 76 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/atombios_crtc.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen.c | 1483 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/evergreend.h | 556 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600.c | 71 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 35 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_atombios.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/rv770.c | 10 |
10 files changed, 2218 insertions, 84 deletions
diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h index 6732b5dd8ff4..26986c8e1f45 100644 --- a/drivers/gpu/drm/radeon/atombios.h +++ b/drivers/gpu/drm/radeon/atombios.h | |||
@@ -5742,6 +5742,9 @@ typedef struct _ATOM_PPLIB_THERMALCONTROLLER | |||
5742 | #define ATOM_PP_THERMALCONTROLLER_RV6xx 7 | 5742 | #define ATOM_PP_THERMALCONTROLLER_RV6xx 7 |
5743 | #define ATOM_PP_THERMALCONTROLLER_RV770 8 | 5743 | #define ATOM_PP_THERMALCONTROLLER_RV770 8 |
5744 | #define ATOM_PP_THERMALCONTROLLER_ADT7473 9 | 5744 | #define ATOM_PP_THERMALCONTROLLER_ADT7473 9 |
5745 | #define ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO 11 | ||
5746 | #define ATOM_PP_THERMALCONTROLLER_EVERGREEN 12 | ||
5747 | #define ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL 0x89 // ADT7473 Fan Control + Internal Thermal Controller | ||
5745 | 5748 | ||
5746 | typedef struct _ATOM_PPLIB_STATE | 5749 | typedef struct _ATOM_PPLIB_STATE |
5747 | { | 5750 | { |
@@ -5749,6 +5752,26 @@ typedef struct _ATOM_PPLIB_STATE | |||
5749 | UCHAR ucClockStateIndices[1]; // variable-sized | 5752 | UCHAR ucClockStateIndices[1]; // variable-sized |
5750 | } ATOM_PPLIB_STATE; | 5753 | } ATOM_PPLIB_STATE; |
5751 | 5754 | ||
5755 | typedef struct _ATOM_PPLIB_FANTABLE | ||
5756 | { | ||
5757 | UCHAR ucFanTableFormat; // Change this if the table format changes or version changes so that the other fields are not the same. | ||
5758 | UCHAR ucTHyst; // Temperature hysteresis. Integer. | ||
5759 | USHORT usTMin; // The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. | ||
5760 | USHORT usTMed; // The middle temperature where we change slopes. | ||
5761 | USHORT usTHigh; // The high point above TMed for adjusting the second slope. | ||
5762 | USHORT usPWMMin; // The minimum PWM value in percent (0.01% increments). | ||
5763 | USHORT usPWMMed; // The PWM value (in percent) at TMed. | ||
5764 | USHORT usPWMHigh; // The PWM value at THigh. | ||
5765 | } ATOM_PPLIB_FANTABLE; | ||
5766 | |||
5767 | typedef struct _ATOM_PPLIB_EXTENDEDHEADER | ||
5768 | { | ||
5769 | USHORT usSize; | ||
5770 | ULONG ulMaxEngineClock; // For Overdrive. | ||
5771 | ULONG ulMaxMemoryClock; // For Overdrive. | ||
5772 | // Add extra system parameters here, always adjust size to include all fields. | ||
5773 | } ATOM_PPLIB_EXTENDEDHEADER; | ||
5774 | |||
5752 | //// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps | 5775 | //// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps |
5753 | #define ATOM_PP_PLATFORM_CAP_BACKBIAS 1 | 5776 | #define ATOM_PP_PLATFORM_CAP_BACKBIAS 1 |
5754 | #define ATOM_PP_PLATFORM_CAP_POWERPLAY 2 | 5777 | #define ATOM_PP_PLATFORM_CAP_POWERPLAY 2 |
@@ -5762,6 +5785,12 @@ typedef struct _ATOM_PPLIB_STATE | |||
5762 | #define ATOM_PP_PLATFORM_CAP_SIDEPORTCONTROL 512 | 5785 | #define ATOM_PP_PLATFORM_CAP_SIDEPORTCONTROL 512 |
5763 | #define ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1 1024 | 5786 | #define ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1 1024 |
5764 | #define ATOM_PP_PLATFORM_CAP_HTLINKCONTROL 2048 | 5787 | #define ATOM_PP_PLATFORM_CAP_HTLINKCONTROL 2048 |
5788 | #define ATOM_PP_PLATFORM_CAP_MVDDCONTROL 4096 | ||
5789 | #define ATOM_PP_PLATFORM_CAP_GOTO_BOOT_ON_ALERT 0x2000 // Go to boot state on alerts, e.g. on an AC->DC transition. | ||
5790 | #define ATOM_PP_PLATFORM_CAP_DONT_WAIT_FOR_VBLANK_ON_ALERT 0x4000 // Do NOT wait for VBLANK during an alert (e.g. AC->DC transition). | ||
5791 | #define ATOM_PP_PLATFORM_CAP_VDDCI_CONTROL 0x8000 // Does the driver control VDDCI independently from VDDC. | ||
5792 | #define ATOM_PP_PLATFORM_CAP_REGULATOR_HOT 0x00010000 // Enable the 'regulator hot' feature. | ||
5793 | #define ATOM_PP_PLATFORM_CAP_BACO 0x00020000 // Does the driver supports BACO state. | ||
5765 | 5794 | ||
5766 | typedef struct _ATOM_PPLIB_POWERPLAYTABLE | 5795 | typedef struct _ATOM_PPLIB_POWERPLAYTABLE |
5767 | { | 5796 | { |
@@ -5797,6 +5826,21 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE | |||
5797 | 5826 | ||
5798 | } ATOM_PPLIB_POWERPLAYTABLE; | 5827 | } ATOM_PPLIB_POWERPLAYTABLE; |
5799 | 5828 | ||
5829 | typedef struct _ATOM_PPLIB_POWERPLAYTABLE2 | ||
5830 | { | ||
5831 | ATOM_PPLIB_POWERPLAYTABLE basicTable; | ||
5832 | UCHAR ucNumCustomThermalPolicy; | ||
5833 | USHORT usCustomThermalPolicyArrayOffset; | ||
5834 | }ATOM_PPLIB_POWERPLAYTABLE2, *LPATOM_PPLIB_POWERPLAYTABLE2; | ||
5835 | |||
5836 | typedef struct _ATOM_PPLIB_POWERPLAYTABLE3 | ||
5837 | { | ||
5838 | ATOM_PPLIB_POWERPLAYTABLE2 basicTable2; | ||
5839 | USHORT usFormatID; // To be used ONLY by PPGen. | ||
5840 | USHORT usFanTableOffset; | ||
5841 | USHORT usExtendendedHeaderOffset; | ||
5842 | } ATOM_PPLIB_POWERPLAYTABLE3, *LPATOM_PPLIB_POWERPLAYTABLE3; | ||
5843 | |||
5800 | //// ATOM_PPLIB_NONCLOCK_INFO::usClassification | 5844 | //// ATOM_PPLIB_NONCLOCK_INFO::usClassification |
5801 | #define ATOM_PPLIB_CLASSIFICATION_UI_MASK 0x0007 | 5845 | #define ATOM_PPLIB_CLASSIFICATION_UI_MASK 0x0007 |
5802 | #define ATOM_PPLIB_CLASSIFICATION_UI_SHIFT 0 | 5846 | #define ATOM_PPLIB_CLASSIFICATION_UI_SHIFT 0 |
@@ -5816,7 +5860,9 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE | |||
5816 | #define ATOM_PPLIB_CLASSIFICATION_UVDSTATE 0x0400 | 5860 | #define ATOM_PPLIB_CLASSIFICATION_UVDSTATE 0x0400 |
5817 | #define ATOM_PPLIB_CLASSIFICATION_3DLOW 0x0800 | 5861 | #define ATOM_PPLIB_CLASSIFICATION_3DLOW 0x0800 |
5818 | #define ATOM_PPLIB_CLASSIFICATION_ACPI 0x1000 | 5862 | #define ATOM_PPLIB_CLASSIFICATION_ACPI 0x1000 |
5819 | // remaining 3 bits are reserved | 5863 | #define ATOM_PPLIB_CLASSIFICATION_HD2STATE 0x2000 |
5864 | #define ATOM_PPLIB_CLASSIFICATION_HDSTATE 0x4000 | ||
5865 | #define ATOM_PPLIB_CLASSIFICATION_SDSTATE 0x8000 | ||
5820 | 5866 | ||
5821 | //// ATOM_PPLIB_NONCLOCK_INFO::ulCapsAndSettings | 5867 | //// ATOM_PPLIB_NONCLOCK_INFO::ulCapsAndSettings |
5822 | #define ATOM_PPLIB_SINGLE_DISPLAY_ONLY 0x00000001 | 5868 | #define ATOM_PPLIB_SINGLE_DISPLAY_ONLY 0x00000001 |
@@ -5840,9 +5886,15 @@ typedef struct _ATOM_PPLIB_POWERPLAYTABLE | |||
5840 | 5886 | ||
5841 | #define ATOM_PPLIB_SOFTWARE_DISABLE_LOADBALANCING 0x00001000 | 5887 | #define ATOM_PPLIB_SOFTWARE_DISABLE_LOADBALANCING 0x00001000 |
5842 | #define ATOM_PPLIB_SOFTWARE_ENABLE_SLEEP_FOR_TIMESTAMPS 0x00002000 | 5888 | #define ATOM_PPLIB_SOFTWARE_ENABLE_SLEEP_FOR_TIMESTAMPS 0x00002000 |
5889 | #define ATOM_PPLIB_DISALLOW_ON_DC 0x00004000 | ||
5843 | #define ATOM_PPLIB_ENABLE_VARIBRIGHT 0x00008000 | 5890 | #define ATOM_PPLIB_ENABLE_VARIBRIGHT 0x00008000 |
5844 | 5891 | ||
5845 | #define ATOM_PPLIB_DISALLOW_ON_DC 0x00004000 | 5892 | //memory related flags |
5893 | #define ATOM_PPLIB_SWSTATE_MEMORY_DLL_OFF 0x000010000 | ||
5894 | |||
5895 | //M3 Arb //2bits, current 3 sets of parameters in total | ||
5896 | #define ATOM_PPLIB_M3ARB_MASK 0x00060000 | ||
5897 | #define ATOM_PPLIB_M3ARB_SHIFT 17 | ||
5846 | 5898 | ||
5847 | // Contained in an array starting at the offset | 5899 | // Contained in an array starting at the offset |
5848 | // in ATOM_PPLIB_POWERPLAYTABLE::usNonClockInfoArrayOffset. | 5900 | // in ATOM_PPLIB_POWERPLAYTABLE::usNonClockInfoArrayOffset. |
@@ -5860,6 +5912,9 @@ typedef struct _ATOM_PPLIB_NONCLOCK_INFO | |||
5860 | // Contained in an array starting at the offset | 5912 | // Contained in an array starting at the offset |
5861 | // in ATOM_PPLIB_POWERPLAYTABLE::usClockInfoArrayOffset. | 5913 | // in ATOM_PPLIB_POWERPLAYTABLE::usClockInfoArrayOffset. |
5862 | // referenced from ATOM_PPLIB_STATE::ucClockStateIndices | 5914 | // referenced from ATOM_PPLIB_STATE::ucClockStateIndices |
5915 | #define ATOM_PPLIB_NONCLOCKINFO_VER1 12 | ||
5916 | #define ATOM_PPLIB_NONCLOCKINFO_VER2 24 | ||
5917 | |||
5863 | typedef struct _ATOM_PPLIB_R600_CLOCK_INFO | 5918 | typedef struct _ATOM_PPLIB_R600_CLOCK_INFO |
5864 | { | 5919 | { |
5865 | USHORT usEngineClockLow; | 5920 | USHORT usEngineClockLow; |
@@ -5882,6 +5937,23 @@ typedef struct _ATOM_PPLIB_R600_CLOCK_INFO | |||
5882 | #define ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE 4 | 5937 | #define ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE 4 |
5883 | #define ATOM_PPLIB_R600_FLAGS_MEMORY_ODT_OFF 8 | 5938 | #define ATOM_PPLIB_R600_FLAGS_MEMORY_ODT_OFF 8 |
5884 | #define ATOM_PPLIB_R600_FLAGS_MEMORY_DLL_OFF 16 | 5939 | #define ATOM_PPLIB_R600_FLAGS_MEMORY_DLL_OFF 16 |
5940 | #define ATOM_PPLIB_R600_FLAGS_LOWPOWER 32 // On the RV770 use 'low power' setting (sequencer S0). | ||
5941 | |||
5942 | typedef struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO | ||
5943 | { | ||
5944 | USHORT usEngineClockLow; | ||
5945 | UCHAR ucEngineClockHigh; | ||
5946 | |||
5947 | USHORT usMemoryClockLow; | ||
5948 | UCHAR ucMemoryClockHigh; | ||
5949 | |||
5950 | USHORT usVDDC; | ||
5951 | USHORT usVDDCI; | ||
5952 | USHORT usUnused; | ||
5953 | |||
5954 | ULONG ulFlags; // ATOM_PPLIB_R600_FLAGS_* | ||
5955 | |||
5956 | } ATOM_PPLIB_EVERGREEN_CLOCK_INFO; | ||
5885 | 5957 | ||
5886 | typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO | 5958 | typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO |
5887 | 5959 | ||
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index a87990b3ae84..3feca6aec4c4 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
@@ -249,17 +249,13 @@ void atombios_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
249 | if (ASIC_IS_DCE3(rdev)) | 249 | if (ASIC_IS_DCE3(rdev)) |
250 | atombios_enable_crtc_memreq(crtc, ATOM_ENABLE); | 250 | atombios_enable_crtc_memreq(crtc, ATOM_ENABLE); |
251 | atombios_blank_crtc(crtc, ATOM_DISABLE); | 251 | atombios_blank_crtc(crtc, ATOM_DISABLE); |
252 | /* XXX re-enable when interrupt support is added */ | 252 | drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); |
253 | if (!ASIC_IS_DCE4(rdev)) | ||
254 | drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); | ||
255 | radeon_crtc_load_lut(crtc); | 253 | radeon_crtc_load_lut(crtc); |
256 | break; | 254 | break; |
257 | case DRM_MODE_DPMS_STANDBY: | 255 | case DRM_MODE_DPMS_STANDBY: |
258 | case DRM_MODE_DPMS_SUSPEND: | 256 | case DRM_MODE_DPMS_SUSPEND: |
259 | case DRM_MODE_DPMS_OFF: | 257 | case DRM_MODE_DPMS_OFF: |
260 | /* XXX re-enable when interrupt support is added */ | 258 | drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); |
261 | if (!ASIC_IS_DCE4(rdev)) | ||
262 | drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id); | ||
263 | atombios_blank_crtc(crtc, ATOM_ENABLE); | 259 | atombios_blank_crtc(crtc, ATOM_ENABLE); |
264 | if (ASIC_IS_DCE3(rdev)) | 260 | if (ASIC_IS_DCE3(rdev)) |
265 | atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); | 261 | atombios_enable_crtc_memreq(crtc, ATOM_DISABLE); |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index bd1bb9fb2b2a..3295154e5934 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -28,39 +28,194 @@ | |||
28 | #include "radeon.h" | 28 | #include "radeon.h" |
29 | #include "radeon_asic.h" | 29 | #include "radeon_asic.h" |
30 | #include "radeon_drm.h" | 30 | #include "radeon_drm.h" |
31 | #include "rv770d.h" | 31 | #include "evergreend.h" |
32 | #include "atom.h" | 32 | #include "atom.h" |
33 | #include "avivod.h" | 33 | #include "avivod.h" |
34 | #include "evergreen_reg.h" | 34 | #include "evergreen_reg.h" |
35 | 35 | ||
36 | #define EVERGREEN_PFP_UCODE_SIZE 1120 | ||
37 | #define EVERGREEN_PM4_UCODE_SIZE 1376 | ||
38 | |||
36 | static void evergreen_gpu_init(struct radeon_device *rdev); | 39 | static void evergreen_gpu_init(struct radeon_device *rdev); |
37 | void evergreen_fini(struct radeon_device *rdev); | 40 | void evergreen_fini(struct radeon_device *rdev); |
38 | 41 | ||
39 | bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) | 42 | bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) |
40 | { | 43 | { |
41 | bool connected = false; | 44 | bool connected = false; |
42 | /* XXX */ | 45 | |
46 | switch (hpd) { | ||
47 | case RADEON_HPD_1: | ||
48 | if (RREG32(DC_HPD1_INT_STATUS) & DC_HPDx_SENSE) | ||
49 | connected = true; | ||
50 | break; | ||
51 | case RADEON_HPD_2: | ||
52 | if (RREG32(DC_HPD2_INT_STATUS) & DC_HPDx_SENSE) | ||
53 | connected = true; | ||
54 | break; | ||
55 | case RADEON_HPD_3: | ||
56 | if (RREG32(DC_HPD3_INT_STATUS) & DC_HPDx_SENSE) | ||
57 | connected = true; | ||
58 | break; | ||
59 | case RADEON_HPD_4: | ||
60 | if (RREG32(DC_HPD4_INT_STATUS) & DC_HPDx_SENSE) | ||
61 | connected = true; | ||
62 | break; | ||
63 | case RADEON_HPD_5: | ||
64 | if (RREG32(DC_HPD5_INT_STATUS) & DC_HPDx_SENSE) | ||
65 | connected = true; | ||
66 | break; | ||
67 | case RADEON_HPD_6: | ||
68 | if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE) | ||
69 | connected = true; | ||
70 | break; | ||
71 | default: | ||
72 | break; | ||
73 | } | ||
74 | |||
43 | return connected; | 75 | return connected; |
44 | } | 76 | } |
45 | 77 | ||
46 | void evergreen_hpd_set_polarity(struct radeon_device *rdev, | 78 | void evergreen_hpd_set_polarity(struct radeon_device *rdev, |
47 | enum radeon_hpd_id hpd) | 79 | enum radeon_hpd_id hpd) |
48 | { | 80 | { |
49 | /* XXX */ | 81 | u32 tmp; |
82 | bool connected = evergreen_hpd_sense(rdev, hpd); | ||
83 | |||
84 | switch (hpd) { | ||
85 | case RADEON_HPD_1: | ||
86 | tmp = RREG32(DC_HPD1_INT_CONTROL); | ||
87 | if (connected) | ||
88 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
89 | else | ||
90 | tmp |= DC_HPDx_INT_POLARITY; | ||
91 | WREG32(DC_HPD1_INT_CONTROL, tmp); | ||
92 | break; | ||
93 | case RADEON_HPD_2: | ||
94 | tmp = RREG32(DC_HPD2_INT_CONTROL); | ||
95 | if (connected) | ||
96 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
97 | else | ||
98 | tmp |= DC_HPDx_INT_POLARITY; | ||
99 | WREG32(DC_HPD2_INT_CONTROL, tmp); | ||
100 | break; | ||
101 | case RADEON_HPD_3: | ||
102 | tmp = RREG32(DC_HPD3_INT_CONTROL); | ||
103 | if (connected) | ||
104 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
105 | else | ||
106 | tmp |= DC_HPDx_INT_POLARITY; | ||
107 | WREG32(DC_HPD3_INT_CONTROL, tmp); | ||
108 | break; | ||
109 | case RADEON_HPD_4: | ||
110 | tmp = RREG32(DC_HPD4_INT_CONTROL); | ||
111 | if (connected) | ||
112 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
113 | else | ||
114 | tmp |= DC_HPDx_INT_POLARITY; | ||
115 | WREG32(DC_HPD4_INT_CONTROL, tmp); | ||
116 | break; | ||
117 | case RADEON_HPD_5: | ||
118 | tmp = RREG32(DC_HPD5_INT_CONTROL); | ||
119 | if (connected) | ||
120 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
121 | else | ||
122 | tmp |= DC_HPDx_INT_POLARITY; | ||
123 | WREG32(DC_HPD5_INT_CONTROL, tmp); | ||
124 | break; | ||
125 | case RADEON_HPD_6: | ||
126 | tmp = RREG32(DC_HPD6_INT_CONTROL); | ||
127 | if (connected) | ||
128 | tmp &= ~DC_HPDx_INT_POLARITY; | ||
129 | else | ||
130 | tmp |= DC_HPDx_INT_POLARITY; | ||
131 | WREG32(DC_HPD6_INT_CONTROL, tmp); | ||
132 | break; | ||
133 | default: | ||
134 | break; | ||
135 | } | ||
50 | } | 136 | } |
51 | 137 | ||
52 | void evergreen_hpd_init(struct radeon_device *rdev) | 138 | void evergreen_hpd_init(struct radeon_device *rdev) |
53 | { | 139 | { |
54 | /* XXX */ | 140 | struct drm_device *dev = rdev->ddev; |
141 | struct drm_connector *connector; | ||
142 | u32 tmp = DC_HPDx_CONNECTION_TIMER(0x9c4) | | ||
143 | DC_HPDx_RX_INT_TIMER(0xfa) | DC_HPDx_EN; | ||
144 | |||
145 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
146 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | ||
147 | switch (radeon_connector->hpd.hpd) { | ||
148 | case RADEON_HPD_1: | ||
149 | WREG32(DC_HPD1_CONTROL, tmp); | ||
150 | rdev->irq.hpd[0] = true; | ||
151 | break; | ||
152 | case RADEON_HPD_2: | ||
153 | WREG32(DC_HPD2_CONTROL, tmp); | ||
154 | rdev->irq.hpd[1] = true; | ||
155 | break; | ||
156 | case RADEON_HPD_3: | ||
157 | WREG32(DC_HPD3_CONTROL, tmp); | ||
158 | rdev->irq.hpd[2] = true; | ||
159 | break; | ||
160 | case RADEON_HPD_4: | ||
161 | WREG32(DC_HPD4_CONTROL, tmp); | ||
162 | rdev->irq.hpd[3] = true; | ||
163 | break; | ||
164 | case RADEON_HPD_5: | ||
165 | WREG32(DC_HPD5_CONTROL, tmp); | ||
166 | rdev->irq.hpd[4] = true; | ||
167 | break; | ||
168 | case RADEON_HPD_6: | ||
169 | WREG32(DC_HPD6_CONTROL, tmp); | ||
170 | rdev->irq.hpd[5] = true; | ||
171 | break; | ||
172 | default: | ||
173 | break; | ||
174 | } | ||
175 | } | ||
176 | if (rdev->irq.installed) | ||
177 | evergreen_irq_set(rdev); | ||
55 | } | 178 | } |
56 | 179 | ||
57 | 180 | void evergreen_hpd_fini(struct radeon_device *rdev) | |
58 | void evergreen_bandwidth_update(struct radeon_device *rdev) | ||
59 | { | 181 | { |
60 | /* XXX */ | 182 | struct drm_device *dev = rdev->ddev; |
183 | struct drm_connector *connector; | ||
184 | |||
185 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | ||
186 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); | ||
187 | switch (radeon_connector->hpd.hpd) { | ||
188 | case RADEON_HPD_1: | ||
189 | WREG32(DC_HPD1_CONTROL, 0); | ||
190 | rdev->irq.hpd[0] = false; | ||
191 | break; | ||
192 | case RADEON_HPD_2: | ||
193 | WREG32(DC_HPD2_CONTROL, 0); | ||
194 | rdev->irq.hpd[1] = false; | ||
195 | break; | ||
196 | case RADEON_HPD_3: | ||
197 | WREG32(DC_HPD3_CONTROL, 0); | ||
198 | rdev->irq.hpd[2] = false; | ||
199 | break; | ||
200 | case RADEON_HPD_4: | ||
201 | WREG32(DC_HPD4_CONTROL, 0); | ||
202 | rdev->irq.hpd[3] = false; | ||
203 | break; | ||
204 | case RADEON_HPD_5: | ||
205 | WREG32(DC_HPD5_CONTROL, 0); | ||
206 | rdev->irq.hpd[4] = false; | ||
207 | break; | ||
208 | case RADEON_HPD_6: | ||
209 | WREG32(DC_HPD6_CONTROL, 0); | ||
210 | rdev->irq.hpd[5] = false; | ||
211 | break; | ||
212 | default: | ||
213 | break; | ||
214 | } | ||
215 | } | ||
61 | } | 216 | } |
62 | 217 | ||
63 | void evergreen_hpd_fini(struct radeon_device *rdev) | 218 | void evergreen_bandwidth_update(struct radeon_device *rdev) |
64 | { | 219 | { |
65 | /* XXX */ | 220 | /* XXX */ |
66 | } | 221 | } |
@@ -83,10 +238,31 @@ static int evergreen_mc_wait_for_idle(struct radeon_device *rdev) | |||
83 | /* | 238 | /* |
84 | * GART | 239 | * GART |
85 | */ | 240 | */ |
241 | void evergreen_pcie_gart_tlb_flush(struct radeon_device *rdev) | ||
242 | { | ||
243 | unsigned i; | ||
244 | u32 tmp; | ||
245 | |||
246 | WREG32(VM_CONTEXT0_REQUEST_RESPONSE, REQUEST_TYPE(1)); | ||
247 | for (i = 0; i < rdev->usec_timeout; i++) { | ||
248 | /* read MC_STATUS */ | ||
249 | tmp = RREG32(VM_CONTEXT0_REQUEST_RESPONSE); | ||
250 | tmp = (tmp & RESPONSE_TYPE_MASK) >> RESPONSE_TYPE_SHIFT; | ||
251 | if (tmp == 2) { | ||
252 | printk(KERN_WARNING "[drm] r600 flush TLB failed\n"); | ||
253 | return; | ||
254 | } | ||
255 | if (tmp) { | ||
256 | return; | ||
257 | } | ||
258 | udelay(1); | ||
259 | } | ||
260 | } | ||
261 | |||
86 | int evergreen_pcie_gart_enable(struct radeon_device *rdev) | 262 | int evergreen_pcie_gart_enable(struct radeon_device *rdev) |
87 | { | 263 | { |
88 | u32 tmp; | 264 | u32 tmp; |
89 | int r, i; | 265 | int r; |
90 | 266 | ||
91 | if (rdev->gart.table.vram.robj == NULL) { | 267 | if (rdev->gart.table.vram.robj == NULL) { |
92 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); | 268 | dev_err(rdev->dev, "No VRAM object for PCIE GART.\n"); |
@@ -121,10 +297,9 @@ int evergreen_pcie_gart_enable(struct radeon_device *rdev) | |||
121 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT); | 297 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT); |
122 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, | 298 | WREG32(VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR, |
123 | (u32)(rdev->dummy_page.addr >> 12)); | 299 | (u32)(rdev->dummy_page.addr >> 12)); |
124 | for (i = 1; i < 7; i++) | 300 | WREG32(VM_CONTEXT1_CNTL, 0); |
125 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | ||
126 | 301 | ||
127 | r600_pcie_gart_tlb_flush(rdev); | 302 | evergreen_pcie_gart_tlb_flush(rdev); |
128 | rdev->gart.ready = true; | 303 | rdev->gart.ready = true; |
129 | return 0; | 304 | return 0; |
130 | } | 305 | } |
@@ -132,11 +307,11 @@ int evergreen_pcie_gart_enable(struct radeon_device *rdev) | |||
132 | void evergreen_pcie_gart_disable(struct radeon_device *rdev) | 307 | void evergreen_pcie_gart_disable(struct radeon_device *rdev) |
133 | { | 308 | { |
134 | u32 tmp; | 309 | u32 tmp; |
135 | int i, r; | 310 | int r; |
136 | 311 | ||
137 | /* Disable all tables */ | 312 | /* Disable all tables */ |
138 | for (i = 0; i < 7; i++) | 313 | WREG32(VM_CONTEXT0_CNTL, 0); |
139 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | 314 | WREG32(VM_CONTEXT1_CNTL, 0); |
140 | 315 | ||
141 | /* Setup L2 cache */ | 316 | /* Setup L2 cache */ |
142 | WREG32(VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING | | 317 | WREG32(VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING | |
@@ -173,7 +348,6 @@ void evergreen_pcie_gart_fini(struct radeon_device *rdev) | |||
173 | void evergreen_agp_enable(struct radeon_device *rdev) | 348 | void evergreen_agp_enable(struct radeon_device *rdev) |
174 | { | 349 | { |
175 | u32 tmp; | 350 | u32 tmp; |
176 | int i; | ||
177 | 351 | ||
178 | /* Setup L2 cache */ | 352 | /* Setup L2 cache */ |
179 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | | 353 | WREG32(VM_L2_CNTL, ENABLE_L2_CACHE | ENABLE_L2_FRAGMENT_PROCESSING | |
@@ -193,8 +367,8 @@ void evergreen_agp_enable(struct radeon_device *rdev) | |||
193 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); | 367 | WREG32(MC_VM_MB_L1_TLB1_CNTL, tmp); |
194 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); | 368 | WREG32(MC_VM_MB_L1_TLB2_CNTL, tmp); |
195 | WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); | 369 | WREG32(MC_VM_MB_L1_TLB3_CNTL, tmp); |
196 | for (i = 0; i < 7; i++) | 370 | WREG32(VM_CONTEXT0_CNTL, 0); |
197 | WREG32(VM_CONTEXT0_CNTL + (i * 4), 0); | 371 | WREG32(VM_CONTEXT1_CNTL, 0); |
198 | } | 372 | } |
199 | 373 | ||
200 | static void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save) | 374 | static void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *save) |
@@ -400,40 +574,656 @@ static void evergreen_mc_program(struct radeon_device *rdev) | |||
400 | rv515_vga_render_disable(rdev); | 574 | rv515_vga_render_disable(rdev); |
401 | } | 575 | } |
402 | 576 | ||
403 | #if 0 | ||
404 | /* | 577 | /* |
405 | * CP. | 578 | * CP. |
406 | */ | 579 | */ |
407 | static void evergreen_cp_stop(struct radeon_device *rdev) | ||
408 | { | ||
409 | /* XXX */ | ||
410 | } | ||
411 | |||
412 | 580 | ||
413 | static int evergreen_cp_load_microcode(struct radeon_device *rdev) | 581 | static int evergreen_cp_load_microcode(struct radeon_device *rdev) |
414 | { | 582 | { |
415 | /* XXX */ | 583 | const __be32 *fw_data; |
584 | int i; | ||
585 | |||
586 | if (!rdev->me_fw || !rdev->pfp_fw) | ||
587 | return -EINVAL; | ||
416 | 588 | ||
589 | r700_cp_stop(rdev); | ||
590 | WREG32(CP_RB_CNTL, RB_NO_UPDATE | (15 << 8) | (3 << 0)); | ||
591 | |||
592 | fw_data = (const __be32 *)rdev->pfp_fw->data; | ||
593 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
594 | for (i = 0; i < EVERGREEN_PFP_UCODE_SIZE; i++) | ||
595 | WREG32(CP_PFP_UCODE_DATA, be32_to_cpup(fw_data++)); | ||
596 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
597 | |||
598 | fw_data = (const __be32 *)rdev->me_fw->data; | ||
599 | WREG32(CP_ME_RAM_WADDR, 0); | ||
600 | for (i = 0; i < EVERGREEN_PM4_UCODE_SIZE; i++) | ||
601 | WREG32(CP_ME_RAM_DATA, be32_to_cpup(fw_data++)); | ||
602 | |||
603 | WREG32(CP_PFP_UCODE_ADDR, 0); | ||
604 | WREG32(CP_ME_RAM_WADDR, 0); | ||
605 | WREG32(CP_ME_RAM_RADDR, 0); | ||
417 | return 0; | 606 | return 0; |
418 | } | 607 | } |
419 | 608 | ||
609 | int evergreen_cp_resume(struct radeon_device *rdev) | ||
610 | { | ||
611 | u32 tmp; | ||
612 | u32 rb_bufsz; | ||
613 | int r; | ||
614 | |||
615 | /* Reset cp; if cp is reset, then PA, SH, VGT also need to be reset */ | ||
616 | WREG32(GRBM_SOFT_RESET, (SOFT_RESET_CP | | ||
617 | SOFT_RESET_PA | | ||
618 | SOFT_RESET_SH | | ||
619 | SOFT_RESET_VGT | | ||
620 | SOFT_RESET_SX)); | ||
621 | RREG32(GRBM_SOFT_RESET); | ||
622 | mdelay(15); | ||
623 | WREG32(GRBM_SOFT_RESET, 0); | ||
624 | RREG32(GRBM_SOFT_RESET); | ||
625 | |||
626 | /* Set ring buffer size */ | ||
627 | rb_bufsz = drm_order(rdev->cp.ring_size / 8); | ||
628 | tmp = RB_NO_UPDATE | (drm_order(RADEON_GPU_PAGE_SIZE/8) << 8) | rb_bufsz; | ||
629 | #ifdef __BIG_ENDIAN | ||
630 | tmp |= BUF_SWAP_32BIT; | ||
631 | #endif | ||
632 | WREG32(CP_RB_CNTL, tmp); | ||
633 | WREG32(CP_SEM_WAIT_TIMER, 0x4); | ||
634 | |||
635 | /* Set the write pointer delay */ | ||
636 | WREG32(CP_RB_WPTR_DELAY, 0); | ||
637 | |||
638 | /* Initialize the ring buffer's read and write pointers */ | ||
639 | WREG32(CP_RB_CNTL, tmp | RB_RPTR_WR_ENA); | ||
640 | WREG32(CP_RB_RPTR_WR, 0); | ||
641 | WREG32(CP_RB_WPTR, 0); | ||
642 | WREG32(CP_RB_RPTR_ADDR, rdev->cp.gpu_addr & 0xFFFFFFFF); | ||
643 | WREG32(CP_RB_RPTR_ADDR_HI, upper_32_bits(rdev->cp.gpu_addr)); | ||
644 | mdelay(1); | ||
645 | WREG32(CP_RB_CNTL, tmp); | ||
646 | |||
647 | WREG32(CP_RB_BASE, rdev->cp.gpu_addr >> 8); | ||
648 | WREG32(CP_DEBUG, (1 << 27) | (1 << 28)); | ||
649 | |||
650 | rdev->cp.rptr = RREG32(CP_RB_RPTR); | ||
651 | rdev->cp.wptr = RREG32(CP_RB_WPTR); | ||
652 | |||
653 | r600_cp_start(rdev); | ||
654 | rdev->cp.ready = true; | ||
655 | r = radeon_ring_test(rdev); | ||
656 | if (r) { | ||
657 | rdev->cp.ready = false; | ||
658 | return r; | ||
659 | } | ||
660 | return 0; | ||
661 | } | ||
420 | 662 | ||
421 | /* | 663 | /* |
422 | * Core functions | 664 | * Core functions |
423 | */ | 665 | */ |
424 | static u32 evergreen_get_tile_pipe_to_backend_map(u32 num_tile_pipes, | 666 | static u32 evergreen_get_tile_pipe_to_backend_map(struct radeon_device *rdev, |
667 | u32 num_tile_pipes, | ||
425 | u32 num_backends, | 668 | u32 num_backends, |
426 | u32 backend_disable_mask) | 669 | u32 backend_disable_mask) |
427 | { | 670 | { |
428 | u32 backend_map = 0; | 671 | u32 backend_map = 0; |
672 | u32 enabled_backends_mask = 0; | ||
673 | u32 enabled_backends_count = 0; | ||
674 | u32 cur_pipe; | ||
675 | u32 swizzle_pipe[EVERGREEN_MAX_PIPES]; | ||
676 | u32 cur_backend = 0; | ||
677 | u32 i; | ||
678 | bool force_no_swizzle; | ||
679 | |||
680 | if (num_tile_pipes > EVERGREEN_MAX_PIPES) | ||
681 | num_tile_pipes = EVERGREEN_MAX_PIPES; | ||
682 | if (num_tile_pipes < 1) | ||
683 | num_tile_pipes = 1; | ||
684 | if (num_backends > EVERGREEN_MAX_BACKENDS) | ||
685 | num_backends = EVERGREEN_MAX_BACKENDS; | ||
686 | if (num_backends < 1) | ||
687 | num_backends = 1; | ||
688 | |||
689 | for (i = 0; i < EVERGREEN_MAX_BACKENDS; ++i) { | ||
690 | if (((backend_disable_mask >> i) & 1) == 0) { | ||
691 | enabled_backends_mask |= (1 << i); | ||
692 | ++enabled_backends_count; | ||
693 | } | ||
694 | if (enabled_backends_count == num_backends) | ||
695 | break; | ||
696 | } | ||
697 | |||
698 | if (enabled_backends_count == 0) { | ||
699 | enabled_backends_mask = 1; | ||
700 | enabled_backends_count = 1; | ||
701 | } | ||
702 | |||
703 | if (enabled_backends_count != num_backends) | ||
704 | num_backends = enabled_backends_count; | ||
705 | |||
706 | memset((uint8_t *)&swizzle_pipe[0], 0, sizeof(u32) * EVERGREEN_MAX_PIPES); | ||
707 | switch (rdev->family) { | ||
708 | case CHIP_CEDAR: | ||
709 | case CHIP_REDWOOD: | ||
710 | force_no_swizzle = false; | ||
711 | break; | ||
712 | case CHIP_CYPRESS: | ||
713 | case CHIP_HEMLOCK: | ||
714 | case CHIP_JUNIPER: | ||
715 | default: | ||
716 | force_no_swizzle = true; | ||
717 | break; | ||
718 | } | ||
719 | if (force_no_swizzle) { | ||
720 | bool last_backend_enabled = false; | ||
721 | |||
722 | force_no_swizzle = false; | ||
723 | for (i = 0; i < EVERGREEN_MAX_BACKENDS; ++i) { | ||
724 | if (((enabled_backends_mask >> i) & 1) == 1) { | ||
725 | if (last_backend_enabled) | ||
726 | force_no_swizzle = true; | ||
727 | last_backend_enabled = true; | ||
728 | } else | ||
729 | last_backend_enabled = false; | ||
730 | } | ||
731 | } | ||
732 | |||
733 | switch (num_tile_pipes) { | ||
734 | case 1: | ||
735 | case 3: | ||
736 | case 5: | ||
737 | case 7: | ||
738 | DRM_ERROR("odd number of pipes!\n"); | ||
739 | break; | ||
740 | case 2: | ||
741 | swizzle_pipe[0] = 0; | ||
742 | swizzle_pipe[1] = 1; | ||
743 | break; | ||
744 | case 4: | ||
745 | if (force_no_swizzle) { | ||
746 | swizzle_pipe[0] = 0; | ||
747 | swizzle_pipe[1] = 1; | ||
748 | swizzle_pipe[2] = 2; | ||
749 | swizzle_pipe[3] = 3; | ||
750 | } else { | ||
751 | swizzle_pipe[0] = 0; | ||
752 | swizzle_pipe[1] = 2; | ||
753 | swizzle_pipe[2] = 1; | ||
754 | swizzle_pipe[3] = 3; | ||
755 | } | ||
756 | break; | ||
757 | case 6: | ||
758 | if (force_no_swizzle) { | ||
759 | swizzle_pipe[0] = 0; | ||
760 | swizzle_pipe[1] = 1; | ||
761 | swizzle_pipe[2] = 2; | ||
762 | swizzle_pipe[3] = 3; | ||
763 | swizzle_pipe[4] = 4; | ||
764 | swizzle_pipe[5] = 5; | ||
765 | } else { | ||
766 | swizzle_pipe[0] = 0; | ||
767 | swizzle_pipe[1] = 2; | ||
768 | swizzle_pipe[2] = 4; | ||
769 | swizzle_pipe[3] = 1; | ||
770 | swizzle_pipe[4] = 3; | ||
771 | swizzle_pipe[5] = 5; | ||
772 | } | ||
773 | break; | ||
774 | case 8: | ||
775 | if (force_no_swizzle) { | ||
776 | swizzle_pipe[0] = 0; | ||
777 | swizzle_pipe[1] = 1; | ||
778 | swizzle_pipe[2] = 2; | ||
779 | swizzle_pipe[3] = 3; | ||
780 | swizzle_pipe[4] = 4; | ||
781 | swizzle_pipe[5] = 5; | ||
782 | swizzle_pipe[6] = 6; | ||
783 | swizzle_pipe[7] = 7; | ||
784 | } else { | ||
785 | swizzle_pipe[0] = 0; | ||
786 | swizzle_pipe[1] = 2; | ||
787 | swizzle_pipe[2] = 4; | ||
788 | swizzle_pipe[3] = 6; | ||
789 | swizzle_pipe[4] = 1; | ||
790 | swizzle_pipe[5] = 3; | ||
791 | swizzle_pipe[6] = 5; | ||
792 | swizzle_pipe[7] = 7; | ||
793 | } | ||
794 | break; | ||
795 | } | ||
796 | |||
797 | for (cur_pipe = 0; cur_pipe < num_tile_pipes; ++cur_pipe) { | ||
798 | while (((1 << cur_backend) & enabled_backends_mask) == 0) | ||
799 | cur_backend = (cur_backend + 1) % EVERGREEN_MAX_BACKENDS; | ||
800 | |||
801 | backend_map |= (((cur_backend & 0xf) << (swizzle_pipe[cur_pipe] * 4))); | ||
802 | |||
803 | cur_backend = (cur_backend + 1) % EVERGREEN_MAX_BACKENDS; | ||
804 | } | ||
429 | 805 | ||
430 | return backend_map; | 806 | return backend_map; |
431 | } | 807 | } |
432 | #endif | ||
433 | 808 | ||
434 | static void evergreen_gpu_init(struct radeon_device *rdev) | 809 | static void evergreen_gpu_init(struct radeon_device *rdev) |
435 | { | 810 | { |
436 | /* XXX */ | 811 | u32 cc_rb_backend_disable = 0; |
812 | u32 cc_gc_shader_pipe_config; | ||
813 | u32 gb_addr_config = 0; | ||
814 | u32 mc_shared_chmap, mc_arb_ramcfg; | ||
815 | u32 gb_backend_map; | ||
816 | u32 grbm_gfx_index; | ||
817 | u32 sx_debug_1; | ||
818 | u32 smx_dc_ctl0; | ||
819 | u32 sq_config; | ||
820 | u32 sq_lds_resource_mgmt; | ||
821 | u32 sq_gpr_resource_mgmt_1; | ||
822 | u32 sq_gpr_resource_mgmt_2; | ||
823 | u32 sq_gpr_resource_mgmt_3; | ||
824 | u32 sq_thread_resource_mgmt; | ||
825 | u32 sq_thread_resource_mgmt_2; | ||
826 | u32 sq_stack_resource_mgmt_1; | ||
827 | u32 sq_stack_resource_mgmt_2; | ||
828 | u32 sq_stack_resource_mgmt_3; | ||
829 | u32 vgt_cache_invalidation; | ||
830 | u32 hdp_host_path_cntl; | ||
831 | int i, j, num_shader_engines, ps_thread_count; | ||
832 | |||
833 | switch (rdev->family) { | ||
834 | case CHIP_CYPRESS: | ||
835 | case CHIP_HEMLOCK: | ||
836 | rdev->config.evergreen.num_ses = 2; | ||
837 | rdev->config.evergreen.max_pipes = 4; | ||
838 | rdev->config.evergreen.max_tile_pipes = 8; | ||
839 | rdev->config.evergreen.max_simds = 10; | ||
840 | rdev->config.evergreen.max_backends = 4 * rdev->config.evergreen.num_ses; | ||
841 | rdev->config.evergreen.max_gprs = 256; | ||
842 | rdev->config.evergreen.max_threads = 248; | ||
843 | rdev->config.evergreen.max_gs_threads = 32; | ||
844 | rdev->config.evergreen.max_stack_entries = 512; | ||
845 | rdev->config.evergreen.sx_num_of_sets = 4; | ||
846 | rdev->config.evergreen.sx_max_export_size = 256; | ||
847 | rdev->config.evergreen.sx_max_export_pos_size = 64; | ||
848 | rdev->config.evergreen.sx_max_export_smx_size = 192; | ||
849 | rdev->config.evergreen.max_hw_contexts = 8; | ||
850 | rdev->config.evergreen.sq_num_cf_insts = 2; | ||
851 | |||
852 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; | ||
853 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; | ||
854 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; | ||
855 | break; | ||
856 | case CHIP_JUNIPER: | ||
857 | rdev->config.evergreen.num_ses = 1; | ||
858 | rdev->config.evergreen.max_pipes = 4; | ||
859 | rdev->config.evergreen.max_tile_pipes = 4; | ||
860 | rdev->config.evergreen.max_simds = 10; | ||
861 | rdev->config.evergreen.max_backends = 4 * rdev->config.evergreen.num_ses; | ||
862 | rdev->config.evergreen.max_gprs = 256; | ||
863 | rdev->config.evergreen.max_threads = 248; | ||
864 | rdev->config.evergreen.max_gs_threads = 32; | ||
865 | rdev->config.evergreen.max_stack_entries = 512; | ||
866 | rdev->config.evergreen.sx_num_of_sets = 4; | ||
867 | rdev->config.evergreen.sx_max_export_size = 256; | ||
868 | rdev->config.evergreen.sx_max_export_pos_size = 64; | ||
869 | rdev->config.evergreen.sx_max_export_smx_size = 192; | ||
870 | rdev->config.evergreen.max_hw_contexts = 8; | ||
871 | rdev->config.evergreen.sq_num_cf_insts = 2; | ||
872 | |||
873 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; | ||
874 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; | ||
875 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; | ||
876 | break; | ||
877 | case CHIP_REDWOOD: | ||
878 | rdev->config.evergreen.num_ses = 1; | ||
879 | rdev->config.evergreen.max_pipes = 4; | ||
880 | rdev->config.evergreen.max_tile_pipes = 4; | ||
881 | rdev->config.evergreen.max_simds = 5; | ||
882 | rdev->config.evergreen.max_backends = 2 * rdev->config.evergreen.num_ses; | ||
883 | rdev->config.evergreen.max_gprs = 256; | ||
884 | rdev->config.evergreen.max_threads = 248; | ||
885 | rdev->config.evergreen.max_gs_threads = 32; | ||
886 | rdev->config.evergreen.max_stack_entries = 256; | ||
887 | rdev->config.evergreen.sx_num_of_sets = 4; | ||
888 | rdev->config.evergreen.sx_max_export_size = 256; | ||
889 | rdev->config.evergreen.sx_max_export_pos_size = 64; | ||
890 | rdev->config.evergreen.sx_max_export_smx_size = 192; | ||
891 | rdev->config.evergreen.max_hw_contexts = 8; | ||
892 | rdev->config.evergreen.sq_num_cf_insts = 2; | ||
893 | |||
894 | rdev->config.evergreen.sc_prim_fifo_size = 0x100; | ||
895 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; | ||
896 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; | ||
897 | break; | ||
898 | case CHIP_CEDAR: | ||
899 | default: | ||
900 | rdev->config.evergreen.num_ses = 1; | ||
901 | rdev->config.evergreen.max_pipes = 2; | ||
902 | rdev->config.evergreen.max_tile_pipes = 2; | ||
903 | rdev->config.evergreen.max_simds = 2; | ||
904 | rdev->config.evergreen.max_backends = 1 * rdev->config.evergreen.num_ses; | ||
905 | rdev->config.evergreen.max_gprs = 256; | ||
906 | rdev->config.evergreen.max_threads = 192; | ||
907 | rdev->config.evergreen.max_gs_threads = 16; | ||
908 | rdev->config.evergreen.max_stack_entries = 256; | ||
909 | rdev->config.evergreen.sx_num_of_sets = 4; | ||
910 | rdev->config.evergreen.sx_max_export_size = 128; | ||
911 | rdev->config.evergreen.sx_max_export_pos_size = 32; | ||
912 | rdev->config.evergreen.sx_max_export_smx_size = 96; | ||
913 | rdev->config.evergreen.max_hw_contexts = 4; | ||
914 | rdev->config.evergreen.sq_num_cf_insts = 1; | ||
915 | |||
916 | rdev->config.evergreen.sc_prim_fifo_size = 0x40; | ||
917 | rdev->config.evergreen.sc_hiz_tile_fifo_size = 0x30; | ||
918 | rdev->config.evergreen.sc_earlyz_tile_fifo_size = 0x130; | ||
919 | break; | ||
920 | } | ||
921 | |||
922 | /* Initialize HDP */ | ||
923 | for (i = 0, j = 0; i < 32; i++, j += 0x18) { | ||
924 | WREG32((0x2c14 + j), 0x00000000); | ||
925 | WREG32((0x2c18 + j), 0x00000000); | ||
926 | WREG32((0x2c1c + j), 0x00000000); | ||
927 | WREG32((0x2c20 + j), 0x00000000); | ||
928 | WREG32((0x2c24 + j), 0x00000000); | ||
929 | } | ||
930 | |||
931 | WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); | ||
932 | |||
933 | cc_gc_shader_pipe_config = RREG32(CC_GC_SHADER_PIPE_CONFIG) & ~2; | ||
934 | |||
935 | cc_gc_shader_pipe_config |= | ||
936 | INACTIVE_QD_PIPES((EVERGREEN_MAX_PIPES_MASK << rdev->config.evergreen.max_pipes) | ||
937 | & EVERGREEN_MAX_PIPES_MASK); | ||
938 | cc_gc_shader_pipe_config |= | ||
939 | INACTIVE_SIMDS((EVERGREEN_MAX_SIMDS_MASK << rdev->config.evergreen.max_simds) | ||
940 | & EVERGREEN_MAX_SIMDS_MASK); | ||
941 | |||
942 | cc_rb_backend_disable = | ||
943 | BACKEND_DISABLE((EVERGREEN_MAX_BACKENDS_MASK << rdev->config.evergreen.max_backends) | ||
944 | & EVERGREEN_MAX_BACKENDS_MASK); | ||
945 | |||
946 | |||
947 | mc_shared_chmap = RREG32(MC_SHARED_CHMAP); | ||
948 | mc_arb_ramcfg = RREG32(MC_ARB_RAMCFG); | ||
949 | |||
950 | switch (rdev->config.evergreen.max_tile_pipes) { | ||
951 | case 1: | ||
952 | default: | ||
953 | gb_addr_config |= NUM_PIPES(0); | ||
954 | break; | ||
955 | case 2: | ||
956 | gb_addr_config |= NUM_PIPES(1); | ||
957 | break; | ||
958 | case 4: | ||
959 | gb_addr_config |= NUM_PIPES(2); | ||
960 | break; | ||
961 | case 8: | ||
962 | gb_addr_config |= NUM_PIPES(3); | ||
963 | break; | ||
964 | } | ||
965 | |||
966 | gb_addr_config |= PIPE_INTERLEAVE_SIZE((mc_arb_ramcfg & BURSTLENGTH_MASK) >> BURSTLENGTH_SHIFT); | ||
967 | gb_addr_config |= BANK_INTERLEAVE_SIZE(0); | ||
968 | gb_addr_config |= NUM_SHADER_ENGINES(rdev->config.evergreen.num_ses - 1); | ||
969 | gb_addr_config |= SHADER_ENGINE_TILE_SIZE(1); | ||
970 | gb_addr_config |= NUM_GPUS(0); /* Hemlock? */ | ||
971 | gb_addr_config |= MULTI_GPU_TILE_SIZE(2); | ||
972 | |||
973 | if (((mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT) > 2) | ||
974 | gb_addr_config |= ROW_SIZE(2); | ||
975 | else | ||
976 | gb_addr_config |= ROW_SIZE((mc_arb_ramcfg & NOOFCOLS_MASK) >> NOOFCOLS_SHIFT); | ||
977 | |||
978 | if (rdev->ddev->pdev->device == 0x689e) { | ||
979 | u32 efuse_straps_4; | ||
980 | u32 efuse_straps_3; | ||
981 | u8 efuse_box_bit_131_124; | ||
982 | |||
983 | WREG32(RCU_IND_INDEX, 0x204); | ||
984 | efuse_straps_4 = RREG32(RCU_IND_DATA); | ||
985 | WREG32(RCU_IND_INDEX, 0x203); | ||
986 | efuse_straps_3 = RREG32(RCU_IND_DATA); | ||
987 | efuse_box_bit_131_124 = (u8)(((efuse_straps_4 & 0xf) << 4) | ((efuse_straps_3 & 0xf0000000) >> 28)); | ||
988 | |||
989 | switch(efuse_box_bit_131_124) { | ||
990 | case 0x00: | ||
991 | gb_backend_map = 0x76543210; | ||
992 | break; | ||
993 | case 0x55: | ||
994 | gb_backend_map = 0x77553311; | ||
995 | break; | ||
996 | case 0x56: | ||
997 | gb_backend_map = 0x77553300; | ||
998 | break; | ||
999 | case 0x59: | ||
1000 | gb_backend_map = 0x77552211; | ||
1001 | break; | ||
1002 | case 0x66: | ||
1003 | gb_backend_map = 0x77443300; | ||
1004 | break; | ||
1005 | case 0x99: | ||
1006 | gb_backend_map = 0x66552211; | ||
1007 | break; | ||
1008 | case 0x5a: | ||
1009 | gb_backend_map = 0x77552200; | ||
1010 | break; | ||
1011 | case 0xaa: | ||
1012 | gb_backend_map = 0x66442200; | ||
1013 | break; | ||
1014 | case 0x95: | ||
1015 | gb_backend_map = 0x66553311; | ||
1016 | break; | ||
1017 | default: | ||
1018 | DRM_ERROR("bad backend map, using default\n"); | ||
1019 | gb_backend_map = | ||
1020 | evergreen_get_tile_pipe_to_backend_map(rdev, | ||
1021 | rdev->config.evergreen.max_tile_pipes, | ||
1022 | rdev->config.evergreen.max_backends, | ||
1023 | ((EVERGREEN_MAX_BACKENDS_MASK << | ||
1024 | rdev->config.evergreen.max_backends) & | ||
1025 | EVERGREEN_MAX_BACKENDS_MASK)); | ||
1026 | break; | ||
1027 | } | ||
1028 | } else if (rdev->ddev->pdev->device == 0x68b9) { | ||
1029 | u32 efuse_straps_3; | ||
1030 | u8 efuse_box_bit_127_124; | ||
1031 | |||
1032 | WREG32(RCU_IND_INDEX, 0x203); | ||
1033 | efuse_straps_3 = RREG32(RCU_IND_DATA); | ||
1034 | efuse_box_bit_127_124 = (u8)(efuse_straps_3 & 0xF0000000) >> 28; | ||
1035 | |||
1036 | switch(efuse_box_bit_127_124) { | ||
1037 | case 0x0: | ||
1038 | gb_backend_map = 0x00003210; | ||
1039 | break; | ||
1040 | case 0x5: | ||
1041 | case 0x6: | ||
1042 | case 0x9: | ||
1043 | case 0xa: | ||
1044 | gb_backend_map = 0x00003311; | ||
1045 | break; | ||
1046 | default: | ||
1047 | DRM_ERROR("bad backend map, using default\n"); | ||
1048 | gb_backend_map = | ||
1049 | evergreen_get_tile_pipe_to_backend_map(rdev, | ||
1050 | rdev->config.evergreen.max_tile_pipes, | ||
1051 | rdev->config.evergreen.max_backends, | ||
1052 | ((EVERGREEN_MAX_BACKENDS_MASK << | ||
1053 | rdev->config.evergreen.max_backends) & | ||
1054 | EVERGREEN_MAX_BACKENDS_MASK)); | ||
1055 | break; | ||
1056 | } | ||
1057 | } else | ||
1058 | gb_backend_map = | ||
1059 | evergreen_get_tile_pipe_to_backend_map(rdev, | ||
1060 | rdev->config.evergreen.max_tile_pipes, | ||
1061 | rdev->config.evergreen.max_backends, | ||
1062 | ((EVERGREEN_MAX_BACKENDS_MASK << | ||
1063 | rdev->config.evergreen.max_backends) & | ||
1064 | EVERGREEN_MAX_BACKENDS_MASK)); | ||
1065 | |||
1066 | WREG32(GB_BACKEND_MAP, gb_backend_map); | ||
1067 | WREG32(GB_ADDR_CONFIG, gb_addr_config); | ||
1068 | WREG32(DMIF_ADDR_CONFIG, gb_addr_config); | ||
1069 | WREG32(HDP_ADDR_CONFIG, gb_addr_config); | ||
1070 | |||
1071 | num_shader_engines = ((RREG32(GB_ADDR_CONFIG) & NUM_SHADER_ENGINES(3)) >> 12) + 1; | ||
1072 | grbm_gfx_index = INSTANCE_BROADCAST_WRITES; | ||
1073 | |||
1074 | for (i = 0; i < rdev->config.evergreen.num_ses; i++) { | ||
1075 | u32 rb = cc_rb_backend_disable | (0xf0 << 16); | ||
1076 | u32 sp = cc_gc_shader_pipe_config; | ||
1077 | u32 gfx = grbm_gfx_index | SE_INDEX(i); | ||
1078 | |||
1079 | if (i == num_shader_engines) { | ||
1080 | rb |= BACKEND_DISABLE(EVERGREEN_MAX_BACKENDS_MASK); | ||
1081 | sp |= INACTIVE_SIMDS(EVERGREEN_MAX_SIMDS_MASK); | ||
1082 | } | ||
1083 | |||
1084 | WREG32(GRBM_GFX_INDEX, gfx); | ||
1085 | WREG32(RLC_GFX_INDEX, gfx); | ||
1086 | |||
1087 | WREG32(CC_RB_BACKEND_DISABLE, rb); | ||
1088 | WREG32(CC_SYS_RB_BACKEND_DISABLE, rb); | ||
1089 | WREG32(GC_USER_RB_BACKEND_DISABLE, rb); | ||
1090 | WREG32(CC_GC_SHADER_PIPE_CONFIG, sp); | ||
1091 | } | ||
1092 | |||
1093 | grbm_gfx_index |= SE_BROADCAST_WRITES; | ||
1094 | WREG32(GRBM_GFX_INDEX, grbm_gfx_index); | ||
1095 | WREG32(RLC_GFX_INDEX, grbm_gfx_index); | ||
1096 | |||
1097 | WREG32(CGTS_SYS_TCC_DISABLE, 0); | ||
1098 | WREG32(CGTS_TCC_DISABLE, 0); | ||
1099 | WREG32(CGTS_USER_SYS_TCC_DISABLE, 0); | ||
1100 | WREG32(CGTS_USER_TCC_DISABLE, 0); | ||
1101 | |||
1102 | /* set HW defaults for 3D engine */ | ||
1103 | WREG32(CP_QUEUE_THRESHOLDS, (ROQ_IB1_START(0x16) | | ||
1104 | ROQ_IB2_START(0x2b))); | ||
1105 | |||
1106 | WREG32(CP_MEQ_THRESHOLDS, STQ_SPLIT(0x30)); | ||
1107 | |||
1108 | WREG32(TA_CNTL_AUX, (DISABLE_CUBE_ANISO | | ||
1109 | SYNC_GRADIENT | | ||
1110 | SYNC_WALKER | | ||
1111 | SYNC_ALIGNER)); | ||
1112 | |||
1113 | sx_debug_1 = RREG32(SX_DEBUG_1); | ||
1114 | sx_debug_1 |= ENABLE_NEW_SMX_ADDRESS; | ||
1115 | WREG32(SX_DEBUG_1, sx_debug_1); | ||
1116 | |||
1117 | |||
1118 | smx_dc_ctl0 = RREG32(SMX_DC_CTL0); | ||
1119 | smx_dc_ctl0 &= ~NUMBER_OF_SETS(0x1ff); | ||
1120 | smx_dc_ctl0 |= NUMBER_OF_SETS(rdev->config.evergreen.sx_num_of_sets); | ||
1121 | WREG32(SMX_DC_CTL0, smx_dc_ctl0); | ||
1122 | |||
1123 | WREG32(SX_EXPORT_BUFFER_SIZES, (COLOR_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_size / 4) - 1) | | ||
1124 | POSITION_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_pos_size / 4) - 1) | | ||
1125 | SMX_BUFFER_SIZE((rdev->config.evergreen.sx_max_export_smx_size / 4) - 1))); | ||
1126 | |||
1127 | WREG32(PA_SC_FIFO_SIZE, (SC_PRIM_FIFO_SIZE(rdev->config.evergreen.sc_prim_fifo_size) | | ||
1128 | SC_HIZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_hiz_tile_fifo_size) | | ||
1129 | SC_EARLYZ_TILE_FIFO_SIZE(rdev->config.evergreen.sc_earlyz_tile_fifo_size))); | ||
1130 | |||
1131 | WREG32(VGT_NUM_INSTANCES, 1); | ||
1132 | WREG32(SPI_CONFIG_CNTL, 0); | ||
1133 | WREG32(SPI_CONFIG_CNTL_1, VTX_DONE_DELAY(4)); | ||
1134 | WREG32(CP_PERFMON_CNTL, 0); | ||
1135 | |||
1136 | WREG32(SQ_MS_FIFO_SIZES, (CACHE_FIFO_SIZE(16 * rdev->config.evergreen.sq_num_cf_insts) | | ||
1137 | FETCH_FIFO_HIWATER(0x4) | | ||
1138 | DONE_FIFO_HIWATER(0xe0) | | ||
1139 | ALU_UPDATE_FIFO_HIWATER(0x8))); | ||
1140 | |||
1141 | sq_config = RREG32(SQ_CONFIG); | ||
1142 | sq_config &= ~(PS_PRIO(3) | | ||
1143 | VS_PRIO(3) | | ||
1144 | GS_PRIO(3) | | ||
1145 | ES_PRIO(3)); | ||
1146 | sq_config |= (VC_ENABLE | | ||
1147 | EXPORT_SRC_C | | ||
1148 | PS_PRIO(0) | | ||
1149 | VS_PRIO(1) | | ||
1150 | GS_PRIO(2) | | ||
1151 | ES_PRIO(3)); | ||
1152 | |||
1153 | if (rdev->family == CHIP_CEDAR) | ||
1154 | /* no vertex cache */ | ||
1155 | sq_config &= ~VC_ENABLE; | ||
1156 | |||
1157 | sq_lds_resource_mgmt = RREG32(SQ_LDS_RESOURCE_MGMT); | ||
1158 | |||
1159 | sq_gpr_resource_mgmt_1 = NUM_PS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2))* 12 / 32); | ||
1160 | sq_gpr_resource_mgmt_1 |= NUM_VS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 6 / 32); | ||
1161 | sq_gpr_resource_mgmt_1 |= NUM_CLAUSE_TEMP_GPRS(4); | ||
1162 | sq_gpr_resource_mgmt_2 = NUM_GS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 4 / 32); | ||
1163 | sq_gpr_resource_mgmt_2 |= NUM_ES_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 4 / 32); | ||
1164 | sq_gpr_resource_mgmt_3 = NUM_HS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 3 / 32); | ||
1165 | sq_gpr_resource_mgmt_3 |= NUM_LS_GPRS((rdev->config.evergreen.max_gprs - (4 * 2)) * 3 / 32); | ||
1166 | |||
1167 | if (rdev->family == CHIP_CEDAR) | ||
1168 | ps_thread_count = 96; | ||
1169 | else | ||
1170 | ps_thread_count = 128; | ||
1171 | |||
1172 | sq_thread_resource_mgmt = NUM_PS_THREADS(ps_thread_count); | ||
1173 | sq_thread_resource_mgmt |= NUM_VS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; | ||
1174 | sq_thread_resource_mgmt |= NUM_GS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; | ||
1175 | sq_thread_resource_mgmt |= NUM_ES_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; | ||
1176 | sq_thread_resource_mgmt_2 = NUM_HS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; | ||
1177 | sq_thread_resource_mgmt_2 |= NUM_LS_THREADS(((rdev->config.evergreen.max_threads - ps_thread_count) / 6) / 8) * 8; | ||
1178 | |||
1179 | sq_stack_resource_mgmt_1 = NUM_PS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1180 | sq_stack_resource_mgmt_1 |= NUM_VS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1181 | sq_stack_resource_mgmt_2 = NUM_GS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1182 | sq_stack_resource_mgmt_2 |= NUM_ES_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1183 | sq_stack_resource_mgmt_3 = NUM_HS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1184 | sq_stack_resource_mgmt_3 |= NUM_LS_STACK_ENTRIES((rdev->config.evergreen.max_stack_entries * 1) / 6); | ||
1185 | |||
1186 | WREG32(SQ_CONFIG, sq_config); | ||
1187 | WREG32(SQ_GPR_RESOURCE_MGMT_1, sq_gpr_resource_mgmt_1); | ||
1188 | WREG32(SQ_GPR_RESOURCE_MGMT_2, sq_gpr_resource_mgmt_2); | ||
1189 | WREG32(SQ_GPR_RESOURCE_MGMT_3, sq_gpr_resource_mgmt_3); | ||
1190 | WREG32(SQ_THREAD_RESOURCE_MGMT, sq_thread_resource_mgmt); | ||
1191 | WREG32(SQ_THREAD_RESOURCE_MGMT_2, sq_thread_resource_mgmt_2); | ||
1192 | WREG32(SQ_STACK_RESOURCE_MGMT_1, sq_stack_resource_mgmt_1); | ||
1193 | WREG32(SQ_STACK_RESOURCE_MGMT_2, sq_stack_resource_mgmt_2); | ||
1194 | WREG32(SQ_STACK_RESOURCE_MGMT_3, sq_stack_resource_mgmt_3); | ||
1195 | WREG32(SQ_DYN_GPR_CNTL_PS_FLUSH_REQ, 0); | ||
1196 | WREG32(SQ_LDS_RESOURCE_MGMT, sq_lds_resource_mgmt); | ||
1197 | |||
1198 | WREG32(PA_SC_FORCE_EOV_MAX_CNTS, (FORCE_EOV_MAX_CLK_CNT(4095) | | ||
1199 | FORCE_EOV_MAX_REZ_CNT(255))); | ||
1200 | |||
1201 | if (rdev->family == CHIP_CEDAR) | ||
1202 | vgt_cache_invalidation = CACHE_INVALIDATION(TC_ONLY); | ||
1203 | else | ||
1204 | vgt_cache_invalidation = CACHE_INVALIDATION(VC_AND_TC); | ||
1205 | vgt_cache_invalidation |= AUTO_INVLD_EN(ES_AND_GS_AUTO); | ||
1206 | WREG32(VGT_CACHE_INVALIDATION, vgt_cache_invalidation); | ||
1207 | |||
1208 | WREG32(VGT_GS_VERTEX_REUSE, 16); | ||
1209 | WREG32(PA_SC_LINE_STIPPLE_STATE, 0); | ||
1210 | |||
1211 | WREG32(CB_PERF_CTR0_SEL_0, 0); | ||
1212 | WREG32(CB_PERF_CTR0_SEL_1, 0); | ||
1213 | WREG32(CB_PERF_CTR1_SEL_0, 0); | ||
1214 | WREG32(CB_PERF_CTR1_SEL_1, 0); | ||
1215 | WREG32(CB_PERF_CTR2_SEL_0, 0); | ||
1216 | WREG32(CB_PERF_CTR2_SEL_1, 0); | ||
1217 | WREG32(CB_PERF_CTR3_SEL_0, 0); | ||
1218 | WREG32(CB_PERF_CTR3_SEL_1, 0); | ||
1219 | |||
1220 | hdp_host_path_cntl = RREG32(HDP_HOST_PATH_CNTL); | ||
1221 | WREG32(HDP_HOST_PATH_CNTL, hdp_host_path_cntl); | ||
1222 | |||
1223 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); | ||
1224 | |||
1225 | udelay(50); | ||
1226 | |||
437 | } | 1227 | } |
438 | 1228 | ||
439 | int evergreen_mc_init(struct radeon_device *rdev) | 1229 | int evergreen_mc_init(struct radeon_device *rdev) |
@@ -493,15 +1283,604 @@ bool evergreen_gpu_is_lockup(struct radeon_device *rdev) | |||
493 | return false; | 1283 | return false; |
494 | } | 1284 | } |
495 | 1285 | ||
1286 | static int evergreen_gpu_soft_reset(struct radeon_device *rdev) | ||
1287 | { | ||
1288 | struct evergreen_mc_save save; | ||
1289 | u32 srbm_reset = 0; | ||
1290 | u32 grbm_reset = 0; | ||
1291 | |||
1292 | dev_info(rdev->dev, "GPU softreset \n"); | ||
1293 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", | ||
1294 | RREG32(GRBM_STATUS)); | ||
1295 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", | ||
1296 | RREG32(GRBM_STATUS_SE0)); | ||
1297 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", | ||
1298 | RREG32(GRBM_STATUS_SE1)); | ||
1299 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", | ||
1300 | RREG32(SRBM_STATUS)); | ||
1301 | evergreen_mc_stop(rdev, &save); | ||
1302 | if (evergreen_mc_wait_for_idle(rdev)) { | ||
1303 | dev_warn(rdev->dev, "Wait for MC idle timedout !\n"); | ||
1304 | } | ||
1305 | /* Disable CP parsing/prefetching */ | ||
1306 | WREG32(CP_ME_CNTL, CP_ME_HALT | CP_PFP_HALT); | ||
1307 | |||
1308 | /* reset all the gfx blocks */ | ||
1309 | grbm_reset = (SOFT_RESET_CP | | ||
1310 | SOFT_RESET_CB | | ||
1311 | SOFT_RESET_DB | | ||
1312 | SOFT_RESET_PA | | ||
1313 | SOFT_RESET_SC | | ||
1314 | SOFT_RESET_SPI | | ||
1315 | SOFT_RESET_SH | | ||
1316 | SOFT_RESET_SX | | ||
1317 | SOFT_RESET_TC | | ||
1318 | SOFT_RESET_TA | | ||
1319 | SOFT_RESET_VC | | ||
1320 | SOFT_RESET_VGT); | ||
1321 | |||
1322 | dev_info(rdev->dev, " GRBM_SOFT_RESET=0x%08X\n", grbm_reset); | ||
1323 | WREG32(GRBM_SOFT_RESET, grbm_reset); | ||
1324 | (void)RREG32(GRBM_SOFT_RESET); | ||
1325 | udelay(50); | ||
1326 | WREG32(GRBM_SOFT_RESET, 0); | ||
1327 | (void)RREG32(GRBM_SOFT_RESET); | ||
1328 | |||
1329 | /* reset all the system blocks */ | ||
1330 | srbm_reset = SRBM_SOFT_RESET_ALL_MASK; | ||
1331 | |||
1332 | dev_info(rdev->dev, " SRBM_SOFT_RESET=0x%08X\n", srbm_reset); | ||
1333 | WREG32(SRBM_SOFT_RESET, srbm_reset); | ||
1334 | (void)RREG32(SRBM_SOFT_RESET); | ||
1335 | udelay(50); | ||
1336 | WREG32(SRBM_SOFT_RESET, 0); | ||
1337 | (void)RREG32(SRBM_SOFT_RESET); | ||
1338 | /* Wait a little for things to settle down */ | ||
1339 | udelay(50); | ||
1340 | dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", | ||
1341 | RREG32(GRBM_STATUS)); | ||
1342 | dev_info(rdev->dev, " GRBM_STATUS_SE0=0x%08X\n", | ||
1343 | RREG32(GRBM_STATUS_SE0)); | ||
1344 | dev_info(rdev->dev, " GRBM_STATUS_SE1=0x%08X\n", | ||
1345 | RREG32(GRBM_STATUS_SE1)); | ||
1346 | dev_info(rdev->dev, " SRBM_STATUS=0x%08X\n", | ||
1347 | RREG32(SRBM_STATUS)); | ||
1348 | /* After reset we need to reinit the asic as GPU often endup in an | ||
1349 | * incoherent state. | ||
1350 | */ | ||
1351 | atom_asic_init(rdev->mode_info.atom_context); | ||
1352 | evergreen_mc_resume(rdev, &save); | ||
1353 | return 0; | ||
1354 | } | ||
1355 | |||
496 | int evergreen_asic_reset(struct radeon_device *rdev) | 1356 | int evergreen_asic_reset(struct radeon_device *rdev) |
497 | { | 1357 | { |
498 | /* FIXME: implement for evergreen */ | 1358 | return evergreen_gpu_soft_reset(rdev); |
1359 | } | ||
1360 | |||
1361 | /* Interrupts */ | ||
1362 | |||
1363 | u32 evergreen_get_vblank_counter(struct radeon_device *rdev, int crtc) | ||
1364 | { | ||
1365 | switch (crtc) { | ||
1366 | case 0: | ||
1367 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC0_REGISTER_OFFSET); | ||
1368 | case 1: | ||
1369 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC1_REGISTER_OFFSET); | ||
1370 | case 2: | ||
1371 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC2_REGISTER_OFFSET); | ||
1372 | case 3: | ||
1373 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC3_REGISTER_OFFSET); | ||
1374 | case 4: | ||
1375 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC4_REGISTER_OFFSET); | ||
1376 | case 5: | ||
1377 | return RREG32(CRTC_STATUS_FRAME_COUNT + EVERGREEN_CRTC5_REGISTER_OFFSET); | ||
1378 | default: | ||
1379 | return 0; | ||
1380 | } | ||
1381 | } | ||
1382 | |||
1383 | void evergreen_disable_interrupt_state(struct radeon_device *rdev) | ||
1384 | { | ||
1385 | u32 tmp; | ||
1386 | |||
1387 | WREG32(CP_INT_CNTL, 0); | ||
1388 | WREG32(GRBM_INT_CNTL, 0); | ||
1389 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); | ||
1390 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); | ||
1391 | WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); | ||
1392 | WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); | ||
1393 | WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); | ||
1394 | WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); | ||
1395 | |||
1396 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); | ||
1397 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); | ||
1398 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC2_REGISTER_OFFSET, 0); | ||
1399 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC3_REGISTER_OFFSET, 0); | ||
1400 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC4_REGISTER_OFFSET, 0); | ||
1401 | WREG32(GRPH_INT_CONTROL + EVERGREEN_CRTC5_REGISTER_OFFSET, 0); | ||
1402 | |||
1403 | WREG32(DACA_AUTODETECT_INT_CONTROL, 0); | ||
1404 | WREG32(DACB_AUTODETECT_INT_CONTROL, 0); | ||
1405 | |||
1406 | tmp = RREG32(DC_HPD1_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1407 | WREG32(DC_HPD1_INT_CONTROL, tmp); | ||
1408 | tmp = RREG32(DC_HPD2_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1409 | WREG32(DC_HPD2_INT_CONTROL, tmp); | ||
1410 | tmp = RREG32(DC_HPD3_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1411 | WREG32(DC_HPD3_INT_CONTROL, tmp); | ||
1412 | tmp = RREG32(DC_HPD4_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1413 | WREG32(DC_HPD4_INT_CONTROL, tmp); | ||
1414 | tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1415 | WREG32(DC_HPD5_INT_CONTROL, tmp); | ||
1416 | tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; | ||
1417 | WREG32(DC_HPD6_INT_CONTROL, tmp); | ||
1418 | |||
1419 | } | ||
1420 | |||
1421 | int evergreen_irq_set(struct radeon_device *rdev) | ||
1422 | { | ||
1423 | u32 cp_int_cntl = CNTX_BUSY_INT_ENABLE | CNTX_EMPTY_INT_ENABLE; | ||
1424 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; | ||
1425 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; | ||
1426 | |||
1427 | if (!rdev->irq.installed) { | ||
1428 | WARN(1, "Can't enable IRQ/MSI because no handler is installed.\n"); | ||
1429 | return -EINVAL; | ||
1430 | } | ||
1431 | /* don't enable anything if the ih is disabled */ | ||
1432 | if (!rdev->ih.enabled) { | ||
1433 | r600_disable_interrupts(rdev); | ||
1434 | /* force the active interrupt state to all disabled */ | ||
1435 | evergreen_disable_interrupt_state(rdev); | ||
1436 | return 0; | ||
1437 | } | ||
1438 | |||
1439 | hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1440 | hpd2 = RREG32(DC_HPD2_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1441 | hpd3 = RREG32(DC_HPD3_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1442 | hpd4 = RREG32(DC_HPD4_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1443 | hpd5 = RREG32(DC_HPD5_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1444 | hpd6 = RREG32(DC_HPD6_INT_CONTROL) & ~DC_HPDx_INT_EN; | ||
1445 | |||
1446 | if (rdev->irq.sw_int) { | ||
1447 | DRM_DEBUG("evergreen_irq_set: sw int\n"); | ||
1448 | cp_int_cntl |= RB_INT_ENABLE; | ||
1449 | } | ||
1450 | if (rdev->irq.crtc_vblank_int[0]) { | ||
1451 | DRM_DEBUG("evergreen_irq_set: vblank 0\n"); | ||
1452 | crtc1 |= VBLANK_INT_MASK; | ||
1453 | } | ||
1454 | if (rdev->irq.crtc_vblank_int[1]) { | ||
1455 | DRM_DEBUG("evergreen_irq_set: vblank 1\n"); | ||
1456 | crtc2 |= VBLANK_INT_MASK; | ||
1457 | } | ||
1458 | if (rdev->irq.crtc_vblank_int[2]) { | ||
1459 | DRM_DEBUG("evergreen_irq_set: vblank 2\n"); | ||
1460 | crtc3 |= VBLANK_INT_MASK; | ||
1461 | } | ||
1462 | if (rdev->irq.crtc_vblank_int[3]) { | ||
1463 | DRM_DEBUG("evergreen_irq_set: vblank 3\n"); | ||
1464 | crtc4 |= VBLANK_INT_MASK; | ||
1465 | } | ||
1466 | if (rdev->irq.crtc_vblank_int[4]) { | ||
1467 | DRM_DEBUG("evergreen_irq_set: vblank 4\n"); | ||
1468 | crtc5 |= VBLANK_INT_MASK; | ||
1469 | } | ||
1470 | if (rdev->irq.crtc_vblank_int[5]) { | ||
1471 | DRM_DEBUG("evergreen_irq_set: vblank 5\n"); | ||
1472 | crtc6 |= VBLANK_INT_MASK; | ||
1473 | } | ||
1474 | if (rdev->irq.hpd[0]) { | ||
1475 | DRM_DEBUG("evergreen_irq_set: hpd 1\n"); | ||
1476 | hpd1 |= DC_HPDx_INT_EN; | ||
1477 | } | ||
1478 | if (rdev->irq.hpd[1]) { | ||
1479 | DRM_DEBUG("evergreen_irq_set: hpd 2\n"); | ||
1480 | hpd2 |= DC_HPDx_INT_EN; | ||
1481 | } | ||
1482 | if (rdev->irq.hpd[2]) { | ||
1483 | DRM_DEBUG("evergreen_irq_set: hpd 3\n"); | ||
1484 | hpd3 |= DC_HPDx_INT_EN; | ||
1485 | } | ||
1486 | if (rdev->irq.hpd[3]) { | ||
1487 | DRM_DEBUG("evergreen_irq_set: hpd 4\n"); | ||
1488 | hpd4 |= DC_HPDx_INT_EN; | ||
1489 | } | ||
1490 | if (rdev->irq.hpd[4]) { | ||
1491 | DRM_DEBUG("evergreen_irq_set: hpd 5\n"); | ||
1492 | hpd5 |= DC_HPDx_INT_EN; | ||
1493 | } | ||
1494 | if (rdev->irq.hpd[5]) { | ||
1495 | DRM_DEBUG("evergreen_irq_set: hpd 6\n"); | ||
1496 | hpd6 |= DC_HPDx_INT_EN; | ||
1497 | } | ||
1498 | |||
1499 | WREG32(CP_INT_CNTL, cp_int_cntl); | ||
1500 | |||
1501 | WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, crtc1); | ||
1502 | WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, crtc2); | ||
1503 | WREG32(INT_MASK + EVERGREEN_CRTC2_REGISTER_OFFSET, crtc3); | ||
1504 | WREG32(INT_MASK + EVERGREEN_CRTC3_REGISTER_OFFSET, crtc4); | ||
1505 | WREG32(INT_MASK + EVERGREEN_CRTC4_REGISTER_OFFSET, crtc5); | ||
1506 | WREG32(INT_MASK + EVERGREEN_CRTC5_REGISTER_OFFSET, crtc6); | ||
1507 | |||
1508 | WREG32(DC_HPD1_INT_CONTROL, hpd1); | ||
1509 | WREG32(DC_HPD2_INT_CONTROL, hpd2); | ||
1510 | WREG32(DC_HPD3_INT_CONTROL, hpd3); | ||
1511 | WREG32(DC_HPD4_INT_CONTROL, hpd4); | ||
1512 | WREG32(DC_HPD5_INT_CONTROL, hpd5); | ||
1513 | WREG32(DC_HPD6_INT_CONTROL, hpd6); | ||
1514 | |||
499 | return 0; | 1515 | return 0; |
500 | } | 1516 | } |
501 | 1517 | ||
1518 | static inline void evergreen_irq_ack(struct radeon_device *rdev, | ||
1519 | u32 *disp_int, | ||
1520 | u32 *disp_int_cont, | ||
1521 | u32 *disp_int_cont2, | ||
1522 | u32 *disp_int_cont3, | ||
1523 | u32 *disp_int_cont4, | ||
1524 | u32 *disp_int_cont5) | ||
1525 | { | ||
1526 | u32 tmp; | ||
1527 | |||
1528 | *disp_int = RREG32(DISP_INTERRUPT_STATUS); | ||
1529 | *disp_int_cont = RREG32(DISP_INTERRUPT_STATUS_CONTINUE); | ||
1530 | *disp_int_cont2 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE2); | ||
1531 | *disp_int_cont3 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE3); | ||
1532 | *disp_int_cont4 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE4); | ||
1533 | *disp_int_cont5 = RREG32(DISP_INTERRUPT_STATUS_CONTINUE5); | ||
1534 | |||
1535 | if (*disp_int & LB_D1_VBLANK_INTERRUPT) | ||
1536 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VBLANK_ACK); | ||
1537 | if (*disp_int & LB_D1_VLINE_INTERRUPT) | ||
1538 | WREG32(VLINE_STATUS + EVERGREEN_CRTC0_REGISTER_OFFSET, VLINE_ACK); | ||
1539 | |||
1540 | if (*disp_int_cont & LB_D2_VBLANK_INTERRUPT) | ||
1541 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VBLANK_ACK); | ||
1542 | if (*disp_int_cont & LB_D2_VLINE_INTERRUPT) | ||
1543 | WREG32(VLINE_STATUS + EVERGREEN_CRTC1_REGISTER_OFFSET, VLINE_ACK); | ||
1544 | |||
1545 | if (*disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) | ||
1546 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VBLANK_ACK); | ||
1547 | if (*disp_int_cont2 & LB_D3_VLINE_INTERRUPT) | ||
1548 | WREG32(VLINE_STATUS + EVERGREEN_CRTC2_REGISTER_OFFSET, VLINE_ACK); | ||
1549 | |||
1550 | if (*disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) | ||
1551 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VBLANK_ACK); | ||
1552 | if (*disp_int_cont3 & LB_D4_VLINE_INTERRUPT) | ||
1553 | WREG32(VLINE_STATUS + EVERGREEN_CRTC3_REGISTER_OFFSET, VLINE_ACK); | ||
1554 | |||
1555 | if (*disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) | ||
1556 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VBLANK_ACK); | ||
1557 | if (*disp_int_cont4 & LB_D5_VLINE_INTERRUPT) | ||
1558 | WREG32(VLINE_STATUS + EVERGREEN_CRTC4_REGISTER_OFFSET, VLINE_ACK); | ||
1559 | |||
1560 | if (*disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) | ||
1561 | WREG32(VBLANK_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VBLANK_ACK); | ||
1562 | if (*disp_int_cont5 & LB_D6_VLINE_INTERRUPT) | ||
1563 | WREG32(VLINE_STATUS + EVERGREEN_CRTC5_REGISTER_OFFSET, VLINE_ACK); | ||
1564 | |||
1565 | if (*disp_int & DC_HPD1_INTERRUPT) { | ||
1566 | tmp = RREG32(DC_HPD1_INT_CONTROL); | ||
1567 | tmp |= DC_HPDx_INT_ACK; | ||
1568 | WREG32(DC_HPD1_INT_CONTROL, tmp); | ||
1569 | } | ||
1570 | if (*disp_int_cont & DC_HPD2_INTERRUPT) { | ||
1571 | tmp = RREG32(DC_HPD2_INT_CONTROL); | ||
1572 | tmp |= DC_HPDx_INT_ACK; | ||
1573 | WREG32(DC_HPD2_INT_CONTROL, tmp); | ||
1574 | } | ||
1575 | if (*disp_int_cont2 & DC_HPD3_INTERRUPT) { | ||
1576 | tmp = RREG32(DC_HPD3_INT_CONTROL); | ||
1577 | tmp |= DC_HPDx_INT_ACK; | ||
1578 | WREG32(DC_HPD3_INT_CONTROL, tmp); | ||
1579 | } | ||
1580 | if (*disp_int_cont3 & DC_HPD4_INTERRUPT) { | ||
1581 | tmp = RREG32(DC_HPD4_INT_CONTROL); | ||
1582 | tmp |= DC_HPDx_INT_ACK; | ||
1583 | WREG32(DC_HPD4_INT_CONTROL, tmp); | ||
1584 | } | ||
1585 | if (*disp_int_cont4 & DC_HPD5_INTERRUPT) { | ||
1586 | tmp = RREG32(DC_HPD5_INT_CONTROL); | ||
1587 | tmp |= DC_HPDx_INT_ACK; | ||
1588 | WREG32(DC_HPD5_INT_CONTROL, tmp); | ||
1589 | } | ||
1590 | if (*disp_int_cont5 & DC_HPD6_INTERRUPT) { | ||
1591 | tmp = RREG32(DC_HPD5_INT_CONTROL); | ||
1592 | tmp |= DC_HPDx_INT_ACK; | ||
1593 | WREG32(DC_HPD6_INT_CONTROL, tmp); | ||
1594 | } | ||
1595 | } | ||
1596 | |||
1597 | void evergreen_irq_disable(struct radeon_device *rdev) | ||
1598 | { | ||
1599 | u32 disp_int, disp_int_cont, disp_int_cont2; | ||
1600 | u32 disp_int_cont3, disp_int_cont4, disp_int_cont5; | ||
1601 | |||
1602 | r600_disable_interrupts(rdev); | ||
1603 | /* Wait and acknowledge irq */ | ||
1604 | mdelay(1); | ||
1605 | evergreen_irq_ack(rdev, &disp_int, &disp_int_cont, &disp_int_cont2, | ||
1606 | &disp_int_cont3, &disp_int_cont4, &disp_int_cont5); | ||
1607 | evergreen_disable_interrupt_state(rdev); | ||
1608 | } | ||
1609 | |||
1610 | static void evergreen_irq_suspend(struct radeon_device *rdev) | ||
1611 | { | ||
1612 | evergreen_irq_disable(rdev); | ||
1613 | r600_rlc_stop(rdev); | ||
1614 | } | ||
1615 | |||
1616 | static inline u32 evergreen_get_ih_wptr(struct radeon_device *rdev) | ||
1617 | { | ||
1618 | u32 wptr, tmp; | ||
1619 | |||
1620 | /* XXX use writeback */ | ||
1621 | wptr = RREG32(IH_RB_WPTR); | ||
1622 | |||
1623 | if (wptr & RB_OVERFLOW) { | ||
1624 | /* When a ring buffer overflow happen start parsing interrupt | ||
1625 | * from the last not overwritten vector (wptr + 16). Hopefully | ||
1626 | * this should allow us to catchup. | ||
1627 | */ | ||
1628 | dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", | ||
1629 | wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); | ||
1630 | rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; | ||
1631 | tmp = RREG32(IH_RB_CNTL); | ||
1632 | tmp |= IH_WPTR_OVERFLOW_CLEAR; | ||
1633 | WREG32(IH_RB_CNTL, tmp); | ||
1634 | } | ||
1635 | return (wptr & rdev->ih.ptr_mask); | ||
1636 | } | ||
1637 | |||
1638 | int evergreen_irq_process(struct radeon_device *rdev) | ||
1639 | { | ||
1640 | u32 wptr = evergreen_get_ih_wptr(rdev); | ||
1641 | u32 rptr = rdev->ih.rptr; | ||
1642 | u32 src_id, src_data; | ||
1643 | u32 ring_index; | ||
1644 | u32 disp_int, disp_int_cont, disp_int_cont2; | ||
1645 | u32 disp_int_cont3, disp_int_cont4, disp_int_cont5; | ||
1646 | unsigned long flags; | ||
1647 | bool queue_hotplug = false; | ||
1648 | |||
1649 | DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); | ||
1650 | if (!rdev->ih.enabled) | ||
1651 | return IRQ_NONE; | ||
1652 | |||
1653 | spin_lock_irqsave(&rdev->ih.lock, flags); | ||
1654 | |||
1655 | if (rptr == wptr) { | ||
1656 | spin_unlock_irqrestore(&rdev->ih.lock, flags); | ||
1657 | return IRQ_NONE; | ||
1658 | } | ||
1659 | if (rdev->shutdown) { | ||
1660 | spin_unlock_irqrestore(&rdev->ih.lock, flags); | ||
1661 | return IRQ_NONE; | ||
1662 | } | ||
1663 | |||
1664 | restart_ih: | ||
1665 | /* display interrupts */ | ||
1666 | evergreen_irq_ack(rdev, &disp_int, &disp_int_cont, &disp_int_cont2, | ||
1667 | &disp_int_cont3, &disp_int_cont4, &disp_int_cont5); | ||
1668 | |||
1669 | rdev->ih.wptr = wptr; | ||
1670 | while (rptr != wptr) { | ||
1671 | /* wptr/rptr are in bytes! */ | ||
1672 | ring_index = rptr / 4; | ||
1673 | src_id = rdev->ih.ring[ring_index] & 0xff; | ||
1674 | src_data = rdev->ih.ring[ring_index + 1] & 0xfffffff; | ||
1675 | |||
1676 | switch (src_id) { | ||
1677 | case 1: /* D1 vblank/vline */ | ||
1678 | switch (src_data) { | ||
1679 | case 0: /* D1 vblank */ | ||
1680 | if (disp_int & LB_D1_VBLANK_INTERRUPT) { | ||
1681 | drm_handle_vblank(rdev->ddev, 0); | ||
1682 | wake_up(&rdev->irq.vblank_queue); | ||
1683 | disp_int &= ~LB_D1_VBLANK_INTERRUPT; | ||
1684 | DRM_DEBUG("IH: D1 vblank\n"); | ||
1685 | } | ||
1686 | break; | ||
1687 | case 1: /* D1 vline */ | ||
1688 | if (disp_int & LB_D1_VLINE_INTERRUPT) { | ||
1689 | disp_int &= ~LB_D1_VLINE_INTERRUPT; | ||
1690 | DRM_DEBUG("IH: D1 vline\n"); | ||
1691 | } | ||
1692 | break; | ||
1693 | default: | ||
1694 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1695 | break; | ||
1696 | } | ||
1697 | break; | ||
1698 | case 2: /* D2 vblank/vline */ | ||
1699 | switch (src_data) { | ||
1700 | case 0: /* D2 vblank */ | ||
1701 | if (disp_int_cont & LB_D2_VBLANK_INTERRUPT) { | ||
1702 | drm_handle_vblank(rdev->ddev, 1); | ||
1703 | wake_up(&rdev->irq.vblank_queue); | ||
1704 | disp_int_cont &= ~LB_D2_VBLANK_INTERRUPT; | ||
1705 | DRM_DEBUG("IH: D2 vblank\n"); | ||
1706 | } | ||
1707 | break; | ||
1708 | case 1: /* D2 vline */ | ||
1709 | if (disp_int_cont & LB_D2_VLINE_INTERRUPT) { | ||
1710 | disp_int_cont &= ~LB_D2_VLINE_INTERRUPT; | ||
1711 | DRM_DEBUG("IH: D2 vline\n"); | ||
1712 | } | ||
1713 | break; | ||
1714 | default: | ||
1715 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1716 | break; | ||
1717 | } | ||
1718 | break; | ||
1719 | case 3: /* D3 vblank/vline */ | ||
1720 | switch (src_data) { | ||
1721 | case 0: /* D3 vblank */ | ||
1722 | if (disp_int_cont2 & LB_D3_VBLANK_INTERRUPT) { | ||
1723 | drm_handle_vblank(rdev->ddev, 2); | ||
1724 | wake_up(&rdev->irq.vblank_queue); | ||
1725 | disp_int_cont2 &= ~LB_D3_VBLANK_INTERRUPT; | ||
1726 | DRM_DEBUG("IH: D3 vblank\n"); | ||
1727 | } | ||
1728 | break; | ||
1729 | case 1: /* D3 vline */ | ||
1730 | if (disp_int_cont2 & LB_D3_VLINE_INTERRUPT) { | ||
1731 | disp_int_cont2 &= ~LB_D3_VLINE_INTERRUPT; | ||
1732 | DRM_DEBUG("IH: D3 vline\n"); | ||
1733 | } | ||
1734 | break; | ||
1735 | default: | ||
1736 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1737 | break; | ||
1738 | } | ||
1739 | break; | ||
1740 | case 4: /* D4 vblank/vline */ | ||
1741 | switch (src_data) { | ||
1742 | case 0: /* D4 vblank */ | ||
1743 | if (disp_int_cont3 & LB_D4_VBLANK_INTERRUPT) { | ||
1744 | drm_handle_vblank(rdev->ddev, 3); | ||
1745 | wake_up(&rdev->irq.vblank_queue); | ||
1746 | disp_int_cont3 &= ~LB_D4_VBLANK_INTERRUPT; | ||
1747 | DRM_DEBUG("IH: D4 vblank\n"); | ||
1748 | } | ||
1749 | break; | ||
1750 | case 1: /* D4 vline */ | ||
1751 | if (disp_int_cont3 & LB_D4_VLINE_INTERRUPT) { | ||
1752 | disp_int_cont3 &= ~LB_D4_VLINE_INTERRUPT; | ||
1753 | DRM_DEBUG("IH: D4 vline\n"); | ||
1754 | } | ||
1755 | break; | ||
1756 | default: | ||
1757 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1758 | break; | ||
1759 | } | ||
1760 | break; | ||
1761 | case 5: /* D5 vblank/vline */ | ||
1762 | switch (src_data) { | ||
1763 | case 0: /* D5 vblank */ | ||
1764 | if (disp_int_cont4 & LB_D5_VBLANK_INTERRUPT) { | ||
1765 | drm_handle_vblank(rdev->ddev, 4); | ||
1766 | wake_up(&rdev->irq.vblank_queue); | ||
1767 | disp_int_cont4 &= ~LB_D5_VBLANK_INTERRUPT; | ||
1768 | DRM_DEBUG("IH: D5 vblank\n"); | ||
1769 | } | ||
1770 | break; | ||
1771 | case 1: /* D5 vline */ | ||
1772 | if (disp_int_cont4 & LB_D5_VLINE_INTERRUPT) { | ||
1773 | disp_int_cont4 &= ~LB_D5_VLINE_INTERRUPT; | ||
1774 | DRM_DEBUG("IH: D5 vline\n"); | ||
1775 | } | ||
1776 | break; | ||
1777 | default: | ||
1778 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1779 | break; | ||
1780 | } | ||
1781 | break; | ||
1782 | case 6: /* D6 vblank/vline */ | ||
1783 | switch (src_data) { | ||
1784 | case 0: /* D6 vblank */ | ||
1785 | if (disp_int_cont5 & LB_D6_VBLANK_INTERRUPT) { | ||
1786 | drm_handle_vblank(rdev->ddev, 5); | ||
1787 | wake_up(&rdev->irq.vblank_queue); | ||
1788 | disp_int_cont5 &= ~LB_D6_VBLANK_INTERRUPT; | ||
1789 | DRM_DEBUG("IH: D6 vblank\n"); | ||
1790 | } | ||
1791 | break; | ||
1792 | case 1: /* D6 vline */ | ||
1793 | if (disp_int_cont5 & LB_D6_VLINE_INTERRUPT) { | ||
1794 | disp_int_cont5 &= ~LB_D6_VLINE_INTERRUPT; | ||
1795 | DRM_DEBUG("IH: D6 vline\n"); | ||
1796 | } | ||
1797 | break; | ||
1798 | default: | ||
1799 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1800 | break; | ||
1801 | } | ||
1802 | break; | ||
1803 | case 42: /* HPD hotplug */ | ||
1804 | switch (src_data) { | ||
1805 | case 0: | ||
1806 | if (disp_int & DC_HPD1_INTERRUPT) { | ||
1807 | disp_int &= ~DC_HPD1_INTERRUPT; | ||
1808 | queue_hotplug = true; | ||
1809 | DRM_DEBUG("IH: HPD1\n"); | ||
1810 | } | ||
1811 | break; | ||
1812 | case 1: | ||
1813 | if (disp_int_cont & DC_HPD2_INTERRUPT) { | ||
1814 | disp_int_cont &= ~DC_HPD2_INTERRUPT; | ||
1815 | queue_hotplug = true; | ||
1816 | DRM_DEBUG("IH: HPD2\n"); | ||
1817 | } | ||
1818 | break; | ||
1819 | case 2: | ||
1820 | if (disp_int_cont2 & DC_HPD3_INTERRUPT) { | ||
1821 | disp_int_cont2 &= ~DC_HPD3_INTERRUPT; | ||
1822 | queue_hotplug = true; | ||
1823 | DRM_DEBUG("IH: HPD3\n"); | ||
1824 | } | ||
1825 | break; | ||
1826 | case 3: | ||
1827 | if (disp_int_cont3 & DC_HPD4_INTERRUPT) { | ||
1828 | disp_int_cont3 &= ~DC_HPD4_INTERRUPT; | ||
1829 | queue_hotplug = true; | ||
1830 | DRM_DEBUG("IH: HPD4\n"); | ||
1831 | } | ||
1832 | break; | ||
1833 | case 4: | ||
1834 | if (disp_int_cont4 & DC_HPD5_INTERRUPT) { | ||
1835 | disp_int_cont4 &= ~DC_HPD5_INTERRUPT; | ||
1836 | queue_hotplug = true; | ||
1837 | DRM_DEBUG("IH: HPD5\n"); | ||
1838 | } | ||
1839 | break; | ||
1840 | case 5: | ||
1841 | if (disp_int_cont5 & DC_HPD6_INTERRUPT) { | ||
1842 | disp_int_cont5 &= ~DC_HPD6_INTERRUPT; | ||
1843 | queue_hotplug = true; | ||
1844 | DRM_DEBUG("IH: HPD6\n"); | ||
1845 | } | ||
1846 | break; | ||
1847 | default: | ||
1848 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1849 | break; | ||
1850 | } | ||
1851 | break; | ||
1852 | case 176: /* CP_INT in ring buffer */ | ||
1853 | case 177: /* CP_INT in IB1 */ | ||
1854 | case 178: /* CP_INT in IB2 */ | ||
1855 | DRM_DEBUG("IH: CP int: 0x%08x\n", src_data); | ||
1856 | radeon_fence_process(rdev); | ||
1857 | break; | ||
1858 | case 181: /* CP EOP event */ | ||
1859 | DRM_DEBUG("IH: CP EOP\n"); | ||
1860 | break; | ||
1861 | default: | ||
1862 | DRM_DEBUG("Unhandled interrupt: %d %d\n", src_id, src_data); | ||
1863 | break; | ||
1864 | } | ||
1865 | |||
1866 | /* wptr/rptr are in bytes! */ | ||
1867 | rptr += 16; | ||
1868 | rptr &= rdev->ih.ptr_mask; | ||
1869 | } | ||
1870 | /* make sure wptr hasn't changed while processing */ | ||
1871 | wptr = evergreen_get_ih_wptr(rdev); | ||
1872 | if (wptr != rdev->ih.wptr) | ||
1873 | goto restart_ih; | ||
1874 | if (queue_hotplug) | ||
1875 | queue_work(rdev->wq, &rdev->hotplug_work); | ||
1876 | rdev->ih.rptr = rptr; | ||
1877 | WREG32(IH_RB_RPTR, rdev->ih.rptr); | ||
1878 | spin_unlock_irqrestore(&rdev->ih.lock, flags); | ||
1879 | return IRQ_HANDLED; | ||
1880 | } | ||
1881 | |||
502 | static int evergreen_startup(struct radeon_device *rdev) | 1882 | static int evergreen_startup(struct radeon_device *rdev) |
503 | { | 1883 | { |
504 | #if 0 | ||
505 | int r; | 1884 | int r; |
506 | 1885 | ||
507 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { | 1886 | if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { |
@@ -511,17 +1890,15 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
511 | return r; | 1890 | return r; |
512 | } | 1891 | } |
513 | } | 1892 | } |
514 | #endif | 1893 | |
515 | evergreen_mc_program(rdev); | 1894 | evergreen_mc_program(rdev); |
516 | #if 0 | ||
517 | if (rdev->flags & RADEON_IS_AGP) { | 1895 | if (rdev->flags & RADEON_IS_AGP) { |
518 | evergreem_agp_enable(rdev); | 1896 | evergreen_agp_enable(rdev); |
519 | } else { | 1897 | } else { |
520 | r = evergreen_pcie_gart_enable(rdev); | 1898 | r = evergreen_pcie_gart_enable(rdev); |
521 | if (r) | 1899 | if (r) |
522 | return r; | 1900 | return r; |
523 | } | 1901 | } |
524 | #endif | ||
525 | evergreen_gpu_init(rdev); | 1902 | evergreen_gpu_init(rdev); |
526 | #if 0 | 1903 | #if 0 |
527 | if (!rdev->r600_blit.shader_obj) { | 1904 | if (!rdev->r600_blit.shader_obj) { |
@@ -542,6 +1919,7 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
542 | DRM_ERROR("failed to pin blit object %d\n", r); | 1919 | DRM_ERROR("failed to pin blit object %d\n", r); |
543 | return r; | 1920 | return r; |
544 | } | 1921 | } |
1922 | #endif | ||
545 | 1923 | ||
546 | /* Enable IRQ */ | 1924 | /* Enable IRQ */ |
547 | r = r600_irq_init(rdev); | 1925 | r = r600_irq_init(rdev); |
@@ -550,7 +1928,7 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
550 | radeon_irq_kms_fini(rdev); | 1928 | radeon_irq_kms_fini(rdev); |
551 | return r; | 1929 | return r; |
552 | } | 1930 | } |
553 | r600_irq_set(rdev); | 1931 | evergreen_irq_set(rdev); |
554 | 1932 | ||
555 | r = radeon_ring_init(rdev, rdev->cp.ring_size); | 1933 | r = radeon_ring_init(rdev, rdev->cp.ring_size); |
556 | if (r) | 1934 | if (r) |
@@ -558,12 +1936,12 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
558 | r = evergreen_cp_load_microcode(rdev); | 1936 | r = evergreen_cp_load_microcode(rdev); |
559 | if (r) | 1937 | if (r) |
560 | return r; | 1938 | return r; |
561 | r = r600_cp_resume(rdev); | 1939 | r = evergreen_cp_resume(rdev); |
562 | if (r) | 1940 | if (r) |
563 | return r; | 1941 | return r; |
564 | /* write back buffer are not vital so don't worry about failure */ | 1942 | /* write back buffer are not vital so don't worry about failure */ |
565 | r600_wb_enable(rdev); | 1943 | r600_wb_enable(rdev); |
566 | #endif | 1944 | |
567 | return 0; | 1945 | return 0; |
568 | } | 1946 | } |
569 | 1947 | ||
@@ -588,13 +1966,13 @@ int evergreen_resume(struct radeon_device *rdev) | |||
588 | DRM_ERROR("r600 startup failed on resume\n"); | 1966 | DRM_ERROR("r600 startup failed on resume\n"); |
589 | return r; | 1967 | return r; |
590 | } | 1968 | } |
591 | #if 0 | 1969 | |
592 | r = r600_ib_test(rdev); | 1970 | r = r600_ib_test(rdev); |
593 | if (r) { | 1971 | if (r) { |
594 | DRM_ERROR("radeon: failled testing IB (%d).\n", r); | 1972 | DRM_ERROR("radeon: failled testing IB (%d).\n", r); |
595 | return r; | 1973 | return r; |
596 | } | 1974 | } |
597 | #endif | 1975 | |
598 | return r; | 1976 | return r; |
599 | 1977 | ||
600 | } | 1978 | } |
@@ -603,12 +1981,14 @@ int evergreen_suspend(struct radeon_device *rdev) | |||
603 | { | 1981 | { |
604 | #if 0 | 1982 | #if 0 |
605 | int r; | 1983 | int r; |
606 | 1984 | #endif | |
607 | /* FIXME: we should wait for ring to be empty */ | 1985 | /* FIXME: we should wait for ring to be empty */ |
608 | r700_cp_stop(rdev); | 1986 | r700_cp_stop(rdev); |
609 | rdev->cp.ready = false; | 1987 | rdev->cp.ready = false; |
1988 | evergreen_irq_suspend(rdev); | ||
610 | r600_wb_disable(rdev); | 1989 | r600_wb_disable(rdev); |
611 | evergreen_pcie_gart_disable(rdev); | 1990 | evergreen_pcie_gart_disable(rdev); |
1991 | #if 0 | ||
612 | /* unpin shaders bo */ | 1992 | /* unpin shaders bo */ |
613 | r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false); | 1993 | r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false); |
614 | if (likely(r == 0)) { | 1994 | if (likely(r == 0)) { |
@@ -708,7 +2088,7 @@ int evergreen_init(struct radeon_device *rdev) | |||
708 | r = radeon_bo_init(rdev); | 2088 | r = radeon_bo_init(rdev); |
709 | if (r) | 2089 | if (r) |
710 | return r; | 2090 | return r; |
711 | #if 0 | 2091 | |
712 | r = radeon_irq_kms_init(rdev); | 2092 | r = radeon_irq_kms_init(rdev); |
713 | if (r) | 2093 | if (r) |
714 | return r; | 2094 | return r; |
@@ -722,14 +2102,16 @@ int evergreen_init(struct radeon_device *rdev) | |||
722 | r = r600_pcie_gart_init(rdev); | 2102 | r = r600_pcie_gart_init(rdev); |
723 | if (r) | 2103 | if (r) |
724 | return r; | 2104 | return r; |
725 | #endif | 2105 | |
726 | rdev->accel_working = false; | 2106 | rdev->accel_working = false; |
727 | r = evergreen_startup(rdev); | 2107 | r = evergreen_startup(rdev); |
728 | if (r) { | 2108 | if (r) { |
729 | evergreen_suspend(rdev); | 2109 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
730 | /*r600_wb_fini(rdev);*/ | 2110 | r700_cp_fini(rdev); |
731 | /*radeon_ring_fini(rdev);*/ | 2111 | r600_wb_fini(rdev); |
732 | /*evergreen_pcie_gart_fini(rdev);*/ | 2112 | r600_irq_fini(rdev); |
2113 | radeon_irq_kms_fini(rdev); | ||
2114 | evergreen_pcie_gart_fini(rdev); | ||
733 | rdev->accel_working = false; | 2115 | rdev->accel_working = false; |
734 | } | 2116 | } |
735 | if (rdev->accel_working) { | 2117 | if (rdev->accel_working) { |
@@ -750,15 +2132,12 @@ int evergreen_init(struct radeon_device *rdev) | |||
750 | void evergreen_fini(struct radeon_device *rdev) | 2132 | void evergreen_fini(struct radeon_device *rdev) |
751 | { | 2133 | { |
752 | radeon_pm_fini(rdev); | 2134 | radeon_pm_fini(rdev); |
753 | evergreen_suspend(rdev); | 2135 | /*r600_blit_fini(rdev);*/ |
754 | #if 0 | 2136 | r700_cp_fini(rdev); |
755 | r600_blit_fini(rdev); | 2137 | r600_wb_fini(rdev); |
756 | r600_irq_fini(rdev); | 2138 | r600_irq_fini(rdev); |
757 | radeon_irq_kms_fini(rdev); | 2139 | radeon_irq_kms_fini(rdev); |
758 | radeon_ring_fini(rdev); | ||
759 | r600_wb_fini(rdev); | ||
760 | evergreen_pcie_gart_fini(rdev); | 2140 | evergreen_pcie_gart_fini(rdev); |
761 | #endif | ||
762 | radeon_gem_fini(rdev); | 2141 | radeon_gem_fini(rdev); |
763 | radeon_fence_driver_fini(rdev); | 2142 | radeon_fence_driver_fini(rdev); |
764 | radeon_clocks_fini(rdev); | 2143 | radeon_clocks_fini(rdev); |
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h new file mode 100644 index 000000000000..93e9e17ad54a --- /dev/null +++ b/drivers/gpu/drm/radeon/evergreend.h | |||
@@ -0,0 +1,556 @@ | |||
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 EVERGREEND_H | ||
25 | #define EVERGREEND_H | ||
26 | |||
27 | #define EVERGREEN_MAX_SH_GPRS 256 | ||
28 | #define EVERGREEN_MAX_TEMP_GPRS 16 | ||
29 | #define EVERGREEN_MAX_SH_THREADS 256 | ||
30 | #define EVERGREEN_MAX_SH_STACK_ENTRIES 4096 | ||
31 | #define EVERGREEN_MAX_FRC_EOV_CNT 16384 | ||
32 | #define EVERGREEN_MAX_BACKENDS 8 | ||
33 | #define EVERGREEN_MAX_BACKENDS_MASK 0xFF | ||
34 | #define EVERGREEN_MAX_SIMDS 16 | ||
35 | #define EVERGREEN_MAX_SIMDS_MASK 0xFFFF | ||
36 | #define EVERGREEN_MAX_PIPES 8 | ||
37 | #define EVERGREEN_MAX_PIPES_MASK 0xFF | ||
38 | #define EVERGREEN_MAX_LDS_NUM 0xFFFF | ||
39 | |||
40 | /* Registers */ | ||
41 | |||
42 | #define RCU_IND_INDEX 0x100 | ||
43 | #define RCU_IND_DATA 0x104 | ||
44 | |||
45 | #define GRBM_GFX_INDEX 0x802C | ||
46 | #define INSTANCE_INDEX(x) ((x) << 0) | ||
47 | #define SE_INDEX(x) ((x) << 16) | ||
48 | #define INSTANCE_BROADCAST_WRITES (1 << 30) | ||
49 | #define SE_BROADCAST_WRITES (1 << 31) | ||
50 | #define RLC_GFX_INDEX 0x3fC4 | ||
51 | #define CC_GC_SHADER_PIPE_CONFIG 0x8950 | ||
52 | #define WRITE_DIS (1 << 0) | ||
53 | #define CC_RB_BACKEND_DISABLE 0x98F4 | ||
54 | #define BACKEND_DISABLE(x) ((x) << 16) | ||
55 | #define GB_ADDR_CONFIG 0x98F8 | ||
56 | #define NUM_PIPES(x) ((x) << 0) | ||
57 | #define PIPE_INTERLEAVE_SIZE(x) ((x) << 4) | ||
58 | #define BANK_INTERLEAVE_SIZE(x) ((x) << 8) | ||
59 | #define NUM_SHADER_ENGINES(x) ((x) << 12) | ||
60 | #define SHADER_ENGINE_TILE_SIZE(x) ((x) << 16) | ||
61 | #define NUM_GPUS(x) ((x) << 20) | ||
62 | #define MULTI_GPU_TILE_SIZE(x) ((x) << 24) | ||
63 | #define ROW_SIZE(x) ((x) << 28) | ||
64 | #define GB_BACKEND_MAP 0x98FC | ||
65 | #define DMIF_ADDR_CONFIG 0xBD4 | ||
66 | #define HDP_ADDR_CONFIG 0x2F48 | ||
67 | |||
68 | #define CC_SYS_RB_BACKEND_DISABLE 0x3F88 | ||
69 | #define GC_USER_RB_BACKEND_DISABLE 0x9B7C | ||
70 | |||
71 | #define CGTS_SYS_TCC_DISABLE 0x3F90 | ||
72 | #define CGTS_TCC_DISABLE 0x9148 | ||
73 | #define CGTS_USER_SYS_TCC_DISABLE 0x3F94 | ||
74 | #define CGTS_USER_TCC_DISABLE 0x914C | ||
75 | |||
76 | #define CONFIG_MEMSIZE 0x5428 | ||
77 | |||
78 | #define CP_ME_CNTL 0x86D8 | ||
79 | #define CP_ME_HALT (1 << 28) | ||
80 | #define CP_PFP_HALT (1 << 26) | ||
81 | #define CP_ME_RAM_DATA 0xC160 | ||
82 | #define CP_ME_RAM_RADDR 0xC158 | ||
83 | #define CP_ME_RAM_WADDR 0xC15C | ||
84 | #define CP_MEQ_THRESHOLDS 0x8764 | ||
85 | #define STQ_SPLIT(x) ((x) << 0) | ||
86 | #define CP_PERFMON_CNTL 0x87FC | ||
87 | #define CP_PFP_UCODE_ADDR 0xC150 | ||
88 | #define CP_PFP_UCODE_DATA 0xC154 | ||
89 | #define CP_QUEUE_THRESHOLDS 0x8760 | ||
90 | #define ROQ_IB1_START(x) ((x) << 0) | ||
91 | #define ROQ_IB2_START(x) ((x) << 8) | ||
92 | #define CP_RB_BASE 0xC100 | ||
93 | #define CP_RB_CNTL 0xC104 | ||
94 | #define RB_BUFSZ(x) ((x) << 0) | ||
95 | #define RB_BLKSZ(x) ((x) << 8) | ||
96 | #define RB_NO_UPDATE (1 << 27) | ||
97 | #define RB_RPTR_WR_ENA (1 << 31) | ||
98 | #define BUF_SWAP_32BIT (2 << 16) | ||
99 | #define CP_RB_RPTR 0x8700 | ||
100 | #define CP_RB_RPTR_ADDR 0xC10C | ||
101 | #define CP_RB_RPTR_ADDR_HI 0xC110 | ||
102 | #define CP_RB_RPTR_WR 0xC108 | ||
103 | #define CP_RB_WPTR 0xC114 | ||
104 | #define CP_RB_WPTR_ADDR 0xC118 | ||
105 | #define CP_RB_WPTR_ADDR_HI 0xC11C | ||
106 | #define CP_RB_WPTR_DELAY 0x8704 | ||
107 | #define CP_SEM_WAIT_TIMER 0x85BC | ||
108 | #define CP_DEBUG 0xC1FC | ||
109 | |||
110 | |||
111 | #define GC_USER_SHADER_PIPE_CONFIG 0x8954 | ||
112 | #define INACTIVE_QD_PIPES(x) ((x) << 8) | ||
113 | #define INACTIVE_QD_PIPES_MASK 0x0000FF00 | ||
114 | #define INACTIVE_SIMDS(x) ((x) << 16) | ||
115 | #define INACTIVE_SIMDS_MASK 0x00FF0000 | ||
116 | |||
117 | #define GRBM_CNTL 0x8000 | ||
118 | #define GRBM_READ_TIMEOUT(x) ((x) << 0) | ||
119 | #define GRBM_SOFT_RESET 0x8020 | ||
120 | #define SOFT_RESET_CP (1 << 0) | ||
121 | #define SOFT_RESET_CB (1 << 1) | ||
122 | #define SOFT_RESET_DB (1 << 3) | ||
123 | #define SOFT_RESET_PA (1 << 5) | ||
124 | #define SOFT_RESET_SC (1 << 6) | ||
125 | #define SOFT_RESET_SPI (1 << 8) | ||
126 | #define SOFT_RESET_SH (1 << 9) | ||
127 | #define SOFT_RESET_SX (1 << 10) | ||
128 | #define SOFT_RESET_TC (1 << 11) | ||
129 | #define SOFT_RESET_TA (1 << 12) | ||
130 | #define SOFT_RESET_VC (1 << 13) | ||
131 | #define SOFT_RESET_VGT (1 << 14) | ||
132 | |||
133 | #define GRBM_STATUS 0x8010 | ||
134 | #define CMDFIFO_AVAIL_MASK 0x0000000F | ||
135 | #define SRBM_RQ_PENDING (1 << 5) | ||
136 | #define CF_RQ_PENDING (1 << 7) | ||
137 | #define PF_RQ_PENDING (1 << 8) | ||
138 | #define GRBM_EE_BUSY (1 << 10) | ||
139 | #define SX_CLEAN (1 << 11) | ||
140 | #define DB_CLEAN (1 << 12) | ||
141 | #define CB_CLEAN (1 << 13) | ||
142 | #define TA_BUSY (1 << 14) | ||
143 | #define VGT_BUSY_NO_DMA (1 << 16) | ||
144 | #define VGT_BUSY (1 << 17) | ||
145 | #define SX_BUSY (1 << 20) | ||
146 | #define SH_BUSY (1 << 21) | ||
147 | #define SPI_BUSY (1 << 22) | ||
148 | #define SC_BUSY (1 << 24) | ||
149 | #define PA_BUSY (1 << 25) | ||
150 | #define DB_BUSY (1 << 26) | ||
151 | #define CP_COHERENCY_BUSY (1 << 28) | ||
152 | #define CP_BUSY (1 << 29) | ||
153 | #define CB_BUSY (1 << 30) | ||
154 | #define GUI_ACTIVE (1 << 31) | ||
155 | #define GRBM_STATUS_SE0 0x8014 | ||
156 | #define GRBM_STATUS_SE1 0x8018 | ||
157 | #define SE_SX_CLEAN (1 << 0) | ||
158 | #define SE_DB_CLEAN (1 << 1) | ||
159 | #define SE_CB_CLEAN (1 << 2) | ||
160 | #define SE_TA_BUSY (1 << 25) | ||
161 | #define SE_SX_BUSY (1 << 26) | ||
162 | #define SE_SPI_BUSY (1 << 27) | ||
163 | #define SE_SH_BUSY (1 << 28) | ||
164 | #define SE_SC_BUSY (1 << 29) | ||
165 | #define SE_DB_BUSY (1 << 30) | ||
166 | #define SE_CB_BUSY (1 << 31) | ||
167 | |||
168 | #define HDP_HOST_PATH_CNTL 0x2C00 | ||
169 | #define HDP_NONSURFACE_BASE 0x2C04 | ||
170 | #define HDP_NONSURFACE_INFO 0x2C08 | ||
171 | #define HDP_NONSURFACE_SIZE 0x2C0C | ||
172 | #define HDP_REG_COHERENCY_FLUSH_CNTL 0x54A0 | ||
173 | #define HDP_TILING_CONFIG 0x2F3C | ||
174 | |||
175 | #define MC_SHARED_CHMAP 0x2004 | ||
176 | #define NOOFCHAN_SHIFT 12 | ||
177 | #define NOOFCHAN_MASK 0x00003000 | ||
178 | |||
179 | #define MC_ARB_RAMCFG 0x2760 | ||
180 | #define NOOFBANK_SHIFT 0 | ||
181 | #define NOOFBANK_MASK 0x00000003 | ||
182 | #define NOOFRANK_SHIFT 2 | ||
183 | #define NOOFRANK_MASK 0x00000004 | ||
184 | #define NOOFROWS_SHIFT 3 | ||
185 | #define NOOFROWS_MASK 0x00000038 | ||
186 | #define NOOFCOLS_SHIFT 6 | ||
187 | #define NOOFCOLS_MASK 0x000000C0 | ||
188 | #define CHANSIZE_SHIFT 8 | ||
189 | #define CHANSIZE_MASK 0x00000100 | ||
190 | #define BURSTLENGTH_SHIFT 9 | ||
191 | #define BURSTLENGTH_MASK 0x00000200 | ||
192 | #define CHANSIZE_OVERRIDE (1 << 11) | ||
193 | #define MC_VM_AGP_TOP 0x2028 | ||
194 | #define MC_VM_AGP_BOT 0x202C | ||
195 | #define MC_VM_AGP_BASE 0x2030 | ||
196 | #define MC_VM_FB_LOCATION 0x2024 | ||
197 | #define MC_VM_MB_L1_TLB0_CNTL 0x2234 | ||
198 | #define MC_VM_MB_L1_TLB1_CNTL 0x2238 | ||
199 | #define MC_VM_MB_L1_TLB2_CNTL 0x223C | ||
200 | #define MC_VM_MB_L1_TLB3_CNTL 0x2240 | ||
201 | #define ENABLE_L1_TLB (1 << 0) | ||
202 | #define ENABLE_L1_FRAGMENT_PROCESSING (1 << 1) | ||
203 | #define SYSTEM_ACCESS_MODE_PA_ONLY (0 << 3) | ||
204 | #define SYSTEM_ACCESS_MODE_USE_SYS_MAP (1 << 3) | ||
205 | #define SYSTEM_ACCESS_MODE_IN_SYS (2 << 3) | ||
206 | #define SYSTEM_ACCESS_MODE_NOT_IN_SYS (3 << 3) | ||
207 | #define SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU (0 << 5) | ||
208 | #define EFFECTIVE_L1_TLB_SIZE(x) ((x)<<15) | ||
209 | #define EFFECTIVE_L1_QUEUE_SIZE(x) ((x)<<18) | ||
210 | #define MC_VM_MD_L1_TLB0_CNTL 0x2654 | ||
211 | #define MC_VM_MD_L1_TLB1_CNTL 0x2658 | ||
212 | #define MC_VM_MD_L1_TLB2_CNTL 0x265C | ||
213 | #define MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR 0x203C | ||
214 | #define MC_VM_SYSTEM_APERTURE_HIGH_ADDR 0x2038 | ||
215 | #define MC_VM_SYSTEM_APERTURE_LOW_ADDR 0x2034 | ||
216 | |||
217 | #define PA_CL_ENHANCE 0x8A14 | ||
218 | #define CLIP_VTX_REORDER_ENA (1 << 0) | ||
219 | #define NUM_CLIP_SEQ(x) ((x) << 1) | ||
220 | #define PA_SC_AA_CONFIG 0x28C04 | ||
221 | #define PA_SC_CLIPRECT_RULE 0x2820C | ||
222 | #define PA_SC_EDGERULE 0x28230 | ||
223 | #define PA_SC_FIFO_SIZE 0x8BCC | ||
224 | #define SC_PRIM_FIFO_SIZE(x) ((x) << 0) | ||
225 | #define SC_HIZ_TILE_FIFO_SIZE(x) ((x) << 12) | ||
226 | #define SC_EARLYZ_TILE_FIFO_SIZE(x) ((x) << 20) | ||
227 | #define PA_SC_FORCE_EOV_MAX_CNTS 0x8B24 | ||
228 | #define FORCE_EOV_MAX_CLK_CNT(x) ((x) << 0) | ||
229 | #define FORCE_EOV_MAX_REZ_CNT(x) ((x) << 16) | ||
230 | #define PA_SC_LINE_STIPPLE 0x28A0C | ||
231 | #define PA_SC_LINE_STIPPLE_STATE 0x8B10 | ||
232 | |||
233 | #define SCRATCH_REG0 0x8500 | ||
234 | #define SCRATCH_REG1 0x8504 | ||
235 | #define SCRATCH_REG2 0x8508 | ||
236 | #define SCRATCH_REG3 0x850C | ||
237 | #define SCRATCH_REG4 0x8510 | ||
238 | #define SCRATCH_REG5 0x8514 | ||
239 | #define SCRATCH_REG6 0x8518 | ||
240 | #define SCRATCH_REG7 0x851C | ||
241 | #define SCRATCH_UMSK 0x8540 | ||
242 | #define SCRATCH_ADDR 0x8544 | ||
243 | |||
244 | #define SMX_DC_CTL0 0xA020 | ||
245 | #define USE_HASH_FUNCTION (1 << 0) | ||
246 | #define NUMBER_OF_SETS(x) ((x) << 1) | ||
247 | #define FLUSH_ALL_ON_EVENT (1 << 10) | ||
248 | #define STALL_ON_EVENT (1 << 11) | ||
249 | #define SMX_EVENT_CTL 0xA02C | ||
250 | #define ES_FLUSH_CTL(x) ((x) << 0) | ||
251 | #define GS_FLUSH_CTL(x) ((x) << 3) | ||
252 | #define ACK_FLUSH_CTL(x) ((x) << 6) | ||
253 | #define SYNC_FLUSH_CTL (1 << 8) | ||
254 | |||
255 | #define SPI_CONFIG_CNTL 0x9100 | ||
256 | #define GPR_WRITE_PRIORITY(x) ((x) << 0) | ||
257 | #define SPI_CONFIG_CNTL_1 0x913C | ||
258 | #define VTX_DONE_DELAY(x) ((x) << 0) | ||
259 | #define INTERP_ONE_PRIM_PER_ROW (1 << 4) | ||
260 | #define SPI_INPUT_Z 0x286D8 | ||
261 | #define SPI_PS_IN_CONTROL_0 0x286CC | ||
262 | #define NUM_INTERP(x) ((x)<<0) | ||
263 | #define POSITION_ENA (1<<8) | ||
264 | #define POSITION_CENTROID (1<<9) | ||
265 | #define POSITION_ADDR(x) ((x)<<10) | ||
266 | #define PARAM_GEN(x) ((x)<<15) | ||
267 | #define PARAM_GEN_ADDR(x) ((x)<<19) | ||
268 | #define BARYC_SAMPLE_CNTL(x) ((x)<<26) | ||
269 | #define PERSP_GRADIENT_ENA (1<<28) | ||
270 | #define LINEAR_GRADIENT_ENA (1<<29) | ||
271 | #define POSITION_SAMPLE (1<<30) | ||
272 | #define BARYC_AT_SAMPLE_ENA (1<<31) | ||
273 | |||
274 | #define SQ_CONFIG 0x8C00 | ||
275 | #define VC_ENABLE (1 << 0) | ||
276 | #define EXPORT_SRC_C (1 << 1) | ||
277 | #define CS_PRIO(x) ((x) << 18) | ||
278 | #define LS_PRIO(x) ((x) << 20) | ||
279 | #define HS_PRIO(x) ((x) << 22) | ||
280 | #define PS_PRIO(x) ((x) << 24) | ||
281 | #define VS_PRIO(x) ((x) << 26) | ||
282 | #define GS_PRIO(x) ((x) << 28) | ||
283 | #define ES_PRIO(x) ((x) << 30) | ||
284 | #define SQ_GPR_RESOURCE_MGMT_1 0x8C04 | ||
285 | #define NUM_PS_GPRS(x) ((x) << 0) | ||
286 | #define NUM_VS_GPRS(x) ((x) << 16) | ||
287 | #define NUM_CLAUSE_TEMP_GPRS(x) ((x) << 28) | ||
288 | #define SQ_GPR_RESOURCE_MGMT_2 0x8C08 | ||
289 | #define NUM_GS_GPRS(x) ((x) << 0) | ||
290 | #define NUM_ES_GPRS(x) ((x) << 16) | ||
291 | #define SQ_GPR_RESOURCE_MGMT_3 0x8C0C | ||
292 | #define NUM_HS_GPRS(x) ((x) << 0) | ||
293 | #define NUM_LS_GPRS(x) ((x) << 16) | ||
294 | #define SQ_THREAD_RESOURCE_MGMT 0x8C18 | ||
295 | #define NUM_PS_THREADS(x) ((x) << 0) | ||
296 | #define NUM_VS_THREADS(x) ((x) << 8) | ||
297 | #define NUM_GS_THREADS(x) ((x) << 16) | ||
298 | #define NUM_ES_THREADS(x) ((x) << 24) | ||
299 | #define SQ_THREAD_RESOURCE_MGMT_2 0x8C1C | ||
300 | #define NUM_HS_THREADS(x) ((x) << 0) | ||
301 | #define NUM_LS_THREADS(x) ((x) << 8) | ||
302 | #define SQ_STACK_RESOURCE_MGMT_1 0x8C20 | ||
303 | #define NUM_PS_STACK_ENTRIES(x) ((x) << 0) | ||
304 | #define NUM_VS_STACK_ENTRIES(x) ((x) << 16) | ||
305 | #define SQ_STACK_RESOURCE_MGMT_2 0x8C24 | ||
306 | #define NUM_GS_STACK_ENTRIES(x) ((x) << 0) | ||
307 | #define NUM_ES_STACK_ENTRIES(x) ((x) << 16) | ||
308 | #define SQ_STACK_RESOURCE_MGMT_3 0x8C28 | ||
309 | #define NUM_HS_STACK_ENTRIES(x) ((x) << 0) | ||
310 | #define NUM_LS_STACK_ENTRIES(x) ((x) << 16) | ||
311 | #define SQ_DYN_GPR_CNTL_PS_FLUSH_REQ 0x8D8C | ||
312 | #define SQ_LDS_RESOURCE_MGMT 0x8E2C | ||
313 | |||
314 | #define SQ_MS_FIFO_SIZES 0x8CF0 | ||
315 | #define CACHE_FIFO_SIZE(x) ((x) << 0) | ||
316 | #define FETCH_FIFO_HIWATER(x) ((x) << 8) | ||
317 | #define DONE_FIFO_HIWATER(x) ((x) << 16) | ||
318 | #define ALU_UPDATE_FIFO_HIWATER(x) ((x) << 24) | ||
319 | |||
320 | #define SX_DEBUG_1 0x9058 | ||
321 | #define ENABLE_NEW_SMX_ADDRESS (1 << 16) | ||
322 | #define SX_EXPORT_BUFFER_SIZES 0x900C | ||
323 | #define COLOR_BUFFER_SIZE(x) ((x) << 0) | ||
324 | #define POSITION_BUFFER_SIZE(x) ((x) << 8) | ||
325 | #define SMX_BUFFER_SIZE(x) ((x) << 16) | ||
326 | #define SX_MISC 0x28350 | ||
327 | |||
328 | #define CB_PERF_CTR0_SEL_0 0x9A20 | ||
329 | #define CB_PERF_CTR0_SEL_1 0x9A24 | ||
330 | #define CB_PERF_CTR1_SEL_0 0x9A28 | ||
331 | #define CB_PERF_CTR1_SEL_1 0x9A2C | ||
332 | #define CB_PERF_CTR2_SEL_0 0x9A30 | ||
333 | #define CB_PERF_CTR2_SEL_1 0x9A34 | ||
334 | #define CB_PERF_CTR3_SEL_0 0x9A38 | ||
335 | #define CB_PERF_CTR3_SEL_1 0x9A3C | ||
336 | |||
337 | #define TA_CNTL_AUX 0x9508 | ||
338 | #define DISABLE_CUBE_WRAP (1 << 0) | ||
339 | #define DISABLE_CUBE_ANISO (1 << 1) | ||
340 | #define SYNC_GRADIENT (1 << 24) | ||
341 | #define SYNC_WALKER (1 << 25) | ||
342 | #define SYNC_ALIGNER (1 << 26) | ||
343 | |||
344 | #define VGT_CACHE_INVALIDATION 0x88C4 | ||
345 | #define CACHE_INVALIDATION(x) ((x) << 0) | ||
346 | #define VC_ONLY 0 | ||
347 | #define TC_ONLY 1 | ||
348 | #define VC_AND_TC 2 | ||
349 | #define AUTO_INVLD_EN(x) ((x) << 6) | ||
350 | #define NO_AUTO 0 | ||
351 | #define ES_AUTO 1 | ||
352 | #define GS_AUTO 2 | ||
353 | #define ES_AND_GS_AUTO 3 | ||
354 | #define VGT_GS_VERTEX_REUSE 0x88D4 | ||
355 | #define VGT_NUM_INSTANCES 0x8974 | ||
356 | #define VGT_OUT_DEALLOC_CNTL 0x28C5C | ||
357 | #define DEALLOC_DIST_MASK 0x0000007F | ||
358 | #define VGT_VERTEX_REUSE_BLOCK_CNTL 0x28C58 | ||
359 | #define VTX_REUSE_DEPTH_MASK 0x000000FF | ||
360 | |||
361 | #define VM_CONTEXT0_CNTL 0x1410 | ||
362 | #define ENABLE_CONTEXT (1 << 0) | ||
363 | #define PAGE_TABLE_DEPTH(x) (((x) & 3) << 1) | ||
364 | #define RANGE_PROTECTION_FAULT_ENABLE_DEFAULT (1 << 4) | ||
365 | #define VM_CONTEXT1_CNTL 0x1414 | ||
366 | #define VM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x153C | ||
367 | #define VM_CONTEXT0_PAGE_TABLE_END_ADDR 0x157C | ||
368 | #define VM_CONTEXT0_PAGE_TABLE_START_ADDR 0x155C | ||
369 | #define VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR 0x1518 | ||
370 | #define VM_CONTEXT0_REQUEST_RESPONSE 0x1470 | ||
371 | #define REQUEST_TYPE(x) (((x) & 0xf) << 0) | ||
372 | #define RESPONSE_TYPE_MASK 0x000000F0 | ||
373 | #define RESPONSE_TYPE_SHIFT 4 | ||
374 | #define VM_L2_CNTL 0x1400 | ||
375 | #define ENABLE_L2_CACHE (1 << 0) | ||
376 | #define ENABLE_L2_FRAGMENT_PROCESSING (1 << 1) | ||
377 | #define ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE (1 << 9) | ||
378 | #define EFFECTIVE_L2_QUEUE_SIZE(x) (((x) & 7) << 14) | ||
379 | #define VM_L2_CNTL2 0x1404 | ||
380 | #define INVALIDATE_ALL_L1_TLBS (1 << 0) | ||
381 | #define INVALIDATE_L2_CACHE (1 << 1) | ||
382 | #define VM_L2_CNTL3 0x1408 | ||
383 | #define BANK_SELECT(x) ((x) << 0) | ||
384 | #define CACHE_UPDATE_MODE(x) ((x) << 6) | ||
385 | #define VM_L2_STATUS 0x140C | ||
386 | #define L2_BUSY (1 << 0) | ||
387 | |||
388 | #define WAIT_UNTIL 0x8040 | ||
389 | |||
390 | #define SRBM_STATUS 0x0E50 | ||
391 | #define SRBM_SOFT_RESET 0x0E60 | ||
392 | #define SRBM_SOFT_RESET_ALL_MASK 0x00FEEFA6 | ||
393 | #define SOFT_RESET_BIF (1 << 1) | ||
394 | #define SOFT_RESET_CG (1 << 2) | ||
395 | #define SOFT_RESET_DC (1 << 5) | ||
396 | #define SOFT_RESET_GRBM (1 << 8) | ||
397 | #define SOFT_RESET_HDP (1 << 9) | ||
398 | #define SOFT_RESET_IH (1 << 10) | ||
399 | #define SOFT_RESET_MC (1 << 11) | ||
400 | #define SOFT_RESET_RLC (1 << 13) | ||
401 | #define SOFT_RESET_ROM (1 << 14) | ||
402 | #define SOFT_RESET_SEM (1 << 15) | ||
403 | #define SOFT_RESET_VMC (1 << 17) | ||
404 | #define SOFT_RESET_TST (1 << 21) | ||
405 | #define SOFT_RESET_REGBB (1 << 22) | ||
406 | #define SOFT_RESET_ORB (1 << 23) | ||
407 | |||
408 | #define IH_RB_CNTL 0x3e00 | ||
409 | # define IH_RB_ENABLE (1 << 0) | ||
410 | # define IH_IB_SIZE(x) ((x) << 1) /* log2 */ | ||
411 | # define IH_RB_FULL_DRAIN_ENABLE (1 << 6) | ||
412 | # define IH_WPTR_WRITEBACK_ENABLE (1 << 8) | ||
413 | # define IH_WPTR_WRITEBACK_TIMER(x) ((x) << 9) /* log2 */ | ||
414 | # define IH_WPTR_OVERFLOW_ENABLE (1 << 16) | ||
415 | # define IH_WPTR_OVERFLOW_CLEAR (1 << 31) | ||
416 | #define IH_RB_BASE 0x3e04 | ||
417 | #define IH_RB_RPTR 0x3e08 | ||
418 | #define IH_RB_WPTR 0x3e0c | ||
419 | # define RB_OVERFLOW (1 << 0) | ||
420 | # define WPTR_OFFSET_MASK 0x3fffc | ||
421 | #define IH_RB_WPTR_ADDR_HI 0x3e10 | ||
422 | #define IH_RB_WPTR_ADDR_LO 0x3e14 | ||
423 | #define IH_CNTL 0x3e18 | ||
424 | # define ENABLE_INTR (1 << 0) | ||
425 | # define IH_MC_SWAP(x) ((x) << 2) | ||
426 | # define IH_MC_SWAP_NONE 0 | ||
427 | # define IH_MC_SWAP_16BIT 1 | ||
428 | # define IH_MC_SWAP_32BIT 2 | ||
429 | # define IH_MC_SWAP_64BIT 3 | ||
430 | # define RPTR_REARM (1 << 4) | ||
431 | # define MC_WRREQ_CREDIT(x) ((x) << 15) | ||
432 | # define MC_WR_CLEAN_CNT(x) ((x) << 20) | ||
433 | |||
434 | #define CP_INT_CNTL 0xc124 | ||
435 | # define CNTX_BUSY_INT_ENABLE (1 << 19) | ||
436 | # define CNTX_EMPTY_INT_ENABLE (1 << 20) | ||
437 | # define SCRATCH_INT_ENABLE (1 << 25) | ||
438 | # define TIME_STAMP_INT_ENABLE (1 << 26) | ||
439 | # define IB2_INT_ENABLE (1 << 29) | ||
440 | # define IB1_INT_ENABLE (1 << 30) | ||
441 | # define RB_INT_ENABLE (1 << 31) | ||
442 | #define CP_INT_STATUS 0xc128 | ||
443 | # define SCRATCH_INT_STAT (1 << 25) | ||
444 | # define TIME_STAMP_INT_STAT (1 << 26) | ||
445 | # define IB2_INT_STAT (1 << 29) | ||
446 | # define IB1_INT_STAT (1 << 30) | ||
447 | # define RB_INT_STAT (1 << 31) | ||
448 | |||
449 | #define GRBM_INT_CNTL 0x8060 | ||
450 | # define RDERR_INT_ENABLE (1 << 0) | ||
451 | # define GUI_IDLE_INT_ENABLE (1 << 19) | ||
452 | |||
453 | /* 0x6e98, 0x7a98, 0x10698, 0x11298, 0x11e98, 0x12a98 */ | ||
454 | #define CRTC_STATUS_FRAME_COUNT 0x6e98 | ||
455 | |||
456 | /* 0x6bb8, 0x77b8, 0x103b8, 0x10fb8, 0x11bb8, 0x127b8 */ | ||
457 | #define VLINE_STATUS 0x6bb8 | ||
458 | # define VLINE_OCCURRED (1 << 0) | ||
459 | # define VLINE_ACK (1 << 4) | ||
460 | # define VLINE_STAT (1 << 12) | ||
461 | # define VLINE_INTERRUPT (1 << 16) | ||
462 | # define VLINE_INTERRUPT_TYPE (1 << 17) | ||
463 | /* 0x6bbc, 0x77bc, 0x103bc, 0x10fbc, 0x11bbc, 0x127bc */ | ||
464 | #define VBLANK_STATUS 0x6bbc | ||
465 | # define VBLANK_OCCURRED (1 << 0) | ||
466 | # define VBLANK_ACK (1 << 4) | ||
467 | # define VBLANK_STAT (1 << 12) | ||
468 | # define VBLANK_INTERRUPT (1 << 16) | ||
469 | # define VBLANK_INTERRUPT_TYPE (1 << 17) | ||
470 | |||
471 | /* 0x6b40, 0x7740, 0x10340, 0x10f40, 0x11b40, 0x12740 */ | ||
472 | #define INT_MASK 0x6b40 | ||
473 | # define VBLANK_INT_MASK (1 << 0) | ||
474 | # define VLINE_INT_MASK (1 << 4) | ||
475 | |||
476 | #define DISP_INTERRUPT_STATUS 0x60f4 | ||
477 | # define LB_D1_VLINE_INTERRUPT (1 << 2) | ||
478 | # define LB_D1_VBLANK_INTERRUPT (1 << 3) | ||
479 | # define DC_HPD1_INTERRUPT (1 << 17) | ||
480 | # define DC_HPD1_RX_INTERRUPT (1 << 18) | ||
481 | # define DACA_AUTODETECT_INTERRUPT (1 << 22) | ||
482 | # define DACB_AUTODETECT_INTERRUPT (1 << 23) | ||
483 | # define DC_I2C_SW_DONE_INTERRUPT (1 << 24) | ||
484 | # define DC_I2C_HW_DONE_INTERRUPT (1 << 25) | ||
485 | #define DISP_INTERRUPT_STATUS_CONTINUE 0x60f8 | ||
486 | # define LB_D2_VLINE_INTERRUPT (1 << 2) | ||
487 | # define LB_D2_VBLANK_INTERRUPT (1 << 3) | ||
488 | # define DC_HPD2_INTERRUPT (1 << 17) | ||
489 | # define DC_HPD2_RX_INTERRUPT (1 << 18) | ||
490 | # define DISP_TIMER_INTERRUPT (1 << 24) | ||
491 | #define DISP_INTERRUPT_STATUS_CONTINUE2 0x60fc | ||
492 | # define LB_D3_VLINE_INTERRUPT (1 << 2) | ||
493 | # define LB_D3_VBLANK_INTERRUPT (1 << 3) | ||
494 | # define DC_HPD3_INTERRUPT (1 << 17) | ||
495 | # define DC_HPD3_RX_INTERRUPT (1 << 18) | ||
496 | #define DISP_INTERRUPT_STATUS_CONTINUE3 0x6100 | ||
497 | # define LB_D4_VLINE_INTERRUPT (1 << 2) | ||
498 | # define LB_D4_VBLANK_INTERRUPT (1 << 3) | ||
499 | # define DC_HPD4_INTERRUPT (1 << 17) | ||
500 | # define DC_HPD4_RX_INTERRUPT (1 << 18) | ||
501 | #define DISP_INTERRUPT_STATUS_CONTINUE4 0x614c | ||
502 | # define LB_D5_VLINE_INTERRUPT (1 << 2) | ||
503 | # define LB_D5_VBLANK_INTERRUPT (1 << 3) | ||
504 | # define DC_HPD5_INTERRUPT (1 << 17) | ||
505 | # define DC_HPD5_RX_INTERRUPT (1 << 18) | ||
506 | #define DISP_INTERRUPT_STATUS_CONTINUE5 0x6050 | ||
507 | # define LB_D6_VLINE_INTERRUPT (1 << 2) | ||
508 | # define LB_D6_VBLANK_INTERRUPT (1 << 3) | ||
509 | # define DC_HPD6_INTERRUPT (1 << 17) | ||
510 | # define DC_HPD6_RX_INTERRUPT (1 << 18) | ||
511 | |||
512 | /* 0x6858, 0x7458, 0x10058, 0x10c58, 0x11858, 0x12458 */ | ||
513 | #define GRPH_INT_STATUS 0x6858 | ||
514 | # define GRPH_PFLIP_INT_OCCURRED (1 << 0) | ||
515 | # define GRPH_PFLIP_INT_CLEAR (1 << 8) | ||
516 | /* 0x685c, 0x745c, 0x1005c, 0x10c5c, 0x1185c, 0x1245c */ | ||
517 | #define GRPH_INT_CONTROL 0x685c | ||
518 | # define GRPH_PFLIP_INT_MASK (1 << 0) | ||
519 | # define GRPH_PFLIP_INT_TYPE (1 << 8) | ||
520 | |||
521 | #define DACA_AUTODETECT_INT_CONTROL 0x66c8 | ||
522 | #define DACB_AUTODETECT_INT_CONTROL 0x67c8 | ||
523 | |||
524 | #define DC_HPD1_INT_STATUS 0x601c | ||
525 | #define DC_HPD2_INT_STATUS 0x6028 | ||
526 | #define DC_HPD3_INT_STATUS 0x6034 | ||
527 | #define DC_HPD4_INT_STATUS 0x6040 | ||
528 | #define DC_HPD5_INT_STATUS 0x604c | ||
529 | #define DC_HPD6_INT_STATUS 0x6058 | ||
530 | # define DC_HPDx_INT_STATUS (1 << 0) | ||
531 | # define DC_HPDx_SENSE (1 << 1) | ||
532 | # define DC_HPDx_RX_INT_STATUS (1 << 8) | ||
533 | |||
534 | #define DC_HPD1_INT_CONTROL 0x6020 | ||
535 | #define DC_HPD2_INT_CONTROL 0x602c | ||
536 | #define DC_HPD3_INT_CONTROL 0x6038 | ||
537 | #define DC_HPD4_INT_CONTROL 0x6044 | ||
538 | #define DC_HPD5_INT_CONTROL 0x6050 | ||
539 | #define DC_HPD6_INT_CONTROL 0x605c | ||
540 | # define DC_HPDx_INT_ACK (1 << 0) | ||
541 | # define DC_HPDx_INT_POLARITY (1 << 8) | ||
542 | # define DC_HPDx_INT_EN (1 << 16) | ||
543 | # define DC_HPDx_RX_INT_ACK (1 << 20) | ||
544 | # define DC_HPDx_RX_INT_EN (1 << 24) | ||
545 | |||
546 | #define DC_HPD1_CONTROL 0x6024 | ||
547 | #define DC_HPD2_CONTROL 0x6030 | ||
548 | #define DC_HPD3_CONTROL 0x603c | ||
549 | #define DC_HPD4_CONTROL 0x6048 | ||
550 | #define DC_HPD5_CONTROL 0x6054 | ||
551 | #define DC_HPD6_CONTROL 0x6060 | ||
552 | # define DC_HPDx_CONNECTION_TIMER(x) ((x) << 0) | ||
553 | # define DC_HPDx_RX_INT_TIMER(x) ((x) << 16) | ||
554 | # define DC_HPDx_EN (1 << 28) | ||
555 | |||
556 | #endif | ||
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 6ea947d669e9..9b08c5743c86 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -44,6 +44,9 @@ | |||
44 | #define R700_PFP_UCODE_SIZE 848 | 44 | #define R700_PFP_UCODE_SIZE 848 |
45 | #define R700_PM4_UCODE_SIZE 1360 | 45 | #define R700_PM4_UCODE_SIZE 1360 |
46 | #define R700_RLC_UCODE_SIZE 1024 | 46 | #define R700_RLC_UCODE_SIZE 1024 |
47 | #define EVERGREEN_PFP_UCODE_SIZE 1120 | ||
48 | #define EVERGREEN_PM4_UCODE_SIZE 1376 | ||
49 | #define EVERGREEN_RLC_UCODE_SIZE 768 | ||
47 | 50 | ||
48 | /* Firmware Names */ | 51 | /* Firmware Names */ |
49 | MODULE_FIRMWARE("radeon/R600_pfp.bin"); | 52 | MODULE_FIRMWARE("radeon/R600_pfp.bin"); |
@@ -68,6 +71,18 @@ MODULE_FIRMWARE("radeon/RV710_pfp.bin"); | |||
68 | MODULE_FIRMWARE("radeon/RV710_me.bin"); | 71 | MODULE_FIRMWARE("radeon/RV710_me.bin"); |
69 | MODULE_FIRMWARE("radeon/R600_rlc.bin"); | 72 | MODULE_FIRMWARE("radeon/R600_rlc.bin"); |
70 | MODULE_FIRMWARE("radeon/R700_rlc.bin"); | 73 | MODULE_FIRMWARE("radeon/R700_rlc.bin"); |
74 | MODULE_FIRMWARE("radeon/CEDAR_pfp.bin"); | ||
75 | MODULE_FIRMWARE("radeon/CEDAR_me.bin"); | ||
76 | MODULE_FIRMWARE("radeon/CEDAR_rlc.bin"); | ||
77 | MODULE_FIRMWARE("radeon/REDWOOD_pfp.bin"); | ||
78 | MODULE_FIRMWARE("radeon/REDWOOD_me.bin"); | ||
79 | MODULE_FIRMWARE("radeon/REDWOOD_rlc.bin"); | ||
80 | MODULE_FIRMWARE("radeon/JUNIPER_pfp.bin"); | ||
81 | MODULE_FIRMWARE("radeon/JUNIPER_me.bin"); | ||
82 | MODULE_FIRMWARE("radeon/JUNIPER_rlc.bin"); | ||
83 | MODULE_FIRMWARE("radeon/CYPRESS_pfp.bin"); | ||
84 | MODULE_FIRMWARE("radeon/CYPRESS_me.bin"); | ||
85 | MODULE_FIRMWARE("radeon/CYPRESS_rlc.bin"); | ||
71 | 86 | ||
72 | int r600_debugfs_mc_info_init(struct radeon_device *rdev); | 87 | int r600_debugfs_mc_info_init(struct radeon_device *rdev); |
73 | 88 | ||
@@ -75,6 +90,7 @@ int r600_debugfs_mc_info_init(struct radeon_device *rdev); | |||
75 | int r600_mc_wait_for_idle(struct radeon_device *rdev); | 90 | int r600_mc_wait_for_idle(struct radeon_device *rdev); |
76 | void r600_gpu_init(struct radeon_device *rdev); | 91 | void r600_gpu_init(struct radeon_device *rdev); |
77 | void r600_fini(struct radeon_device *rdev); | 92 | void r600_fini(struct radeon_device *rdev); |
93 | void r600_irq_disable(struct radeon_device *rdev); | ||
78 | 94 | ||
79 | /* hpd for digital panel detect/disconnect */ | 95 | /* hpd for digital panel detect/disconnect */ |
80 | bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) | 96 | bool r600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) |
@@ -1450,10 +1466,31 @@ int r600_init_microcode(struct radeon_device *rdev) | |||
1450 | chip_name = "RV710"; | 1466 | chip_name = "RV710"; |
1451 | rlc_chip_name = "R700"; | 1467 | rlc_chip_name = "R700"; |
1452 | break; | 1468 | break; |
1469 | case CHIP_CEDAR: | ||
1470 | chip_name = "CEDAR"; | ||
1471 | rlc_chip_name = "CEDAR"; | ||
1472 | break; | ||
1473 | case CHIP_REDWOOD: | ||
1474 | chip_name = "REDWOOD"; | ||
1475 | rlc_chip_name = "REDWOOD"; | ||
1476 | break; | ||
1477 | case CHIP_JUNIPER: | ||
1478 | chip_name = "JUNIPER"; | ||
1479 | rlc_chip_name = "JUNIPER"; | ||
1480 | break; | ||
1481 | case CHIP_CYPRESS: | ||
1482 | case CHIP_HEMLOCK: | ||
1483 | chip_name = "CYPRESS"; | ||
1484 | rlc_chip_name = "CYPRESS"; | ||
1485 | break; | ||
1453 | default: BUG(); | 1486 | default: BUG(); |
1454 | } | 1487 | } |
1455 | 1488 | ||
1456 | if (rdev->family >= CHIP_RV770) { | 1489 | if (rdev->family >= CHIP_CEDAR) { |
1490 | pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4; | ||
1491 | me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4; | ||
1492 | rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4; | ||
1493 | } else if (rdev->family >= CHIP_RV770) { | ||
1457 | pfp_req_size = R700_PFP_UCODE_SIZE * 4; | 1494 | pfp_req_size = R700_PFP_UCODE_SIZE * 4; |
1458 | me_req_size = R700_PM4_UCODE_SIZE * 4; | 1495 | me_req_size = R700_PM4_UCODE_SIZE * 4; |
1459 | rlc_req_size = R700_RLC_UCODE_SIZE * 4; | 1496 | rlc_req_size = R700_RLC_UCODE_SIZE * 4; |
@@ -1567,12 +1604,15 @@ int r600_cp_start(struct radeon_device *rdev) | |||
1567 | } | 1604 | } |
1568 | radeon_ring_write(rdev, PACKET3(PACKET3_ME_INITIALIZE, 5)); | 1605 | radeon_ring_write(rdev, PACKET3(PACKET3_ME_INITIALIZE, 5)); |
1569 | radeon_ring_write(rdev, 0x1); | 1606 | radeon_ring_write(rdev, 0x1); |
1570 | if (rdev->family < CHIP_RV770) { | 1607 | if (rdev->family >= CHIP_CEDAR) { |
1571 | radeon_ring_write(rdev, 0x3); | 1608 | radeon_ring_write(rdev, 0x0); |
1572 | radeon_ring_write(rdev, rdev->config.r600.max_hw_contexts - 1); | 1609 | radeon_ring_write(rdev, rdev->config.evergreen.max_hw_contexts - 1); |
1573 | } else { | 1610 | } else if (rdev->family >= CHIP_RV770) { |
1574 | radeon_ring_write(rdev, 0x0); | 1611 | radeon_ring_write(rdev, 0x0); |
1575 | radeon_ring_write(rdev, rdev->config.rv770.max_hw_contexts - 1); | 1612 | radeon_ring_write(rdev, rdev->config.rv770.max_hw_contexts - 1); |
1613 | } else { | ||
1614 | radeon_ring_write(rdev, 0x3); | ||
1615 | radeon_ring_write(rdev, rdev->config.r600.max_hw_contexts - 1); | ||
1576 | } | 1616 | } |
1577 | radeon_ring_write(rdev, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); | 1617 | radeon_ring_write(rdev, PACKET3_ME_INITIALIZE_DEVICE_ID(1)); |
1578 | radeon_ring_write(rdev, 0); | 1618 | radeon_ring_write(rdev, 0); |
@@ -2273,10 +2313,11 @@ static void r600_ih_ring_fini(struct radeon_device *rdev) | |||
2273 | } | 2313 | } |
2274 | } | 2314 | } |
2275 | 2315 | ||
2276 | static void r600_rlc_stop(struct radeon_device *rdev) | 2316 | void r600_rlc_stop(struct radeon_device *rdev) |
2277 | { | 2317 | { |
2278 | 2318 | ||
2279 | if (rdev->family >= CHIP_RV770) { | 2319 | if ((rdev->family >= CHIP_RV770) && |
2320 | (rdev->family <= CHIP_RV740)) { | ||
2280 | /* r7xx asics need to soft reset RLC before halting */ | 2321 | /* r7xx asics need to soft reset RLC before halting */ |
2281 | WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC); | 2322 | WREG32(SRBM_SOFT_RESET, SOFT_RESET_RLC); |
2282 | RREG32(SRBM_SOFT_RESET); | 2323 | RREG32(SRBM_SOFT_RESET); |
@@ -2313,7 +2354,12 @@ static int r600_rlc_init(struct radeon_device *rdev) | |||
2313 | WREG32(RLC_UCODE_CNTL, 0); | 2354 | WREG32(RLC_UCODE_CNTL, 0); |
2314 | 2355 | ||
2315 | fw_data = (const __be32 *)rdev->rlc_fw->data; | 2356 | fw_data = (const __be32 *)rdev->rlc_fw->data; |
2316 | if (rdev->family >= CHIP_RV770) { | 2357 | if (rdev->family >= CHIP_CEDAR) { |
2358 | for (i = 0; i < EVERGREEN_RLC_UCODE_SIZE; i++) { | ||
2359 | WREG32(RLC_UCODE_ADDR, i); | ||
2360 | WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); | ||
2361 | } | ||
2362 | } else if (rdev->family >= CHIP_RV770) { | ||
2317 | for (i = 0; i < R700_RLC_UCODE_SIZE; i++) { | 2363 | for (i = 0; i < R700_RLC_UCODE_SIZE; i++) { |
2318 | WREG32(RLC_UCODE_ADDR, i); | 2364 | WREG32(RLC_UCODE_ADDR, i); |
2319 | WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); | 2365 | WREG32(RLC_UCODE_DATA, be32_to_cpup(fw_data++)); |
@@ -2343,7 +2389,7 @@ static void r600_enable_interrupts(struct radeon_device *rdev) | |||
2343 | rdev->ih.enabled = true; | 2389 | rdev->ih.enabled = true; |
2344 | } | 2390 | } |
2345 | 2391 | ||
2346 | static void r600_disable_interrupts(struct radeon_device *rdev) | 2392 | void r600_disable_interrupts(struct radeon_device *rdev) |
2347 | { | 2393 | { |
2348 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); | 2394 | u32 ih_rb_cntl = RREG32(IH_RB_CNTL); |
2349 | u32 ih_cntl = RREG32(IH_CNTL); | 2395 | u32 ih_cntl = RREG32(IH_CNTL); |
@@ -2458,7 +2504,10 @@ int r600_irq_init(struct radeon_device *rdev) | |||
2458 | WREG32(IH_CNTL, ih_cntl); | 2504 | WREG32(IH_CNTL, ih_cntl); |
2459 | 2505 | ||
2460 | /* force the active interrupt state to all disabled */ | 2506 | /* force the active interrupt state to all disabled */ |
2461 | r600_disable_interrupt_state(rdev); | 2507 | if (rdev->family >= CHIP_CEDAR) |
2508 | evergreen_disable_interrupt_state(rdev); | ||
2509 | else | ||
2510 | r600_disable_interrupt_state(rdev); | ||
2462 | 2511 | ||
2463 | /* enable irqs */ | 2512 | /* enable irqs */ |
2464 | r600_enable_interrupts(rdev); | 2513 | r600_enable_interrupts(rdev); |
@@ -2468,7 +2517,7 @@ int r600_irq_init(struct radeon_device *rdev) | |||
2468 | 2517 | ||
2469 | void r600_irq_suspend(struct radeon_device *rdev) | 2518 | void r600_irq_suspend(struct radeon_device *rdev) |
2470 | { | 2519 | { |
2471 | r600_disable_interrupts(rdev); | 2520 | r600_irq_disable(rdev); |
2472 | r600_rlc_stop(rdev); | 2521 | r600_rlc_stop(rdev); |
2473 | } | 2522 | } |
2474 | 2523 | ||
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index be7570ac901c..e9120985a652 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -372,7 +372,7 @@ struct radeon_irq { | |||
372 | bool installed; | 372 | bool installed; |
373 | bool sw_int; | 373 | bool sw_int; |
374 | /* FIXME: use a define max crtc rather than hardcode it */ | 374 | /* FIXME: use a define max crtc rather than hardcode it */ |
375 | bool crtc_vblank_int[2]; | 375 | bool crtc_vblank_int[6]; |
376 | wait_queue_head_t vblank_queue; | 376 | wait_queue_head_t vblank_queue; |
377 | /* FIXME: use defines for max hpd/dacs */ | 377 | /* FIXME: use defines for max hpd/dacs */ |
378 | bool hpd[6]; | 378 | bool hpd[6]; |
@@ -870,11 +870,36 @@ struct rv770_asic { | |||
870 | struct r100_gpu_lockup lockup; | 870 | struct r100_gpu_lockup lockup; |
871 | }; | 871 | }; |
872 | 872 | ||
873 | struct evergreen_asic { | ||
874 | unsigned num_ses; | ||
875 | unsigned max_pipes; | ||
876 | unsigned max_tile_pipes; | ||
877 | unsigned max_simds; | ||
878 | unsigned max_backends; | ||
879 | unsigned max_gprs; | ||
880 | unsigned max_threads; | ||
881 | unsigned max_stack_entries; | ||
882 | unsigned max_hw_contexts; | ||
883 | unsigned max_gs_threads; | ||
884 | unsigned sx_max_export_size; | ||
885 | unsigned sx_max_export_pos_size; | ||
886 | unsigned sx_max_export_smx_size; | ||
887 | unsigned sq_num_cf_insts; | ||
888 | unsigned sx_num_of_sets; | ||
889 | unsigned sc_prim_fifo_size; | ||
890 | unsigned sc_hiz_tile_fifo_size; | ||
891 | unsigned sc_earlyz_tile_fifo_size; | ||
892 | unsigned tiling_nbanks; | ||
893 | unsigned tiling_npipes; | ||
894 | unsigned tiling_group_size; | ||
895 | }; | ||
896 | |||
873 | union radeon_asic_config { | 897 | union radeon_asic_config { |
874 | struct r300_asic r300; | 898 | struct r300_asic r300; |
875 | struct r100_asic r100; | 899 | struct r100_asic r100; |
876 | struct r600_asic r600; | 900 | struct r600_asic r600; |
877 | struct rv770_asic rv770; | 901 | struct rv770_asic rv770; |
902 | struct evergreen_asic evergreen; | ||
878 | }; | 903 | }; |
879 | 904 | ||
880 | /* | 905 | /* |
@@ -1272,6 +1297,7 @@ extern void rs690_line_buffer_adjust(struct radeon_device *rdev, | |||
1272 | extern void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); | 1297 | extern void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
1273 | extern bool r600_card_posted(struct radeon_device *rdev); | 1298 | extern bool r600_card_posted(struct radeon_device *rdev); |
1274 | extern void r600_cp_stop(struct radeon_device *rdev); | 1299 | extern void r600_cp_stop(struct radeon_device *rdev); |
1300 | extern int r600_cp_start(struct radeon_device *rdev); | ||
1275 | extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size); | 1301 | extern void r600_ring_init(struct radeon_device *rdev, unsigned ring_size); |
1276 | extern int r600_cp_resume(struct radeon_device *rdev); | 1302 | extern int r600_cp_resume(struct radeon_device *rdev); |
1277 | extern void r600_cp_fini(struct radeon_device *rdev); | 1303 | extern void r600_cp_fini(struct radeon_device *rdev); |
@@ -1295,6 +1321,8 @@ extern void r600_irq_fini(struct radeon_device *rdev); | |||
1295 | extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); | 1321 | extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); |
1296 | extern int r600_irq_set(struct radeon_device *rdev); | 1322 | extern int r600_irq_set(struct radeon_device *rdev); |
1297 | extern void r600_irq_suspend(struct radeon_device *rdev); | 1323 | extern void r600_irq_suspend(struct radeon_device *rdev); |
1324 | extern void r600_disable_interrupts(struct radeon_device *rdev); | ||
1325 | extern void r600_rlc_stop(struct radeon_device *rdev); | ||
1298 | /* r600 audio */ | 1326 | /* r600 audio */ |
1299 | extern int r600_audio_init(struct radeon_device *rdev); | 1327 | extern int r600_audio_init(struct radeon_device *rdev); |
1300 | extern int r600_audio_tmds_index(struct drm_encoder *encoder); | 1328 | extern int r600_audio_tmds_index(struct drm_encoder *encoder); |
@@ -1312,6 +1340,11 @@ extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder, | |||
1312 | uint8_t status_bits, | 1340 | uint8_t status_bits, |
1313 | uint8_t category_code); | 1341 | uint8_t category_code); |
1314 | 1342 | ||
1343 | extern void r700_cp_stop(struct radeon_device *rdev); | ||
1344 | extern void r700_cp_fini(struct radeon_device *rdev); | ||
1345 | extern void evergreen_disable_interrupt_state(struct radeon_device *rdev); | ||
1346 | extern int evergreen_irq_set(struct radeon_device *rdev); | ||
1347 | |||
1315 | /* evergreen */ | 1348 | /* evergreen */ |
1316 | struct evergreen_mc_save { | 1349 | struct evergreen_mc_save { |
1317 | u32 vga_control[6]; | 1350 | u32 vga_control[6]; |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index 0d7664b8e489..f835333c1b69 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c | |||
@@ -635,17 +635,17 @@ static struct radeon_asic evergreen_asic = { | |||
635 | .fini = &evergreen_fini, | 635 | .fini = &evergreen_fini, |
636 | .suspend = &evergreen_suspend, | 636 | .suspend = &evergreen_suspend, |
637 | .resume = &evergreen_resume, | 637 | .resume = &evergreen_resume, |
638 | .cp_commit = NULL, | 638 | .cp_commit = &r600_cp_commit, |
639 | .gpu_is_lockup = &evergreen_gpu_is_lockup, | 639 | .gpu_is_lockup = &evergreen_gpu_is_lockup, |
640 | .asic_reset = &evergreen_asic_reset, | 640 | .asic_reset = &evergreen_asic_reset, |
641 | .vga_set_state = &r600_vga_set_state, | 641 | .vga_set_state = &r600_vga_set_state, |
642 | .gart_tlb_flush = &r600_pcie_gart_tlb_flush, | 642 | .gart_tlb_flush = &evergreen_pcie_gart_tlb_flush, |
643 | .gart_set_page = &rs600_gart_set_page, | 643 | .gart_set_page = &rs600_gart_set_page, |
644 | .ring_test = NULL, | 644 | .ring_test = &r600_ring_test, |
645 | .ring_ib_execute = NULL, | 645 | .ring_ib_execute = &r600_ring_ib_execute, |
646 | .irq_set = NULL, | 646 | .irq_set = &evergreen_irq_set, |
647 | .irq_process = NULL, | 647 | .irq_process = &evergreen_irq_process, |
648 | .get_vblank_counter = NULL, | 648 | .get_vblank_counter = &evergreen_get_vblank_counter, |
649 | .fence_ring_emit = NULL, | 649 | .fence_ring_emit = NULL, |
650 | .cs_parse = NULL, | 650 | .cs_parse = NULL, |
651 | .copy_blit = NULL, | 651 | .copy_blit = NULL, |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index 77d48ba4a29a..ef2c7ba1bdc9 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h | |||
@@ -281,6 +281,7 @@ int rv770_resume(struct radeon_device *rdev); | |||
281 | /* | 281 | /* |
282 | * evergreen | 282 | * evergreen |
283 | */ | 283 | */ |
284 | void evergreen_pcie_gart_tlb_flush(struct radeon_device *rdev); | ||
284 | int evergreen_init(struct radeon_device *rdev); | 285 | int evergreen_init(struct radeon_device *rdev); |
285 | void evergreen_fini(struct radeon_device *rdev); | 286 | void evergreen_fini(struct radeon_device *rdev); |
286 | int evergreen_suspend(struct radeon_device *rdev); | 287 | int evergreen_suspend(struct radeon_device *rdev); |
@@ -293,4 +294,8 @@ void evergreen_hpd_fini(struct radeon_device *rdev); | |||
293 | bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); | 294 | bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); |
294 | void evergreen_hpd_set_polarity(struct radeon_device *rdev, | 295 | void evergreen_hpd_set_polarity(struct radeon_device *rdev, |
295 | enum radeon_hpd_id hpd); | 296 | enum radeon_hpd_id hpd); |
297 | u32 evergreen_get_vblank_counter(struct radeon_device *rdev, int crtc); | ||
298 | int evergreen_irq_set(struct radeon_device *rdev); | ||
299 | int evergreen_irq_process(struct radeon_device *rdev); | ||
300 | |||
296 | #endif | 301 | #endif |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 5673665ff216..273019925e0b 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
@@ -1462,6 +1462,10 @@ static const char *pp_lib_thermal_controller_names[] = { | |||
1462 | "RV6xx", | 1462 | "RV6xx", |
1463 | "RV770", | 1463 | "RV770", |
1464 | "ADT7473", | 1464 | "ADT7473", |
1465 | "External GPIO", | ||
1466 | "Evergreen", | ||
1467 | "ADT7473 with internal", | ||
1468 | |||
1465 | }; | 1469 | }; |
1466 | 1470 | ||
1467 | union power_info { | 1471 | union power_info { |
@@ -1707,15 +1711,21 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) | |||
1707 | break; | 1711 | break; |
1708 | } | 1712 | } |
1709 | } | 1713 | } |
1710 | } else if (frev == 4) { | 1714 | } else { |
1711 | /* add the i2c bus for thermal/fan chip */ | 1715 | /* add the i2c bus for thermal/fan chip */ |
1712 | /* no support for internal controller yet */ | 1716 | /* no support for internal controller yet */ |
1713 | if (power_info->info_4.sThermalController.ucType > 0) { | 1717 | if (power_info->info_4.sThermalController.ucType > 0) { |
1714 | if ((power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) || | 1718 | if ((power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) || |
1715 | (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV770)) { | 1719 | (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV770) || |
1720 | (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_EVERGREEN)) { | ||
1716 | DRM_INFO("Internal thermal controller %s fan control\n", | 1721 | DRM_INFO("Internal thermal controller %s fan control\n", |
1717 | (power_info->info_4.sThermalController.ucFanParameters & | 1722 | (power_info->info_4.sThermalController.ucFanParameters & |
1718 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); | 1723 | ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with"); |
1724 | } else if ((power_info->info_4.sThermalController.ucType == | ||
1725 | ATOM_PP_THERMALCONTROLLER_EXTERNAL_GPIO) || | ||
1726 | (power_info->info_4.sThermalController.ucType == | ||
1727 | ATOM_PP_THERMALCONTROLLER_ADT7473_WITH_INTERNAL)) { | ||
1728 | DRM_INFO("Special thermal controller config\n"); | ||
1719 | } else { | 1729 | } else { |
1720 | DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n", | 1730 | DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n", |
1721 | pp_lib_thermal_controller_names[power_info->info_4.sThermalController.ucType], | 1731 | pp_lib_thermal_controller_names[power_info->info_4.sThermalController.ucType], |
@@ -1763,6 +1773,36 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) | |||
1763 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = | 1773 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = |
1764 | clock_info->usVDDC; | 1774 | clock_info->usVDDC; |
1765 | mode_index++; | 1775 | mode_index++; |
1776 | } else if (ASIC_IS_DCE4(rdev)) { | ||
1777 | struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO *clock_info = | ||
1778 | (struct _ATOM_PPLIB_EVERGREEN_CLOCK_INFO *) | ||
1779 | (mode_info->atom_context->bios + | ||
1780 | data_offset + | ||
1781 | le16_to_cpu(power_info->info_4.usClockInfoArrayOffset) + | ||
1782 | (power_state->ucClockStateIndices[j] * | ||
1783 | power_info->info_4.ucClockInfoSize)); | ||
1784 | sclk = le16_to_cpu(clock_info->usEngineClockLow); | ||
1785 | sclk |= clock_info->ucEngineClockHigh << 16; | ||
1786 | mclk = le16_to_cpu(clock_info->usMemoryClockLow); | ||
1787 | mclk |= clock_info->ucMemoryClockHigh << 16; | ||
1788 | rdev->pm.power_state[state_index].clock_info[mode_index].mclk = mclk; | ||
1789 | rdev->pm.power_state[state_index].clock_info[mode_index].sclk = sclk; | ||
1790 | /* skip invalid modes */ | ||
1791 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk == 0) || | ||
1792 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk == 0)) | ||
1793 | continue; | ||
1794 | /* skip overclock modes for now */ | ||
1795 | if ((rdev->pm.power_state[state_index].clock_info[mode_index].mclk > | ||
1796 | rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) || | ||
1797 | (rdev->pm.power_state[state_index].clock_info[mode_index].sclk > | ||
1798 | rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN)) | ||
1799 | continue; | ||
1800 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.type = | ||
1801 | VOLTAGE_SW; | ||
1802 | rdev->pm.power_state[state_index].clock_info[mode_index].voltage.voltage = | ||
1803 | clock_info->usVDDC; | ||
1804 | /* XXX usVDDCI */ | ||
1805 | mode_index++; | ||
1766 | } else { | 1806 | } else { |
1767 | struct _ATOM_PPLIB_R600_CLOCK_INFO *clock_info = | 1807 | struct _ATOM_PPLIB_R600_CLOCK_INFO *clock_info = |
1768 | (struct _ATOM_PPLIB_R600_CLOCK_INFO *) | 1808 | (struct _ATOM_PPLIB_R600_CLOCK_INFO *) |
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c index 72bc57a92388..c14f3be25b4b 100644 --- a/drivers/gpu/drm/radeon/rv770.c +++ b/drivers/gpu/drm/radeon/rv770.c | |||
@@ -237,7 +237,6 @@ void r700_cp_stop(struct radeon_device *rdev) | |||
237 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); | 237 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); |
238 | } | 238 | } |
239 | 239 | ||
240 | |||
241 | static int rv770_cp_load_microcode(struct radeon_device *rdev) | 240 | static int rv770_cp_load_microcode(struct radeon_device *rdev) |
242 | { | 241 | { |
243 | const __be32 *fw_data; | 242 | const __be32 *fw_data; |
@@ -272,6 +271,11 @@ static int rv770_cp_load_microcode(struct radeon_device *rdev) | |||
272 | return 0; | 271 | return 0; |
273 | } | 272 | } |
274 | 273 | ||
274 | void r700_cp_fini(struct radeon_device *rdev) | ||
275 | { | ||
276 | r700_cp_stop(rdev); | ||
277 | radeon_ring_fini(rdev); | ||
278 | } | ||
275 | 279 | ||
276 | /* | 280 | /* |
277 | * Core functions | 281 | * Core functions |
@@ -1126,7 +1130,7 @@ int rv770_init(struct radeon_device *rdev) | |||
1126 | r = rv770_startup(rdev); | 1130 | r = rv770_startup(rdev); |
1127 | if (r) { | 1131 | if (r) { |
1128 | dev_err(rdev->dev, "disabling GPU acceleration\n"); | 1132 | dev_err(rdev->dev, "disabling GPU acceleration\n"); |
1129 | r600_cp_fini(rdev); | 1133 | r700_cp_fini(rdev); |
1130 | r600_wb_fini(rdev); | 1134 | r600_wb_fini(rdev); |
1131 | r600_irq_fini(rdev); | 1135 | r600_irq_fini(rdev); |
1132 | radeon_irq_kms_fini(rdev); | 1136 | radeon_irq_kms_fini(rdev); |
@@ -1160,7 +1164,7 @@ void rv770_fini(struct radeon_device *rdev) | |||
1160 | { | 1164 | { |
1161 | radeon_pm_fini(rdev); | 1165 | radeon_pm_fini(rdev); |
1162 | r600_blit_fini(rdev); | 1166 | r600_blit_fini(rdev); |
1163 | r600_cp_fini(rdev); | 1167 | r700_cp_fini(rdev); |
1164 | r600_wb_fini(rdev); | 1168 | r600_wb_fini(rdev); |
1165 | r600_irq_fini(rdev); | 1169 | r600_irq_fini(rdev); |
1166 | radeon_irq_kms_fini(rdev); | 1170 | radeon_irq_kms_fini(rdev); |