2 * Copyright 2004 ATI Technologies Inc., Markham, Ontario
3 * Copyright 2007-8 Advanced Micro Devices, Inc.
4 * Copyright 2008 Red Hat Inc.
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
28 #include "radeon_drm.h"
32 #ifdef CONFIG_PPC_PMAC
33 /* not sure which of these are needed */
34 #include <asm/machdep.h>
35 #include <asm/pmac_feature.h>
37 #include <asm/pci-bridge.h>
38 #endif /* CONFIG_PPC_PMAC */
40 /* from radeon_encoder.c */
42 radeon_get_encoder_enum(struct drm_device
*dev
, uint32_t supported_device
,
44 extern void radeon_link_encoder_connector(struct drm_device
*dev
);
46 /* from radeon_connector.c */
48 radeon_add_legacy_connector(struct drm_device
*dev
,
49 uint32_t connector_id
,
50 uint32_t supported_device
,
52 struct radeon_i2c_bus_rec
*i2c_bus
,
53 uint16_t connector_object_id
,
54 struct radeon_hpd
*hpd
);
56 /* from radeon_legacy_encoder.c */
58 radeon_add_legacy_encoder(struct drm_device
*dev
, uint32_t encoder_enum
,
59 uint32_t supported_device
);
61 /* old legacy ATI BIOS routines */
63 /* COMBIOS table offsets */
64 enum radeon_combios_table_offset
{
65 /* absolute offset tables */
66 COMBIOS_ASIC_INIT_1_TABLE
,
67 COMBIOS_BIOS_SUPPORT_TABLE
,
68 COMBIOS_DAC_PROGRAMMING_TABLE
,
69 COMBIOS_MAX_COLOR_DEPTH_TABLE
,
70 COMBIOS_CRTC_INFO_TABLE
,
71 COMBIOS_PLL_INFO_TABLE
,
72 COMBIOS_TV_INFO_TABLE
,
73 COMBIOS_DFP_INFO_TABLE
,
74 COMBIOS_HW_CONFIG_INFO_TABLE
,
75 COMBIOS_MULTIMEDIA_INFO_TABLE
,
76 COMBIOS_TV_STD_PATCH_TABLE
,
77 COMBIOS_LCD_INFO_TABLE
,
78 COMBIOS_MOBILE_INFO_TABLE
,
79 COMBIOS_PLL_INIT_TABLE
,
80 COMBIOS_MEM_CONFIG_TABLE
,
81 COMBIOS_SAVE_MASK_TABLE
,
82 COMBIOS_HARDCODED_EDID_TABLE
,
83 COMBIOS_ASIC_INIT_2_TABLE
,
84 COMBIOS_CONNECTOR_INFO_TABLE
,
85 COMBIOS_DYN_CLK_1_TABLE
,
86 COMBIOS_RESERVED_MEM_TABLE
,
87 COMBIOS_EXT_TMDS_INFO_TABLE
,
88 COMBIOS_MEM_CLK_INFO_TABLE
,
89 COMBIOS_EXT_DAC_INFO_TABLE
,
90 COMBIOS_MISC_INFO_TABLE
,
91 COMBIOS_CRT_INFO_TABLE
,
92 COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE
,
93 COMBIOS_COMPONENT_VIDEO_INFO_TABLE
,
94 COMBIOS_FAN_SPEED_INFO_TABLE
,
95 COMBIOS_OVERDRIVE_INFO_TABLE
,
96 COMBIOS_OEM_INFO_TABLE
,
97 COMBIOS_DYN_CLK_2_TABLE
,
98 COMBIOS_POWER_CONNECTOR_INFO_TABLE
,
99 COMBIOS_I2C_INFO_TABLE
,
100 /* relative offset tables */
101 COMBIOS_ASIC_INIT_3_TABLE
, /* offset from misc info */
102 COMBIOS_ASIC_INIT_4_TABLE
, /* offset from misc info */
103 COMBIOS_DETECTED_MEM_TABLE
, /* offset from misc info */
104 COMBIOS_ASIC_INIT_5_TABLE
, /* offset from misc info */
105 COMBIOS_RAM_RESET_TABLE
, /* offset from mem config */
106 COMBIOS_POWERPLAY_INFO_TABLE
, /* offset from mobile info */
107 COMBIOS_GPIO_INFO_TABLE
, /* offset from mobile info */
108 COMBIOS_LCD_DDC_INFO_TABLE
, /* offset from mobile info */
109 COMBIOS_TMDS_POWER_TABLE
, /* offset from mobile info */
110 COMBIOS_TMDS_POWER_ON_TABLE
, /* offset from tmds power */
111 COMBIOS_TMDS_POWER_OFF_TABLE
, /* offset from tmds power */
114 enum radeon_combios_ddc
{
124 enum radeon_combios_connector
{
125 CONNECTOR_NONE_LEGACY
,
126 CONNECTOR_PROPRIETARY_LEGACY
,
127 CONNECTOR_CRT_LEGACY
,
128 CONNECTOR_DVI_I_LEGACY
,
129 CONNECTOR_DVI_D_LEGACY
,
130 CONNECTOR_CTV_LEGACY
,
131 CONNECTOR_STV_LEGACY
,
132 CONNECTOR_UNSUPPORTED_LEGACY
135 const int legacy_connector_convert
[] = {
136 DRM_MODE_CONNECTOR_Unknown
,
137 DRM_MODE_CONNECTOR_DVID
,
138 DRM_MODE_CONNECTOR_VGA
,
139 DRM_MODE_CONNECTOR_DVII
,
140 DRM_MODE_CONNECTOR_DVID
,
141 DRM_MODE_CONNECTOR_Composite
,
142 DRM_MODE_CONNECTOR_SVIDEO
,
143 DRM_MODE_CONNECTOR_Unknown
,
146 static uint16_t combios_get_table_offset(struct drm_device
*dev
,
147 enum radeon_combios_table_offset table
)
149 struct radeon_device
*rdev
= dev
->dev_private
;
151 uint16_t offset
= 0, check_offset
;
157 /* absolute offset tables */
158 case COMBIOS_ASIC_INIT_1_TABLE
:
159 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0xc);
161 offset
= check_offset
;
163 case COMBIOS_BIOS_SUPPORT_TABLE
:
164 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x14);
166 offset
= check_offset
;
168 case COMBIOS_DAC_PROGRAMMING_TABLE
:
169 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x2a);
171 offset
= check_offset
;
173 case COMBIOS_MAX_COLOR_DEPTH_TABLE
:
174 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x2c);
176 offset
= check_offset
;
178 case COMBIOS_CRTC_INFO_TABLE
:
179 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x2e);
181 offset
= check_offset
;
183 case COMBIOS_PLL_INFO_TABLE
:
184 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x30);
186 offset
= check_offset
;
188 case COMBIOS_TV_INFO_TABLE
:
189 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x32);
191 offset
= check_offset
;
193 case COMBIOS_DFP_INFO_TABLE
:
194 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x34);
196 offset
= check_offset
;
198 case COMBIOS_HW_CONFIG_INFO_TABLE
:
199 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x36);
201 offset
= check_offset
;
203 case COMBIOS_MULTIMEDIA_INFO_TABLE
:
204 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x38);
206 offset
= check_offset
;
208 case COMBIOS_TV_STD_PATCH_TABLE
:
209 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x3e);
211 offset
= check_offset
;
213 case COMBIOS_LCD_INFO_TABLE
:
214 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x40);
216 offset
= check_offset
;
218 case COMBIOS_MOBILE_INFO_TABLE
:
219 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x42);
221 offset
= check_offset
;
223 case COMBIOS_PLL_INIT_TABLE
:
224 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x46);
226 offset
= check_offset
;
228 case COMBIOS_MEM_CONFIG_TABLE
:
229 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x48);
231 offset
= check_offset
;
233 case COMBIOS_SAVE_MASK_TABLE
:
234 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x4a);
236 offset
= check_offset
;
238 case COMBIOS_HARDCODED_EDID_TABLE
:
239 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x4c);
241 offset
= check_offset
;
243 case COMBIOS_ASIC_INIT_2_TABLE
:
244 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x4e);
246 offset
= check_offset
;
248 case COMBIOS_CONNECTOR_INFO_TABLE
:
249 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x50);
251 offset
= check_offset
;
253 case COMBIOS_DYN_CLK_1_TABLE
:
254 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x52);
256 offset
= check_offset
;
258 case COMBIOS_RESERVED_MEM_TABLE
:
259 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x54);
261 offset
= check_offset
;
263 case COMBIOS_EXT_TMDS_INFO_TABLE
:
264 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x58);
266 offset
= check_offset
;
268 case COMBIOS_MEM_CLK_INFO_TABLE
:
269 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x5a);
271 offset
= check_offset
;
273 case COMBIOS_EXT_DAC_INFO_TABLE
:
274 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x5c);
276 offset
= check_offset
;
278 case COMBIOS_MISC_INFO_TABLE
:
279 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x5e);
281 offset
= check_offset
;
283 case COMBIOS_CRT_INFO_TABLE
:
284 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x60);
286 offset
= check_offset
;
288 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE
:
289 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x62);
291 offset
= check_offset
;
293 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE
:
294 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x64);
296 offset
= check_offset
;
298 case COMBIOS_FAN_SPEED_INFO_TABLE
:
299 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x66);
301 offset
= check_offset
;
303 case COMBIOS_OVERDRIVE_INFO_TABLE
:
304 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x68);
306 offset
= check_offset
;
308 case COMBIOS_OEM_INFO_TABLE
:
309 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x6a);
311 offset
= check_offset
;
313 case COMBIOS_DYN_CLK_2_TABLE
:
314 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x6c);
316 offset
= check_offset
;
318 case COMBIOS_POWER_CONNECTOR_INFO_TABLE
:
319 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x6e);
321 offset
= check_offset
;
323 case COMBIOS_I2C_INFO_TABLE
:
324 check_offset
= RBIOS16(rdev
->bios_header_start
+ 0x70);
326 offset
= check_offset
;
328 /* relative offset tables */
329 case COMBIOS_ASIC_INIT_3_TABLE
: /* offset from misc info */
331 combios_get_table_offset(dev
, COMBIOS_MISC_INFO_TABLE
);
333 rev
= RBIOS8(check_offset
);
335 check_offset
= RBIOS16(check_offset
+ 0x3);
337 offset
= check_offset
;
341 case COMBIOS_ASIC_INIT_4_TABLE
: /* offset from misc info */
343 combios_get_table_offset(dev
, COMBIOS_MISC_INFO_TABLE
);
345 rev
= RBIOS8(check_offset
);
347 check_offset
= RBIOS16(check_offset
+ 0x5);
349 offset
= check_offset
;
353 case COMBIOS_DETECTED_MEM_TABLE
: /* offset from misc info */
355 combios_get_table_offset(dev
, COMBIOS_MISC_INFO_TABLE
);
357 rev
= RBIOS8(check_offset
);
359 check_offset
= RBIOS16(check_offset
+ 0x7);
361 offset
= check_offset
;
365 case COMBIOS_ASIC_INIT_5_TABLE
: /* offset from misc info */
367 combios_get_table_offset(dev
, COMBIOS_MISC_INFO_TABLE
);
369 rev
= RBIOS8(check_offset
);
371 check_offset
= RBIOS16(check_offset
+ 0x9);
373 offset
= check_offset
;
377 case COMBIOS_RAM_RESET_TABLE
: /* offset from mem config */
379 combios_get_table_offset(dev
, COMBIOS_MEM_CONFIG_TABLE
);
381 while (RBIOS8(check_offset
++));
384 offset
= check_offset
;
387 case COMBIOS_POWERPLAY_INFO_TABLE
: /* offset from mobile info */
389 combios_get_table_offset(dev
, COMBIOS_MOBILE_INFO_TABLE
);
391 check_offset
= RBIOS16(check_offset
+ 0x11);
393 offset
= check_offset
;
396 case COMBIOS_GPIO_INFO_TABLE
: /* offset from mobile info */
398 combios_get_table_offset(dev
, COMBIOS_MOBILE_INFO_TABLE
);
400 check_offset
= RBIOS16(check_offset
+ 0x13);
402 offset
= check_offset
;
405 case COMBIOS_LCD_DDC_INFO_TABLE
: /* offset from mobile info */
407 combios_get_table_offset(dev
, COMBIOS_MOBILE_INFO_TABLE
);
409 check_offset
= RBIOS16(check_offset
+ 0x15);
411 offset
= check_offset
;
414 case COMBIOS_TMDS_POWER_TABLE
: /* offset from mobile info */
416 combios_get_table_offset(dev
, COMBIOS_MOBILE_INFO_TABLE
);
418 check_offset
= RBIOS16(check_offset
+ 0x17);
420 offset
= check_offset
;
423 case COMBIOS_TMDS_POWER_ON_TABLE
: /* offset from tmds power */
425 combios_get_table_offset(dev
, COMBIOS_TMDS_POWER_TABLE
);
427 check_offset
= RBIOS16(check_offset
+ 0x2);
429 offset
= check_offset
;
432 case COMBIOS_TMDS_POWER_OFF_TABLE
: /* offset from tmds power */
434 combios_get_table_offset(dev
, COMBIOS_TMDS_POWER_TABLE
);
436 check_offset
= RBIOS16(check_offset
+ 0x4);
438 offset
= check_offset
;
449 bool radeon_combios_check_hardcoded_edid(struct radeon_device
*rdev
)
454 edid_info
= combios_get_table_offset(rdev
->ddev
, COMBIOS_HARDCODED_EDID_TABLE
);
458 raw
= rdev
->bios
+ edid_info
;
459 size
= EDID_LENGTH
* (raw
[0x7e] + 1);
460 edid
= kmalloc(size
, GFP_KERNEL
);
464 memcpy((unsigned char *)edid
, raw
, size
);
466 if (!drm_edid_is_valid(edid
)) {
471 rdev
->mode_info
.bios_hardcoded_edid
= edid
;
472 rdev
->mode_info
.bios_hardcoded_edid_size
= size
;
476 /* this is used for atom LCDs as well */
478 radeon_bios_get_hardcoded_edid(struct radeon_device
*rdev
)
482 if (rdev
->mode_info
.bios_hardcoded_edid
) {
483 edid
= kmalloc(rdev
->mode_info
.bios_hardcoded_edid_size
, GFP_KERNEL
);
485 memcpy((unsigned char *)edid
,
486 (unsigned char *)rdev
->mode_info
.bios_hardcoded_edid
,
487 rdev
->mode_info
.bios_hardcoded_edid_size
);
494 static struct radeon_i2c_bus_rec
combios_setup_i2c_bus(struct radeon_device
*rdev
,
495 enum radeon_combios_ddc ddc
,
499 struct radeon_i2c_bus_rec i2c
;
503 * DDC_NONE_DETECTED = none
504 * DDC_DVI = RADEON_GPIO_DVI_DDC
505 * DDC_VGA = RADEON_GPIO_VGA_DDC
506 * DDC_LCD = RADEON_GPIOPAD_MASK
507 * DDC_GPIO = RADEON_MDGPIO_MASK
509 * DDC_MONID = RADEON_GPIO_MONID
510 * DDC_CRT2 = RADEON_GPIO_CRT2_DDC
512 * DDC_MONID = RADEON_GPIO_MONID
513 * DDC_CRT2 = RADEON_GPIO_DVI_DDC
515 * DDC_MONID = RADEON_GPIOPAD_MASK
516 * DDC_CRT2 = RADEON_GPIO_MONID
519 case DDC_NONE_DETECTED
:
524 ddc_line
= RADEON_GPIO_DVI_DDC
;
527 ddc_line
= RADEON_GPIO_VGA_DDC
;
530 ddc_line
= RADEON_GPIOPAD_MASK
;
533 ddc_line
= RADEON_MDGPIO_MASK
;
536 if (rdev
->family
== CHIP_RS300
||
537 rdev
->family
== CHIP_RS400
||
538 rdev
->family
== CHIP_RS480
)
539 ddc_line
= RADEON_GPIOPAD_MASK
;
541 ddc_line
= RADEON_GPIO_MONID
;
544 if (rdev
->family
== CHIP_RS300
||
545 rdev
->family
== CHIP_RS400
||
546 rdev
->family
== CHIP_RS480
)
547 ddc_line
= RADEON_GPIO_MONID
;
548 else if (rdev
->family
>= CHIP_R300
) {
549 ddc_line
= RADEON_GPIO_DVI_DDC
;
552 ddc_line
= RADEON_GPIO_CRT2_DDC
;
556 if (ddc_line
== RADEON_GPIOPAD_MASK
) {
557 i2c
.mask_clk_reg
= RADEON_GPIOPAD_MASK
;
558 i2c
.mask_data_reg
= RADEON_GPIOPAD_MASK
;
559 i2c
.a_clk_reg
= RADEON_GPIOPAD_A
;
560 i2c
.a_data_reg
= RADEON_GPIOPAD_A
;
561 i2c
.en_clk_reg
= RADEON_GPIOPAD_EN
;
562 i2c
.en_data_reg
= RADEON_GPIOPAD_EN
;
563 i2c
.y_clk_reg
= RADEON_GPIOPAD_Y
;
564 i2c
.y_data_reg
= RADEON_GPIOPAD_Y
;
565 } else if (ddc_line
== RADEON_MDGPIO_MASK
) {
566 i2c
.mask_clk_reg
= RADEON_MDGPIO_MASK
;
567 i2c
.mask_data_reg
= RADEON_MDGPIO_MASK
;
568 i2c
.a_clk_reg
= RADEON_MDGPIO_A
;
569 i2c
.a_data_reg
= RADEON_MDGPIO_A
;
570 i2c
.en_clk_reg
= RADEON_MDGPIO_EN
;
571 i2c
.en_data_reg
= RADEON_MDGPIO_EN
;
572 i2c
.y_clk_reg
= RADEON_MDGPIO_Y
;
573 i2c
.y_data_reg
= RADEON_MDGPIO_Y
;
575 i2c
.mask_clk_reg
= ddc_line
;
576 i2c
.mask_data_reg
= ddc_line
;
577 i2c
.a_clk_reg
= ddc_line
;
578 i2c
.a_data_reg
= ddc_line
;
579 i2c
.en_clk_reg
= ddc_line
;
580 i2c
.en_data_reg
= ddc_line
;
581 i2c
.y_clk_reg
= ddc_line
;
582 i2c
.y_data_reg
= ddc_line
;
585 if (clk_mask
&& data_mask
) {
586 /* system specific masks */
587 i2c
.mask_clk_mask
= clk_mask
;
588 i2c
.mask_data_mask
= data_mask
;
589 i2c
.a_clk_mask
= clk_mask
;
590 i2c
.a_data_mask
= data_mask
;
591 i2c
.en_clk_mask
= clk_mask
;
592 i2c
.en_data_mask
= data_mask
;
593 i2c
.y_clk_mask
= clk_mask
;
594 i2c
.y_data_mask
= data_mask
;
595 } else if ((ddc_line
== RADEON_GPIOPAD_MASK
) ||
596 (ddc_line
== RADEON_MDGPIO_MASK
)) {
597 /* default gpiopad masks */
598 i2c
.mask_clk_mask
= (0x20 << 8);
599 i2c
.mask_data_mask
= 0x80;
600 i2c
.a_clk_mask
= (0x20 << 8);
601 i2c
.a_data_mask
= 0x80;
602 i2c
.en_clk_mask
= (0x20 << 8);
603 i2c
.en_data_mask
= 0x80;
604 i2c
.y_clk_mask
= (0x20 << 8);
605 i2c
.y_data_mask
= 0x80;
607 /* default masks for ddc pads */
608 i2c
.mask_clk_mask
= RADEON_GPIO_EN_1
;
609 i2c
.mask_data_mask
= RADEON_GPIO_EN_0
;
610 i2c
.a_clk_mask
= RADEON_GPIO_A_1
;
611 i2c
.a_data_mask
= RADEON_GPIO_A_0
;
612 i2c
.en_clk_mask
= RADEON_GPIO_EN_1
;
613 i2c
.en_data_mask
= RADEON_GPIO_EN_0
;
614 i2c
.y_clk_mask
= RADEON_GPIO_Y_1
;
615 i2c
.y_data_mask
= RADEON_GPIO_Y_0
;
618 switch (rdev
->family
) {
626 case RADEON_GPIO_DVI_DDC
:
627 i2c
.hw_capable
= true;
630 i2c
.hw_capable
= false;
636 case RADEON_GPIO_DVI_DDC
:
637 case RADEON_GPIO_MONID
:
638 i2c
.hw_capable
= true;
641 i2c
.hw_capable
= false;
648 case RADEON_GPIO_VGA_DDC
:
649 case RADEON_GPIO_DVI_DDC
:
650 case RADEON_GPIO_CRT2_DDC
:
651 i2c
.hw_capable
= true;
654 i2c
.hw_capable
= false;
661 case RADEON_GPIO_VGA_DDC
:
662 case RADEON_GPIO_DVI_DDC
:
663 i2c
.hw_capable
= true;
666 i2c
.hw_capable
= false;
675 case RADEON_GPIO_VGA_DDC
:
676 case RADEON_GPIO_DVI_DDC
:
677 i2c
.hw_capable
= true;
679 case RADEON_GPIO_MONID
:
680 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
681 * reliably on some pre-r4xx hardware; not sure why.
683 i2c
.hw_capable
= false;
686 i2c
.hw_capable
= false;
691 i2c
.hw_capable
= false;
697 i2c
.hpd
= RADEON_HPD_NONE
;
707 void radeon_combios_i2c_init(struct radeon_device
*rdev
)
709 struct drm_device
*dev
= rdev
->ddev
;
710 struct radeon_i2c_bus_rec i2c
;
713 i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
714 rdev
->i2c_bus
[0] = radeon_i2c_create(dev
, &i2c
, "DVI_DDC");
716 i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
717 rdev
->i2c_bus
[1] = radeon_i2c_create(dev
, &i2c
, "VGA_DDC");
720 i2c
.hw_capable
= true;
723 rdev
->i2c_bus
[2] = radeon_i2c_create(dev
, &i2c
, "MM_I2C");
725 if (rdev
->family
== CHIP_RS300
||
726 rdev
->family
== CHIP_RS400
||
727 rdev
->family
== CHIP_RS480
) {
729 u8 id
, blocks
, clk
, data
;
732 i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
733 rdev
->i2c_bus
[3] = radeon_i2c_create(dev
, &i2c
, "MONID");
735 offset
= combios_get_table_offset(dev
, COMBIOS_I2C_INFO_TABLE
);
737 blocks
= RBIOS8(offset
+ 2);
738 for (i
= 0; i
< blocks
; i
++) {
739 id
= RBIOS8(offset
+ 3 + (i
* 5) + 0);
741 clk
= RBIOS8(offset
+ 3 + (i
* 5) + 3);
742 data
= RBIOS8(offset
+ 3 + (i
* 5) + 4);
743 i2c
= combios_setup_i2c_bus(rdev
, DDC_MONID
,
744 (1 << clk
), (1 << data
));
745 rdev
->i2c_bus
[4] = radeon_i2c_create(dev
, &i2c
, "GPIOPAD_MASK");
751 } else if (rdev
->family
>= CHIP_R300
) {
752 i2c
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
753 rdev
->i2c_bus
[3] = radeon_i2c_create(dev
, &i2c
, "MONID");
755 i2c
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
756 rdev
->i2c_bus
[3] = radeon_i2c_create(dev
, &i2c
, "MONID");
758 i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
759 rdev
->i2c_bus
[4] = radeon_i2c_create(dev
, &i2c
, "CRT2_DDC");
763 bool radeon_combios_get_clock_info(struct drm_device
*dev
)
765 struct radeon_device
*rdev
= dev
->dev_private
;
767 struct radeon_pll
*p1pll
= &rdev
->clock
.p1pll
;
768 struct radeon_pll
*p2pll
= &rdev
->clock
.p2pll
;
769 struct radeon_pll
*spll
= &rdev
->clock
.spll
;
770 struct radeon_pll
*mpll
= &rdev
->clock
.mpll
;
774 pll_info
= combios_get_table_offset(dev
, COMBIOS_PLL_INFO_TABLE
);
776 rev
= RBIOS8(pll_info
);
779 p1pll
->reference_freq
= RBIOS16(pll_info
+ 0xe);
780 p1pll
->reference_div
= RBIOS16(pll_info
+ 0x10);
781 p1pll
->pll_out_min
= RBIOS32(pll_info
+ 0x12);
782 p1pll
->pll_out_max
= RBIOS32(pll_info
+ 0x16);
783 p1pll
->lcd_pll_out_min
= p1pll
->pll_out_min
;
784 p1pll
->lcd_pll_out_max
= p1pll
->pll_out_max
;
787 p1pll
->pll_in_min
= RBIOS32(pll_info
+ 0x36);
788 p1pll
->pll_in_max
= RBIOS32(pll_info
+ 0x3a);
790 p1pll
->pll_in_min
= 40;
791 p1pll
->pll_in_max
= 500;
796 spll
->reference_freq
= RBIOS16(pll_info
+ 0x1a);
797 spll
->reference_div
= RBIOS16(pll_info
+ 0x1c);
798 spll
->pll_out_min
= RBIOS32(pll_info
+ 0x1e);
799 spll
->pll_out_max
= RBIOS32(pll_info
+ 0x22);
802 spll
->pll_in_min
= RBIOS32(pll_info
+ 0x48);
803 spll
->pll_in_max
= RBIOS32(pll_info
+ 0x4c);
806 spll
->pll_in_min
= 40;
807 spll
->pll_in_max
= 500;
811 mpll
->reference_freq
= RBIOS16(pll_info
+ 0x26);
812 mpll
->reference_div
= RBIOS16(pll_info
+ 0x28);
813 mpll
->pll_out_min
= RBIOS32(pll_info
+ 0x2a);
814 mpll
->pll_out_max
= RBIOS32(pll_info
+ 0x2e);
817 mpll
->pll_in_min
= RBIOS32(pll_info
+ 0x5a);
818 mpll
->pll_in_max
= RBIOS32(pll_info
+ 0x5e);
821 mpll
->pll_in_min
= 40;
822 mpll
->pll_in_max
= 500;
825 /* default sclk/mclk */
826 sclk
= RBIOS16(pll_info
+ 0xa);
827 mclk
= RBIOS16(pll_info
+ 0x8);
833 rdev
->clock
.default_sclk
= sclk
;
834 rdev
->clock
.default_mclk
= mclk
;
841 bool radeon_combios_sideport_present(struct radeon_device
*rdev
)
843 struct drm_device
*dev
= rdev
->ddev
;
846 /* sideport is AMD only */
847 if (rdev
->family
== CHIP_RS400
)
850 igp_info
= combios_get_table_offset(dev
, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE
);
853 if (RBIOS16(igp_info
+ 0x4))
859 static const uint32_t default_primarydac_adj
[CHIP_LAST
] = {
860 0x00000808, /* r100 */
861 0x00000808, /* rv100 */
862 0x00000808, /* rs100 */
863 0x00000808, /* rv200 */
864 0x00000808, /* rs200 */
865 0x00000808, /* r200 */
866 0x00000808, /* rv250 */
867 0x00000000, /* rs300 */
868 0x00000808, /* rv280 */
869 0x00000808, /* r300 */
870 0x00000808, /* r350 */
871 0x00000808, /* rv350 */
872 0x00000808, /* rv380 */
873 0x00000808, /* r420 */
874 0x00000808, /* r423 */
875 0x00000808, /* rv410 */
876 0x00000000, /* rs400 */
877 0x00000000, /* rs480 */
880 static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device
*rdev
,
881 struct radeon_encoder_primary_dac
*p_dac
)
883 p_dac
->ps2_pdac_adj
= default_primarydac_adj
[rdev
->family
];
887 struct radeon_encoder_primary_dac
*radeon_combios_get_primary_dac_info(struct
891 struct drm_device
*dev
= encoder
->base
.dev
;
892 struct radeon_device
*rdev
= dev
->dev_private
;
894 uint8_t rev
, bg
, dac
;
895 struct radeon_encoder_primary_dac
*p_dac
= NULL
;
898 p_dac
= kzalloc(sizeof(struct radeon_encoder_primary_dac
),
904 /* check CRT table */
905 dac_info
= combios_get_table_offset(dev
, COMBIOS_CRT_INFO_TABLE
);
907 rev
= RBIOS8(dac_info
) & 0x3;
909 bg
= RBIOS8(dac_info
+ 0x2) & 0xf;
910 dac
= (RBIOS8(dac_info
+ 0x2) >> 4) & 0xf;
911 p_dac
->ps2_pdac_adj
= (bg
<< 8) | (dac
);
913 bg
= RBIOS8(dac_info
+ 0x2) & 0xf;
914 dac
= RBIOS8(dac_info
+ 0x3) & 0xf;
915 p_dac
->ps2_pdac_adj
= (bg
<< 8) | (dac
);
917 /* if the values are all zeros, use the table */
918 if (p_dac
->ps2_pdac_adj
)
922 if (!found
) /* fallback to defaults */
923 radeon_legacy_get_primary_dac_info_from_table(rdev
, p_dac
);
929 radeon_combios_get_tv_info(struct radeon_device
*rdev
)
931 struct drm_device
*dev
= rdev
->ddev
;
933 enum radeon_tv_std tv_std
= TV_STD_NTSC
;
935 tv_info
= combios_get_table_offset(dev
, COMBIOS_TV_INFO_TABLE
);
937 if (RBIOS8(tv_info
+ 6) == 'T') {
938 switch (RBIOS8(tv_info
+ 7) & 0xf) {
940 tv_std
= TV_STD_NTSC
;
941 DRM_DEBUG_KMS("Default TV standard: NTSC\n");
945 DRM_DEBUG_KMS("Default TV standard: PAL\n");
948 tv_std
= TV_STD_PAL_M
;
949 DRM_DEBUG_KMS("Default TV standard: PAL-M\n");
952 tv_std
= TV_STD_PAL_60
;
953 DRM_DEBUG_KMS("Default TV standard: PAL-60\n");
956 tv_std
= TV_STD_NTSC_J
;
957 DRM_DEBUG_KMS("Default TV standard: NTSC-J\n");
960 tv_std
= TV_STD_SCART_PAL
;
961 DRM_DEBUG_KMS("Default TV standard: SCART-PAL\n");
964 tv_std
= TV_STD_NTSC
;
966 ("Unknown TV standard; defaulting to NTSC\n");
970 switch ((RBIOS8(tv_info
+ 9) >> 2) & 0x3) {
972 DRM_DEBUG_KMS("29.498928713 MHz TV ref clk\n");
975 DRM_DEBUG_KMS("28.636360000 MHz TV ref clk\n");
978 DRM_DEBUG_KMS("14.318180000 MHz TV ref clk\n");
981 DRM_DEBUG_KMS("27.000000000 MHz TV ref clk\n");
991 static const uint32_t default_tvdac_adj
[CHIP_LAST
] = {
992 0x00000000, /* r100 */
993 0x00280000, /* rv100 */
994 0x00000000, /* rs100 */
995 0x00880000, /* rv200 */
996 0x00000000, /* rs200 */
997 0x00000000, /* r200 */
998 0x00770000, /* rv250 */
999 0x00290000, /* rs300 */
1000 0x00560000, /* rv280 */
1001 0x00780000, /* r300 */
1002 0x00770000, /* r350 */
1003 0x00780000, /* rv350 */
1004 0x00780000, /* rv380 */
1005 0x01080000, /* r420 */
1006 0x01080000, /* r423 */
1007 0x01080000, /* rv410 */
1008 0x00780000, /* rs400 */
1009 0x00780000, /* rs480 */
1012 static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device
*rdev
,
1013 struct radeon_encoder_tv_dac
*tv_dac
)
1015 tv_dac
->ps2_tvdac_adj
= default_tvdac_adj
[rdev
->family
];
1016 if ((rdev
->flags
& RADEON_IS_MOBILITY
) && (rdev
->family
== CHIP_RV250
))
1017 tv_dac
->ps2_tvdac_adj
= 0x00880000;
1018 tv_dac
->pal_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1019 tv_dac
->ntsc_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1023 struct radeon_encoder_tv_dac
*radeon_combios_get_tv_dac_info(struct
1027 struct drm_device
*dev
= encoder
->base
.dev
;
1028 struct radeon_device
*rdev
= dev
->dev_private
;
1030 uint8_t rev
, bg
, dac
;
1031 struct radeon_encoder_tv_dac
*tv_dac
= NULL
;
1034 tv_dac
= kzalloc(sizeof(struct radeon_encoder_tv_dac
), GFP_KERNEL
);
1038 /* first check TV table */
1039 dac_info
= combios_get_table_offset(dev
, COMBIOS_TV_INFO_TABLE
);
1041 rev
= RBIOS8(dac_info
+ 0x3);
1043 bg
= RBIOS8(dac_info
+ 0xc) & 0xf;
1044 dac
= RBIOS8(dac_info
+ 0xd) & 0xf;
1045 tv_dac
->ps2_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1047 bg
= RBIOS8(dac_info
+ 0xe) & 0xf;
1048 dac
= RBIOS8(dac_info
+ 0xf) & 0xf;
1049 tv_dac
->pal_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1051 bg
= RBIOS8(dac_info
+ 0x10) & 0xf;
1052 dac
= RBIOS8(dac_info
+ 0x11) & 0xf;
1053 tv_dac
->ntsc_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1054 /* if the values are all zeros, use the table */
1055 if (tv_dac
->ps2_tvdac_adj
)
1057 } else if (rev
> 1) {
1058 bg
= RBIOS8(dac_info
+ 0xc) & 0xf;
1059 dac
= (RBIOS8(dac_info
+ 0xc) >> 4) & 0xf;
1060 tv_dac
->ps2_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1062 bg
= RBIOS8(dac_info
+ 0xd) & 0xf;
1063 dac
= (RBIOS8(dac_info
+ 0xd) >> 4) & 0xf;
1064 tv_dac
->pal_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1066 bg
= RBIOS8(dac_info
+ 0xe) & 0xf;
1067 dac
= (RBIOS8(dac_info
+ 0xe) >> 4) & 0xf;
1068 tv_dac
->ntsc_tvdac_adj
= (bg
<< 16) | (dac
<< 20);
1069 /* if the values are all zeros, use the table */
1070 if (tv_dac
->ps2_tvdac_adj
)
1073 tv_dac
->tv_std
= radeon_combios_get_tv_info(rdev
);
1076 /* then check CRT table */
1078 combios_get_table_offset(dev
, COMBIOS_CRT_INFO_TABLE
);
1080 rev
= RBIOS8(dac_info
) & 0x3;
1082 bg
= RBIOS8(dac_info
+ 0x3) & 0xf;
1083 dac
= (RBIOS8(dac_info
+ 0x3) >> 4) & 0xf;
1084 tv_dac
->ps2_tvdac_adj
=
1085 (bg
<< 16) | (dac
<< 20);
1086 tv_dac
->pal_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1087 tv_dac
->ntsc_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1088 /* if the values are all zeros, use the table */
1089 if (tv_dac
->ps2_tvdac_adj
)
1092 bg
= RBIOS8(dac_info
+ 0x4) & 0xf;
1093 dac
= RBIOS8(dac_info
+ 0x5) & 0xf;
1094 tv_dac
->ps2_tvdac_adj
=
1095 (bg
<< 16) | (dac
<< 20);
1096 tv_dac
->pal_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1097 tv_dac
->ntsc_tvdac_adj
= tv_dac
->ps2_tvdac_adj
;
1098 /* if the values are all zeros, use the table */
1099 if (tv_dac
->ps2_tvdac_adj
)
1103 DRM_INFO("No TV DAC info found in BIOS\n");
1107 if (!found
) /* fallback to defaults */
1108 radeon_legacy_get_tv_dac_info_from_table(rdev
, tv_dac
);
1113 static struct radeon_encoder_lvds
*radeon_legacy_get_lvds_info_from_regs(struct
1117 struct radeon_encoder_lvds
*lvds
= NULL
;
1118 uint32_t fp_vert_stretch
, fp_horz_stretch
;
1119 uint32_t ppll_div_sel
, ppll_val
;
1120 uint32_t lvds_ss_gen_cntl
= RREG32(RADEON_LVDS_SS_GEN_CNTL
);
1122 lvds
= kzalloc(sizeof(struct radeon_encoder_lvds
), GFP_KERNEL
);
1127 fp_vert_stretch
= RREG32(RADEON_FP_VERT_STRETCH
);
1128 fp_horz_stretch
= RREG32(RADEON_FP_HORZ_STRETCH
);
1130 /* These should be fail-safe defaults, fingers crossed */
1131 lvds
->panel_pwr_delay
= 200;
1132 lvds
->panel_vcc_delay
= 2000;
1134 lvds
->lvds_gen_cntl
= RREG32(RADEON_LVDS_GEN_CNTL
);
1135 lvds
->panel_digon_delay
= (lvds_ss_gen_cntl
>> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT
) & 0xf;
1136 lvds
->panel_blon_delay
= (lvds_ss_gen_cntl
>> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT
) & 0xf;
1138 if (fp_vert_stretch
& RADEON_VERT_STRETCH_ENABLE
)
1139 lvds
->native_mode
.vdisplay
=
1140 ((fp_vert_stretch
& RADEON_VERT_PANEL_SIZE
) >>
1141 RADEON_VERT_PANEL_SHIFT
) + 1;
1143 lvds
->native_mode
.vdisplay
=
1144 (RREG32(RADEON_CRTC_V_TOTAL_DISP
) >> 16) + 1;
1146 if (fp_horz_stretch
& RADEON_HORZ_STRETCH_ENABLE
)
1147 lvds
->native_mode
.hdisplay
=
1148 (((fp_horz_stretch
& RADEON_HORZ_PANEL_SIZE
) >>
1149 RADEON_HORZ_PANEL_SHIFT
) + 1) * 8;
1151 lvds
->native_mode
.hdisplay
=
1152 ((RREG32(RADEON_CRTC_H_TOTAL_DISP
) >> 16) + 1) * 8;
1154 if ((lvds
->native_mode
.hdisplay
< 640) ||
1155 (lvds
->native_mode
.vdisplay
< 480)) {
1156 lvds
->native_mode
.hdisplay
= 640;
1157 lvds
->native_mode
.vdisplay
= 480;
1160 ppll_div_sel
= RREG8(RADEON_CLOCK_CNTL_INDEX
+ 1) & 0x3;
1161 ppll_val
= RREG32_PLL(RADEON_PPLL_DIV_0
+ ppll_div_sel
);
1162 if ((ppll_val
& 0x000707ff) == 0x1bb)
1163 lvds
->use_bios_dividers
= false;
1165 lvds
->panel_ref_divider
=
1166 RREG32_PLL(RADEON_PPLL_REF_DIV
) & 0x3ff;
1167 lvds
->panel_post_divider
= (ppll_val
>> 16) & 0x7;
1168 lvds
->panel_fb_divider
= ppll_val
& 0x7ff;
1170 if ((lvds
->panel_ref_divider
!= 0) &&
1171 (lvds
->panel_fb_divider
> 3))
1172 lvds
->use_bios_dividers
= true;
1174 lvds
->panel_vcc_delay
= 200;
1176 DRM_INFO("Panel info derived from registers\n");
1177 DRM_INFO("Panel Size %dx%d\n", lvds
->native_mode
.hdisplay
,
1178 lvds
->native_mode
.vdisplay
);
1183 struct radeon_encoder_lvds
*radeon_combios_get_lvds_info(struct radeon_encoder
1186 struct drm_device
*dev
= encoder
->base
.dev
;
1187 struct radeon_device
*rdev
= dev
->dev_private
;
1189 uint32_t panel_setup
;
1192 struct radeon_encoder_lvds
*lvds
= NULL
;
1194 lcd_info
= combios_get_table_offset(dev
, COMBIOS_LCD_INFO_TABLE
);
1197 lvds
= kzalloc(sizeof(struct radeon_encoder_lvds
), GFP_KERNEL
);
1202 for (i
= 0; i
< 24; i
++)
1203 stmp
[i
] = RBIOS8(lcd_info
+ i
+ 1);
1206 DRM_INFO("Panel ID String: %s\n", stmp
);
1208 lvds
->native_mode
.hdisplay
= RBIOS16(lcd_info
+ 0x19);
1209 lvds
->native_mode
.vdisplay
= RBIOS16(lcd_info
+ 0x1b);
1211 DRM_INFO("Panel Size %dx%d\n", lvds
->native_mode
.hdisplay
,
1212 lvds
->native_mode
.vdisplay
);
1214 lvds
->panel_vcc_delay
= RBIOS16(lcd_info
+ 0x2c);
1215 lvds
->panel_vcc_delay
= min_t(u16
, lvds
->panel_vcc_delay
, 2000);
1217 lvds
->panel_pwr_delay
= RBIOS8(lcd_info
+ 0x24);
1218 lvds
->panel_digon_delay
= RBIOS16(lcd_info
+ 0x38) & 0xf;
1219 lvds
->panel_blon_delay
= (RBIOS16(lcd_info
+ 0x38) >> 4) & 0xf;
1221 lvds
->panel_ref_divider
= RBIOS16(lcd_info
+ 0x2e);
1222 lvds
->panel_post_divider
= RBIOS8(lcd_info
+ 0x30);
1223 lvds
->panel_fb_divider
= RBIOS16(lcd_info
+ 0x31);
1224 if ((lvds
->panel_ref_divider
!= 0) &&
1225 (lvds
->panel_fb_divider
> 3))
1226 lvds
->use_bios_dividers
= true;
1228 panel_setup
= RBIOS32(lcd_info
+ 0x39);
1229 lvds
->lvds_gen_cntl
= 0xff00;
1230 if (panel_setup
& 0x1)
1231 lvds
->lvds_gen_cntl
|= RADEON_LVDS_PANEL_FORMAT
;
1233 if ((panel_setup
>> 4) & 0x1)
1234 lvds
->lvds_gen_cntl
|= RADEON_LVDS_PANEL_TYPE
;
1236 switch ((panel_setup
>> 8) & 0x7) {
1238 lvds
->lvds_gen_cntl
|= RADEON_LVDS_NO_FM
;
1241 lvds
->lvds_gen_cntl
|= RADEON_LVDS_2_GREY
;
1244 lvds
->lvds_gen_cntl
|= RADEON_LVDS_4_GREY
;
1250 if ((panel_setup
>> 16) & 0x1)
1251 lvds
->lvds_gen_cntl
|= RADEON_LVDS_FP_POL_LOW
;
1253 if ((panel_setup
>> 17) & 0x1)
1254 lvds
->lvds_gen_cntl
|= RADEON_LVDS_LP_POL_LOW
;
1256 if ((panel_setup
>> 18) & 0x1)
1257 lvds
->lvds_gen_cntl
|= RADEON_LVDS_DTM_POL_LOW
;
1259 if ((panel_setup
>> 23) & 0x1)
1260 lvds
->lvds_gen_cntl
|= RADEON_LVDS_BL_CLK_SEL
;
1262 lvds
->lvds_gen_cntl
|= (panel_setup
& 0xf0000000);
1264 for (i
= 0; i
< 32; i
++) {
1265 tmp
= RBIOS16(lcd_info
+ 64 + i
* 2);
1269 if ((RBIOS16(tmp
) == lvds
->native_mode
.hdisplay
) &&
1270 (RBIOS16(tmp
+ 2) == lvds
->native_mode
.vdisplay
)) {
1271 lvds
->native_mode
.htotal
= lvds
->native_mode
.hdisplay
+
1272 (RBIOS16(tmp
+ 17) - RBIOS16(tmp
+ 19)) * 8;
1273 lvds
->native_mode
.hsync_start
= lvds
->native_mode
.hdisplay
+
1274 (RBIOS16(tmp
+ 21) - RBIOS16(tmp
+ 19) - 1) * 8;
1275 lvds
->native_mode
.hsync_end
= lvds
->native_mode
.hsync_start
+
1276 (RBIOS8(tmp
+ 23) * 8);
1278 lvds
->native_mode
.vtotal
= lvds
->native_mode
.vdisplay
+
1279 (RBIOS16(tmp
+ 24) - RBIOS16(tmp
+ 26));
1280 lvds
->native_mode
.vsync_start
= lvds
->native_mode
.vdisplay
+
1281 ((RBIOS16(tmp
+ 28) & 0x7ff) - RBIOS16(tmp
+ 26));
1282 lvds
->native_mode
.vsync_end
= lvds
->native_mode
.vsync_start
+
1283 ((RBIOS16(tmp
+ 28) & 0xf800) >> 11);
1285 lvds
->native_mode
.clock
= RBIOS16(tmp
+ 9) * 10;
1286 lvds
->native_mode
.flags
= 0;
1287 /* set crtc values */
1288 drm_mode_set_crtcinfo(&lvds
->native_mode
, CRTC_INTERLACE_HALVE_V
);
1293 DRM_INFO("No panel info found in BIOS\n");
1294 lvds
= radeon_legacy_get_lvds_info_from_regs(rdev
);
1298 encoder
->native_mode
= lvds
->native_mode
;
1302 static const struct radeon_tmds_pll default_tmds_pll
[CHIP_LAST
][4] = {
1303 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1304 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1305 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1306 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1307 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1308 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1309 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1310 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1311 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1312 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1313 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1314 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1315 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1316 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1317 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1318 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
1319 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1320 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
1323 bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder
*encoder
,
1324 struct radeon_encoder_int_tmds
*tmds
)
1326 struct drm_device
*dev
= encoder
->base
.dev
;
1327 struct radeon_device
*rdev
= dev
->dev_private
;
1330 for (i
= 0; i
< 4; i
++) {
1331 tmds
->tmds_pll
[i
].value
=
1332 default_tmds_pll
[rdev
->family
][i
].value
;
1333 tmds
->tmds_pll
[i
].freq
= default_tmds_pll
[rdev
->family
][i
].freq
;
1339 bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder
*encoder
,
1340 struct radeon_encoder_int_tmds
*tmds
)
1342 struct drm_device
*dev
= encoder
->base
.dev
;
1343 struct radeon_device
*rdev
= dev
->dev_private
;
1348 tmds_info
= combios_get_table_offset(dev
, COMBIOS_DFP_INFO_TABLE
);
1351 ver
= RBIOS8(tmds_info
);
1352 DRM_DEBUG_KMS("DFP table revision: %d\n", ver
);
1354 n
= RBIOS8(tmds_info
+ 5) + 1;
1357 for (i
= 0; i
< n
; i
++) {
1358 tmds
->tmds_pll
[i
].value
=
1359 RBIOS32(tmds_info
+ i
* 10 + 0x08);
1360 tmds
->tmds_pll
[i
].freq
=
1361 RBIOS16(tmds_info
+ i
* 10 + 0x10);
1362 DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
1363 tmds
->tmds_pll
[i
].freq
,
1364 tmds
->tmds_pll
[i
].value
);
1366 } else if (ver
== 4) {
1368 n
= RBIOS8(tmds_info
+ 5) + 1;
1371 for (i
= 0; i
< n
; i
++) {
1372 tmds
->tmds_pll
[i
].value
=
1373 RBIOS32(tmds_info
+ stride
+ 0x08);
1374 tmds
->tmds_pll
[i
].freq
=
1375 RBIOS16(tmds_info
+ stride
+ 0x10);
1380 DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
1381 tmds
->tmds_pll
[i
].freq
,
1382 tmds
->tmds_pll
[i
].value
);
1386 DRM_INFO("No TMDS info found in BIOS\n");
1392 bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder
*encoder
,
1393 struct radeon_encoder_ext_tmds
*tmds
)
1395 struct drm_device
*dev
= encoder
->base
.dev
;
1396 struct radeon_device
*rdev
= dev
->dev_private
;
1397 struct radeon_i2c_bus_rec i2c_bus
;
1399 /* default for macs */
1400 i2c_bus
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
1401 tmds
->i2c_bus
= radeon_i2c_lookup(rdev
, &i2c_bus
);
1403 /* XXX some macs have duallink chips */
1404 switch (rdev
->mode_info
.connector_table
) {
1405 case CT_POWERBOOK_EXTERNAL
:
1406 case CT_MINI_EXTERNAL
:
1408 tmds
->dvo_chip
= DVO_SIL164
;
1409 tmds
->slave_addr
= 0x70 >> 1; /* 7 bit addressing */
1416 bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder
*encoder
,
1417 struct radeon_encoder_ext_tmds
*tmds
)
1419 struct drm_device
*dev
= encoder
->base
.dev
;
1420 struct radeon_device
*rdev
= dev
->dev_private
;
1423 enum radeon_combios_ddc gpio
;
1424 struct radeon_i2c_bus_rec i2c_bus
;
1426 tmds
->i2c_bus
= NULL
;
1427 if (rdev
->flags
& RADEON_IS_IGP
) {
1428 i2c_bus
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
1429 tmds
->i2c_bus
= radeon_i2c_lookup(rdev
, &i2c_bus
);
1430 tmds
->dvo_chip
= DVO_SIL164
;
1431 tmds
->slave_addr
= 0x70 >> 1; /* 7 bit addressing */
1433 offset
= combios_get_table_offset(dev
, COMBIOS_EXT_TMDS_INFO_TABLE
);
1435 ver
= RBIOS8(offset
);
1436 DRM_DEBUG_KMS("External TMDS Table revision: %d\n", ver
);
1437 tmds
->slave_addr
= RBIOS8(offset
+ 4 + 2);
1438 tmds
->slave_addr
>>= 1; /* 7 bit addressing */
1439 gpio
= RBIOS8(offset
+ 4 + 3);
1440 if (gpio
== DDC_LCD
) {
1442 i2c_bus
.valid
= true;
1443 i2c_bus
.hw_capable
= true;
1444 i2c_bus
.mm_i2c
= true;
1445 i2c_bus
.i2c_id
= 0xa0;
1447 i2c_bus
= combios_setup_i2c_bus(rdev
, gpio
, 0, 0);
1448 tmds
->i2c_bus
= radeon_i2c_lookup(rdev
, &i2c_bus
);
1452 if (!tmds
->i2c_bus
) {
1453 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1460 bool radeon_get_legacy_connector_info_from_table(struct drm_device
*dev
)
1462 struct radeon_device
*rdev
= dev
->dev_private
;
1463 struct radeon_i2c_bus_rec ddc_i2c
;
1464 struct radeon_hpd hpd
;
1466 rdev
->mode_info
.connector_table
= radeon_connector_table
;
1467 if (rdev
->mode_info
.connector_table
== CT_NONE
) {
1468 #ifdef CONFIG_PPC_PMAC
1469 if (of_machine_is_compatible("PowerBook3,3")) {
1470 /* powerbook with VGA */
1471 rdev
->mode_info
.connector_table
= CT_POWERBOOK_VGA
;
1472 } else if (of_machine_is_compatible("PowerBook3,4") ||
1473 of_machine_is_compatible("PowerBook3,5")) {
1474 /* powerbook with internal tmds */
1475 rdev
->mode_info
.connector_table
= CT_POWERBOOK_INTERNAL
;
1476 } else if (of_machine_is_compatible("PowerBook5,1") ||
1477 of_machine_is_compatible("PowerBook5,2") ||
1478 of_machine_is_compatible("PowerBook5,3") ||
1479 of_machine_is_compatible("PowerBook5,4") ||
1480 of_machine_is_compatible("PowerBook5,5")) {
1481 /* powerbook with external single link tmds (sil164) */
1482 rdev
->mode_info
.connector_table
= CT_POWERBOOK_EXTERNAL
;
1483 } else if (of_machine_is_compatible("PowerBook5,6")) {
1484 /* powerbook with external dual or single link tmds */
1485 rdev
->mode_info
.connector_table
= CT_POWERBOOK_EXTERNAL
;
1486 } else if (of_machine_is_compatible("PowerBook5,7") ||
1487 of_machine_is_compatible("PowerBook5,8") ||
1488 of_machine_is_compatible("PowerBook5,9")) {
1489 /* PowerBook6,2 ? */
1490 /* powerbook with external dual link tmds (sil1178?) */
1491 rdev
->mode_info
.connector_table
= CT_POWERBOOK_EXTERNAL
;
1492 } else if (of_machine_is_compatible("PowerBook4,1") ||
1493 of_machine_is_compatible("PowerBook4,2") ||
1494 of_machine_is_compatible("PowerBook4,3") ||
1495 of_machine_is_compatible("PowerBook6,3") ||
1496 of_machine_is_compatible("PowerBook6,5") ||
1497 of_machine_is_compatible("PowerBook6,7")) {
1499 rdev
->mode_info
.connector_table
= CT_IBOOK
;
1500 } else if (of_machine_is_compatible("PowerMac4,4")) {
1502 rdev
->mode_info
.connector_table
= CT_EMAC
;
1503 } else if (of_machine_is_compatible("PowerMac10,1")) {
1504 /* mini with internal tmds */
1505 rdev
->mode_info
.connector_table
= CT_MINI_INTERNAL
;
1506 } else if (of_machine_is_compatible("PowerMac10,2")) {
1507 /* mini with external tmds */
1508 rdev
->mode_info
.connector_table
= CT_MINI_EXTERNAL
;
1509 } else if (of_machine_is_compatible("PowerMac12,1")) {
1511 /* imac g5 isight */
1512 rdev
->mode_info
.connector_table
= CT_IMAC_G5_ISIGHT
;
1513 } else if ((rdev
->pdev
->device
== 0x4a48) &&
1514 (rdev
->pdev
->subsystem_vendor
== 0x1002) &&
1515 (rdev
->pdev
->subsystem_device
== 0x4a48)) {
1517 rdev
->mode_info
.connector_table
= CT_MAC_X800
;
1518 } else if ((rdev
->pdev
->device
== 0x4150) &&
1519 (rdev
->pdev
->subsystem_vendor
== 0x1002) &&
1520 (rdev
->pdev
->subsystem_device
== 0x4150)) {
1522 rdev
->mode_info
.connector_table
= CT_MAC_G5_9600
;
1524 #endif /* CONFIG_PPC_PMAC */
1526 if (ASIC_IS_RN50(rdev
))
1527 rdev
->mode_info
.connector_table
= CT_RN50_POWER
;
1530 rdev
->mode_info
.connector_table
= CT_GENERIC
;
1533 switch (rdev
->mode_info
.connector_table
) {
1535 DRM_INFO("Connector Table: %d (generic)\n",
1536 rdev
->mode_info
.connector_table
);
1537 /* these are the most common settings */
1538 if (rdev
->flags
& RADEON_SINGLE_CRTC
) {
1539 /* VGA - primary dac */
1540 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1541 hpd
.hpd
= RADEON_HPD_NONE
;
1542 radeon_add_legacy_encoder(dev
,
1543 radeon_get_encoder_enum(dev
,
1544 ATOM_DEVICE_CRT1_SUPPORT
,
1546 ATOM_DEVICE_CRT1_SUPPORT
);
1547 radeon_add_legacy_connector(dev
, 0,
1548 ATOM_DEVICE_CRT1_SUPPORT
,
1549 DRM_MODE_CONNECTOR_VGA
,
1551 CONNECTOR_OBJECT_ID_VGA
,
1553 } else if (rdev
->flags
& RADEON_IS_MOBILITY
) {
1555 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_NONE_DETECTED
, 0, 0);
1556 hpd
.hpd
= RADEON_HPD_NONE
;
1557 radeon_add_legacy_encoder(dev
,
1558 radeon_get_encoder_enum(dev
,
1559 ATOM_DEVICE_LCD1_SUPPORT
,
1561 ATOM_DEVICE_LCD1_SUPPORT
);
1562 radeon_add_legacy_connector(dev
, 0,
1563 ATOM_DEVICE_LCD1_SUPPORT
,
1564 DRM_MODE_CONNECTOR_LVDS
,
1566 CONNECTOR_OBJECT_ID_LVDS
,
1569 /* VGA - primary dac */
1570 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1571 hpd
.hpd
= RADEON_HPD_NONE
;
1572 radeon_add_legacy_encoder(dev
,
1573 radeon_get_encoder_enum(dev
,
1574 ATOM_DEVICE_CRT1_SUPPORT
,
1576 ATOM_DEVICE_CRT1_SUPPORT
);
1577 radeon_add_legacy_connector(dev
, 1,
1578 ATOM_DEVICE_CRT1_SUPPORT
,
1579 DRM_MODE_CONNECTOR_VGA
,
1581 CONNECTOR_OBJECT_ID_VGA
,
1584 /* DVI-I - tv dac, int tmds */
1585 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1586 hpd
.hpd
= RADEON_HPD_1
;
1587 radeon_add_legacy_encoder(dev
,
1588 radeon_get_encoder_enum(dev
,
1589 ATOM_DEVICE_DFP1_SUPPORT
,
1591 ATOM_DEVICE_DFP1_SUPPORT
);
1592 radeon_add_legacy_encoder(dev
,
1593 radeon_get_encoder_enum(dev
,
1594 ATOM_DEVICE_CRT2_SUPPORT
,
1596 ATOM_DEVICE_CRT2_SUPPORT
);
1597 radeon_add_legacy_connector(dev
, 0,
1598 ATOM_DEVICE_DFP1_SUPPORT
|
1599 ATOM_DEVICE_CRT2_SUPPORT
,
1600 DRM_MODE_CONNECTOR_DVII
,
1602 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
1605 /* VGA - primary dac */
1606 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1607 hpd
.hpd
= RADEON_HPD_NONE
;
1608 radeon_add_legacy_encoder(dev
,
1609 radeon_get_encoder_enum(dev
,
1610 ATOM_DEVICE_CRT1_SUPPORT
,
1612 ATOM_DEVICE_CRT1_SUPPORT
);
1613 radeon_add_legacy_connector(dev
, 1,
1614 ATOM_DEVICE_CRT1_SUPPORT
,
1615 DRM_MODE_CONNECTOR_VGA
,
1617 CONNECTOR_OBJECT_ID_VGA
,
1621 if (rdev
->family
!= CHIP_R100
&& rdev
->family
!= CHIP_R200
) {
1623 ddc_i2c
.valid
= false;
1624 hpd
.hpd
= RADEON_HPD_NONE
;
1625 radeon_add_legacy_encoder(dev
,
1626 radeon_get_encoder_enum(dev
,
1627 ATOM_DEVICE_TV1_SUPPORT
,
1629 ATOM_DEVICE_TV1_SUPPORT
);
1630 radeon_add_legacy_connector(dev
, 2,
1631 ATOM_DEVICE_TV1_SUPPORT
,
1632 DRM_MODE_CONNECTOR_SVIDEO
,
1634 CONNECTOR_OBJECT_ID_SVIDEO
,
1639 DRM_INFO("Connector Table: %d (ibook)\n",
1640 rdev
->mode_info
.connector_table
);
1642 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1643 hpd
.hpd
= RADEON_HPD_NONE
;
1644 radeon_add_legacy_encoder(dev
,
1645 radeon_get_encoder_enum(dev
,
1646 ATOM_DEVICE_LCD1_SUPPORT
,
1648 ATOM_DEVICE_LCD1_SUPPORT
);
1649 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_LCD1_SUPPORT
,
1650 DRM_MODE_CONNECTOR_LVDS
, &ddc_i2c
,
1651 CONNECTOR_OBJECT_ID_LVDS
,
1654 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1655 hpd
.hpd
= RADEON_HPD_NONE
;
1656 radeon_add_legacy_encoder(dev
,
1657 radeon_get_encoder_enum(dev
,
1658 ATOM_DEVICE_CRT2_SUPPORT
,
1660 ATOM_DEVICE_CRT2_SUPPORT
);
1661 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_CRT2_SUPPORT
,
1662 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1663 CONNECTOR_OBJECT_ID_VGA
,
1666 ddc_i2c
.valid
= false;
1667 hpd
.hpd
= RADEON_HPD_NONE
;
1668 radeon_add_legacy_encoder(dev
,
1669 radeon_get_encoder_enum(dev
,
1670 ATOM_DEVICE_TV1_SUPPORT
,
1672 ATOM_DEVICE_TV1_SUPPORT
);
1673 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1674 DRM_MODE_CONNECTOR_SVIDEO
,
1676 CONNECTOR_OBJECT_ID_SVIDEO
,
1679 case CT_POWERBOOK_EXTERNAL
:
1680 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1681 rdev
->mode_info
.connector_table
);
1683 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1684 hpd
.hpd
= RADEON_HPD_NONE
;
1685 radeon_add_legacy_encoder(dev
,
1686 radeon_get_encoder_enum(dev
,
1687 ATOM_DEVICE_LCD1_SUPPORT
,
1689 ATOM_DEVICE_LCD1_SUPPORT
);
1690 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_LCD1_SUPPORT
,
1691 DRM_MODE_CONNECTOR_LVDS
, &ddc_i2c
,
1692 CONNECTOR_OBJECT_ID_LVDS
,
1694 /* DVI-I - primary dac, ext tmds */
1695 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1696 hpd
.hpd
= RADEON_HPD_2
; /* ??? */
1697 radeon_add_legacy_encoder(dev
,
1698 radeon_get_encoder_enum(dev
,
1699 ATOM_DEVICE_DFP2_SUPPORT
,
1701 ATOM_DEVICE_DFP2_SUPPORT
);
1702 radeon_add_legacy_encoder(dev
,
1703 radeon_get_encoder_enum(dev
,
1704 ATOM_DEVICE_CRT1_SUPPORT
,
1706 ATOM_DEVICE_CRT1_SUPPORT
);
1707 /* XXX some are SL */
1708 radeon_add_legacy_connector(dev
, 1,
1709 ATOM_DEVICE_DFP2_SUPPORT
|
1710 ATOM_DEVICE_CRT1_SUPPORT
,
1711 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
1712 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
,
1715 ddc_i2c
.valid
= false;
1716 hpd
.hpd
= RADEON_HPD_NONE
;
1717 radeon_add_legacy_encoder(dev
,
1718 radeon_get_encoder_enum(dev
,
1719 ATOM_DEVICE_TV1_SUPPORT
,
1721 ATOM_DEVICE_TV1_SUPPORT
);
1722 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1723 DRM_MODE_CONNECTOR_SVIDEO
,
1725 CONNECTOR_OBJECT_ID_SVIDEO
,
1728 case CT_POWERBOOK_INTERNAL
:
1729 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1730 rdev
->mode_info
.connector_table
);
1732 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1733 hpd
.hpd
= RADEON_HPD_NONE
;
1734 radeon_add_legacy_encoder(dev
,
1735 radeon_get_encoder_enum(dev
,
1736 ATOM_DEVICE_LCD1_SUPPORT
,
1738 ATOM_DEVICE_LCD1_SUPPORT
);
1739 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_LCD1_SUPPORT
,
1740 DRM_MODE_CONNECTOR_LVDS
, &ddc_i2c
,
1741 CONNECTOR_OBJECT_ID_LVDS
,
1743 /* DVI-I - primary dac, int tmds */
1744 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1745 hpd
.hpd
= RADEON_HPD_1
; /* ??? */
1746 radeon_add_legacy_encoder(dev
,
1747 radeon_get_encoder_enum(dev
,
1748 ATOM_DEVICE_DFP1_SUPPORT
,
1750 ATOM_DEVICE_DFP1_SUPPORT
);
1751 radeon_add_legacy_encoder(dev
,
1752 radeon_get_encoder_enum(dev
,
1753 ATOM_DEVICE_CRT1_SUPPORT
,
1755 ATOM_DEVICE_CRT1_SUPPORT
);
1756 radeon_add_legacy_connector(dev
, 1,
1757 ATOM_DEVICE_DFP1_SUPPORT
|
1758 ATOM_DEVICE_CRT1_SUPPORT
,
1759 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
1760 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
1763 ddc_i2c
.valid
= false;
1764 hpd
.hpd
= RADEON_HPD_NONE
;
1765 radeon_add_legacy_encoder(dev
,
1766 radeon_get_encoder_enum(dev
,
1767 ATOM_DEVICE_TV1_SUPPORT
,
1769 ATOM_DEVICE_TV1_SUPPORT
);
1770 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1771 DRM_MODE_CONNECTOR_SVIDEO
,
1773 CONNECTOR_OBJECT_ID_SVIDEO
,
1776 case CT_POWERBOOK_VGA
:
1777 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1778 rdev
->mode_info
.connector_table
);
1780 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1781 hpd
.hpd
= RADEON_HPD_NONE
;
1782 radeon_add_legacy_encoder(dev
,
1783 radeon_get_encoder_enum(dev
,
1784 ATOM_DEVICE_LCD1_SUPPORT
,
1786 ATOM_DEVICE_LCD1_SUPPORT
);
1787 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_LCD1_SUPPORT
,
1788 DRM_MODE_CONNECTOR_LVDS
, &ddc_i2c
,
1789 CONNECTOR_OBJECT_ID_LVDS
,
1791 /* VGA - primary dac */
1792 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1793 hpd
.hpd
= RADEON_HPD_NONE
;
1794 radeon_add_legacy_encoder(dev
,
1795 radeon_get_encoder_enum(dev
,
1796 ATOM_DEVICE_CRT1_SUPPORT
,
1798 ATOM_DEVICE_CRT1_SUPPORT
);
1799 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_CRT1_SUPPORT
,
1800 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1801 CONNECTOR_OBJECT_ID_VGA
,
1804 ddc_i2c
.valid
= false;
1805 hpd
.hpd
= RADEON_HPD_NONE
;
1806 radeon_add_legacy_encoder(dev
,
1807 radeon_get_encoder_enum(dev
,
1808 ATOM_DEVICE_TV1_SUPPORT
,
1810 ATOM_DEVICE_TV1_SUPPORT
);
1811 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1812 DRM_MODE_CONNECTOR_SVIDEO
,
1814 CONNECTOR_OBJECT_ID_SVIDEO
,
1817 case CT_MINI_EXTERNAL
:
1818 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1819 rdev
->mode_info
.connector_table
);
1820 /* DVI-I - tv dac, ext tmds */
1821 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
1822 hpd
.hpd
= RADEON_HPD_2
; /* ??? */
1823 radeon_add_legacy_encoder(dev
,
1824 radeon_get_encoder_enum(dev
,
1825 ATOM_DEVICE_DFP2_SUPPORT
,
1827 ATOM_DEVICE_DFP2_SUPPORT
);
1828 radeon_add_legacy_encoder(dev
,
1829 radeon_get_encoder_enum(dev
,
1830 ATOM_DEVICE_CRT2_SUPPORT
,
1832 ATOM_DEVICE_CRT2_SUPPORT
);
1833 /* XXX are any DL? */
1834 radeon_add_legacy_connector(dev
, 0,
1835 ATOM_DEVICE_DFP2_SUPPORT
|
1836 ATOM_DEVICE_CRT2_SUPPORT
,
1837 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
1838 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
1841 ddc_i2c
.valid
= false;
1842 hpd
.hpd
= RADEON_HPD_NONE
;
1843 radeon_add_legacy_encoder(dev
,
1844 radeon_get_encoder_enum(dev
,
1845 ATOM_DEVICE_TV1_SUPPORT
,
1847 ATOM_DEVICE_TV1_SUPPORT
);
1848 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_TV1_SUPPORT
,
1849 DRM_MODE_CONNECTOR_SVIDEO
,
1851 CONNECTOR_OBJECT_ID_SVIDEO
,
1854 case CT_MINI_INTERNAL
:
1855 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1856 rdev
->mode_info
.connector_table
);
1857 /* DVI-I - tv dac, int tmds */
1858 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
1859 hpd
.hpd
= RADEON_HPD_1
; /* ??? */
1860 radeon_add_legacy_encoder(dev
,
1861 radeon_get_encoder_enum(dev
,
1862 ATOM_DEVICE_DFP1_SUPPORT
,
1864 ATOM_DEVICE_DFP1_SUPPORT
);
1865 radeon_add_legacy_encoder(dev
,
1866 radeon_get_encoder_enum(dev
,
1867 ATOM_DEVICE_CRT2_SUPPORT
,
1869 ATOM_DEVICE_CRT2_SUPPORT
);
1870 radeon_add_legacy_connector(dev
, 0,
1871 ATOM_DEVICE_DFP1_SUPPORT
|
1872 ATOM_DEVICE_CRT2_SUPPORT
,
1873 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
1874 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
1877 ddc_i2c
.valid
= false;
1878 hpd
.hpd
= RADEON_HPD_NONE
;
1879 radeon_add_legacy_encoder(dev
,
1880 radeon_get_encoder_enum(dev
,
1881 ATOM_DEVICE_TV1_SUPPORT
,
1883 ATOM_DEVICE_TV1_SUPPORT
);
1884 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_TV1_SUPPORT
,
1885 DRM_MODE_CONNECTOR_SVIDEO
,
1887 CONNECTOR_OBJECT_ID_SVIDEO
,
1890 case CT_IMAC_G5_ISIGHT
:
1891 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1892 rdev
->mode_info
.connector_table
);
1893 /* DVI-D - int tmds */
1894 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
1895 hpd
.hpd
= RADEON_HPD_1
; /* ??? */
1896 radeon_add_legacy_encoder(dev
,
1897 radeon_get_encoder_enum(dev
,
1898 ATOM_DEVICE_DFP1_SUPPORT
,
1900 ATOM_DEVICE_DFP1_SUPPORT
);
1901 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_DFP1_SUPPORT
,
1902 DRM_MODE_CONNECTOR_DVID
, &ddc_i2c
,
1903 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D
,
1906 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
1907 hpd
.hpd
= RADEON_HPD_NONE
;
1908 radeon_add_legacy_encoder(dev
,
1909 radeon_get_encoder_enum(dev
,
1910 ATOM_DEVICE_CRT2_SUPPORT
,
1912 ATOM_DEVICE_CRT2_SUPPORT
);
1913 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_CRT2_SUPPORT
,
1914 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1915 CONNECTOR_OBJECT_ID_VGA
,
1918 ddc_i2c
.valid
= false;
1919 hpd
.hpd
= RADEON_HPD_NONE
;
1920 radeon_add_legacy_encoder(dev
,
1921 radeon_get_encoder_enum(dev
,
1922 ATOM_DEVICE_TV1_SUPPORT
,
1924 ATOM_DEVICE_TV1_SUPPORT
);
1925 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1926 DRM_MODE_CONNECTOR_SVIDEO
,
1928 CONNECTOR_OBJECT_ID_SVIDEO
,
1932 DRM_INFO("Connector Table: %d (emac)\n",
1933 rdev
->mode_info
.connector_table
);
1934 /* VGA - primary dac */
1935 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1936 hpd
.hpd
= RADEON_HPD_NONE
;
1937 radeon_add_legacy_encoder(dev
,
1938 radeon_get_encoder_enum(dev
,
1939 ATOM_DEVICE_CRT1_SUPPORT
,
1941 ATOM_DEVICE_CRT1_SUPPORT
);
1942 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_CRT1_SUPPORT
,
1943 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1944 CONNECTOR_OBJECT_ID_VGA
,
1947 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
1948 hpd
.hpd
= RADEON_HPD_NONE
;
1949 radeon_add_legacy_encoder(dev
,
1950 radeon_get_encoder_enum(dev
,
1951 ATOM_DEVICE_CRT2_SUPPORT
,
1953 ATOM_DEVICE_CRT2_SUPPORT
);
1954 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_CRT2_SUPPORT
,
1955 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1956 CONNECTOR_OBJECT_ID_VGA
,
1959 ddc_i2c
.valid
= false;
1960 hpd
.hpd
= RADEON_HPD_NONE
;
1961 radeon_add_legacy_encoder(dev
,
1962 radeon_get_encoder_enum(dev
,
1963 ATOM_DEVICE_TV1_SUPPORT
,
1965 ATOM_DEVICE_TV1_SUPPORT
);
1966 radeon_add_legacy_connector(dev
, 2, ATOM_DEVICE_TV1_SUPPORT
,
1967 DRM_MODE_CONNECTOR_SVIDEO
,
1969 CONNECTOR_OBJECT_ID_SVIDEO
,
1973 DRM_INFO("Connector Table: %d (rn50-power)\n",
1974 rdev
->mode_info
.connector_table
);
1975 /* VGA - primary dac */
1976 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
1977 hpd
.hpd
= RADEON_HPD_NONE
;
1978 radeon_add_legacy_encoder(dev
,
1979 radeon_get_encoder_enum(dev
,
1980 ATOM_DEVICE_CRT1_SUPPORT
,
1982 ATOM_DEVICE_CRT1_SUPPORT
);
1983 radeon_add_legacy_connector(dev
, 0, ATOM_DEVICE_CRT1_SUPPORT
,
1984 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1985 CONNECTOR_OBJECT_ID_VGA
,
1987 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_CRT2
, 0, 0);
1988 hpd
.hpd
= RADEON_HPD_NONE
;
1989 radeon_add_legacy_encoder(dev
,
1990 radeon_get_encoder_enum(dev
,
1991 ATOM_DEVICE_CRT2_SUPPORT
,
1993 ATOM_DEVICE_CRT2_SUPPORT
);
1994 radeon_add_legacy_connector(dev
, 1, ATOM_DEVICE_CRT2_SUPPORT
,
1995 DRM_MODE_CONNECTOR_VGA
, &ddc_i2c
,
1996 CONNECTOR_OBJECT_ID_VGA
,
2000 DRM_INFO("Connector Table: %d (mac x800)\n",
2001 rdev
->mode_info
.connector_table
);
2002 /* DVI - primary dac, internal tmds */
2003 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
2004 hpd
.hpd
= RADEON_HPD_1
; /* ??? */
2005 radeon_add_legacy_encoder(dev
,
2006 radeon_get_encoder_enum(dev
,
2007 ATOM_DEVICE_DFP1_SUPPORT
,
2009 ATOM_DEVICE_DFP1_SUPPORT
);
2010 radeon_add_legacy_encoder(dev
,
2011 radeon_get_encoder_enum(dev
,
2012 ATOM_DEVICE_CRT1_SUPPORT
,
2014 ATOM_DEVICE_CRT1_SUPPORT
);
2015 radeon_add_legacy_connector(dev
, 0,
2016 ATOM_DEVICE_DFP1_SUPPORT
|
2017 ATOM_DEVICE_CRT1_SUPPORT
,
2018 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
2019 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
2021 /* DVI - tv dac, dvo */
2022 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_MONID
, 0, 0);
2023 hpd
.hpd
= RADEON_HPD_2
; /* ??? */
2024 radeon_add_legacy_encoder(dev
,
2025 radeon_get_encoder_enum(dev
,
2026 ATOM_DEVICE_DFP2_SUPPORT
,
2028 ATOM_DEVICE_DFP2_SUPPORT
);
2029 radeon_add_legacy_encoder(dev
,
2030 radeon_get_encoder_enum(dev
,
2031 ATOM_DEVICE_CRT2_SUPPORT
,
2033 ATOM_DEVICE_CRT2_SUPPORT
);
2034 radeon_add_legacy_connector(dev
, 1,
2035 ATOM_DEVICE_DFP2_SUPPORT
|
2036 ATOM_DEVICE_CRT2_SUPPORT
,
2037 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
2038 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
,
2041 case CT_MAC_G5_9600
:
2042 DRM_INFO("Connector Table: %d (mac g5 9600)\n",
2043 rdev
->mode_info
.connector_table
);
2044 /* DVI - tv dac, dvo */
2045 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
2046 hpd
.hpd
= RADEON_HPD_1
; /* ??? */
2047 radeon_add_legacy_encoder(dev
,
2048 radeon_get_encoder_enum(dev
,
2049 ATOM_DEVICE_DFP2_SUPPORT
,
2051 ATOM_DEVICE_DFP2_SUPPORT
);
2052 radeon_add_legacy_encoder(dev
,
2053 radeon_get_encoder_enum(dev
,
2054 ATOM_DEVICE_CRT2_SUPPORT
,
2056 ATOM_DEVICE_CRT2_SUPPORT
);
2057 radeon_add_legacy_connector(dev
, 0,
2058 ATOM_DEVICE_DFP2_SUPPORT
|
2059 ATOM_DEVICE_CRT2_SUPPORT
,
2060 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
2061 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
2063 /* ADC - primary dac, internal tmds */
2064 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
2065 hpd
.hpd
= RADEON_HPD_2
; /* ??? */
2066 radeon_add_legacy_encoder(dev
,
2067 radeon_get_encoder_enum(dev
,
2068 ATOM_DEVICE_DFP1_SUPPORT
,
2070 ATOM_DEVICE_DFP1_SUPPORT
);
2071 radeon_add_legacy_encoder(dev
,
2072 radeon_get_encoder_enum(dev
,
2073 ATOM_DEVICE_CRT1_SUPPORT
,
2075 ATOM_DEVICE_CRT1_SUPPORT
);
2076 radeon_add_legacy_connector(dev
, 1,
2077 ATOM_DEVICE_DFP1_SUPPORT
|
2078 ATOM_DEVICE_CRT1_SUPPORT
,
2079 DRM_MODE_CONNECTOR_DVII
, &ddc_i2c
,
2080 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
2084 DRM_INFO("Connector table: %d (invalid)\n",
2085 rdev
->mode_info
.connector_table
);
2089 radeon_link_encoder_connector(dev
);
2094 static bool radeon_apply_legacy_quirks(struct drm_device
*dev
,
2096 enum radeon_combios_connector
2098 struct radeon_i2c_bus_rec
*ddc_i2c
,
2099 struct radeon_hpd
*hpd
)
2102 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
2103 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
2104 if (dev
->pdev
->device
== 0x515e &&
2105 dev
->pdev
->subsystem_vendor
== 0x1014) {
2106 if (*legacy_connector
== CONNECTOR_CRT_LEGACY
&&
2107 ddc_i2c
->mask_clk_reg
== RADEON_GPIO_CRT2_DDC
)
2111 /* X300 card with extra non-existent DVI port */
2112 if (dev
->pdev
->device
== 0x5B60 &&
2113 dev
->pdev
->subsystem_vendor
== 0x17af &&
2114 dev
->pdev
->subsystem_device
== 0x201e && bios_index
== 2) {
2115 if (*legacy_connector
== CONNECTOR_DVI_I_LEGACY
)
2122 static bool radeon_apply_legacy_tv_quirks(struct drm_device
*dev
)
2124 /* Acer 5102 has non-existent TV port */
2125 if (dev
->pdev
->device
== 0x5975 &&
2126 dev
->pdev
->subsystem_vendor
== 0x1025 &&
2127 dev
->pdev
->subsystem_device
== 0x009f)
2130 /* HP dc5750 has non-existent TV port */
2131 if (dev
->pdev
->device
== 0x5974 &&
2132 dev
->pdev
->subsystem_vendor
== 0x103c &&
2133 dev
->pdev
->subsystem_device
== 0x280a)
2136 /* MSI S270 has non-existent TV port */
2137 if (dev
->pdev
->device
== 0x5955 &&
2138 dev
->pdev
->subsystem_vendor
== 0x1462 &&
2139 dev
->pdev
->subsystem_device
== 0x0131)
2145 static uint16_t combios_check_dl_dvi(struct drm_device
*dev
, int is_dvi_d
)
2147 struct radeon_device
*rdev
= dev
->dev_private
;
2148 uint32_t ext_tmds_info
;
2150 if (rdev
->flags
& RADEON_IS_IGP
) {
2152 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D
;
2154 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
;
2156 ext_tmds_info
= combios_get_table_offset(dev
, COMBIOS_EXT_TMDS_INFO_TABLE
);
2157 if (ext_tmds_info
) {
2158 uint8_t rev
= RBIOS8(ext_tmds_info
);
2159 uint8_t flags
= RBIOS8(ext_tmds_info
+ 4 + 5);
2162 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
;
2164 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
;
2168 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
;
2170 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
;
2175 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D
;
2177 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
;
2180 bool radeon_get_legacy_connector_info_from_bios(struct drm_device
*dev
)
2182 struct radeon_device
*rdev
= dev
->dev_private
;
2183 uint32_t conn_info
, entry
, devices
;
2184 uint16_t tmp
, connector_object_id
;
2185 enum radeon_combios_ddc ddc_type
;
2186 enum radeon_combios_connector connector
;
2188 struct radeon_i2c_bus_rec ddc_i2c
;
2189 struct radeon_hpd hpd
;
2191 conn_info
= combios_get_table_offset(dev
, COMBIOS_CONNECTOR_INFO_TABLE
);
2193 for (i
= 0; i
< 4; i
++) {
2194 entry
= conn_info
+ 2 + i
* 2;
2196 if (!RBIOS16(entry
))
2199 tmp
= RBIOS16(entry
);
2201 connector
= (tmp
>> 12) & 0xf;
2203 ddc_type
= (tmp
>> 8) & 0xf;
2204 ddc_i2c
= combios_setup_i2c_bus(rdev
, ddc_type
, 0, 0);
2206 switch (connector
) {
2207 case CONNECTOR_PROPRIETARY_LEGACY
:
2208 case CONNECTOR_DVI_I_LEGACY
:
2209 case CONNECTOR_DVI_D_LEGACY
:
2210 if ((tmp
>> 4) & 0x1)
2211 hpd
.hpd
= RADEON_HPD_2
;
2213 hpd
.hpd
= RADEON_HPD_1
;
2216 hpd
.hpd
= RADEON_HPD_NONE
;
2220 if (!radeon_apply_legacy_quirks(dev
, i
, &connector
,
2224 switch (connector
) {
2225 case CONNECTOR_PROPRIETARY_LEGACY
:
2226 if ((tmp
>> 4) & 0x1)
2227 devices
= ATOM_DEVICE_DFP2_SUPPORT
;
2229 devices
= ATOM_DEVICE_DFP1_SUPPORT
;
2230 radeon_add_legacy_encoder(dev
,
2231 radeon_get_encoder_enum
2234 radeon_add_legacy_connector(dev
, i
, devices
,
2235 legacy_connector_convert
2238 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D
,
2241 case CONNECTOR_CRT_LEGACY
:
2243 devices
= ATOM_DEVICE_CRT2_SUPPORT
;
2244 radeon_add_legacy_encoder(dev
,
2245 radeon_get_encoder_enum
2247 ATOM_DEVICE_CRT2_SUPPORT
,
2249 ATOM_DEVICE_CRT2_SUPPORT
);
2251 devices
= ATOM_DEVICE_CRT1_SUPPORT
;
2252 radeon_add_legacy_encoder(dev
,
2253 radeon_get_encoder_enum
2255 ATOM_DEVICE_CRT1_SUPPORT
,
2257 ATOM_DEVICE_CRT1_SUPPORT
);
2259 radeon_add_legacy_connector(dev
,
2262 legacy_connector_convert
2265 CONNECTOR_OBJECT_ID_VGA
,
2268 case CONNECTOR_DVI_I_LEGACY
:
2271 devices
|= ATOM_DEVICE_CRT2_SUPPORT
;
2272 radeon_add_legacy_encoder(dev
,
2273 radeon_get_encoder_enum
2275 ATOM_DEVICE_CRT2_SUPPORT
,
2277 ATOM_DEVICE_CRT2_SUPPORT
);
2279 devices
|= ATOM_DEVICE_CRT1_SUPPORT
;
2280 radeon_add_legacy_encoder(dev
,
2281 radeon_get_encoder_enum
2283 ATOM_DEVICE_CRT1_SUPPORT
,
2285 ATOM_DEVICE_CRT1_SUPPORT
);
2287 if ((tmp
>> 4) & 0x1) {
2288 devices
|= ATOM_DEVICE_DFP2_SUPPORT
;
2289 radeon_add_legacy_encoder(dev
,
2290 radeon_get_encoder_enum
2292 ATOM_DEVICE_DFP2_SUPPORT
,
2294 ATOM_DEVICE_DFP2_SUPPORT
);
2295 connector_object_id
= combios_check_dl_dvi(dev
, 0);
2297 devices
|= ATOM_DEVICE_DFP1_SUPPORT
;
2298 radeon_add_legacy_encoder(dev
,
2299 radeon_get_encoder_enum
2301 ATOM_DEVICE_DFP1_SUPPORT
,
2303 ATOM_DEVICE_DFP1_SUPPORT
);
2304 connector_object_id
= CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
;
2306 radeon_add_legacy_connector(dev
,
2309 legacy_connector_convert
2312 connector_object_id
,
2315 case CONNECTOR_DVI_D_LEGACY
:
2316 if ((tmp
>> 4) & 0x1) {
2317 devices
= ATOM_DEVICE_DFP2_SUPPORT
;
2318 connector_object_id
= combios_check_dl_dvi(dev
, 1);
2320 devices
= ATOM_DEVICE_DFP1_SUPPORT
;
2321 connector_object_id
= CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
;
2323 radeon_add_legacy_encoder(dev
,
2324 radeon_get_encoder_enum
2327 radeon_add_legacy_connector(dev
, i
, devices
,
2328 legacy_connector_convert
2331 connector_object_id
,
2334 case CONNECTOR_CTV_LEGACY
:
2335 case CONNECTOR_STV_LEGACY
:
2336 radeon_add_legacy_encoder(dev
,
2337 radeon_get_encoder_enum
2339 ATOM_DEVICE_TV1_SUPPORT
,
2341 ATOM_DEVICE_TV1_SUPPORT
);
2342 radeon_add_legacy_connector(dev
, i
,
2343 ATOM_DEVICE_TV1_SUPPORT
,
2344 legacy_connector_convert
2347 CONNECTOR_OBJECT_ID_SVIDEO
,
2351 DRM_ERROR("Unknown connector type: %d\n",
2358 uint16_t tmds_info
=
2359 combios_get_table_offset(dev
, COMBIOS_DFP_INFO_TABLE
);
2361 DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n");
2363 radeon_add_legacy_encoder(dev
,
2364 radeon_get_encoder_enum(dev
,
2365 ATOM_DEVICE_CRT1_SUPPORT
,
2367 ATOM_DEVICE_CRT1_SUPPORT
);
2368 radeon_add_legacy_encoder(dev
,
2369 radeon_get_encoder_enum(dev
,
2370 ATOM_DEVICE_DFP1_SUPPORT
,
2372 ATOM_DEVICE_DFP1_SUPPORT
);
2374 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_DVI
, 0, 0);
2375 hpd
.hpd
= RADEON_HPD_1
;
2376 radeon_add_legacy_connector(dev
,
2378 ATOM_DEVICE_CRT1_SUPPORT
|
2379 ATOM_DEVICE_DFP1_SUPPORT
,
2380 DRM_MODE_CONNECTOR_DVII
,
2382 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
,
2386 combios_get_table_offset(dev
, COMBIOS_CRT_INFO_TABLE
);
2387 DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n");
2389 radeon_add_legacy_encoder(dev
,
2390 radeon_get_encoder_enum(dev
,
2391 ATOM_DEVICE_CRT1_SUPPORT
,
2393 ATOM_DEVICE_CRT1_SUPPORT
);
2394 ddc_i2c
= combios_setup_i2c_bus(rdev
, DDC_VGA
, 0, 0);
2395 hpd
.hpd
= RADEON_HPD_NONE
;
2396 radeon_add_legacy_connector(dev
,
2398 ATOM_DEVICE_CRT1_SUPPORT
,
2399 DRM_MODE_CONNECTOR_VGA
,
2401 CONNECTOR_OBJECT_ID_VGA
,
2404 DRM_DEBUG_KMS("No connector info found\n");
2410 if (rdev
->flags
& RADEON_IS_MOBILITY
|| rdev
->flags
& RADEON_IS_IGP
) {
2412 combios_get_table_offset(dev
, COMBIOS_LCD_INFO_TABLE
);
2414 uint16_t lcd_ddc_info
=
2415 combios_get_table_offset(dev
,
2416 COMBIOS_LCD_DDC_INFO_TABLE
);
2418 radeon_add_legacy_encoder(dev
,
2419 radeon_get_encoder_enum(dev
,
2420 ATOM_DEVICE_LCD1_SUPPORT
,
2422 ATOM_DEVICE_LCD1_SUPPORT
);
2425 ddc_type
= RBIOS8(lcd_ddc_info
+ 2);
2429 combios_setup_i2c_bus(rdev
,
2431 RBIOS32(lcd_ddc_info
+ 3),
2432 RBIOS32(lcd_ddc_info
+ 7));
2433 radeon_i2c_add(rdev
, &ddc_i2c
, "LCD");
2437 combios_setup_i2c_bus(rdev
,
2439 RBIOS32(lcd_ddc_info
+ 3),
2440 RBIOS32(lcd_ddc_info
+ 7));
2441 radeon_i2c_add(rdev
, &ddc_i2c
, "LCD");
2445 combios_setup_i2c_bus(rdev
, ddc_type
, 0, 0);
2448 DRM_DEBUG_KMS("LCD DDC Info Table found!\n");
2450 ddc_i2c
.valid
= false;
2452 hpd
.hpd
= RADEON_HPD_NONE
;
2453 radeon_add_legacy_connector(dev
,
2455 ATOM_DEVICE_LCD1_SUPPORT
,
2456 DRM_MODE_CONNECTOR_LVDS
,
2458 CONNECTOR_OBJECT_ID_LVDS
,
2463 /* check TV table */
2464 if (rdev
->family
!= CHIP_R100
&& rdev
->family
!= CHIP_R200
) {
2466 combios_get_table_offset(dev
, COMBIOS_TV_INFO_TABLE
);
2468 if (RBIOS8(tv_info
+ 6) == 'T') {
2469 if (radeon_apply_legacy_tv_quirks(dev
)) {
2470 hpd
.hpd
= RADEON_HPD_NONE
;
2471 ddc_i2c
.valid
= false;
2472 radeon_add_legacy_encoder(dev
,
2473 radeon_get_encoder_enum
2475 ATOM_DEVICE_TV1_SUPPORT
,
2477 ATOM_DEVICE_TV1_SUPPORT
);
2478 radeon_add_legacy_connector(dev
, 6,
2479 ATOM_DEVICE_TV1_SUPPORT
,
2480 DRM_MODE_CONNECTOR_SVIDEO
,
2482 CONNECTOR_OBJECT_ID_SVIDEO
,
2489 radeon_link_encoder_connector(dev
);
2494 void radeon_combios_get_power_modes(struct radeon_device
*rdev
)
2496 struct drm_device
*dev
= rdev
->ddev
;
2497 u16 offset
, misc
, misc2
= 0;
2498 u8 rev
, blocks
, tmp
;
2499 int state_index
= 0;
2501 rdev
->pm
.default_power_state_index
= -1;
2503 /* allocate 2 power states */
2504 rdev
->pm
.power_state
= kzalloc(sizeof(struct radeon_power_state
) * 2, GFP_KERNEL
);
2505 if (!rdev
->pm
.power_state
) {
2506 rdev
->pm
.default_power_state_index
= state_index
;
2507 rdev
->pm
.num_power_states
= 0;
2509 rdev
->pm
.current_power_state_index
= rdev
->pm
.default_power_state_index
;
2510 rdev
->pm
.current_clock_mode_index
= 0;
2514 if (rdev
->flags
& RADEON_IS_MOBILITY
) {
2515 offset
= combios_get_table_offset(dev
, COMBIOS_POWERPLAY_INFO_TABLE
);
2517 rev
= RBIOS8(offset
);
2518 blocks
= RBIOS8(offset
+ 0x2);
2519 /* power mode 0 tends to be the only valid one */
2520 rdev
->pm
.power_state
[state_index
].num_clock_modes
= 1;
2521 rdev
->pm
.power_state
[state_index
].clock_info
[0].mclk
= RBIOS32(offset
+ 0x5 + 0x2);
2522 rdev
->pm
.power_state
[state_index
].clock_info
[0].sclk
= RBIOS32(offset
+ 0x5 + 0x6);
2523 if ((rdev
->pm
.power_state
[state_index
].clock_info
[0].mclk
== 0) ||
2524 (rdev
->pm
.power_state
[state_index
].clock_info
[0].sclk
== 0))
2526 rdev
->pm
.power_state
[state_index
].type
=
2527 POWER_STATE_TYPE_BATTERY
;
2528 misc
= RBIOS16(offset
+ 0x5 + 0x0);
2530 misc2
= RBIOS16(offset
+ 0x5 + 0xe);
2531 rdev
->pm
.power_state
[state_index
].misc
= misc
;
2532 rdev
->pm
.power_state
[state_index
].misc2
= misc2
;
2534 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.type
= VOLTAGE_GPIO
;
2536 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.active_high
=
2539 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.active_high
=
2541 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.valid
= true;
2543 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.reg
=
2544 RBIOS16(offset
+ 0x5 + 0xb) * 4;
2545 tmp
= RBIOS8(offset
+ 0x5 + 0xd);
2546 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.mask
= (1 << tmp
);
2548 u8 entries
= RBIOS8(offset
+ 0x5 + 0xb);
2549 u16 voltage_table_offset
= RBIOS16(offset
+ 0x5 + 0xc);
2550 if (entries
&& voltage_table_offset
) {
2551 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.reg
=
2552 RBIOS16(voltage_table_offset
) * 4;
2553 tmp
= RBIOS8(voltage_table_offset
+ 0x2);
2554 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.mask
= (1 << tmp
);
2556 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.gpio
.valid
= false;
2558 switch ((misc2
& 0x700) >> 8) {
2561 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.delay
= 0;
2564 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.delay
= 33;
2567 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.delay
= 66;
2570 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.delay
= 99;
2573 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.delay
= 132;
2577 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.type
= VOLTAGE_NONE
;
2579 rdev
->pm
.power_state
[state_index
].pcie_lanes
=
2580 RBIOS8(offset
+ 0x5 + 0x10);
2581 rdev
->pm
.power_state
[state_index
].flags
= RADEON_PM_STATE_SINGLE_DISPLAY_ONLY
;
2584 /* XXX figure out some good default low power mode for mobility cards w/out power tables */
2587 /* XXX figure out some good default low power mode for desktop cards */
2591 /* add the default mode */
2592 rdev
->pm
.power_state
[state_index
].type
=
2593 POWER_STATE_TYPE_DEFAULT
;
2594 rdev
->pm
.power_state
[state_index
].num_clock_modes
= 1;
2595 rdev
->pm
.power_state
[state_index
].clock_info
[0].mclk
= rdev
->clock
.default_mclk
;
2596 rdev
->pm
.power_state
[state_index
].clock_info
[0].sclk
= rdev
->clock
.default_sclk
;
2597 rdev
->pm
.power_state
[state_index
].default_clock_mode
= &rdev
->pm
.power_state
[state_index
].clock_info
[0];
2598 if ((state_index
> 0) &&
2599 (rdev
->pm
.power_state
[0].clock_info
[0].voltage
.type
== VOLTAGE_GPIO
))
2600 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
=
2601 rdev
->pm
.power_state
[0].clock_info
[0].voltage
;
2603 rdev
->pm
.power_state
[state_index
].clock_info
[0].voltage
.type
= VOLTAGE_NONE
;
2604 rdev
->pm
.power_state
[state_index
].pcie_lanes
= 16;
2605 rdev
->pm
.power_state
[state_index
].flags
= 0;
2606 rdev
->pm
.default_power_state_index
= state_index
;
2607 rdev
->pm
.num_power_states
= state_index
+ 1;
2609 rdev
->pm
.current_power_state_index
= rdev
->pm
.default_power_state_index
;
2610 rdev
->pm
.current_clock_mode_index
= 0;
2613 void radeon_external_tmds_setup(struct drm_encoder
*encoder
)
2615 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
2616 struct radeon_encoder_ext_tmds
*tmds
= radeon_encoder
->enc_priv
;
2621 switch (tmds
->dvo_chip
) {
2624 radeon_i2c_put_byte(tmds
->i2c_bus
,
2627 radeon_i2c_put_byte(tmds
->i2c_bus
,
2630 radeon_i2c_put_byte(tmds
->i2c_bus
,
2633 radeon_i2c_put_byte(tmds
->i2c_bus
,
2636 radeon_i2c_put_byte(tmds
->i2c_bus
,
2641 /* sil 1178 - untested */
2660 bool radeon_combios_external_tmds_setup(struct drm_encoder
*encoder
)
2662 struct drm_device
*dev
= encoder
->dev
;
2663 struct radeon_device
*rdev
= dev
->dev_private
;
2664 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
2666 uint8_t blocks
, slave_addr
, rev
;
2668 uint32_t reg
, val
, and_mask
, or_mask
;
2669 struct radeon_encoder_ext_tmds
*tmds
= radeon_encoder
->enc_priv
;
2674 if (rdev
->flags
& RADEON_IS_IGP
) {
2675 offset
= combios_get_table_offset(dev
, COMBIOS_TMDS_POWER_ON_TABLE
);
2676 rev
= RBIOS8(offset
);
2678 rev
= RBIOS8(offset
);
2680 blocks
= RBIOS8(offset
+ 3);
2682 while (blocks
> 0) {
2683 id
= RBIOS16(index
);
2687 reg
= (id
& 0x1fff) * 4;
2688 val
= RBIOS32(index
);
2693 reg
= (id
& 0x1fff) * 4;
2694 and_mask
= RBIOS32(index
);
2696 or_mask
= RBIOS32(index
);
2699 val
= (val
& and_mask
) | or_mask
;
2703 val
= RBIOS16(index
);
2708 val
= RBIOS16(index
);
2713 slave_addr
= id
& 0xff;
2714 slave_addr
>>= 1; /* 7 bit addressing */
2716 reg
= RBIOS8(index
);
2718 val
= RBIOS8(index
);
2720 radeon_i2c_put_byte(tmds
->i2c_bus
,
2725 DRM_ERROR("Unknown id %d\n", id
>> 13);
2734 offset
= combios_get_table_offset(dev
, COMBIOS_EXT_TMDS_INFO_TABLE
);
2736 index
= offset
+ 10;
2737 id
= RBIOS16(index
);
2738 while (id
!= 0xffff) {
2742 reg
= (id
& 0x1fff) * 4;
2743 val
= RBIOS32(index
);
2747 reg
= (id
& 0x1fff) * 4;
2748 and_mask
= RBIOS32(index
);
2750 or_mask
= RBIOS32(index
);
2753 val
= (val
& and_mask
) | or_mask
;
2757 val
= RBIOS16(index
);
2763 and_mask
= RBIOS32(index
);
2765 or_mask
= RBIOS32(index
);
2767 val
= RREG32_PLL(reg
);
2768 val
= (val
& and_mask
) | or_mask
;
2769 WREG32_PLL(reg
, val
);
2773 val
= RBIOS8(index
);
2775 radeon_i2c_put_byte(tmds
->i2c_bus
,
2780 DRM_ERROR("Unknown id %d\n", id
>> 13);
2783 id
= RBIOS16(index
);
2791 static void combios_parse_mmio_table(struct drm_device
*dev
, uint16_t offset
)
2793 struct radeon_device
*rdev
= dev
->dev_private
;
2796 while (RBIOS16(offset
)) {
2797 uint16_t cmd
= ((RBIOS16(offset
) & 0xe000) >> 13);
2798 uint32_t addr
= (RBIOS16(offset
) & 0x1fff);
2799 uint32_t val
, and_mask
, or_mask
;
2805 val
= RBIOS32(offset
);
2810 val
= RBIOS32(offset
);
2815 and_mask
= RBIOS32(offset
);
2817 or_mask
= RBIOS32(offset
);
2825 and_mask
= RBIOS32(offset
);
2827 or_mask
= RBIOS32(offset
);
2835 val
= RBIOS16(offset
);
2840 val
= RBIOS16(offset
);
2847 (RADEON_CLK_PWRMGT_CNTL
) &
2854 if ((RREG32(RADEON_MC_STATUS
) &
2870 static void combios_parse_pll_table(struct drm_device
*dev
, uint16_t offset
)
2872 struct radeon_device
*rdev
= dev
->dev_private
;
2875 while (RBIOS8(offset
)) {
2876 uint8_t cmd
= ((RBIOS8(offset
) & 0xc0) >> 6);
2877 uint8_t addr
= (RBIOS8(offset
) & 0x3f);
2878 uint32_t val
, shift
, tmp
;
2879 uint32_t and_mask
, or_mask
;
2884 val
= RBIOS32(offset
);
2886 WREG32_PLL(addr
, val
);
2889 shift
= RBIOS8(offset
) * 8;
2891 and_mask
= RBIOS8(offset
) << shift
;
2892 and_mask
|= ~(0xff << shift
);
2894 or_mask
= RBIOS8(offset
) << shift
;
2896 tmp
= RREG32_PLL(addr
);
2899 WREG32_PLL(addr
, tmp
);
2915 (RADEON_CLK_PWRMGT_CNTL
) &
2923 (RADEON_CLK_PWRMGT_CNTL
) &
2930 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL
);
2931 if (tmp
& RADEON_CG_NO1_DEBUG_0
) {
2933 uint32_t mclk_cntl
=
2936 mclk_cntl
&= 0xffff0000;
2937 /*mclk_cntl |= 0x00001111;*//* ??? */
2938 WREG32_PLL(RADEON_MCLK_CNTL
,
2943 (RADEON_CLK_PWRMGT_CNTL
,
2945 ~RADEON_CG_NO1_DEBUG_0
);
2960 static void combios_parse_ram_reset_table(struct drm_device
*dev
,
2963 struct radeon_device
*rdev
= dev
->dev_private
;
2967 uint8_t val
= RBIOS8(offset
);
2968 while (val
!= 0xff) {
2972 uint32_t channel_complete_mask
;
2974 if (ASIC_IS_R300(rdev
))
2975 channel_complete_mask
=
2976 R300_MEM_PWRUP_COMPLETE
;
2978 channel_complete_mask
=
2979 RADEON_MEM_PWRUP_COMPLETE
;
2982 if ((RREG32(RADEON_MEM_STR_CNTL
) &
2983 channel_complete_mask
) ==
2984 channel_complete_mask
)
2988 uint32_t or_mask
= RBIOS16(offset
);
2991 tmp
= RREG32(RADEON_MEM_SDRAM_MODE_REG
);
2992 tmp
&= RADEON_SDRAM_MODE_MASK
;
2994 WREG32(RADEON_MEM_SDRAM_MODE_REG
, tmp
);
2996 or_mask
= val
<< 24;
2997 tmp
= RREG32(RADEON_MEM_SDRAM_MODE_REG
);
2998 tmp
&= RADEON_B3MEM_RESET_MASK
;
3000 WREG32(RADEON_MEM_SDRAM_MODE_REG
, tmp
);
3002 val
= RBIOS8(offset
);
3007 static uint32_t combios_detect_ram(struct drm_device
*dev
, int ram
,
3008 int mem_addr_mapping
)
3010 struct radeon_device
*rdev
= dev
->dev_private
;
3015 mem_cntl
= RREG32(RADEON_MEM_CNTL
);
3016 if (mem_cntl
& RV100_HALF_MODE
)
3019 mem_cntl
&= ~(0xff << 8);
3020 mem_cntl
|= (mem_addr_mapping
& 0xff) << 8;
3021 WREG32(RADEON_MEM_CNTL
, mem_cntl
);
3022 RREG32(RADEON_MEM_CNTL
);
3026 /* something like this???? */
3028 addr
= ram
* 1024 * 1024;
3029 /* write to each page */
3030 WREG32(RADEON_MM_INDEX
, (addr
) | RADEON_MM_APER
);
3031 WREG32(RADEON_MM_DATA
, 0xdeadbeef);
3032 /* read back and verify */
3033 WREG32(RADEON_MM_INDEX
, (addr
) | RADEON_MM_APER
);
3034 if (RREG32(RADEON_MM_DATA
) != 0xdeadbeef)
3041 static void combios_write_ram_size(struct drm_device
*dev
)
3043 struct radeon_device
*rdev
= dev
->dev_private
;
3046 uint32_t mem_size
= 0;
3047 uint32_t mem_cntl
= 0;
3049 /* should do something smarter here I guess... */
3050 if (rdev
->flags
& RADEON_IS_IGP
)
3053 /* first check detected mem table */
3054 offset
= combios_get_table_offset(dev
, COMBIOS_DETECTED_MEM_TABLE
);
3056 rev
= RBIOS8(offset
);
3058 mem_cntl
= RBIOS32(offset
+ 1);
3059 mem_size
= RBIOS16(offset
+ 5);
3060 if ((rdev
->family
< CHIP_R200
) &&
3061 !ASIC_IS_RN50(rdev
))
3062 WREG32(RADEON_MEM_CNTL
, mem_cntl
);
3068 combios_get_table_offset(dev
, COMBIOS_MEM_CONFIG_TABLE
);
3070 rev
= RBIOS8(offset
- 1);
3072 if ((rdev
->family
< CHIP_R200
)
3073 && !ASIC_IS_RN50(rdev
)) {
3075 int mem_addr_mapping
= 0;
3077 while (RBIOS8(offset
)) {
3078 ram
= RBIOS8(offset
);
3081 if (mem_addr_mapping
!= 0x25)
3084 combios_detect_ram(dev
, ram
,
3091 mem_size
= RBIOS8(offset
);
3093 mem_size
= RBIOS8(offset
);
3094 mem_size
*= 2; /* convert to MB */
3099 mem_size
*= (1024 * 1024); /* convert to bytes */
3100 WREG32(RADEON_CONFIG_MEMSIZE
, mem_size
);
3103 void radeon_combios_dyn_clk_setup(struct drm_device
*dev
, int enable
)
3105 uint16_t dyn_clk_info
=
3106 combios_get_table_offset(dev
, COMBIOS_DYN_CLK_1_TABLE
);
3109 combios_parse_pll_table(dev
, dyn_clk_info
);
3112 void radeon_combios_asic_init(struct drm_device
*dev
)
3114 struct radeon_device
*rdev
= dev
->dev_private
;
3117 /* port hardcoded mac stuff from radeonfb */
3118 if (rdev
->bios
== NULL
)
3122 table
= combios_get_table_offset(dev
, COMBIOS_ASIC_INIT_1_TABLE
);
3124 combios_parse_mmio_table(dev
, table
);
3127 table
= combios_get_table_offset(dev
, COMBIOS_PLL_INIT_TABLE
);
3129 combios_parse_pll_table(dev
, table
);
3132 table
= combios_get_table_offset(dev
, COMBIOS_ASIC_INIT_2_TABLE
);
3134 combios_parse_mmio_table(dev
, table
);
3136 if (!(rdev
->flags
& RADEON_IS_IGP
)) {
3139 combios_get_table_offset(dev
, COMBIOS_ASIC_INIT_4_TABLE
);
3141 combios_parse_mmio_table(dev
, table
);
3144 table
= combios_get_table_offset(dev
, COMBIOS_RAM_RESET_TABLE
);
3146 combios_parse_ram_reset_table(dev
, table
);
3150 combios_get_table_offset(dev
, COMBIOS_ASIC_INIT_3_TABLE
);
3152 combios_parse_mmio_table(dev
, table
);
3154 /* write CONFIG_MEMSIZE */
3155 combios_write_ram_size(dev
);
3158 /* quirk for rs4xx HP nx6125 laptop to make it resume
3159 * - it hangs on resume inside the dynclk 1 table.
3161 if (rdev
->family
== CHIP_RS480
&&
3162 rdev
->pdev
->subsystem_vendor
== 0x103c &&
3163 rdev
->pdev
->subsystem_device
== 0x308b)
3166 /* quirk for rs4xx HP dv5000 laptop to make it resume
3167 * - it hangs on resume inside the dynclk 1 table.
3169 if (rdev
->family
== CHIP_RS480
&&
3170 rdev
->pdev
->subsystem_vendor
== 0x103c &&
3171 rdev
->pdev
->subsystem_device
== 0x30a4)
3175 table
= combios_get_table_offset(dev
, COMBIOS_DYN_CLK_1_TABLE
);
3177 combios_parse_pll_table(dev
, table
);
3181 void radeon_combios_initialize_bios_scratch_regs(struct drm_device
*dev
)
3183 struct radeon_device
*rdev
= dev
->dev_private
;
3184 uint32_t bios_0_scratch
, bios_6_scratch
, bios_7_scratch
;
3186 bios_0_scratch
= RREG32(RADEON_BIOS_0_SCRATCH
);
3187 bios_6_scratch
= RREG32(RADEON_BIOS_6_SCRATCH
);
3188 bios_7_scratch
= RREG32(RADEON_BIOS_7_SCRATCH
);
3190 /* let the bios control the backlight */
3191 bios_0_scratch
&= ~RADEON_DRIVER_BRIGHTNESS_EN
;
3193 /* tell the bios not to handle mode switching */
3194 bios_6_scratch
|= (RADEON_DISPLAY_SWITCHING_DIS
|
3195 RADEON_ACC_MODE_CHANGE
);
3197 /* tell the bios a driver is loaded */
3198 bios_7_scratch
|= RADEON_DRV_LOADED
;
3200 WREG32(RADEON_BIOS_0_SCRATCH
, bios_0_scratch
);
3201 WREG32(RADEON_BIOS_6_SCRATCH
, bios_6_scratch
);
3202 WREG32(RADEON_BIOS_7_SCRATCH
, bios_7_scratch
);
3205 void radeon_combios_output_lock(struct drm_encoder
*encoder
, bool lock
)
3207 struct drm_device
*dev
= encoder
->dev
;
3208 struct radeon_device
*rdev
= dev
->dev_private
;
3209 uint32_t bios_6_scratch
;
3211 bios_6_scratch
= RREG32(RADEON_BIOS_6_SCRATCH
);
3214 bios_6_scratch
|= RADEON_DRIVER_CRITICAL
;
3216 bios_6_scratch
&= ~RADEON_DRIVER_CRITICAL
;
3218 WREG32(RADEON_BIOS_6_SCRATCH
, bios_6_scratch
);
3222 radeon_combios_connected_scratch_regs(struct drm_connector
*connector
,
3223 struct drm_encoder
*encoder
,
3226 struct drm_device
*dev
= connector
->dev
;
3227 struct radeon_device
*rdev
= dev
->dev_private
;
3228 struct radeon_connector
*radeon_connector
=
3229 to_radeon_connector(connector
);
3230 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
3231 uint32_t bios_4_scratch
= RREG32(RADEON_BIOS_4_SCRATCH
);
3232 uint32_t bios_5_scratch
= RREG32(RADEON_BIOS_5_SCRATCH
);
3234 if ((radeon_encoder
->devices
& ATOM_DEVICE_TV1_SUPPORT
) &&
3235 (radeon_connector
->devices
& ATOM_DEVICE_TV1_SUPPORT
)) {
3237 DRM_DEBUG_KMS("TV1 connected\n");
3239 bios_4_scratch
|= RADEON_TV1_ATTACHED_SVIDEO
;
3240 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
3241 bios_5_scratch
|= RADEON_TV1_ON
;
3242 bios_5_scratch
|= RADEON_ACC_REQ_TV1
;
3244 DRM_DEBUG_KMS("TV1 disconnected\n");
3245 bios_4_scratch
&= ~RADEON_TV1_ATTACHED_MASK
;
3246 bios_5_scratch
&= ~RADEON_TV1_ON
;
3247 bios_5_scratch
&= ~RADEON_ACC_REQ_TV1
;
3250 if ((radeon_encoder
->devices
& ATOM_DEVICE_LCD1_SUPPORT
) &&
3251 (radeon_connector
->devices
& ATOM_DEVICE_LCD1_SUPPORT
)) {
3253 DRM_DEBUG_KMS("LCD1 connected\n");
3254 bios_4_scratch
|= RADEON_LCD1_ATTACHED
;
3255 bios_5_scratch
|= RADEON_LCD1_ON
;
3256 bios_5_scratch
|= RADEON_ACC_REQ_LCD1
;
3258 DRM_DEBUG_KMS("LCD1 disconnected\n");
3259 bios_4_scratch
&= ~RADEON_LCD1_ATTACHED
;
3260 bios_5_scratch
&= ~RADEON_LCD1_ON
;
3261 bios_5_scratch
&= ~RADEON_ACC_REQ_LCD1
;
3264 if ((radeon_encoder
->devices
& ATOM_DEVICE_CRT1_SUPPORT
) &&
3265 (radeon_connector
->devices
& ATOM_DEVICE_CRT1_SUPPORT
)) {
3267 DRM_DEBUG_KMS("CRT1 connected\n");
3268 bios_4_scratch
|= RADEON_CRT1_ATTACHED_COLOR
;
3269 bios_5_scratch
|= RADEON_CRT1_ON
;
3270 bios_5_scratch
|= RADEON_ACC_REQ_CRT1
;
3272 DRM_DEBUG_KMS("CRT1 disconnected\n");
3273 bios_4_scratch
&= ~RADEON_CRT1_ATTACHED_MASK
;
3274 bios_5_scratch
&= ~RADEON_CRT1_ON
;
3275 bios_5_scratch
&= ~RADEON_ACC_REQ_CRT1
;
3278 if ((radeon_encoder
->devices
& ATOM_DEVICE_CRT2_SUPPORT
) &&
3279 (radeon_connector
->devices
& ATOM_DEVICE_CRT2_SUPPORT
)) {
3281 DRM_DEBUG_KMS("CRT2 connected\n");
3282 bios_4_scratch
|= RADEON_CRT2_ATTACHED_COLOR
;
3283 bios_5_scratch
|= RADEON_CRT2_ON
;
3284 bios_5_scratch
|= RADEON_ACC_REQ_CRT2
;
3286 DRM_DEBUG_KMS("CRT2 disconnected\n");
3287 bios_4_scratch
&= ~RADEON_CRT2_ATTACHED_MASK
;
3288 bios_5_scratch
&= ~RADEON_CRT2_ON
;
3289 bios_5_scratch
&= ~RADEON_ACC_REQ_CRT2
;
3292 if ((radeon_encoder
->devices
& ATOM_DEVICE_DFP1_SUPPORT
) &&
3293 (radeon_connector
->devices
& ATOM_DEVICE_DFP1_SUPPORT
)) {
3295 DRM_DEBUG_KMS("DFP1 connected\n");
3296 bios_4_scratch
|= RADEON_DFP1_ATTACHED
;
3297 bios_5_scratch
|= RADEON_DFP1_ON
;
3298 bios_5_scratch
|= RADEON_ACC_REQ_DFP1
;
3300 DRM_DEBUG_KMS("DFP1 disconnected\n");
3301 bios_4_scratch
&= ~RADEON_DFP1_ATTACHED
;
3302 bios_5_scratch
&= ~RADEON_DFP1_ON
;
3303 bios_5_scratch
&= ~RADEON_ACC_REQ_DFP1
;
3306 if ((radeon_encoder
->devices
& ATOM_DEVICE_DFP2_SUPPORT
) &&
3307 (radeon_connector
->devices
& ATOM_DEVICE_DFP2_SUPPORT
)) {
3309 DRM_DEBUG_KMS("DFP2 connected\n");
3310 bios_4_scratch
|= RADEON_DFP2_ATTACHED
;
3311 bios_5_scratch
|= RADEON_DFP2_ON
;
3312 bios_5_scratch
|= RADEON_ACC_REQ_DFP2
;
3314 DRM_DEBUG_KMS("DFP2 disconnected\n");
3315 bios_4_scratch
&= ~RADEON_DFP2_ATTACHED
;
3316 bios_5_scratch
&= ~RADEON_DFP2_ON
;
3317 bios_5_scratch
&= ~RADEON_ACC_REQ_DFP2
;
3320 WREG32(RADEON_BIOS_4_SCRATCH
, bios_4_scratch
);
3321 WREG32(RADEON_BIOS_5_SCRATCH
, bios_5_scratch
);
3325 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder
*encoder
, int crtc
)
3327 struct drm_device
*dev
= encoder
->dev
;
3328 struct radeon_device
*rdev
= dev
->dev_private
;
3329 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
3330 uint32_t bios_5_scratch
= RREG32(RADEON_BIOS_5_SCRATCH
);
3332 if (radeon_encoder
->devices
& ATOM_DEVICE_TV1_SUPPORT
) {
3333 bios_5_scratch
&= ~RADEON_TV1_CRTC_MASK
;
3334 bios_5_scratch
|= (crtc
<< RADEON_TV1_CRTC_SHIFT
);
3336 if (radeon_encoder
->devices
& ATOM_DEVICE_CRT1_SUPPORT
) {
3337 bios_5_scratch
&= ~RADEON_CRT1_CRTC_MASK
;
3338 bios_5_scratch
|= (crtc
<< RADEON_CRT1_CRTC_SHIFT
);
3340 if (radeon_encoder
->devices
& ATOM_DEVICE_CRT2_SUPPORT
) {
3341 bios_5_scratch
&= ~RADEON_CRT2_CRTC_MASK
;
3342 bios_5_scratch
|= (crtc
<< RADEON_CRT2_CRTC_SHIFT
);
3344 if (radeon_encoder
->devices
& ATOM_DEVICE_LCD1_SUPPORT
) {
3345 bios_5_scratch
&= ~RADEON_LCD1_CRTC_MASK
;
3346 bios_5_scratch
|= (crtc
<< RADEON_LCD1_CRTC_SHIFT
);
3348 if (radeon_encoder
->devices
& ATOM_DEVICE_DFP1_SUPPORT
) {
3349 bios_5_scratch
&= ~RADEON_DFP1_CRTC_MASK
;
3350 bios_5_scratch
|= (crtc
<< RADEON_DFP1_CRTC_SHIFT
);
3352 if (radeon_encoder
->devices
& ATOM_DEVICE_DFP2_SUPPORT
) {
3353 bios_5_scratch
&= ~RADEON_DFP2_CRTC_MASK
;
3354 bios_5_scratch
|= (crtc
<< RADEON_DFP2_CRTC_SHIFT
);
3356 WREG32(RADEON_BIOS_5_SCRATCH
, bios_5_scratch
);
3360 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder
*encoder
, bool on
)
3362 struct drm_device
*dev
= encoder
->dev
;
3363 struct radeon_device
*rdev
= dev
->dev_private
;
3364 struct radeon_encoder
*radeon_encoder
= to_radeon_encoder(encoder
);
3365 uint32_t bios_6_scratch
= RREG32(RADEON_BIOS_6_SCRATCH
);
3367 if (radeon_encoder
->devices
& (ATOM_DEVICE_TV_SUPPORT
)) {
3369 bios_6_scratch
|= RADEON_TV_DPMS_ON
;
3371 bios_6_scratch
&= ~RADEON_TV_DPMS_ON
;
3373 if (radeon_encoder
->devices
& (ATOM_DEVICE_CRT_SUPPORT
)) {
3375 bios_6_scratch
|= RADEON_CRT_DPMS_ON
;
3377 bios_6_scratch
&= ~RADEON_CRT_DPMS_ON
;
3379 if (radeon_encoder
->devices
& (ATOM_DEVICE_LCD_SUPPORT
)) {
3381 bios_6_scratch
|= RADEON_LCD_DPMS_ON
;
3383 bios_6_scratch
&= ~RADEON_LCD_DPMS_ON
;
3385 if (radeon_encoder
->devices
& (ATOM_DEVICE_DFP_SUPPORT
)) {
3387 bios_6_scratch
|= RADEON_DFP_DPMS_ON
;
3389 bios_6_scratch
&= ~RADEON_DFP_DPMS_ON
;
3391 WREG32(RADEON_BIOS_6_SCRATCH
, bios_6_scratch
);