aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2011-01-06 21:19:31 -0500
committerDave Airlie <airlied@redhat.com>2011-01-06 23:11:40 -0500
commit0af62b0168043896a042b005ff88caa77dd94d04 (patch)
tree1e64c1dcafd80f53f16172955c41d40122b00117 /drivers/gpu/drm
parentfee298fd6f3d8bde5fc2912192d026c78ba81982 (diff)
drm/radeon/kms: add ucode loader for NI
The MC ucode is no longer loaded by the vbios tables as on previous asics. It now must be loaded by the driver. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/radeon/Makefile2
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c21
-rw-r--r--drivers/gpu/drm/radeon/ni.c316
-rw-r--r--drivers/gpu/drm/radeon/nid.h41
-rw-r--r--drivers/gpu/drm/radeon/radeon.h4
5 files changed, 380 insertions, 4 deletions
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index e97e6f842699..e47eecfc2df4 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -66,7 +66,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
66 r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \ 66 r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \
67 r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \ 67 r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o \
68 evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \ 68 evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \
69 radeon_trace_points.o 69 radeon_trace_points.o ni.o
70 70
71radeon-$(CONFIG_COMPAT) += radeon_ioc32.o 71radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
72radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o 72radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index c40e5ad251dd..4fb2101ee476 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2855,12 +2855,27 @@ static int evergreen_startup(struct radeon_device *rdev)
2855 /* enable pcie gen2 link */ 2855 /* enable pcie gen2 link */
2856 evergreen_pcie_gen2_enable(rdev); 2856 evergreen_pcie_gen2_enable(rdev);
2857 2857
2858 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 2858 if (ASIC_IS_DCE5(rdev)) {
2859 r = r600_init_microcode(rdev); 2859 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) {
2860 r = ni_init_microcode(rdev);
2861 if (r) {
2862 DRM_ERROR("Failed to load firmware!\n");
2863 return r;
2864 }
2865 }
2866 r = btc_mc_load_microcode(rdev);
2860 if (r) { 2867 if (r) {
2861 DRM_ERROR("Failed to load firmware!\n"); 2868 DRM_ERROR("Failed to load MC firmware!\n");
2862 return r; 2869 return r;
2863 } 2870 }
2871 } else {
2872 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
2873 r = r600_init_microcode(rdev);
2874 if (r) {
2875 DRM_ERROR("Failed to load firmware!\n");
2876 return r;
2877 }
2878 }
2864 } 2879 }
2865 2880
2866 evergreen_mc_program(rdev); 2881 evergreen_mc_program(rdev);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
new file mode 100644
index 000000000000..5e0bef80ad7f
--- /dev/null
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -0,0 +1,316 @@
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#include <linux/firmware.h>
25#include <linux/platform_device.h>
26#include <linux/slab.h>
27#include "drmP.h"
28#include "radeon.h"
29#include "radeon_asic.h"
30#include "radeon_drm.h"
31#include "nid.h"
32#include "atom.h"
33#include "ni_reg.h"
34
35#define EVERGREEN_PFP_UCODE_SIZE 1120
36#define EVERGREEN_PM4_UCODE_SIZE 1376
37#define EVERGREEN_RLC_UCODE_SIZE 768
38#define BTC_MC_UCODE_SIZE 6024
39
40/* Firmware Names */
41MODULE_FIRMWARE("radeon/BARTS_pfp.bin");
42MODULE_FIRMWARE("radeon/BARTS_me.bin");
43MODULE_FIRMWARE("radeon/BARTS_mc.bin");
44MODULE_FIRMWARE("radeon/BTC_rlc.bin");
45MODULE_FIRMWARE("radeon/TURKS_pfp.bin");
46MODULE_FIRMWARE("radeon/TURKS_me.bin");
47MODULE_FIRMWARE("radeon/TURKS_mc.bin");
48MODULE_FIRMWARE("radeon/CAICOS_pfp.bin");
49MODULE_FIRMWARE("radeon/CAICOS_me.bin");
50MODULE_FIRMWARE("radeon/CAICOS_mc.bin");
51
52#define BTC_IO_MC_REGS_SIZE 29
53
54static const u32 barts_io_mc_regs[BTC_IO_MC_REGS_SIZE][2] = {
55 {0x00000077, 0xff010100},
56 {0x00000078, 0x00000000},
57 {0x00000079, 0x00001434},
58 {0x0000007a, 0xcc08ec08},
59 {0x0000007b, 0x00040000},
60 {0x0000007c, 0x000080c0},
61 {0x0000007d, 0x09000000},
62 {0x0000007e, 0x00210404},
63 {0x00000081, 0x08a8e800},
64 {0x00000082, 0x00030444},
65 {0x00000083, 0x00000000},
66 {0x00000085, 0x00000001},
67 {0x00000086, 0x00000002},
68 {0x00000087, 0x48490000},
69 {0x00000088, 0x20244647},
70 {0x00000089, 0x00000005},
71 {0x0000008b, 0x66030000},
72 {0x0000008c, 0x00006603},
73 {0x0000008d, 0x00000100},
74 {0x0000008f, 0x00001c0a},
75 {0x00000090, 0xff000001},
76 {0x00000094, 0x00101101},
77 {0x00000095, 0x00000fff},
78 {0x00000096, 0x00116fff},
79 {0x00000097, 0x60010000},
80 {0x00000098, 0x10010000},
81 {0x00000099, 0x00006000},
82 {0x0000009a, 0x00001000},
83 {0x0000009f, 0x00946a00}
84};
85
86static const u32 turks_io_mc_regs[BTC_IO_MC_REGS_SIZE][2] = {
87 {0x00000077, 0xff010100},
88 {0x00000078, 0x00000000},
89 {0x00000079, 0x00001434},
90 {0x0000007a, 0xcc08ec08},
91 {0x0000007b, 0x00040000},
92 {0x0000007c, 0x000080c0},
93 {0x0000007d, 0x09000000},
94 {0x0000007e, 0x00210404},
95 {0x00000081, 0x08a8e800},
96 {0x00000082, 0x00030444},
97 {0x00000083, 0x00000000},
98 {0x00000085, 0x00000001},
99 {0x00000086, 0x00000002},
100 {0x00000087, 0x48490000},
101 {0x00000088, 0x20244647},
102 {0x00000089, 0x00000005},
103 {0x0000008b, 0x66030000},
104 {0x0000008c, 0x00006603},
105 {0x0000008d, 0x00000100},
106 {0x0000008f, 0x00001c0a},
107 {0x00000090, 0xff000001},
108 {0x00000094, 0x00101101},
109 {0x00000095, 0x00000fff},
110 {0x00000096, 0x00116fff},
111 {0x00000097, 0x60010000},
112 {0x00000098, 0x10010000},
113 {0x00000099, 0x00006000},
114 {0x0000009a, 0x00001000},
115 {0x0000009f, 0x00936a00}
116};
117
118static const u32 caicos_io_mc_regs[BTC_IO_MC_REGS_SIZE][2] = {
119 {0x00000077, 0xff010100},
120 {0x00000078, 0x00000000},
121 {0x00000079, 0x00001434},
122 {0x0000007a, 0xcc08ec08},
123 {0x0000007b, 0x00040000},
124 {0x0000007c, 0x000080c0},
125 {0x0000007d, 0x09000000},
126 {0x0000007e, 0x00210404},
127 {0x00000081, 0x08a8e800},
128 {0x00000082, 0x00030444},
129 {0x00000083, 0x00000000},
130 {0x00000085, 0x00000001},
131 {0x00000086, 0x00000002},
132 {0x00000087, 0x48490000},
133 {0x00000088, 0x20244647},
134 {0x00000089, 0x00000005},
135 {0x0000008b, 0x66030000},
136 {0x0000008c, 0x00006603},
137 {0x0000008d, 0x00000100},
138 {0x0000008f, 0x00001c0a},
139 {0x00000090, 0xff000001},
140 {0x00000094, 0x00101101},
141 {0x00000095, 0x00000fff},
142 {0x00000096, 0x00116fff},
143 {0x00000097, 0x60010000},
144 {0x00000098, 0x10010000},
145 {0x00000099, 0x00006000},
146 {0x0000009a, 0x00001000},
147 {0x0000009f, 0x00916a00}
148};
149
150int btc_mc_load_microcode(struct radeon_device *rdev)
151{
152 const __be32 *fw_data;
153 u32 mem_type, running, blackout = 0;
154 u32 *io_mc_regs;
155 int i;
156
157 if (!rdev->mc_fw)
158 return -EINVAL;
159
160 switch (rdev->family) {
161 case CHIP_BARTS:
162 io_mc_regs = (u32 *)&barts_io_mc_regs;
163 break;
164 case CHIP_TURKS:
165 io_mc_regs = (u32 *)&turks_io_mc_regs;
166 break;
167 case CHIP_CAICOS:
168 default:
169 io_mc_regs = (u32 *)&caicos_io_mc_regs;
170 break;
171 }
172
173 mem_type = (RREG32(MC_SEQ_MISC0) & MC_SEQ_MISC0_GDDR5_MASK) >> MC_SEQ_MISC0_GDDR5_SHIFT;
174 running = RREG32(MC_SEQ_SUP_CNTL) & RUN_MASK;
175
176 if ((mem_type == MC_SEQ_MISC0_GDDR5_VALUE) && (running == 0)) {
177 if (running) {
178 blackout = RREG32(MC_SHARED_BLACKOUT_CNTL);
179 WREG32(MC_SHARED_BLACKOUT_CNTL, 1);
180 }
181
182 /* reset the engine and set to writable */
183 WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
184 WREG32(MC_SEQ_SUP_CNTL, 0x00000010);
185
186 /* load mc io regs */
187 for (i = 0; i < BTC_IO_MC_REGS_SIZE; i++) {
188 WREG32(MC_SEQ_IO_DEBUG_INDEX, io_mc_regs[(i << 1)]);
189 WREG32(MC_SEQ_IO_DEBUG_DATA, io_mc_regs[(i << 1) + 1]);
190 }
191 /* load the MC ucode */
192 fw_data = (const __be32 *)rdev->mc_fw->data;
193 for (i = 0; i < BTC_MC_UCODE_SIZE; i++)
194 WREG32(MC_SEQ_SUP_PGM, be32_to_cpup(fw_data++));
195
196 /* put the engine back into the active state */
197 WREG32(MC_SEQ_SUP_CNTL, 0x00000008);
198 WREG32(MC_SEQ_SUP_CNTL, 0x00000004);
199 WREG32(MC_SEQ_SUP_CNTL, 0x00000001);
200
201 /* wait for training to complete */
202 while (!(RREG32(MC_IO_PAD_CNTL_D0) & MEM_FALL_OUT_CMD))
203 udelay(10);
204
205 if (running)
206 WREG32(MC_SHARED_BLACKOUT_CNTL, blackout);
207 }
208
209 return 0;
210}
211
212int ni_init_microcode(struct radeon_device *rdev)
213{
214 struct platform_device *pdev;
215 const char *chip_name;
216 const char *rlc_chip_name;
217 size_t pfp_req_size, me_req_size, rlc_req_size, mc_req_size;
218 char fw_name[30];
219 int err;
220
221 DRM_DEBUG("\n");
222
223 pdev = platform_device_register_simple("radeon_cp", 0, NULL, 0);
224 err = IS_ERR(pdev);
225 if (err) {
226 printk(KERN_ERR "radeon_cp: Failed to register firmware\n");
227 return -EINVAL;
228 }
229
230 switch (rdev->family) {
231 case CHIP_BARTS:
232 chip_name = "BARTS";
233 rlc_chip_name = "BTC";
234 break;
235 case CHIP_TURKS:
236 chip_name = "TURKS";
237 rlc_chip_name = "BTC";
238 break;
239 case CHIP_CAICOS:
240 chip_name = "CAICOS";
241 rlc_chip_name = "BTC";
242 break;
243 default: BUG();
244 }
245
246 pfp_req_size = EVERGREEN_PFP_UCODE_SIZE * 4;
247 me_req_size = EVERGREEN_PM4_UCODE_SIZE * 4;
248 rlc_req_size = EVERGREEN_RLC_UCODE_SIZE * 4;
249 mc_req_size = BTC_MC_UCODE_SIZE * 4;
250
251 DRM_INFO("Loading %s Microcode\n", chip_name);
252
253 snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
254 err = request_firmware(&rdev->pfp_fw, fw_name, &pdev->dev);
255 if (err)
256 goto out;
257 if (rdev->pfp_fw->size != pfp_req_size) {
258 printk(KERN_ERR
259 "ni_cp: Bogus length %zu in firmware \"%s\"\n",
260 rdev->pfp_fw->size, fw_name);
261 err = -EINVAL;
262 goto out;
263 }
264
265 snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
266 err = request_firmware(&rdev->me_fw, fw_name, &pdev->dev);
267 if (err)
268 goto out;
269 if (rdev->me_fw->size != me_req_size) {
270 printk(KERN_ERR
271 "ni_cp: Bogus length %zu in firmware \"%s\"\n",
272 rdev->me_fw->size, fw_name);
273 err = -EINVAL;
274 }
275
276 snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", rlc_chip_name);
277 err = request_firmware(&rdev->rlc_fw, fw_name, &pdev->dev);
278 if (err)
279 goto out;
280 if (rdev->rlc_fw->size != rlc_req_size) {
281 printk(KERN_ERR
282 "ni_rlc: Bogus length %zu in firmware \"%s\"\n",
283 rdev->rlc_fw->size, fw_name);
284 err = -EINVAL;
285 }
286
287 snprintf(fw_name, sizeof(fw_name), "radeon/%s_mc.bin", chip_name);
288 err = request_firmware(&rdev->mc_fw, fw_name, &pdev->dev);
289 if (err)
290 goto out;
291 if (rdev->mc_fw->size != mc_req_size) {
292 printk(KERN_ERR
293 "ni_mc: Bogus length %zu in firmware \"%s\"\n",
294 rdev->mc_fw->size, fw_name);
295 err = -EINVAL;
296 }
297out:
298 platform_device_unregister(pdev);
299
300 if (err) {
301 if (err != -EINVAL)
302 printk(KERN_ERR
303 "ni_cp: Failed to load firmware \"%s\"\n",
304 fw_name);
305 release_firmware(rdev->pfp_fw);
306 rdev->pfp_fw = NULL;
307 release_firmware(rdev->me_fw);
308 rdev->me_fw = NULL;
309 release_firmware(rdev->rlc_fw);
310 rdev->rlc_fw = NULL;
311 release_firmware(rdev->mc_fw);
312 rdev->mc_fw = NULL;
313 }
314 return err;
315}
316
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
new file mode 100644
index 000000000000..f7b445390e02
--- /dev/null
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -0,0 +1,41 @@
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 NI_H
25#define NI_H
26
27#define MC_SHARED_BLACKOUT_CNTL 0x20ac
28#define MC_SEQ_SUP_CNTL 0x28c8
29#define RUN_MASK (1 << 0)
30#define MC_SEQ_SUP_PGM 0x28cc
31#define MC_IO_PAD_CNTL_D0 0x29d0
32#define MEM_FALL_OUT_CMD (1 << 8)
33#define MC_SEQ_MISC0 0x2a00
34#define MC_SEQ_MISC0_GDDR5_SHIFT 28
35#define MC_SEQ_MISC0_GDDR5_MASK 0xf0000000
36#define MC_SEQ_MISC0_GDDR5_VALUE 5
37#define MC_SEQ_IO_DEBUG_INDEX 0x2a44
38#define MC_SEQ_IO_DEBUG_DATA 0x2a48
39
40#endif
41
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 8c62b2f58923..da21105488da 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1152,6 +1152,7 @@ struct radeon_device {
1152 const struct firmware *me_fw; /* all family ME firmware */ 1152 const struct firmware *me_fw; /* all family ME firmware */
1153 const struct firmware *pfp_fw; /* r6/700 PFP firmware */ 1153 const struct firmware *pfp_fw; /* r6/700 PFP firmware */
1154 const struct firmware *rlc_fw; /* r6/700 RLC firmware */ 1154 const struct firmware *rlc_fw; /* r6/700 RLC firmware */
1155 const struct firmware *mc_fw; /* NI MC firmware */
1155 struct r600_blit r600_blit; 1156 struct r600_blit r600_blit;
1156 struct r700_vram_scratch vram_scratch; 1157 struct r700_vram_scratch vram_scratch;
1157 int msi_enabled; /* msi enabled */ 1158 int msi_enabled; /* msi enabled */
@@ -1561,6 +1562,9 @@ extern int evergreen_irq_set(struct radeon_device *rdev);
1561extern int evergreen_blit_init(struct radeon_device *rdev); 1562extern int evergreen_blit_init(struct radeon_device *rdev);
1562extern void evergreen_blit_fini(struct radeon_device *rdev); 1563extern void evergreen_blit_fini(struct radeon_device *rdev);
1563 1564
1565extern int ni_init_microcode(struct radeon_device *rdev);
1566extern int btc_mc_load_microcode(struct radeon_device *rdev);
1567
1564/* radeon_acpi.c */ 1568/* radeon_acpi.c */
1565#if defined(CONFIG_ACPI) 1569#if defined(CONFIG_ACPI)
1566extern int radeon_acpi_init(struct radeon_device *rdev); 1570extern int radeon_acpi_init(struct radeon_device *rdev);