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 <linux/acpi.h>
30 #include <linux/pci.h>
31 #include <linux/slab.h>
33 #include <drm/drm_device.h>
37 #include "radeon_reg.h"
43 /* If you boot an IGP board with a discrete card as the primary,
44 * the IGP rom is not accessible via the rom bar as the IGP rom is
45 * part of the system bios. On boot, the system bios puts a
46 * copy of the igp rom at the start of vram if a discrete card is
49 static bool igp_read_bios_from_vram(struct radeon_device
*rdev
)
51 uint8_t __iomem
*bios
;
52 resource_size_t vram_base
;
53 resource_size_t size
= 256 * 1024; /* ??? */
55 if (!(rdev
->flags
& RADEON_IS_IGP
))
56 if (!radeon_card_posted(rdev
))
60 vram_base
= pci_resource_start(rdev
->pdev
, 0);
61 bios
= ioremap(vram_base
, size
);
66 if (size
== 0 || bios
[0] != 0x55 || bios
[1] != 0xaa) {
70 rdev
->bios
= kmalloc(size
, GFP_KERNEL
);
71 if (rdev
->bios
== NULL
) {
75 memcpy_fromio(rdev
->bios
, bios
, size
);
80 static bool radeon_read_bios(struct radeon_device
*rdev
)
82 uint8_t __iomem
*bios
, val1
, val2
;
86 /* XXX: some cards may return 0 for rom size? ddx has a workaround */
87 bios
= pci_map_rom(rdev
->pdev
, &size
);
92 val1
= readb(&bios
[0]);
93 val2
= readb(&bios
[1]);
95 if (size
== 0 || val1
!= 0x55 || val2
!= 0xaa) {
96 pci_unmap_rom(rdev
->pdev
, bios
);
99 rdev
->bios
= kzalloc(size
, GFP_KERNEL
);
100 if (rdev
->bios
== NULL
) {
101 pci_unmap_rom(rdev
->pdev
, bios
);
104 memcpy_fromio(rdev
->bios
, bios
, size
);
105 pci_unmap_rom(rdev
->pdev
, bios
);
109 static bool radeon_read_platform_bios(struct radeon_device
*rdev
)
111 uint8_t __iomem
*bios
;
116 bios
= pci_platform_rom(rdev
->pdev
, &size
);
121 if (size
== 0 || bios
[0] != 0x55 || bios
[1] != 0xaa) {
124 rdev
->bios
= kmemdup(bios
, size
, GFP_KERNEL
);
125 if (rdev
->bios
== NULL
) {
133 /* ATRM is used to get the BIOS on the discrete cards in
136 /* retrieve the ROM in 4k blocks */
137 #define ATRM_BIOS_PAGE 4096
139 * radeon_atrm_call - fetch a chunk of the vbios
141 * @atrm_handle: acpi ATRM handle
142 * @bios: vbios image pointer
143 * @offset: offset of vbios image data to fetch
144 * @len: length of vbios image data to fetch
146 * Executes ATRM to fetch a chunk of the discrete
147 * vbios image on PX systems (all asics).
148 * Returns the length of the buffer fetched.
150 static int radeon_atrm_call(acpi_handle atrm_handle
, uint8_t *bios
,
154 union acpi_object atrm_arg_elements
[2], *obj
;
155 struct acpi_object_list atrm_arg
;
156 struct acpi_buffer buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
159 atrm_arg
.pointer
= &atrm_arg_elements
[0];
161 atrm_arg_elements
[0].type
= ACPI_TYPE_INTEGER
;
162 atrm_arg_elements
[0].integer
.value
= offset
;
164 atrm_arg_elements
[1].type
= ACPI_TYPE_INTEGER
;
165 atrm_arg_elements
[1].integer
.value
= len
;
167 status
= acpi_evaluate_object(atrm_handle
, NULL
, &atrm_arg
, &buffer
);
168 if (ACPI_FAILURE(status
)) {
169 printk("failed to evaluate ATRM got %s\n", acpi_format_exception(status
));
173 obj
= (union acpi_object
*)buffer
.pointer
;
174 memcpy(bios
+offset
, obj
->buffer
.pointer
, obj
->buffer
.length
);
175 len
= obj
->buffer
.length
;
176 kfree(buffer
.pointer
);
180 static bool radeon_atrm_get_bios(struct radeon_device
*rdev
)
183 int size
= 256 * 1024;
185 struct pci_dev
*pdev
= NULL
;
186 acpi_handle dhandle
, atrm_handle
;
190 /* ATRM is for the discrete card only */
191 if (rdev
->flags
& RADEON_IS_IGP
)
194 while ((pdev
= pci_get_class(PCI_CLASS_DISPLAY_VGA
<< 8, pdev
)) != NULL
) {
195 dhandle
= ACPI_HANDLE(&pdev
->dev
);
199 status
= acpi_get_handle(dhandle
, "ATRM", &atrm_handle
);
200 if (!ACPI_FAILURE(status
)) {
207 while ((pdev
= pci_get_class(PCI_CLASS_DISPLAY_OTHER
<< 8, pdev
)) != NULL
) {
208 dhandle
= ACPI_HANDLE(&pdev
->dev
);
212 status
= acpi_get_handle(dhandle
, "ATRM", &atrm_handle
);
213 if (!ACPI_FAILURE(status
)) {
223 rdev
->bios
= kmalloc(size
, GFP_KERNEL
);
225 DRM_ERROR("Unable to allocate bios\n");
229 for (i
= 0; i
< size
/ ATRM_BIOS_PAGE
; i
++) {
230 ret
= radeon_atrm_call(atrm_handle
,
232 (i
* ATRM_BIOS_PAGE
),
234 if (ret
< ATRM_BIOS_PAGE
)
238 if (i
== 0 || rdev
->bios
[0] != 0x55 || rdev
->bios
[1] != 0xaa) {
245 static inline bool radeon_atrm_get_bios(struct radeon_device
*rdev
)
251 static bool ni_read_disabled_bios(struct radeon_device
*rdev
)
256 u32 vga_render_control
;
260 bus_cntl
= RREG32(R600_BUS_CNTL
);
261 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
262 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
263 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
264 rom_cntl
= RREG32(R600_ROM_CNTL
);
267 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
268 if (!ASIC_IS_NODCE(rdev
)) {
269 /* Disable VGA mode */
270 WREG32(AVIVO_D1VGA_CONTROL
,
271 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
272 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
273 WREG32(AVIVO_D2VGA_CONTROL
,
274 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
275 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
276 WREG32(AVIVO_VGA_RENDER_CONTROL
,
277 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
279 WREG32(R600_ROM_CNTL
, rom_cntl
| R600_SCK_OVERWRITE
);
281 r
= radeon_read_bios(rdev
);
284 WREG32(R600_BUS_CNTL
, bus_cntl
);
285 if (!ASIC_IS_NODCE(rdev
)) {
286 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
287 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
288 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
290 WREG32(R600_ROM_CNTL
, rom_cntl
);
294 static bool r700_read_disabled_bios(struct radeon_device
*rdev
)
296 uint32_t viph_control
;
298 uint32_t d1vga_control
;
299 uint32_t d2vga_control
;
300 uint32_t vga_render_control
;
302 uint32_t cg_spll_func_cntl
= 0;
303 uint32_t cg_spll_status
;
306 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
307 bus_cntl
= RREG32(R600_BUS_CNTL
);
308 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
309 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
310 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
311 rom_cntl
= RREG32(R600_ROM_CNTL
);
314 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
316 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
317 /* Disable VGA mode */
318 WREG32(AVIVO_D1VGA_CONTROL
,
319 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
320 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
321 WREG32(AVIVO_D2VGA_CONTROL
,
322 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
323 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
324 WREG32(AVIVO_VGA_RENDER_CONTROL
,
325 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
327 if (rdev
->family
== CHIP_RV730
) {
328 cg_spll_func_cntl
= RREG32(R600_CG_SPLL_FUNC_CNTL
);
330 /* enable bypass mode */
331 WREG32(R600_CG_SPLL_FUNC_CNTL
, (cg_spll_func_cntl
|
332 R600_SPLL_BYPASS_EN
));
334 /* wait for SPLL_CHG_STATUS to change to 1 */
336 while (!(cg_spll_status
& R600_SPLL_CHG_STATUS
))
337 cg_spll_status
= RREG32(R600_CG_SPLL_STATUS
);
339 WREG32(R600_ROM_CNTL
, (rom_cntl
& ~R600_SCK_OVERWRITE
));
341 WREG32(R600_ROM_CNTL
, (rom_cntl
| R600_SCK_OVERWRITE
));
343 r
= radeon_read_bios(rdev
);
346 if (rdev
->family
== CHIP_RV730
) {
347 WREG32(R600_CG_SPLL_FUNC_CNTL
, cg_spll_func_cntl
);
349 /* wait for SPLL_CHG_STATUS to change to 1 */
351 while (!(cg_spll_status
& R600_SPLL_CHG_STATUS
))
352 cg_spll_status
= RREG32(R600_CG_SPLL_STATUS
);
354 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
355 WREG32(R600_BUS_CNTL
, bus_cntl
);
356 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
357 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
358 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
359 WREG32(R600_ROM_CNTL
, rom_cntl
);
363 static bool r600_read_disabled_bios(struct radeon_device
*rdev
)
365 uint32_t viph_control
;
367 uint32_t d1vga_control
;
368 uint32_t d2vga_control
;
369 uint32_t vga_render_control
;
371 uint32_t general_pwrmgt
;
372 uint32_t low_vid_lower_gpio_cntl
;
373 uint32_t medium_vid_lower_gpio_cntl
;
374 uint32_t high_vid_lower_gpio_cntl
;
375 uint32_t ctxsw_vid_lower_gpio_cntl
;
376 uint32_t lower_gpio_enable
;
379 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
380 bus_cntl
= RREG32(R600_BUS_CNTL
);
381 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
382 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
383 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
384 rom_cntl
= RREG32(R600_ROM_CNTL
);
385 general_pwrmgt
= RREG32(R600_GENERAL_PWRMGT
);
386 low_vid_lower_gpio_cntl
= RREG32(R600_LOW_VID_LOWER_GPIO_CNTL
);
387 medium_vid_lower_gpio_cntl
= RREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
);
388 high_vid_lower_gpio_cntl
= RREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
);
389 ctxsw_vid_lower_gpio_cntl
= RREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
);
390 lower_gpio_enable
= RREG32(R600_LOWER_GPIO_ENABLE
);
393 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
395 WREG32(R600_BUS_CNTL
, (bus_cntl
& ~R600_BIOS_ROM_DIS
));
396 /* Disable VGA mode */
397 WREG32(AVIVO_D1VGA_CONTROL
,
398 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
399 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
400 WREG32(AVIVO_D2VGA_CONTROL
,
401 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
402 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
403 WREG32(AVIVO_VGA_RENDER_CONTROL
,
404 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
406 WREG32(R600_ROM_CNTL
,
407 ((rom_cntl
& ~R600_SCK_PRESCALE_CRYSTAL_CLK_MASK
) |
408 (1 << R600_SCK_PRESCALE_CRYSTAL_CLK_SHIFT
) |
409 R600_SCK_OVERWRITE
));
411 WREG32(R600_GENERAL_PWRMGT
, (general_pwrmgt
& ~R600_OPEN_DRAIN_PADS
));
412 WREG32(R600_LOW_VID_LOWER_GPIO_CNTL
,
413 (low_vid_lower_gpio_cntl
& ~0x400));
414 WREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
,
415 (medium_vid_lower_gpio_cntl
& ~0x400));
416 WREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
,
417 (high_vid_lower_gpio_cntl
& ~0x400));
418 WREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
,
419 (ctxsw_vid_lower_gpio_cntl
& ~0x400));
420 WREG32(R600_LOWER_GPIO_ENABLE
, (lower_gpio_enable
| 0x400));
422 r
= radeon_read_bios(rdev
);
425 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
426 WREG32(R600_BUS_CNTL
, bus_cntl
);
427 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
428 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
429 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
430 WREG32(R600_ROM_CNTL
, rom_cntl
);
431 WREG32(R600_GENERAL_PWRMGT
, general_pwrmgt
);
432 WREG32(R600_LOW_VID_LOWER_GPIO_CNTL
, low_vid_lower_gpio_cntl
);
433 WREG32(R600_MEDIUM_VID_LOWER_GPIO_CNTL
, medium_vid_lower_gpio_cntl
);
434 WREG32(R600_HIGH_VID_LOWER_GPIO_CNTL
, high_vid_lower_gpio_cntl
);
435 WREG32(R600_CTXSW_VID_LOWER_GPIO_CNTL
, ctxsw_vid_lower_gpio_cntl
);
436 WREG32(R600_LOWER_GPIO_ENABLE
, lower_gpio_enable
);
440 static bool avivo_read_disabled_bios(struct radeon_device
*rdev
)
442 uint32_t seprom_cntl1
;
443 uint32_t viph_control
;
445 uint32_t d1vga_control
;
446 uint32_t d2vga_control
;
447 uint32_t vga_render_control
;
450 uint32_t gpiopad_mask
;
453 seprom_cntl1
= RREG32(RADEON_SEPROM_CNTL1
);
454 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
455 bus_cntl
= RREG32(RV370_BUS_CNTL
);
456 d1vga_control
= RREG32(AVIVO_D1VGA_CONTROL
);
457 d2vga_control
= RREG32(AVIVO_D2VGA_CONTROL
);
458 vga_render_control
= RREG32(AVIVO_VGA_RENDER_CONTROL
);
459 gpiopad_a
= RREG32(RADEON_GPIOPAD_A
);
460 gpiopad_en
= RREG32(RADEON_GPIOPAD_EN
);
461 gpiopad_mask
= RREG32(RADEON_GPIOPAD_MASK
);
463 WREG32(RADEON_SEPROM_CNTL1
,
464 ((seprom_cntl1
& ~RADEON_SCK_PRESCALE_MASK
) |
465 (0xc << RADEON_SCK_PRESCALE_SHIFT
)));
466 WREG32(RADEON_GPIOPAD_A
, 0);
467 WREG32(RADEON_GPIOPAD_EN
, 0);
468 WREG32(RADEON_GPIOPAD_MASK
, 0);
471 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
474 WREG32(RV370_BUS_CNTL
, (bus_cntl
& ~RV370_BUS_BIOS_DIS_ROM
));
476 /* Disable VGA mode */
477 WREG32(AVIVO_D1VGA_CONTROL
,
478 (d1vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
479 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
480 WREG32(AVIVO_D2VGA_CONTROL
,
481 (d2vga_control
& ~(AVIVO_DVGA_CONTROL_MODE_ENABLE
|
482 AVIVO_DVGA_CONTROL_TIMING_SELECT
)));
483 WREG32(AVIVO_VGA_RENDER_CONTROL
,
484 (vga_render_control
& ~AVIVO_VGA_VSTATUS_CNTL_MASK
));
486 r
= radeon_read_bios(rdev
);
489 WREG32(RADEON_SEPROM_CNTL1
, seprom_cntl1
);
490 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
491 WREG32(RV370_BUS_CNTL
, bus_cntl
);
492 WREG32(AVIVO_D1VGA_CONTROL
, d1vga_control
);
493 WREG32(AVIVO_D2VGA_CONTROL
, d2vga_control
);
494 WREG32(AVIVO_VGA_RENDER_CONTROL
, vga_render_control
);
495 WREG32(RADEON_GPIOPAD_A
, gpiopad_a
);
496 WREG32(RADEON_GPIOPAD_EN
, gpiopad_en
);
497 WREG32(RADEON_GPIOPAD_MASK
, gpiopad_mask
);
501 static bool legacy_read_disabled_bios(struct radeon_device
*rdev
)
503 uint32_t seprom_cntl1
;
504 uint32_t viph_control
;
506 uint32_t crtc_gen_cntl
;
507 uint32_t crtc2_gen_cntl
;
508 uint32_t crtc_ext_cntl
;
509 uint32_t fp2_gen_cntl
;
512 seprom_cntl1
= RREG32(RADEON_SEPROM_CNTL1
);
513 viph_control
= RREG32(RADEON_VIPH_CONTROL
);
514 if (rdev
->flags
& RADEON_IS_PCIE
)
515 bus_cntl
= RREG32(RV370_BUS_CNTL
);
517 bus_cntl
= RREG32(RADEON_BUS_CNTL
);
518 crtc_gen_cntl
= RREG32(RADEON_CRTC_GEN_CNTL
);
520 crtc_ext_cntl
= RREG32(RADEON_CRTC_EXT_CNTL
);
523 if (rdev
->ddev
->pdev
->device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
524 fp2_gen_cntl
= RREG32(RADEON_FP2_GEN_CNTL
);
527 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
528 crtc2_gen_cntl
= RREG32(RADEON_CRTC2_GEN_CNTL
);
531 WREG32(RADEON_SEPROM_CNTL1
,
532 ((seprom_cntl1
& ~RADEON_SCK_PRESCALE_MASK
) |
533 (0xc << RADEON_SCK_PRESCALE_SHIFT
)));
536 WREG32(RADEON_VIPH_CONTROL
, (viph_control
& ~RADEON_VIPH_EN
));
539 if (rdev
->flags
& RADEON_IS_PCIE
)
540 WREG32(RV370_BUS_CNTL
, (bus_cntl
& ~RV370_BUS_BIOS_DIS_ROM
));
542 WREG32(RADEON_BUS_CNTL
, (bus_cntl
& ~RADEON_BUS_BIOS_DIS_ROM
));
544 /* Turn off mem requests and CRTC for both controllers */
545 WREG32(RADEON_CRTC_GEN_CNTL
,
546 ((crtc_gen_cntl
& ~RADEON_CRTC_EN
) |
547 (RADEON_CRTC_DISP_REQ_EN_B
|
548 RADEON_CRTC_EXT_DISP_EN
)));
549 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
550 WREG32(RADEON_CRTC2_GEN_CNTL
,
551 ((crtc2_gen_cntl
& ~RADEON_CRTC2_EN
) |
552 RADEON_CRTC2_DISP_REQ_EN_B
));
555 WREG32(RADEON_CRTC_EXT_CNTL
,
556 ((crtc_ext_cntl
& ~RADEON_CRTC_CRT_ON
) |
557 (RADEON_CRTC_SYNC_TRISTAT
|
558 RADEON_CRTC_DISPLAY_DIS
)));
560 if (rdev
->ddev
->pdev
->device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
561 WREG32(RADEON_FP2_GEN_CNTL
, (fp2_gen_cntl
& ~RADEON_FP2_ON
));
564 r
= radeon_read_bios(rdev
);
567 WREG32(RADEON_SEPROM_CNTL1
, seprom_cntl1
);
568 WREG32(RADEON_VIPH_CONTROL
, viph_control
);
569 if (rdev
->flags
& RADEON_IS_PCIE
)
570 WREG32(RV370_BUS_CNTL
, bus_cntl
);
572 WREG32(RADEON_BUS_CNTL
, bus_cntl
);
573 WREG32(RADEON_CRTC_GEN_CNTL
, crtc_gen_cntl
);
574 if (!(rdev
->flags
& RADEON_SINGLE_CRTC
)) {
575 WREG32(RADEON_CRTC2_GEN_CNTL
, crtc2_gen_cntl
);
577 WREG32(RADEON_CRTC_EXT_CNTL
, crtc_ext_cntl
);
578 if (rdev
->ddev
->pdev
->device
== PCI_DEVICE_ID_ATI_RADEON_QY
) {
579 WREG32(RADEON_FP2_GEN_CNTL
, fp2_gen_cntl
);
584 static bool radeon_read_disabled_bios(struct radeon_device
*rdev
)
586 if (rdev
->flags
& RADEON_IS_IGP
)
587 return igp_read_bios_from_vram(rdev
);
588 else if (rdev
->family
>= CHIP_BARTS
)
589 return ni_read_disabled_bios(rdev
);
590 else if (rdev
->family
>= CHIP_RV770
)
591 return r700_read_disabled_bios(rdev
);
592 else if (rdev
->family
>= CHIP_R600
)
593 return r600_read_disabled_bios(rdev
);
594 else if (rdev
->family
>= CHIP_RS600
)
595 return avivo_read_disabled_bios(rdev
);
597 return legacy_read_disabled_bios(rdev
);
601 static bool radeon_acpi_vfct_bios(struct radeon_device
*rdev
)
603 struct acpi_table_header
*hdr
;
605 UEFI_ACPI_VFCT
*vfct
;
608 if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr
)))
610 tbl_size
= hdr
->length
;
611 if (tbl_size
< sizeof(UEFI_ACPI_VFCT
)) {
612 DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n");
616 vfct
= (UEFI_ACPI_VFCT
*)hdr
;
617 offset
= vfct
->VBIOSImageOffset
;
619 while (offset
< tbl_size
) {
620 GOP_VBIOS_CONTENT
*vbios
= (GOP_VBIOS_CONTENT
*)((char *)hdr
+ offset
);
621 VFCT_IMAGE_HEADER
*vhdr
= &vbios
->VbiosHeader
;
623 offset
+= sizeof(VFCT_IMAGE_HEADER
);
624 if (offset
> tbl_size
) {
625 DRM_ERROR("ACPI VFCT image header truncated\n");
629 offset
+= vhdr
->ImageLength
;
630 if (offset
> tbl_size
) {
631 DRM_ERROR("ACPI VFCT image truncated\n");
635 if (vhdr
->ImageLength
&&
636 vhdr
->PCIBus
== rdev
->pdev
->bus
->number
&&
637 vhdr
->PCIDevice
== PCI_SLOT(rdev
->pdev
->devfn
) &&
638 vhdr
->PCIFunction
== PCI_FUNC(rdev
->pdev
->devfn
) &&
639 vhdr
->VendorID
== rdev
->pdev
->vendor
&&
640 vhdr
->DeviceID
== rdev
->pdev
->device
) {
641 rdev
->bios
= kmemdup(&vbios
->VbiosContent
,
651 DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n");
655 static inline bool radeon_acpi_vfct_bios(struct radeon_device
*rdev
)
661 bool radeon_get_bios(struct radeon_device
*rdev
)
666 r
= radeon_atrm_get_bios(rdev
);
668 r
= radeon_acpi_vfct_bios(rdev
);
670 r
= igp_read_bios_from_vram(rdev
);
672 r
= radeon_read_bios(rdev
);
674 r
= radeon_read_disabled_bios(rdev
);
676 r
= radeon_read_platform_bios(rdev
);
677 if (!r
|| rdev
->bios
== NULL
) {
678 DRM_ERROR("Unable to locate a BIOS ROM\n");
682 if (rdev
->bios
[0] != 0x55 || rdev
->bios
[1] != 0xaa) {
683 printk("BIOS signature incorrect %x %x\n", rdev
->bios
[0], rdev
->bios
[1]);
688 if (RBIOS8(tmp
+ 0x14) != 0x0) {
689 DRM_INFO("Not an x86 BIOS ROM, not using.\n");
693 rdev
->bios_header_start
= RBIOS16(0x48);
694 if (!rdev
->bios_header_start
) {
697 tmp
= rdev
->bios_header_start
+ 4;
698 if (!memcmp(rdev
->bios
+ tmp
, "ATOM", 4) ||
699 !memcmp(rdev
->bios
+ tmp
, "MOTA", 4)) {
700 rdev
->is_atom_bios
= true;
702 rdev
->is_atom_bios
= false;
705 DRM_DEBUG("%sBIOS detected\n", rdev
->is_atom_bios
? "ATOM" : "COM");