Rev 2997 | Rev 5078 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1128 | serge | 1 | /* |
2 | * Copyright 2008 Advanced Micro Devices, Inc. |
||
3 | * Copyright 2008 Red Hat Inc. |
||
4 | * Copyright 2009 Jerome Glisse. |
||
5 | * |
||
6 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
7 | * copy of this software and associated documentation files (the "Software"), |
||
8 | * to deal in the Software without restriction, including without limitation |
||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
10 | * and/or sell copies of the Software, and to permit persons to whom the |
||
11 | * Software is furnished to do so, subject to the following conditions: |
||
12 | * |
||
13 | * The above copyright notice and this permission notice shall be included in |
||
14 | * all copies or substantial portions of the Software. |
||
15 | * |
||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||
22 | * OTHER DEALINGS IN THE SOFTWARE. |
||
23 | * |
||
24 | * Authors: Dave Airlie |
||
25 | * Alex Deucher |
||
26 | * Jerome Glisse |
||
27 | */ |
||
1221 | serge | 28 | /* RS600 / Radeon X1250/X1270 integrated GPU |
29 | * |
||
30 | * This file gather function specific to RS600 which is the IGP of |
||
31 | * the X1250/X1270 family supporting intel CPU (while RS690/RS740 |
||
32 | * is the X1250/X1270 supporting AMD CPU). The display engine are |
||
33 | * the avivo one, bios is an atombios, 3D block are the one of the |
||
34 | * R4XX family. The GART is different from the RS400 one and is very |
||
35 | * close to the one of the R600 family (R600 likely being an evolution |
||
36 | * of the RS600 GART block). |
||
37 | */ |
||
2997 | Serge | 38 | #include |
1128 | serge | 39 | #include "radeon.h" |
1963 | serge | 40 | #include "radeon_asic.h" |
1221 | serge | 41 | #include "atom.h" |
42 | #include "rs600d.h" |
||
1128 | serge | 43 | |
1179 | serge | 44 | #include "rs600_reg_safe.h" |
45 | |||
2997 | Serge | 46 | static void rs600_gpu_init(struct radeon_device *rdev); |
1128 | serge | 47 | int rs600_mc_wait_for_idle(struct radeon_device *rdev); |
48 | |||
2997 | Serge | 49 | static const u32 crtc_offsets[2] = |
50 | { |
||
51 | 0, |
||
52 | AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL |
||
53 | }; |
||
54 | |||
55 | void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc) |
||
56 | { |
||
57 | int i; |
||
58 | |||
59 | if (crtc >= rdev->num_crtc) |
||
60 | return; |
||
61 | |||
62 | if (RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[crtc]) & AVIVO_CRTC_EN) { |
||
63 | for (i = 0; i < rdev->usec_timeout; i++) { |
||
64 | if (!(RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK)) |
||
65 | break; |
||
66 | udelay(1); |
||
67 | } |
||
68 | for (i = 0; i < rdev->usec_timeout; i++) { |
||
69 | if (RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK) |
||
70 | break; |
||
71 | udelay(1); |
||
72 | } |
||
73 | } |
||
74 | } |
||
1321 | serge | 75 | /* hpd for digital panel detect/disconnect */ |
76 | bool rs600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd) |
||
77 | { |
||
78 | u32 tmp; |
||
79 | bool connected = false; |
||
80 | |||
81 | switch (hpd) { |
||
82 | case RADEON_HPD_1: |
||
83 | tmp = RREG32(R_007D04_DC_HOT_PLUG_DETECT1_INT_STATUS); |
||
84 | if (G_007D04_DC_HOT_PLUG_DETECT1_SENSE(tmp)) |
||
85 | connected = true; |
||
86 | break; |
||
87 | case RADEON_HPD_2: |
||
88 | tmp = RREG32(R_007D14_DC_HOT_PLUG_DETECT2_INT_STATUS); |
||
89 | if (G_007D14_DC_HOT_PLUG_DETECT2_SENSE(tmp)) |
||
90 | connected = true; |
||
91 | break; |
||
92 | default: |
||
93 | break; |
||
94 | } |
||
95 | return connected; |
||
96 | } |
||
97 | |||
98 | void rs600_hpd_set_polarity(struct radeon_device *rdev, |
||
99 | enum radeon_hpd_id hpd) |
||
100 | { |
||
101 | u32 tmp; |
||
102 | bool connected = rs600_hpd_sense(rdev, hpd); |
||
103 | |||
104 | switch (hpd) { |
||
105 | case RADEON_HPD_1: |
||
106 | tmp = RREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL); |
||
107 | if (connected) |
||
108 | tmp &= ~S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); |
||
109 | else |
||
110 | tmp |= S_007D08_DC_HOT_PLUG_DETECT1_INT_POLARITY(1); |
||
111 | WREG32(R_007D08_DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp); |
||
112 | break; |
||
113 | case RADEON_HPD_2: |
||
114 | tmp = RREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL); |
||
115 | if (connected) |
||
116 | tmp &= ~S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); |
||
117 | else |
||
118 | tmp |= S_007D18_DC_HOT_PLUG_DETECT2_INT_POLARITY(1); |
||
119 | WREG32(R_007D18_DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp); |
||
120 | break; |
||
121 | default: |
||
122 | break; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | void rs600_hpd_init(struct radeon_device *rdev) |
||
127 | { |
||
128 | struct drm_device *dev = rdev->ddev; |
||
129 | struct drm_connector *connector; |
||
2997 | Serge | 130 | unsigned enable = 0; |
1321 | serge | 131 | |
132 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
||
133 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
||
134 | switch (radeon_connector->hpd.hpd) { |
||
135 | case RADEON_HPD_1: |
||
136 | WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, |
||
137 | S_007D00_DC_HOT_PLUG_DETECT1_EN(1)); |
||
138 | break; |
||
139 | case RADEON_HPD_2: |
||
140 | WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, |
||
141 | S_007D10_DC_HOT_PLUG_DETECT2_EN(1)); |
||
142 | break; |
||
143 | default: |
||
144 | break; |
||
145 | } |
||
2997 | Serge | 146 | enable |= 1 << radeon_connector->hpd.hpd; |
147 | radeon_hpd_set_polarity(rdev, radeon_connector->hpd.hpd); |
||
1321 | serge | 148 | } |
2997 | Serge | 149 | // radeon_irq_kms_enable_hpd(rdev, enable); |
1321 | serge | 150 | } |
151 | |||
152 | void rs600_hpd_fini(struct radeon_device *rdev) |
||
153 | { |
||
154 | struct drm_device *dev = rdev->ddev; |
||
155 | struct drm_connector *connector; |
||
2997 | Serge | 156 | unsigned disable = 0; |
1321 | serge | 157 | |
158 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
||
159 | struct radeon_connector *radeon_connector = to_radeon_connector(connector); |
||
160 | switch (radeon_connector->hpd.hpd) { |
||
161 | case RADEON_HPD_1: |
||
162 | WREG32(R_007D00_DC_HOT_PLUG_DETECT1_CONTROL, |
||
163 | S_007D00_DC_HOT_PLUG_DETECT1_EN(0)); |
||
164 | break; |
||
165 | case RADEON_HPD_2: |
||
166 | WREG32(R_007D10_DC_HOT_PLUG_DETECT2_CONTROL, |
||
167 | S_007D10_DC_HOT_PLUG_DETECT2_EN(0)); |
||
168 | break; |
||
169 | default: |
||
170 | break; |
||
171 | } |
||
2997 | Serge | 172 | disable |= 1 << radeon_connector->hpd.hpd; |
1321 | serge | 173 | } |
2997 | Serge | 174 | // radeon_irq_kms_disable_hpd(rdev, disable); |
1321 | serge | 175 | } |
176 | |||
1963 | serge | 177 | int rs600_asic_reset(struct radeon_device *rdev) |
178 | { |
||
179 | struct rv515_mc_save save; |
||
180 | u32 status, tmp; |
||
181 | int ret = 0; |
||
182 | |||
183 | status = RREG32(R_000E40_RBBM_STATUS); |
||
184 | if (!G_000E40_GUI_ACTIVE(status)) { |
||
185 | return 0; |
||
186 | } |
||
187 | /* Stops all mc clients */ |
||
188 | rv515_mc_stop(rdev, &save); |
||
189 | status = RREG32(R_000E40_RBBM_STATUS); |
||
190 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); |
||
191 | /* stop CP */ |
||
192 | WREG32(RADEON_CP_CSQ_CNTL, 0); |
||
193 | tmp = RREG32(RADEON_CP_RB_CNTL); |
||
194 | WREG32(RADEON_CP_RB_CNTL, tmp | RADEON_RB_RPTR_WR_ENA); |
||
195 | WREG32(RADEON_CP_RB_RPTR_WR, 0); |
||
196 | WREG32(RADEON_CP_RB_WPTR, 0); |
||
197 | WREG32(RADEON_CP_RB_CNTL, tmp); |
||
198 | // pci_save_state(rdev->pdev); |
||
199 | /* disable bus mastering */ |
||
2997 | Serge | 200 | // pci_clear_master(rdev->pdev); |
201 | mdelay(1); |
||
1963 | serge | 202 | /* reset GA+VAP */ |
203 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) | |
||
204 | S_0000F0_SOFT_RESET_GA(1)); |
||
205 | RREG32(R_0000F0_RBBM_SOFT_RESET); |
||
206 | mdelay(500); |
||
207 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); |
||
208 | mdelay(1); |
||
209 | status = RREG32(R_000E40_RBBM_STATUS); |
||
210 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); |
||
211 | /* reset CP */ |
||
212 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_CP(1)); |
||
213 | RREG32(R_0000F0_RBBM_SOFT_RESET); |
||
214 | mdelay(500); |
||
215 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); |
||
216 | mdelay(1); |
||
217 | status = RREG32(R_000E40_RBBM_STATUS); |
||
218 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); |
||
219 | /* reset MC */ |
||
220 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_MC(1)); |
||
221 | RREG32(R_0000F0_RBBM_SOFT_RESET); |
||
222 | mdelay(500); |
||
223 | WREG32(R_0000F0_RBBM_SOFT_RESET, 0); |
||
224 | mdelay(1); |
||
225 | status = RREG32(R_000E40_RBBM_STATUS); |
||
226 | dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status); |
||
227 | /* restore PCI & busmastering */ |
||
228 | // pci_restore_state(rdev->pdev); |
||
229 | /* Check if GPU is idle */ |
||
230 | if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) { |
||
231 | dev_err(rdev->dev, "failed to reset GPU\n"); |
||
232 | ret = -1; |
||
233 | } else |
||
234 | dev_info(rdev->dev, "GPU reset succeed\n"); |
||
235 | rv515_mc_resume(rdev, &save); |
||
236 | return ret; |
||
237 | } |
||
238 | |||
1128 | serge | 239 | /* |
240 | * GART. |
||
241 | */ |
||
242 | void rs600_gart_tlb_flush(struct radeon_device *rdev) |
||
243 | { |
||
244 | uint32_t tmp; |
||
245 | |||
1221 |