2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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.
24 * Authors: Dave Airlie
29 #include "radeon_reg.h"
33 #include <linux/vga_switcheroo.h>
34 #include <linux/slab.h>
35 #include <linux/acpi.h>
40 /* If you boot an IGP board with a discrete card as the primary,
41 * the IGP rom is not accessible via the rom bar as the IGP rom is
42 * part of the system bios. On boot, the system bios puts a
43 * copy of the igp rom at the start of vram if a discrete card is
46 static bool igp_read_bios_from_vram(struct radeon_device
*rdev
)
48 uint8_t __iomem
*bios
;
49 resource_size_t vram_base
;
50 resource_size_t size
= 256 * 1024; /* ??? */
52 if (!(rdev
->flags
& RADEON_IS_IGP
))
53 if (!radeon_card_posted(rdev
))
57 vram_base
= pci_resource_start(rdev
->pdev
, 0);
58 bios
= ioremap(vram_base
, size
);
63 if (size
== 0 || bios
[0] != 0x55 || bios
[1] != 0xaa) {
67 rdev
->bios
= kmalloc(size
, GFP_KERNEL
);
68 if (rdev
->bios
== NULL
) {
72 memcpy_fromio(rdev
->bios
, bios
, size
);
77 static bool radeon_read_bios(struct radeon_device
*rdev
)
79 uint8_t __iomem
*bios
;
83 /* XXX: some cards may return 0 for rom size? ddx has a workaround */
84 bios
= pci_map_rom(rdev
->pdev
, &size
);
89 if (size
== 0 || bios
[0] != 0x55 || bios
[1] != 0xaa) {
90 pci_unmap_rom(rdev
->pdev
, bios
);
93 rdev
->bios
= kmemdup(bios
, size
, GFP_KERNEL
);
94 if (rdev
->bios
== NULL
) {
95 pci_unmap_rom(rdev
->pdev
, bios
);
98 pci_unmap_rom(rdev
->pdev
, bios
);
102 static bool radeon_read_platform_bios(struct radeon_device
*rdev
)
104 uint8_t __iomem
*bios
;
109 bios
= pci_platform_rom(rdev
->pdev
, &size
);
114 if (size
== 0 || bios
[0] != 0x55 || bios
[1] != 0xaa) {
117 rdev
->bios
= kmemdup(bios
, size
, GFP_KERNEL
);
118 if (rdev
->bios
== NULL
) {
126 /* ATRM is used to get the BIOS on the discrete cards in
129 /* retrieve the ROM in 4k blocks */
130 #define ATRM_BIOS_PAGE 4096
132 * radeon_atrm_call - fetch a chunk of the vbios
134 * @atrm_handle: acpi ATRM handle
135 * @bios: vbios image pointer
136 * @offset: offset of vbios image data to fetch
137 * @len: length of vbios image data to fetch
139 * Executes ATRM to fetch a chunk of the discrete
140 * vbios image on PX systems (all asics).
141 * Returns the length of the buffer fetched.
143 static int radeon_atrm_call(acpi_handle atrm_handle
, uint8_t *bios
,
147 union acpi_object atrm_arg_elements
[2], *obj
;
148 struct acpi_object_list atrm_arg
;
149 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
152 atrm_arg
.pointer
= &atrm_arg_elements
[0];
154 atrm_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
155 atrm_arg_elements
[0].integer
.value
= offset
;
157 atrm_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
158 atrm_arg_elements
[1].integer
.value
= len
;
160 status
= acpi_evaluate_object(atrm_handle
, NULL
, &atrm_arg
, &buffer
);
161 if (ACPI_FAILURE(status
)) {
162 printk("failed to evaluate ATRM got %s\n", acpi_format_exception(status
));
166 obj
= (union acpi_object
*)buffer
.pointer
;
167 memcpy(bios
+offset
, obj
->buffer
.pointer
, obj
->buffer
.length
);
168 len
= obj
->buffer
.length
;
169 kfree(buffer
.pointer
);
173 static bool radeon_atrm_get_bios(struct radeon_device
*rdev
)
176 int size
= 256 * 1024;
178 struct pci_dev
*pdev
= NULL
;
179 acpi_handle dhandle
, atrm_handle
;
183 /* ATRM is for the discrete card only */
184 if (rdev
->flags
& RADEON_IS_IGP
)
187 while ((pdev
= pci_get_class(PCI_CLASS_DISPLAY_VGA
<< 8, pdev
)) != NULL
) {
188 dhandle
= DEVICE_ACPI_HANDLE(&pdev
->dev
);
192 status
= acpi_get_handle(dhandle
, "ATRM", &atrm_handle
);
193 if (!ACPI_FAILURE(status
)) {
200 while ((pdev
= pci_get_class(PCI_CLASS_DISPLAY_OTHER
<< 8, pdev
)) != NULL
) {
201 dhandle
= ACPI_HANDLE(&pdev
->dev
);
205 status
= acpi_get_handle(dhandle
, "ATRM", &atrm_handle
);
206 if (!ACPI_FAILURE(status
)) {
216 rdev
->bios
= kmalloc(size
, GFP_KERNEL
);
218 DRM_ERROR("Unable to allocate bios\n");
222 for (i
= 0; i
< size
/ ATRM_BIOS_PAGE
; i
++) {
223 ret
= radeon_atrm_call(atrm_handle
,
225 (i
* ATRM_BIOS_PAGE
),
227 if (ret
< ATRM_BIOS_PAGE
)
231 if (i
== 0 || rdev
->bios
[0] != 0x55 || rdev
->bios
[1] != 0xaa) {
238 static inline bool radeon_atrm_get_bios(struct radeon_device
*rdev
)
244 static bool ni_read_disabled_bios(struct radeon_device
*rdev
)
249 u32 vga_render_control
;
253 bus_cntl
= RREG32(R600_BUS_CNTL
);
254 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
255 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
256 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
257 rom_cntl
= RREG32(R600_ROM_CNTL
);
260 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
261 if (!ASIC_IS_NODCE(rdev
)) {
262 /* Disable VGA mode */
263 WREG32(AVIVO_D1VGA_CONTROL
,
264 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
265 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
266 WREG32(AVIVO_D2VGA_CONTROL
,
267 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
268 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
269 WREG32(AVIVO_VGA_RENDER_CONTROL
,
270 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
272 WREG32(R600_ROM_CNTL
, rom_cntl
| R600_SCK_OVERWRITE
);
274 r
= radeon_read_bios(rdev
);
277 WREG32(R600_BUS_CNTL
, bus_cntl
);
278 if (!ASIC_IS_NODCE(rdev
)) {
279 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
280 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
281 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
283 WREG32(R600_ROM_CNTL
, rom_cntl
);
287 static bool r700_read_disabled_bios(struct radeon_device
*rdev
)
289 uint32_t viph_control
;
291 uint32_t d1vga_control
;
292 uint32_t d2vga_control
;
293 uint32_t vga_render_control
;
295 uint32_t cg_spll_func_cntl
= 0;
296 uint32_t cg_spll_status
;
299 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
300 bus_cntl
= RREG32(R600_BUS_CNTL
);
301 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
302 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
303 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
304 rom_cntl
= RREG32(R600_ROM_CNTL
);
307 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
309 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
310 /* Disable VGA mode */
311 WREG32(AVIVO_D1VGA_CONTROL
,
312 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
313 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
314 WREG32(AVIVO_D2VGA_CONTROL
,
315 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
316 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
317 WREG32(AVIVO_VGA_RENDER_CONTROL
,
318 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
320 if (rdev
->family
== CHIP_RV730
) {
321 cg_spll_func_cntl
= RREG32(R600_CG_SPLL_FUNC_CNTL
);
323 /* enable bypass mode */
324 WREG32(R600_CG_SPLL_FUNC_CNTL
, (cg_spll_func_cntl
|
325 R600_SPLL_BYPASS_EN
));
327 /* wait for SPLL_CHG_STATUS to change to 1 */
329 while (!(cg_spll_status
& R600_SPLL_CHG_STATUS
))
330 cg_spll_status
= RREG32(R600_CG_SPLL_STATUS
);
332 WREG32(R600_ROM_CNTL
, (rom_cntl
& ~R600_SCK_OVERWRITE
));
334 WREG32(R600_ROM_CNTL
, (rom_cntl
| R600_SCK_OVERWRITE
));
336 r
= radeon_read_bios(rdev
);
339 if (rdev
->family
== CHIP_RV730
) {
340 WREG32(R600_CG_SPLL_FUNC_CNTL
, cg_spll_func_cntl
);
342 /* wait for SPLL_CHG_STATUS to change to 1 */
344 while (!(cg_spll_status
& R600_SPLL_CHG_STATUS
))
345 cg_spll_status
= RREG32(R600_CG_SPLL_STATUS
);
347 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
348 WREG32(R600_BUS_CNTL
, bus_cntl
);
349 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
350 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
351 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
352 WREG32(R600_ROM_CNTL
, rom_cntl
);
356 static bool r600_read_disabled_bios(struct radeon_device
*rdev
)
358 uint32_t viph_control
;
360 uint32_t d1vga_control
;
361 uint32_t d2vga_control
;
362 uint32_t vga_render_control
;
364 uint32_t general_pwrmgt
;
365 uint32_t low_vid_lower_gpio_cntl
;
366 uint32_t medium_vid_lower_gpio_cntl
;
367 uint32_t high_vid_lower_gpio_cntl
;
368 uint32_t ctxsw_vid_lower_gpio_cntl
;
369 uint32_t lower_gpio_enable
;
372 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
373 bus_cntl
= RREG32(R600_BUS_CNTL
);
374 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
375 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
376 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
377 rom_cntl
= RREG32(R600_ROM_CNTL
);
378 general_pwrmgt
= RREG32(R600_GENERAL_PWRMGT
);
379 low_vid_lower_gpio_cntl
= RREG32(R600_LOW_VID_LOWER_GPIO_CNTL
);
380 medium_vid_lower_gpio_cntl
= RREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
);
381 high_vid_lower_gpio_cntl
= RREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
);
382 ctxsw_vid_lower_gpio_cntl
= RREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
);
383 lower_gpio_enable
= RREG32(R600_LOWER_GPIO_ENABLE
);
386 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
388 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
389 /* Disable VGA mode */
390 WREG32(AVIVO_D1VGA_CONTROL
,
391 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
392 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
393 WREG32(AVIVO_D2VGA_CONTROL
,
394 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
395 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
396 WREG32(AVIVO_VGA_RENDER_CONTROL
,
397 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
399 WREG32(R600_ROM_CNTL
,
400 ((rom_cntl
& ~R600_SCK_PRESCALE_CRYSTAL_CLK_MASK
) |
401 (1 << R600_SCK_PRESCALE_CRYSTAL_CLK_SHIFT
) |
402 R600_SCK_OVERWRITE
));
404 WREG32(R600_GENERAL_PWRMGT
, (general_pwrmgt
& ~R600_OPEN_DRAIN_PADS
));
405 WREG32(R600_LOW_VID_LOWER_GPIO_CNTL
,
406 (low_vid_lower_gpio_cntl
& ~0x400));
407 WREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
,
408 (medium_vid_lower_gpio_cntl
& ~0x400));
409 WREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
,
410 (high_vid_lower_gpio_cntl
& ~0x400));
411 WREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
,
412 (ctxsw_vid_lower_gpio_cntl
& ~0x400));
413 WREG32(R600_LOWER_GPIO_ENABLE
, (lower_gpio_enable
| 0x400));
415 r
= radeon_read_bios(rdev
);
418 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
419 WREG32(R600_BUS_CNTL
, bus_cntl
);
420 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
421 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
422 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
423 WREG32(R600_ROM_CNTL
, rom_cntl
);
424 WREG32(R600_GENERAL_PWRMGT
, general_pwrmgt
);
425 WREG32(R600_LOW_VID_LOWER_GPIO_CNTL
, low_vid_lower_gpio_cntl
);
426 WREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
, medium_vid_lower_gpio_cntl
);
427 WREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
, high_vid_lower_gpio_cntl
);
428 WREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
, ctxsw_vid_lower_gpio_cntl
);
429 WREG32(R600_LOWER_GPIO_ENABLE
, lower_gpio_enable
);
433 static bool avivo_read_disabled_bios(struct radeon_device
*rdev
)
435 uint32_t seprom_cntl1
;
436 uint32_t viph_control
;
438 uint32_t d1vga_control
;
439 uint32_t d2vga_control
;
440 uint32_t vga_render_control
;
443 uint32_t gpiopad_mask
;
446 seprom_cntl1
= RREG32(RADEON_SEPROM_CNTL1
);
447 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
448 bus_cntl
= RREG32(RV370_BUS_CNTL
);
449 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
450 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
451 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
452 gpiopad_a
= RREG32(RADEON_GPIOPAD_A
);
453 gpiopad_en
= RREG32(RADEON_GPIOPAD_EN
);
454 gpiopad_mask
= RREG32(RADEON_GPIOPAD_MASK
);
456 WREG32(RADEON_SEPROM_CNTL1
,
457 ((seprom_cntl1
& ~RADEON_SCK_PRESCALE_MASK
) |
458 (0xc << RADEON_SCK_PRESCALE_SHIFT
)));
459 WREG32(RADEON_GPIOPAD_A
, 0);
460 WREG32(RADEON_GPIOPAD_EN
, 0);
461 WREG32(RADEON_GPIOPAD_MASK
, 0);
464 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
467 WREG32(RV370_BUS_CNTL
, (bus_cntl
& ~RV370_BUS_BIOS_DIS_ROM
));
469 /* Disable VGA mode */
470 WREG32(AVIVO_D1VGA_CONTROL
,
471 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
472 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
473 WREG32(AVIVO_D2VGA_CONTROL
,
474 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
475 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
476 WREG32(AVIVO_VGA_RENDER_CONTROL
,
477 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
479 r
= radeon_read_bios(rdev
);
482 WREG32(RADEON_SEPROM_CNTL1
, seprom_cntl1
);
483 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
484 WREG32(RV370_BUS_CNTL
, bus_cntl
);
485 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
486 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
487 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
488 WREG32(RADEON_GPIOPAD_A
, gpiopad_a
);
489 WREG32(RADEON_GPIOPAD_EN
, gpiopad_en
);
490 WREG32(RADEON_GPIOPAD_MASK
, gpiopad_mask
);
494 static bool legacy_read_disabled_bios(struct radeon_device
*rdev
)
496 uint32_t seprom_cntl1
;
497 uint32_t viph_control
;
499 uint32_t crtc_gen_cntl
;
500 uint32_t crtc2_gen_cntl
;
501 uint32_t crtc_ext_cntl
;
502 uint32_t fp2_gen_cntl
;
505 seprom_cntl1
= RREG32(RADEON_SEPROM_CNTL1
);
506 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
507 if (rdev
->flags
& RADEON_IS_PCIE
)
508 bus_cntl
= RREG32(RV370_BUS_CNTL
);
510 bus_cntl
= RREG32(RADEON_BUS_CNTL
);
511 crtc_gen_cntl
= RREG32(RADEON_CRTC_GEN_CNTL
);
513 crtc_ext_cntl
= RREG32(RADEON_CRTC_EXT_CNTL
);
516 if (rdev
->ddev
->pci_device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
517 fp2_gen_cntl
= RREG32(RADEON_FP2_GEN_CNTL
);
520 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
521 crtc2_gen_cntl
= RREG32(RADEON_CRTC2_GEN_CNTL
);
524 WREG32(RADEON_SEPROM_CNTL1
,
525 ((seprom_cntl1
& ~RADEON_SCK_PRESCALE_MASK
) |
526 (0xc << RADEON_SCK_PRESCALE_SHIFT
)));
529 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
532 if (rdev
->flags
& RADEON_IS_PCIE
)
533 WREG32(RV370_BUS_CNTL
, (bus_cntl
& ~RV370_BUS_BIOS_DIS_ROM
));
535 WREG32(RADEON_BUS_CNTL
, (bus_cntl
& ~RADEON_BUS_BIOS_DIS_ROM
));
537 /* Turn off mem requests and CRTC for both controllers */
538 WREG32(RADEON_CRTC_GEN_CNTL
,
539 ((crtc_gen_cntl
& ~RADEON_CRTC_EN
) |
540 (RADEON_CRTC_DISP_REQ_EN_B
|
541 RADEON_CRTC_EXT_DISP_EN
)));
542 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
543 WREG32(RADEON_CRTC2_GEN_CNTL
,
544 ((crtc2_gen_cntl
& ~RADEON_CRTC2_EN
) |
545 RADEON_CRTC2_DISP_REQ_EN_B
));
548 WREG32(RADEON_CRTC_EXT_CNTL
,
549 ((crtc_ext_cntl
& ~RADEON_CRTC_CRT_ON
) |
550 (RADEON_CRTC_SYNC_TRISTAT
|
551 RADEON_CRTC_DISPLAY_DIS
)));
553 if (rdev
->ddev
->pci_device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
554 WREG32(RADEON_FP2_GEN_CNTL
, (fp2_gen_cntl
& ~RADEON_FP2_ON
));
557 r
= radeon_read_bios(rdev
);
560 WREG32(RADEON_SEPROM_CNTL1
, seprom_cntl1
);
561 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
562 if (rdev
->flags
& RADEON_IS_PCIE
)
563 WREG32(RV370_BUS_CNTL
, bus_cntl
);
565 WREG32(RADEON_BUS_CNTL
, bus_cntl
);
566 WREG32(RADEON_CRTC_GEN_CNTL
, crtc_gen_cntl
);
567 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
568 WREG32(RADEON_CRTC2_GEN_CNTL
, crtc2_gen_cntl
);
570 WREG32(RADEON_CRTC_EXT_CNTL
, crtc_ext_cntl
);
571 if (rdev
->ddev
->pci_device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
572 WREG32(RADEON_FP2_GEN_CNTL
, fp2_gen_cntl
);
577 static bool radeon_read_disabled_bios(struct radeon_device
*rdev
)
579 if (rdev
->flags
& RADEON_IS_IGP
)
580 return igp_read_bios_from_vram(rdev
);
581 else if (rdev
->family
>= CHIP_BARTS
)
582 return ni_read_disabled_bios(rdev
);
583 else if (rdev
->family
>= CHIP_RV770
)
584 return r700_read_disabled_bios(rdev
);
585 else if (rdev
->family
>= CHIP_R600
)
586 return r600_read_disabled_bios(rdev
);
587 else if (rdev
->family
>= CHIP_RS600
)
588 return avivo_read_disabled_bios(rdev
);
590 return legacy_read_disabled_bios(rdev
);
594 static bool radeon_acpi_vfct_bios(struct radeon_device
*rdev
)
597 struct acpi_table_header
*hdr
;
599 UEFI_ACPI_VFCT
*vfct
;
600 GOP_VBIOS_CONTENT
*vbios
;
601 VFCT_IMAGE_HEADER
*vhdr
;
603 if (!ACPI_SUCCESS(acpi_get_table_with_size("VFCT", 1, &hdr
, &tbl_size
)))
605 if (tbl_size
< sizeof(UEFI_ACPI_VFCT
)) {
606 DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n");
610 vfct
= (UEFI_ACPI_VFCT
*)hdr
;
611 if (vfct
->VBIOSImageOffset
+ sizeof(VFCT_IMAGE_HEADER
) > tbl_size
) {
612 DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n");
616 vbios
= (GOP_VBIOS_CONTENT
*)((char *)hdr
+ vfct
->VBIOSImageOffset
);
617 vhdr
= &vbios
->VbiosHeader
;
618 DRM_INFO("ACPI VFCT contains a BIOS for %02x:%02x.%d %04x:%04x, size %d\n",
619 vhdr
->PCIBus
, vhdr
->PCIDevice
, vhdr
->PCIFunction
,
620 vhdr
->VendorID
, vhdr
->DeviceID
, vhdr
->ImageLength
);
622 if (vhdr
->PCIBus
!= rdev
->pdev
->bus
->number
||
623 vhdr
->PCIDevice
!= PCI_SLOT(rdev
->pdev
->devfn
) ||
624 vhdr
->PCIFunction
!= PCI_FUNC(rdev
->pdev
->devfn
) ||
625 vhdr
->VendorID
!= rdev
->pdev
->vendor
||
626 vhdr
->DeviceID
!= rdev
->pdev
->device
) {
627 DRM_INFO("ACPI VFCT table is not for this card\n");
631 if (vfct
->VBIOSImageOffset
+ sizeof(VFCT_IMAGE_HEADER
) + vhdr
->ImageLength
> tbl_size
) {
632 DRM_ERROR("ACPI VFCT image truncated\n");
636 rdev
->bios
= kmemdup(&vbios
->VbiosContent
, vhdr
->ImageLength
, GFP_KERNEL
);
643 static inline bool radeon_acpi_vfct_bios(struct radeon_device
*rdev
)
649 bool radeon_get_bios(struct radeon_device
*rdev
)
654 r
= radeon_atrm_get_bios(rdev
);
656 r
= radeon_acpi_vfct_bios(rdev
);
658 r
= igp_read_bios_from_vram(rdev
);
660 r
= radeon_read_bios(rdev
);
662 r
= radeon_read_disabled_bios(rdev
);
665 r
= radeon_read_platform_bios(rdev
);
667 if (r
== false || rdev
->bios
== NULL
) {
668 DRM_ERROR("Unable to locate a BIOS ROM\n");
672 if (rdev
->bios
[0] != 0x55 || rdev
->bios
[1] != 0xaa) {
673 printk("BIOS signature incorrect %x %x\n", rdev
->bios
[0], rdev
->bios
[1]);
678 if (RBIOS8(tmp
+ 0x14) != 0x0) {
679 DRM_INFO("Not an x86 BIOS ROM, not using.\n");
683 rdev
->bios_header_start
= RBIOS16(0x48);
684 if (!rdev
->bios_header_start
) {
687 tmp
= rdev
->bios_header_start
+ 4;
688 if (!memcmp(rdev
->bios
+ tmp
, "ATOM", 4) ||
689 !memcmp(rdev
->bios
+ tmp
, "MOTA", 4)) {
690 rdev
->is_atom_bios
= true;
692 rdev
->is_atom_bios
= false;
695 DRM_DEBUG("%sBIOS detected\n", rdev
->is_atom_bios
? "ATOM" : "COM");