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_id(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);
55 /* from radeon_legacy_encoder.c */
57 radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
58 uint32_t supported_device);
60 /* old legacy ATI BIOS routines */
62 /* COMBIOS table offsets */
63 enum radeon_combios_table_offset {
64 /* absolute offset tables */
65 COMBIOS_ASIC_INIT_1_TABLE,
66 COMBIOS_BIOS_SUPPORT_TABLE,
67 COMBIOS_DAC_PROGRAMMING_TABLE,
68 COMBIOS_MAX_COLOR_DEPTH_TABLE,
69 COMBIOS_CRTC_INFO_TABLE,
70 COMBIOS_PLL_INFO_TABLE,
71 COMBIOS_TV_INFO_TABLE,
72 COMBIOS_DFP_INFO_TABLE,
73 COMBIOS_HW_CONFIG_INFO_TABLE,
74 COMBIOS_MULTIMEDIA_INFO_TABLE,
75 COMBIOS_TV_STD_PATCH_TABLE,
76 COMBIOS_LCD_INFO_TABLE,
77 COMBIOS_MOBILE_INFO_TABLE,
78 COMBIOS_PLL_INIT_TABLE,
79 COMBIOS_MEM_CONFIG_TABLE,
80 COMBIOS_SAVE_MASK_TABLE,
81 COMBIOS_HARDCODED_EDID_TABLE,
82 COMBIOS_ASIC_INIT_2_TABLE,
83 COMBIOS_CONNECTOR_INFO_TABLE,
84 COMBIOS_DYN_CLK_1_TABLE,
85 COMBIOS_RESERVED_MEM_TABLE,
86 COMBIOS_EXT_TMDS_INFO_TABLE,
87 COMBIOS_MEM_CLK_INFO_TABLE,
88 COMBIOS_EXT_DAC_INFO_TABLE,
89 COMBIOS_MISC_INFO_TABLE,
90 COMBIOS_CRT_INFO_TABLE,
91 COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE,
92 COMBIOS_COMPONENT_VIDEO_INFO_TABLE,
93 COMBIOS_FAN_SPEED_INFO_TABLE,
94 COMBIOS_OVERDRIVE_INFO_TABLE,
95 COMBIOS_OEM_INFO_TABLE,
96 COMBIOS_DYN_CLK_2_TABLE,
97 COMBIOS_POWER_CONNECTOR_INFO_TABLE,
98 COMBIOS_I2C_INFO_TABLE,
99 /* relative offset tables */
100 COMBIOS_ASIC_INIT_3_TABLE, /* offset from misc info */
101 COMBIOS_ASIC_INIT_4_TABLE, /* offset from misc info */
102 COMBIOS_DETECTED_MEM_TABLE, /* offset from misc info */
103 COMBIOS_ASIC_INIT_5_TABLE, /* offset from misc info */
104 COMBIOS_RAM_RESET_TABLE, /* offset from mem config */
105 COMBIOS_POWERPLAY_INFO_TABLE, /* offset from mobile info */
106 COMBIOS_GPIO_INFO_TABLE, /* offset from mobile info */
107 COMBIOS_LCD_DDC_INFO_TABLE, /* offset from mobile info */
108 COMBIOS_TMDS_POWER_TABLE, /* offset from mobile info */
109 COMBIOS_TMDS_POWER_ON_TABLE, /* offset from tmds power */
110 COMBIOS_TMDS_POWER_OFF_TABLE, /* offset from tmds power */
113 enum radeon_combios_ddc {
123 enum radeon_combios_connector {
124 CONNECTOR_NONE_LEGACY,
125 CONNECTOR_PROPRIETARY_LEGACY,
126 CONNECTOR_CRT_LEGACY,
127 CONNECTOR_DVI_I_LEGACY,
128 CONNECTOR_DVI_D_LEGACY,
129 CONNECTOR_CTV_LEGACY,
130 CONNECTOR_STV_LEGACY,
131 CONNECTOR_UNSUPPORTED_LEGACY
134 const int legacy_connector_convert[] = {
135 DRM_MODE_CONNECTOR_Unknown,
136 DRM_MODE_CONNECTOR_DVID,
137 DRM_MODE_CONNECTOR_VGA,
138 DRM_MODE_CONNECTOR_DVII,
139 DRM_MODE_CONNECTOR_DVID,
140 DRM_MODE_CONNECTOR_Composite,
141 DRM_MODE_CONNECTOR_SVIDEO,
142 DRM_MODE_CONNECTOR_Unknown,
145 static uint16_t combios_get_table_offset(struct drm_device *dev,
146 enum radeon_combios_table_offset table)
148 struct radeon_device *rdev = dev->dev_private;
150 uint16_t offset = 0, check_offset;
153 /* absolute offset tables */
154 case COMBIOS_ASIC_INIT_1_TABLE:
155 check_offset = RBIOS16(rdev->bios_header_start + 0xc);
157 offset = check_offset;
159 case COMBIOS_BIOS_SUPPORT_TABLE:
160 check_offset = RBIOS16(rdev->bios_header_start + 0x14);
162 offset = check_offset;
164 case COMBIOS_DAC_PROGRAMMING_TABLE:
165 check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
167 offset = check_offset;
169 case COMBIOS_MAX_COLOR_DEPTH_TABLE:
170 check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
172 offset = check_offset;
174 case COMBIOS_CRTC_INFO_TABLE:
175 check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
177 offset = check_offset;
179 case COMBIOS_PLL_INFO_TABLE:
180 check_offset = RBIOS16(rdev->bios_header_start + 0x30);
182 offset = check_offset;
184 case COMBIOS_TV_INFO_TABLE:
185 check_offset = RBIOS16(rdev->bios_header_start + 0x32);
187 offset = check_offset;
189 case COMBIOS_DFP_INFO_TABLE:
190 check_offset = RBIOS16(rdev->bios_header_start + 0x34);
192 offset = check_offset;
194 case COMBIOS_HW_CONFIG_INFO_TABLE:
195 check_offset = RBIOS16(rdev->bios_header_start + 0x36);
197 offset = check_offset;
199 case COMBIOS_MULTIMEDIA_INFO_TABLE:
200 check_offset = RBIOS16(rdev->bios_header_start + 0x38);
202 offset = check_offset;
204 case COMBIOS_TV_STD_PATCH_TABLE:
205 check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
207 offset = check_offset;
209 case COMBIOS_LCD_INFO_TABLE:
210 check_offset = RBIOS16(rdev->bios_header_start + 0x40);
212 offset = check_offset;
214 case COMBIOS_MOBILE_INFO_TABLE:
215 check_offset = RBIOS16(rdev->bios_header_start + 0x42);
217 offset = check_offset;
219 case COMBIOS_PLL_INIT_TABLE:
220 check_offset = RBIOS16(rdev->bios_header_start + 0x46);
222 offset = check_offset;
224 case COMBIOS_MEM_CONFIG_TABLE:
225 check_offset = RBIOS16(rdev->bios_header_start + 0x48);
227 offset = check_offset;
229 case COMBIOS_SAVE_MASK_TABLE:
230 check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
232 offset = check_offset;
234 case COMBIOS_HARDCODED_EDID_TABLE:
235 check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
237 offset = check_offset;
239 case COMBIOS_ASIC_INIT_2_TABLE:
240 check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
242 offset = check_offset;
244 case COMBIOS_CONNECTOR_INFO_TABLE:
245 check_offset = RBIOS16(rdev->bios_header_start + 0x50);
247 offset = check_offset;
249 case COMBIOS_DYN_CLK_1_TABLE:
250 check_offset = RBIOS16(rdev->bios_header_start + 0x52);
252 offset = check_offset;
254 case COMBIOS_RESERVED_MEM_TABLE:
255 check_offset = RBIOS16(rdev->bios_header_start + 0x54);
257 offset = check_offset;
259 case COMBIOS_EXT_TMDS_INFO_TABLE:
260 check_offset = RBIOS16(rdev->bios_header_start + 0x58);
262 offset = check_offset;
264 case COMBIOS_MEM_CLK_INFO_TABLE:
265 check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
267 offset = check_offset;
269 case COMBIOS_EXT_DAC_INFO_TABLE:
270 check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
272 offset = check_offset;
274 case COMBIOS_MISC_INFO_TABLE:
275 check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
277 offset = check_offset;
279 case COMBIOS_CRT_INFO_TABLE:
280 check_offset = RBIOS16(rdev->bios_header_start + 0x60);
282 offset = check_offset;
284 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
285 check_offset = RBIOS16(rdev->bios_header_start + 0x62);
287 offset = check_offset;
289 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
290 check_offset = RBIOS16(rdev->bios_header_start + 0x64);
292 offset = check_offset;
294 case COMBIOS_FAN_SPEED_INFO_TABLE:
295 check_offset = RBIOS16(rdev->bios_header_start + 0x66);
297 offset = check_offset;
299 case COMBIOS_OVERDRIVE_INFO_TABLE:
300 check_offset = RBIOS16(rdev->bios_header_start + 0x68);
302 offset = check_offset;
304 case COMBIOS_OEM_INFO_TABLE:
305 check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
307 offset = check_offset;
309 case COMBIOS_DYN_CLK_2_TABLE:
310 check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
312 offset = check_offset;
314 case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
315 check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
317 offset = check_offset;
319 case COMBIOS_I2C_INFO_TABLE:
320 check_offset = RBIOS16(rdev->bios_header_start + 0x70);
322 offset = check_offset;
324 /* relative offset tables */
325 case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
327 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
329 rev = RBIOS8(check_offset);
331 check_offset = RBIOS16(check_offset + 0x3);
333 offset = check_offset;
337 case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */
339 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
341 rev = RBIOS8(check_offset);
343 check_offset = RBIOS16(check_offset + 0x5);
345 offset = check_offset;
349 case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */
351 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
353 rev = RBIOS8(check_offset);
355 check_offset = RBIOS16(check_offset + 0x7);
357 offset = check_offset;
361 case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */
363 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
365 rev = RBIOS8(check_offset);
367 check_offset = RBIOS16(check_offset + 0x9);
369 offset = check_offset;
373 case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */
375 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
377 while (RBIOS8(check_offset++));
380 offset = check_offset;
383 case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */
385 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
387 check_offset = RBIOS16(check_offset + 0x11);
389 offset = check_offset;
392 case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */
394 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
396 check_offset = RBIOS16(check_offset + 0x13);
398 offset = check_offset;
401 case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */
403 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
405 check_offset = RBIOS16(check_offset + 0x15);
407 offset = check_offset;
410 case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */
412 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
414 check_offset = RBIOS16(check_offset + 0x17);
416 offset = check_offset;
419 case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */
421 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
423 check_offset = RBIOS16(check_offset + 0x2);
425 offset = check_offset;
428 case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */
430 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
432 check_offset = RBIOS16(check_offset + 0x4);
434 offset = check_offset;
445 static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
448 struct radeon_i2c_bus_rec i2c;
450 if (ddc_line == RADEON_GPIOPAD_MASK) {
451 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
452 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
453 i2c.a_clk_reg = RADEON_GPIOPAD_A;
454 i2c.a_data_reg = RADEON_GPIOPAD_A;
455 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
456 i2c.en_data_reg = RADEON_GPIOPAD_EN;
457 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
458 i2c.y_data_reg = RADEON_GPIOPAD_Y;
459 } else if (ddc_line == RADEON_MDGPIO_MASK) {
460 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
461 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
462 i2c.a_clk_reg = RADEON_MDGPIO_A;
463 i2c.a_data_reg = RADEON_MDGPIO_A;
464 i2c.en_clk_reg = RADEON_MDGPIO_EN;
465 i2c.en_data_reg = RADEON_MDGPIO_EN;
466 i2c.y_clk_reg = RADEON_MDGPIO_Y;
467 i2c.y_data_reg = RADEON_MDGPIO_Y;
469 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
470 i2c.mask_data_mask = RADEON_GPIO_EN_0;
471 i2c.a_clk_mask = RADEON_GPIO_A_1;
472 i2c.a_data_mask = RADEON_GPIO_A_0;
473 i2c.en_clk_mask = RADEON_GPIO_EN_1;
474 i2c.en_data_mask = RADEON_GPIO_EN_0;
475 i2c.y_clk_mask = RADEON_GPIO_Y_1;
476 i2c.y_data_mask = RADEON_GPIO_Y_0;
478 i2c.mask_clk_reg = ddc_line;
479 i2c.mask_data_reg = ddc_line;
480 i2c.a_clk_reg = ddc_line;
481 i2c.a_data_reg = ddc_line;
482 i2c.en_clk_reg = ddc_line;
483 i2c.en_data_reg = ddc_line;
484 i2c.y_clk_reg = ddc_line;
485 i2c.y_data_reg = ddc_line;
488 if (rdev->family < CHIP_R200)
489 i2c.hw_capable = false;
492 case RADEON_GPIO_VGA_DDC:
493 case RADEON_GPIO_DVI_DDC:
494 i2c.hw_capable = true;
496 case RADEON_GPIO_MONID:
497 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
498 * reliably on some pre-r4xx hardware; not sure why.
500 i2c.hw_capable = false;
503 i2c.hw_capable = false;
518 bool radeon_combios_get_clock_info(struct drm_device *dev)
520 struct radeon_device *rdev = dev->dev_private;
522 struct radeon_pll *p1pll = &rdev->clock.p1pll;
523 struct radeon_pll *p2pll = &rdev->clock.p2pll;
524 struct radeon_pll *spll = &rdev->clock.spll;
525 struct radeon_pll *mpll = &rdev->clock.mpll;
529 if (rdev->bios == NULL)
532 pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
534 rev = RBIOS8(pll_info);
537 p1pll->reference_freq = RBIOS16(pll_info + 0xe);
538 p1pll->reference_div = RBIOS16(pll_info + 0x10);
539 p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
540 p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
543 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
544 p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
546 p1pll->pll_in_min = 40;
547 p1pll->pll_in_max = 500;
552 spll->reference_freq = RBIOS16(pll_info + 0x1a);
553 spll->reference_div = RBIOS16(pll_info + 0x1c);
554 spll->pll_out_min = RBIOS32(pll_info + 0x1e);
555 spll->pll_out_max = RBIOS32(pll_info + 0x22);
558 spll->pll_in_min = RBIOS32(pll_info + 0x48);
559 spll->pll_in_max = RBIOS32(pll_info + 0x4c);
562 spll->pll_in_min = 40;
563 spll->pll_in_max = 500;
567 mpll->reference_freq = RBIOS16(pll_info + 0x26);
568 mpll->reference_div = RBIOS16(pll_info + 0x28);
569 mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
570 mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
573 mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
574 mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
577 mpll->pll_in_min = 40;
578 mpll->pll_in_max = 500;
581 /* default sclk/mclk */
582 sclk = RBIOS16(pll_info + 0xa);
583 mclk = RBIOS16(pll_info + 0x8);
589 rdev->clock.default_sclk = sclk;
590 rdev->clock.default_mclk = mclk;
597 struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
601 struct drm_device *dev = encoder->base.dev;
602 struct radeon_device *rdev = dev->dev_private;
604 uint8_t rev, bg, dac;
605 struct radeon_encoder_primary_dac *p_dac = NULL;
607 if (rdev->bios == NULL)
610 /* check CRT table */
611 dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
614 kzalloc(sizeof(struct radeon_encoder_primary_dac),
620 rev = RBIOS8(dac_info) & 0x3;
622 bg = RBIOS8(dac_info + 0x2) & 0xf;
623 dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
624 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
626 bg = RBIOS8(dac_info + 0x2) & 0xf;
627 dac = RBIOS8(dac_info + 0x3) & 0xf;
628 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
636 static enum radeon_tv_std
637 radeon_combios_get_tv_info(struct radeon_encoder *encoder)
639 struct drm_device *dev = encoder->base.dev;
640 struct radeon_device *rdev = dev->dev_private;
642 enum radeon_tv_std tv_std = TV_STD_NTSC;
644 tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
646 if (RBIOS8(tv_info + 6) == 'T') {
647 switch (RBIOS8(tv_info + 7) & 0xf) {
649 tv_std = TV_STD_NTSC;
650 DRM_INFO("Default TV standard: NTSC\n");
654 DRM_INFO("Default TV standard: PAL\n");
657 tv_std = TV_STD_PAL_M;
658 DRM_INFO("Default TV standard: PAL-M\n");
661 tv_std = TV_STD_PAL_60;
662 DRM_INFO("Default TV standard: PAL-60\n");
665 tv_std = TV_STD_NTSC_J;
666 DRM_INFO("Default TV standard: NTSC-J\n");
669 tv_std = TV_STD_SCART_PAL;
670 DRM_INFO("Default TV standard: SCART-PAL\n");
673 tv_std = TV_STD_NTSC;
675 ("Unknown TV standard; defaulting to NTSC\n");
679 switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
681 DRM_INFO("29.498928713 MHz TV ref clk\n");
684 DRM_INFO("28.636360000 MHz TV ref clk\n");
687 DRM_INFO("14.318180000 MHz TV ref clk\n");
690 DRM_INFO("27.000000000 MHz TV ref clk\n");
700 static const uint32_t default_tvdac_adj[CHIP_LAST] = {
701 0x00000000, /* r100 */
702 0x00280000, /* rv100 */
703 0x00000000, /* rs100 */
704 0x00880000, /* rv200 */
705 0x00000000, /* rs200 */
706 0x00000000, /* r200 */
707 0x00770000, /* rv250 */
708 0x00290000, /* rs300 */
709 0x00560000, /* rv280 */
710 0x00780000, /* r300 */
711 0x00770000, /* r350 */
712 0x00780000, /* rv350 */
713 0x00780000, /* rv380 */
714 0x01080000, /* r420 */
715 0x01080000, /* r423 */
716 0x01080000, /* rv410 */
717 0x00780000, /* rs400 */
718 0x00780000, /* rs480 */
721 static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
722 struct radeon_encoder_tv_dac *tv_dac)
724 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
725 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
726 tv_dac->ps2_tvdac_adj = 0x00880000;
727 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
728 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
732 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
736 struct drm_device *dev = encoder->base.dev;
737 struct radeon_device *rdev = dev->dev_private;
739 uint8_t rev, bg, dac;
740 struct radeon_encoder_tv_dac *tv_dac = NULL;
743 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
747 if (rdev->bios == NULL)
750 /* first check TV table */
751 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
753 rev = RBIOS8(dac_info + 0x3);
755 bg = RBIOS8(dac_info + 0xc) & 0xf;
756 dac = RBIOS8(dac_info + 0xd) & 0xf;
757 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
759 bg = RBIOS8(dac_info + 0xe) & 0xf;
760 dac = RBIOS8(dac_info + 0xf) & 0xf;
761 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
763 bg = RBIOS8(dac_info + 0x10) & 0xf;
764 dac = RBIOS8(dac_info + 0x11) & 0xf;
765 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
767 } else if (rev > 1) {
768 bg = RBIOS8(dac_info + 0xc) & 0xf;
769 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
770 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
772 bg = RBIOS8(dac_info + 0xd) & 0xf;
773 dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
774 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
776 bg = RBIOS8(dac_info + 0xe) & 0xf;
777 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
778 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
781 tv_dac->tv_std = radeon_combios_get_tv_info(encoder);
784 /* then check CRT table */
786 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
788 rev = RBIOS8(dac_info) & 0x3;
790 bg = RBIOS8(dac_info + 0x3) & 0xf;
791 dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
792 tv_dac->ps2_tvdac_adj =
793 (bg << 16) | (dac << 20);
794 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
795 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
798 bg = RBIOS8(dac_info + 0x4) & 0xf;
799 dac = RBIOS8(dac_info + 0x5) & 0xf;
800 tv_dac->ps2_tvdac_adj =
801 (bg << 16) | (dac << 20);
802 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
803 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
807 DRM_INFO("No TV DAC info found in BIOS\n");
812 if (!found) /* fallback to defaults */
813 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
818 static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
822 struct radeon_encoder_lvds *lvds = NULL;
823 uint32_t fp_vert_stretch, fp_horz_stretch;
824 uint32_t ppll_div_sel, ppll_val;
825 uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
827 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
832 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
833 fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
835 /* These should be fail-safe defaults, fingers crossed */
836 lvds->panel_pwr_delay = 200;
837 lvds->panel_vcc_delay = 2000;
839 lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
840 lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
841 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
843 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
844 lvds->native_mode.vdisplay =
845 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
846 RADEON_VERT_PANEL_SHIFT) + 1;
848 lvds->native_mode.vdisplay =
849 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
851 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
852 lvds->native_mode.hdisplay =
853 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
854 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
856 lvds->native_mode.hdisplay =
857 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
859 if ((lvds->native_mode.hdisplay < 640) ||
860 (lvds->native_mode.vdisplay < 480)) {
861 lvds->native_mode.hdisplay = 640;
862 lvds->native_mode.vdisplay = 480;
865 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
866 ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
867 if ((ppll_val & 0x000707ff) == 0x1bb)
868 lvds->use_bios_dividers = false;
870 lvds->panel_ref_divider =
871 RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
872 lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
873 lvds->panel_fb_divider = ppll_val & 0x7ff;
875 if ((lvds->panel_ref_divider != 0) &&
876 (lvds->panel_fb_divider > 3))
877 lvds->use_bios_dividers = true;
879 lvds->panel_vcc_delay = 200;
881 DRM_INFO("Panel info derived from registers\n");
882 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
883 lvds->native_mode.vdisplay);
888 struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
891 struct drm_device *dev = encoder->base.dev;
892 struct radeon_device *rdev = dev->dev_private;
894 uint32_t panel_setup;
897 struct radeon_encoder_lvds *lvds = NULL;
899 if (rdev->bios == NULL) {
900 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
904 lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
907 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
912 for (i = 0; i < 24; i++)
913 stmp[i] = RBIOS8(lcd_info + i + 1);
916 DRM_INFO("Panel ID String: %s\n", stmp);
918 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
919 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
921 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
922 lvds->native_mode.vdisplay);
924 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
925 if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0)
926 lvds->panel_vcc_delay = 2000;
928 lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
929 lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
930 lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
932 lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
933 lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
934 lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
935 if ((lvds->panel_ref_divider != 0) &&
936 (lvds->panel_fb_divider > 3))
937 lvds->use_bios_dividers = true;
939 panel_setup = RBIOS32(lcd_info + 0x39);
940 lvds->lvds_gen_cntl = 0xff00;
941 if (panel_setup & 0x1)
942 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
944 if ((panel_setup >> 4) & 0x1)
945 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
947 switch ((panel_setup >> 8) & 0x7) {
949 lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
952 lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
955 lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
961 if ((panel_setup >> 16) & 0x1)
962 lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
964 if ((panel_setup >> 17) & 0x1)
965 lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
967 if ((panel_setup >> 18) & 0x1)
968 lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
970 if ((panel_setup >> 23) & 0x1)
971 lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
973 lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
975 for (i = 0; i < 32; i++) {
976 tmp = RBIOS16(lcd_info + 64 + i * 2);
980 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
982 lvds->native_mode.vdisplay)) {
983 lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
984 lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
985 lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
986 RBIOS16(tmp + 21)) * 8;
988 lvds->native_mode.vtotal = RBIOS16(tmp + 24);
989 lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
990 lvds->native_mode.vsync_end =
991 ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
992 (RBIOS16(tmp + 28) & 0x7ff);
994 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
995 lvds->native_mode.flags = 0;
996 /* set crtc values */
997 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1002 DRM_INFO("No panel info found in BIOS\n");
1003 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
1007 encoder->native_mode = lvds->native_mode;
1011 static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
1012 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1013 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1014 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1015 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1016 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1017 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1018 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1019 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1020 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1021 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1022 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1023 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1024 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1025 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1026 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1027 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
1028 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1029 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
1032 bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
1033 struct radeon_encoder_int_tmds *tmds)
1035 struct drm_device *dev = encoder->base.dev;
1036 struct radeon_device *rdev = dev->dev_private;
1039 for (i = 0; i < 4; i++) {
1040 tmds->tmds_pll[i].value =
1041 default_tmds_pll[rdev->family][i].value;
1042 tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
1048 bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
1049 struct radeon_encoder_int_tmds *tmds)
1051 struct drm_device *dev = encoder->base.dev;
1052 struct radeon_device *rdev = dev->dev_private;
1057 if (rdev->bios == NULL)
1060 tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1063 ver = RBIOS8(tmds_info);
1064 DRM_INFO("DFP table revision: %d\n", ver);
1066 n = RBIOS8(tmds_info + 5) + 1;
1069 for (i = 0; i < n; i++) {
1070 tmds->tmds_pll[i].value =
1071 RBIOS32(tmds_info + i * 10 + 0x08);
1072 tmds->tmds_pll[i].freq =
1073 RBIOS16(tmds_info + i * 10 + 0x10);
1074 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1075 tmds->tmds_pll[i].freq,
1076 tmds->tmds_pll[i].value);
1078 } else if (ver == 4) {
1080 n = RBIOS8(tmds_info + 5) + 1;
1083 for (i = 0; i < n; i++) {
1084 tmds->tmds_pll[i].value =
1085 RBIOS32(tmds_info + stride + 0x08);
1086 tmds->tmds_pll[i].freq =
1087 RBIOS16(tmds_info + stride + 0x10);
1092 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1093 tmds->tmds_pll[i].freq,
1094 tmds->tmds_pll[i].value);
1098 DRM_INFO("No TMDS info found in BIOS\n");
1104 bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1105 struct radeon_encoder_ext_tmds *tmds)
1107 struct drm_device *dev = encoder->base.dev;
1108 struct radeon_device *rdev = dev->dev_private;
1109 struct radeon_i2c_bus_rec i2c_bus;
1111 /* default for macs */
1112 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1113 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1115 /* XXX some macs have duallink chips */
1116 switch (rdev->mode_info.connector_table) {
1117 case CT_POWERBOOK_EXTERNAL:
1118 case CT_MINI_EXTERNAL:
1120 tmds->dvo_chip = DVO_SIL164;
1121 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1128 bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
1129 struct radeon_encoder_ext_tmds *tmds)
1131 struct drm_device *dev = encoder->base.dev;
1132 struct radeon_device *rdev = dev->dev_private;
1134 uint8_t ver, id, blocks, clk, data;
1136 enum radeon_combios_ddc gpio;
1137 struct radeon_i2c_bus_rec i2c_bus;
1139 if (rdev->bios == NULL)
1142 tmds->i2c_bus = NULL;
1143 if (rdev->flags & RADEON_IS_IGP) {
1144 offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
1146 ver = RBIOS8(offset);
1147 DRM_INFO("GPIO Table revision: %d\n", ver);
1148 blocks = RBIOS8(offset + 2);
1149 for (i = 0; i < blocks; i++) {
1150 id = RBIOS8(offset + 3 + (i * 5) + 0);
1152 clk = RBIOS8(offset + 3 + (i * 5) + 3);
1153 data = RBIOS8(offset + 3 + (i * 5) + 4);
1154 i2c_bus.valid = true;
1155 i2c_bus.mask_clk_mask = (1 << clk);
1156 i2c_bus.mask_data_mask = (1 << data);
1157 i2c_bus.a_clk_mask = (1 << clk);
1158 i2c_bus.a_data_mask = (1 << data);
1159 i2c_bus.en_clk_mask = (1 << clk);
1160 i2c_bus.en_data_mask = (1 << data);
1161 i2c_bus.y_clk_mask = (1 << clk);
1162 i2c_bus.y_data_mask = (1 << data);
1163 i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
1164 i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
1165 i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
1166 i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
1167 i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
1168 i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
1169 i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
1170 i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
1171 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1172 tmds->dvo_chip = DVO_SIL164;
1173 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1179 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1181 ver = RBIOS8(offset);
1182 DRM_INFO("External TMDS Table revision: %d\n", ver);
1183 tmds->slave_addr = RBIOS8(offset + 4 + 2);
1184 tmds->slave_addr >>= 1; /* 7 bit addressing */
1185 gpio = RBIOS8(offset + 4 + 3);
1188 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1189 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1192 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1193 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1196 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1197 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1200 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1201 if (rdev->family >= CHIP_R300)
1202 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1204 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1205 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1207 case DDC_LCD: /* MM i2c */
1208 DRM_ERROR("MM i2c requires hw i2c engine\n");
1211 DRM_ERROR("Unsupported gpio %d\n", gpio);
1217 if (!tmds->i2c_bus) {
1218 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1225 bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1227 struct radeon_device *rdev = dev->dev_private;
1228 struct radeon_i2c_bus_rec ddc_i2c;
1230 rdev->mode_info.connector_table = radeon_connector_table;
1231 if (rdev->mode_info.connector_table == CT_NONE) {
1232 #ifdef CONFIG_PPC_PMAC
1233 if (machine_is_compatible("PowerBook3,3")) {
1234 /* powerbook with VGA */
1235 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
1236 } else if (machine_is_compatible("PowerBook3,4") ||
1237 machine_is_compatible("PowerBook3,5")) {
1238 /* powerbook with internal tmds */
1239 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
1240 } else if (machine_is_compatible("PowerBook5,1") ||
1241 machine_is_compatible("PowerBook5,2") ||
1242 machine_is_compatible("PowerBook5,3") ||
1243 machine_is_compatible("PowerBook5,4") ||
1244 machine_is_compatible("PowerBook5,5")) {
1245 /* powerbook with external single link tmds (sil164) */
1246 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1247 } else if (machine_is_compatible("PowerBook5,6")) {
1248 /* powerbook with external dual or single link tmds */
1249 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1250 } else if (machine_is_compatible("PowerBook5,7") ||
1251 machine_is_compatible("PowerBook5,8") ||
1252 machine_is_compatible("PowerBook5,9")) {
1253 /* PowerBook6,2 ? */
1254 /* powerbook with external dual link tmds (sil1178?) */
1255 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1256 } else if (machine_is_compatible("PowerBook4,1") ||
1257 machine_is_compatible("PowerBook4,2") ||
1258 machine_is_compatible("PowerBook4,3") ||
1259 machine_is_compatible("PowerBook6,3") ||
1260 machine_is_compatible("PowerBook6,5") ||
1261 machine_is_compatible("PowerBook6,7")) {
1263 rdev->mode_info.connector_table = CT_IBOOK;
1264 } else if (machine_is_compatible("PowerMac4,4")) {
1266 rdev->mode_info.connector_table = CT_EMAC;
1267 } else if (machine_is_compatible("PowerMac10,1")) {
1268 /* mini with internal tmds */
1269 rdev->mode_info.connector_table = CT_MINI_INTERNAL;
1270 } else if (machine_is_compatible("PowerMac10,2")) {
1271 /* mini with external tmds */
1272 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
1273 } else if (machine_is_compatible("PowerMac12,1")) {
1275 /* imac g5 isight */
1276 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1278 #endif /* CONFIG_PPC_PMAC */
1279 rdev->mode_info.connector_table = CT_GENERIC;
1282 switch (rdev->mode_info.connector_table) {
1284 DRM_INFO("Connector Table: %d (generic)\n",
1285 rdev->mode_info.connector_table);
1286 /* these are the most common settings */
1287 if (rdev->flags & RADEON_SINGLE_CRTC) {
1288 /* VGA - primary dac */
1289 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1290 radeon_add_legacy_encoder(dev,
1291 radeon_get_encoder_id(dev,
1292 ATOM_DEVICE_CRT1_SUPPORT,
1294 ATOM_DEVICE_CRT1_SUPPORT);
1295 radeon_add_legacy_connector(dev, 0,
1296 ATOM_DEVICE_CRT1_SUPPORT,
1297 DRM_MODE_CONNECTOR_VGA,
1299 CONNECTOR_OBJECT_ID_VGA);
1300 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1302 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
1303 radeon_add_legacy_encoder(dev,
1304 radeon_get_encoder_id(dev,
1305 ATOM_DEVICE_LCD1_SUPPORT,
1307 ATOM_DEVICE_LCD1_SUPPORT);
1308 radeon_add_legacy_connector(dev, 0,
1309 ATOM_DEVICE_LCD1_SUPPORT,
1310 DRM_MODE_CONNECTOR_LVDS,
1312 CONNECTOR_OBJECT_ID_LVDS);
1314 /* VGA - primary dac */
1315 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1316 radeon_add_legacy_encoder(dev,
1317 radeon_get_encoder_id(dev,
1318 ATOM_DEVICE_CRT1_SUPPORT,
1320 ATOM_DEVICE_CRT1_SUPPORT);
1321 radeon_add_legacy_connector(dev, 1,
1322 ATOM_DEVICE_CRT1_SUPPORT,
1323 DRM_MODE_CONNECTOR_VGA,
1325 CONNECTOR_OBJECT_ID_VGA);
1327 /* DVI-I - tv dac, int tmds */
1328 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1329 radeon_add_legacy_encoder(dev,
1330 radeon_get_encoder_id(dev,
1331 ATOM_DEVICE_DFP1_SUPPORT,
1333 ATOM_DEVICE_DFP1_SUPPORT);
1334 radeon_add_legacy_encoder(dev,
1335 radeon_get_encoder_id(dev,
1336 ATOM_DEVICE_CRT2_SUPPORT,
1338 ATOM_DEVICE_CRT2_SUPPORT);
1339 radeon_add_legacy_connector(dev, 0,
1340 ATOM_DEVICE_DFP1_SUPPORT |
1341 ATOM_DEVICE_CRT2_SUPPORT,
1342 DRM_MODE_CONNECTOR_DVII,
1344 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1346 /* VGA - primary dac */
1347 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1348 radeon_add_legacy_encoder(dev,
1349 radeon_get_encoder_id(dev,
1350 ATOM_DEVICE_CRT1_SUPPORT,
1352 ATOM_DEVICE_CRT1_SUPPORT);
1353 radeon_add_legacy_connector(dev, 1,
1354 ATOM_DEVICE_CRT1_SUPPORT,
1355 DRM_MODE_CONNECTOR_VGA,
1357 CONNECTOR_OBJECT_ID_VGA);
1360 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
1362 radeon_add_legacy_encoder(dev,
1363 radeon_get_encoder_id(dev,
1364 ATOM_DEVICE_TV1_SUPPORT,
1366 ATOM_DEVICE_TV1_SUPPORT);
1367 radeon_add_legacy_connector(dev, 2,
1368 ATOM_DEVICE_TV1_SUPPORT,
1369 DRM_MODE_CONNECTOR_SVIDEO,
1371 CONNECTOR_OBJECT_ID_SVIDEO);
1375 DRM_INFO("Connector Table: %d (ibook)\n",
1376 rdev->mode_info.connector_table);
1378 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1379 radeon_add_legacy_encoder(dev,
1380 radeon_get_encoder_id(dev,
1381 ATOM_DEVICE_LCD1_SUPPORT,
1383 ATOM_DEVICE_LCD1_SUPPORT);
1384 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1385 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1386 CONNECTOR_OBJECT_ID_LVDS);
1388 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1389 radeon_add_legacy_encoder(dev,
1390 radeon_get_encoder_id(dev,
1391 ATOM_DEVICE_CRT2_SUPPORT,
1393 ATOM_DEVICE_CRT2_SUPPORT);
1394 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1395 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1396 CONNECTOR_OBJECT_ID_VGA);
1398 radeon_add_legacy_encoder(dev,
1399 radeon_get_encoder_id(dev,
1400 ATOM_DEVICE_TV1_SUPPORT,
1402 ATOM_DEVICE_TV1_SUPPORT);
1403 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1404 DRM_MODE_CONNECTOR_SVIDEO,
1406 CONNECTOR_OBJECT_ID_SVIDEO);
1408 case CT_POWERBOOK_EXTERNAL:
1409 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1410 rdev->mode_info.connector_table);
1412 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1413 radeon_add_legacy_encoder(dev,
1414 radeon_get_encoder_id(dev,
1415 ATOM_DEVICE_LCD1_SUPPORT,
1417 ATOM_DEVICE_LCD1_SUPPORT);
1418 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1419 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1420 CONNECTOR_OBJECT_ID_LVDS);
1421 /* DVI-I - primary dac, ext tmds */
1422 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1423 radeon_add_legacy_encoder(dev,
1424 radeon_get_encoder_id(dev,
1425 ATOM_DEVICE_DFP2_SUPPORT,
1427 ATOM_DEVICE_DFP2_SUPPORT);
1428 radeon_add_legacy_encoder(dev,
1429 radeon_get_encoder_id(dev,
1430 ATOM_DEVICE_CRT1_SUPPORT,
1432 ATOM_DEVICE_CRT1_SUPPORT);
1433 /* XXX some are SL */
1434 radeon_add_legacy_connector(dev, 1,
1435 ATOM_DEVICE_DFP2_SUPPORT |
1436 ATOM_DEVICE_CRT1_SUPPORT,
1437 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1438 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I);
1440 radeon_add_legacy_encoder(dev,
1441 radeon_get_encoder_id(dev,
1442 ATOM_DEVICE_TV1_SUPPORT,
1444 ATOM_DEVICE_TV1_SUPPORT);
1445 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1446 DRM_MODE_CONNECTOR_SVIDEO,
1448 CONNECTOR_OBJECT_ID_SVIDEO);
1450 case CT_POWERBOOK_INTERNAL:
1451 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1452 rdev->mode_info.connector_table);
1454 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1455 radeon_add_legacy_encoder(dev,
1456 radeon_get_encoder_id(dev,
1457 ATOM_DEVICE_LCD1_SUPPORT,
1459 ATOM_DEVICE_LCD1_SUPPORT);
1460 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1461 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1462 CONNECTOR_OBJECT_ID_LVDS);
1463 /* DVI-I - primary dac, int tmds */
1464 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1465 radeon_add_legacy_encoder(dev,
1466 radeon_get_encoder_id(dev,
1467 ATOM_DEVICE_DFP1_SUPPORT,
1469 ATOM_DEVICE_DFP1_SUPPORT);
1470 radeon_add_legacy_encoder(dev,
1471 radeon_get_encoder_id(dev,
1472 ATOM_DEVICE_CRT1_SUPPORT,
1474 ATOM_DEVICE_CRT1_SUPPORT);
1475 radeon_add_legacy_connector(dev, 1,
1476 ATOM_DEVICE_DFP1_SUPPORT |
1477 ATOM_DEVICE_CRT1_SUPPORT,
1478 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1479 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1481 radeon_add_legacy_encoder(dev,
1482 radeon_get_encoder_id(dev,
1483 ATOM_DEVICE_TV1_SUPPORT,
1485 ATOM_DEVICE_TV1_SUPPORT);
1486 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1487 DRM_MODE_CONNECTOR_SVIDEO,
1489 CONNECTOR_OBJECT_ID_SVIDEO);
1491 case CT_POWERBOOK_VGA:
1492 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1493 rdev->mode_info.connector_table);
1495 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1496 radeon_add_legacy_encoder(dev,
1497 radeon_get_encoder_id(dev,
1498 ATOM_DEVICE_LCD1_SUPPORT,
1500 ATOM_DEVICE_LCD1_SUPPORT);
1501 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1502 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1503 CONNECTOR_OBJECT_ID_LVDS);
1504 /* VGA - primary dac */
1505 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1506 radeon_add_legacy_encoder(dev,
1507 radeon_get_encoder_id(dev,
1508 ATOM_DEVICE_CRT1_SUPPORT,
1510 ATOM_DEVICE_CRT1_SUPPORT);
1511 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
1512 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1513 CONNECTOR_OBJECT_ID_VGA);
1515 radeon_add_legacy_encoder(dev,
1516 radeon_get_encoder_id(dev,
1517 ATOM_DEVICE_TV1_SUPPORT,
1519 ATOM_DEVICE_TV1_SUPPORT);
1520 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1521 DRM_MODE_CONNECTOR_SVIDEO,
1523 CONNECTOR_OBJECT_ID_SVIDEO);
1525 case CT_MINI_EXTERNAL:
1526 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1527 rdev->mode_info.connector_table);
1528 /* DVI-I - tv dac, ext tmds */
1529 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1530 radeon_add_legacy_encoder(dev,
1531 radeon_get_encoder_id(dev,
1532 ATOM_DEVICE_DFP2_SUPPORT,
1534 ATOM_DEVICE_DFP2_SUPPORT);
1535 radeon_add_legacy_encoder(dev,
1536 radeon_get_encoder_id(dev,
1537 ATOM_DEVICE_CRT2_SUPPORT,
1539 ATOM_DEVICE_CRT2_SUPPORT);
1540 /* XXX are any DL? */
1541 radeon_add_legacy_connector(dev, 0,
1542 ATOM_DEVICE_DFP2_SUPPORT |
1543 ATOM_DEVICE_CRT2_SUPPORT,
1544 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1545 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1547 radeon_add_legacy_encoder(dev,
1548 radeon_get_encoder_id(dev,
1549 ATOM_DEVICE_TV1_SUPPORT,
1551 ATOM_DEVICE_TV1_SUPPORT);
1552 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1553 DRM_MODE_CONNECTOR_SVIDEO,
1555 CONNECTOR_OBJECT_ID_SVIDEO);
1557 case CT_MINI_INTERNAL:
1558 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1559 rdev->mode_info.connector_table);
1560 /* DVI-I - tv dac, int tmds */
1561 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1562 radeon_add_legacy_encoder(dev,
1563 radeon_get_encoder_id(dev,
1564 ATOM_DEVICE_DFP1_SUPPORT,
1566 ATOM_DEVICE_DFP1_SUPPORT);
1567 radeon_add_legacy_encoder(dev,
1568 radeon_get_encoder_id(dev,
1569 ATOM_DEVICE_CRT2_SUPPORT,
1571 ATOM_DEVICE_CRT2_SUPPORT);
1572 radeon_add_legacy_connector(dev, 0,
1573 ATOM_DEVICE_DFP1_SUPPORT |
1574 ATOM_DEVICE_CRT2_SUPPORT,
1575 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1576 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1578 radeon_add_legacy_encoder(dev,
1579 radeon_get_encoder_id(dev,
1580 ATOM_DEVICE_TV1_SUPPORT,
1582 ATOM_DEVICE_TV1_SUPPORT);
1583 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1584 DRM_MODE_CONNECTOR_SVIDEO,
1586 CONNECTOR_OBJECT_ID_SVIDEO);
1588 case CT_IMAC_G5_ISIGHT:
1589 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1590 rdev->mode_info.connector_table);
1591 /* DVI-D - int tmds */
1592 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1593 radeon_add_legacy_encoder(dev,
1594 radeon_get_encoder_id(dev,
1595 ATOM_DEVICE_DFP1_SUPPORT,
1597 ATOM_DEVICE_DFP1_SUPPORT);
1598 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
1599 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
1600 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D);
1602 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1603 radeon_add_legacy_encoder(dev,
1604 radeon_get_encoder_id(dev,
1605 ATOM_DEVICE_CRT2_SUPPORT,
1607 ATOM_DEVICE_CRT2_SUPPORT);
1608 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1609 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1610 CONNECTOR_OBJECT_ID_VGA);
1612 radeon_add_legacy_encoder(dev,
1613 radeon_get_encoder_id(dev,
1614 ATOM_DEVICE_TV1_SUPPORT,
1616 ATOM_DEVICE_TV1_SUPPORT);
1617 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1618 DRM_MODE_CONNECTOR_SVIDEO,
1620 CONNECTOR_OBJECT_ID_SVIDEO);
1623 DRM_INFO("Connector Table: %d (emac)\n",
1624 rdev->mode_info.connector_table);
1625 /* VGA - primary dac */
1626 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1627 radeon_add_legacy_encoder(dev,
1628 radeon_get_encoder_id(dev,
1629 ATOM_DEVICE_CRT1_SUPPORT,
1631 ATOM_DEVICE_CRT1_SUPPORT);
1632 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1633 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1634 CONNECTOR_OBJECT_ID_VGA);
1636 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1637 radeon_add_legacy_encoder(dev,
1638 radeon_get_encoder_id(dev,
1639 ATOM_DEVICE_CRT2_SUPPORT,
1641 ATOM_DEVICE_CRT2_SUPPORT);
1642 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1643 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1644 CONNECTOR_OBJECT_ID_VGA);
1646 radeon_add_legacy_encoder(dev,
1647 radeon_get_encoder_id(dev,
1648 ATOM_DEVICE_TV1_SUPPORT,
1650 ATOM_DEVICE_TV1_SUPPORT);
1651 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1652 DRM_MODE_CONNECTOR_SVIDEO,
1654 CONNECTOR_OBJECT_ID_SVIDEO);
1657 DRM_INFO("Connector table: %d (invalid)\n",
1658 rdev->mode_info.connector_table);
1662 radeon_link_encoder_connector(dev);
1667 static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1669 enum radeon_combios_connector
1671 struct radeon_i2c_bus_rec *ddc_i2c)
1673 struct radeon_device *rdev = dev->dev_private;
1675 /* XPRESS DDC quirks */
1676 if ((rdev->family == CHIP_RS400 ||
1677 rdev->family == CHIP_RS480) &&
1678 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1679 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1680 else if ((rdev->family == CHIP_RS400 ||
1681 rdev->family == CHIP_RS480) &&
1682 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
1683 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
1684 ddc_i2c->mask_clk_mask = (0x20 << 8);
1685 ddc_i2c->mask_data_mask = 0x80;
1686 ddc_i2c->a_clk_mask = (0x20 << 8);
1687 ddc_i2c->a_data_mask = 0x80;
1688 ddc_i2c->en_clk_mask = (0x20 << 8);
1689 ddc_i2c->en_data_mask = 0x80;
1690 ddc_i2c->y_clk_mask = (0x20 << 8);
1691 ddc_i2c->y_data_mask = 0x80;
1694 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1695 if ((rdev->family >= CHIP_R300) &&
1696 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1697 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1699 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1700 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
1701 if (dev->pdev->device == 0x515e &&
1702 dev->pdev->subsystem_vendor == 0x1014) {
1703 if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
1704 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1708 /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
1709 if (dev->pdev->device == 0x5159 &&
1710 dev->pdev->subsystem_vendor == 0x1002 &&
1711 dev->pdev->subsystem_device == 0x013a) {
1712 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1713 *legacy_connector = CONNECTOR_CRT_LEGACY;
1717 /* X300 card with extra non-existent DVI port */
1718 if (dev->pdev->device == 0x5B60 &&
1719 dev->pdev->subsystem_vendor == 0x17af &&
1720 dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
1721 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1728 static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
1730 /* Acer 5102 has non-existent TV port */
1731 if (dev->pdev->device == 0x5975 &&
1732 dev->pdev->subsystem_vendor == 0x1025 &&
1733 dev->pdev->subsystem_device == 0x009f)
1736 /* HP dc5750 has non-existent TV port */
1737 if (dev->pdev->device == 0x5974 &&
1738 dev->pdev->subsystem_vendor == 0x103c &&
1739 dev->pdev->subsystem_device == 0x280a)
1742 /* MSI S270 has non-existent TV port */
1743 if (dev->pdev->device == 0x5955 &&
1744 dev->pdev->subsystem_vendor == 0x1462 &&
1745 dev->pdev->subsystem_device == 0x0131)
1751 static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
1753 struct radeon_device *rdev = dev->dev_private;
1754 uint32_t ext_tmds_info;
1756 if (rdev->flags & RADEON_IS_IGP) {
1758 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1760 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1762 ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1763 if (ext_tmds_info) {
1764 uint8_t rev = RBIOS8(ext_tmds_info);
1765 uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
1768 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1770 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1774 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1776 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1781 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1783 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1786 bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1788 struct radeon_device *rdev = dev->dev_private;
1789 uint32_t conn_info, entry, devices;
1790 uint16_t tmp, connector_object_id;
1791 enum radeon_combios_ddc ddc_type;
1792 enum radeon_combios_connector connector;
1794 struct radeon_i2c_bus_rec ddc_i2c;
1796 if (rdev->bios == NULL)
1799 conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
1801 for (i = 0; i < 4; i++) {
1802 entry = conn_info + 2 + i * 2;
1804 if (!RBIOS16(entry))
1807 tmp = RBIOS16(entry);
1809 connector = (tmp >> 12) & 0xf;
1811 ddc_type = (tmp >> 8) & 0xf;
1815 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1819 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1823 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1827 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1833 if (!radeon_apply_legacy_quirks(dev, i, &connector,
1837 switch (connector) {
1838 case CONNECTOR_PROPRIETARY_LEGACY:
1839 if ((tmp >> 4) & 0x1)
1840 devices = ATOM_DEVICE_DFP2_SUPPORT;
1842 devices = ATOM_DEVICE_DFP1_SUPPORT;
1843 radeon_add_legacy_encoder(dev,
1844 radeon_get_encoder_id
1847 radeon_add_legacy_connector(dev, i, devices,
1848 legacy_connector_convert
1851 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D);
1853 case CONNECTOR_CRT_LEGACY:
1855 devices = ATOM_DEVICE_CRT2_SUPPORT;
1856 radeon_add_legacy_encoder(dev,
1857 radeon_get_encoder_id
1859 ATOM_DEVICE_CRT2_SUPPORT,
1861 ATOM_DEVICE_CRT2_SUPPORT);
1863 devices = ATOM_DEVICE_CRT1_SUPPORT;
1864 radeon_add_legacy_encoder(dev,
1865 radeon_get_encoder_id
1867 ATOM_DEVICE_CRT1_SUPPORT,
1869 ATOM_DEVICE_CRT1_SUPPORT);
1871 radeon_add_legacy_connector(dev,
1874 legacy_connector_convert
1877 CONNECTOR_OBJECT_ID_VGA);
1879 case CONNECTOR_DVI_I_LEGACY:
1882 devices |= ATOM_DEVICE_CRT2_SUPPORT;
1883 radeon_add_legacy_encoder(dev,
1884 radeon_get_encoder_id
1886 ATOM_DEVICE_CRT2_SUPPORT,
1888 ATOM_DEVICE_CRT2_SUPPORT);
1890 devices |= ATOM_DEVICE_CRT1_SUPPORT;
1891 radeon_add_legacy_encoder(dev,
1892 radeon_get_encoder_id
1894 ATOM_DEVICE_CRT1_SUPPORT,
1896 ATOM_DEVICE_CRT1_SUPPORT);
1898 if ((tmp >> 4) & 0x1) {
1899 devices |= ATOM_DEVICE_DFP2_SUPPORT;
1900 radeon_add_legacy_encoder(dev,
1901 radeon_get_encoder_id
1903 ATOM_DEVICE_DFP2_SUPPORT,
1905 ATOM_DEVICE_DFP2_SUPPORT);
1906 connector_object_id = combios_check_dl_dvi(dev, 0);
1908 devices |= ATOM_DEVICE_DFP1_SUPPORT;
1909 radeon_add_legacy_encoder(dev,
1910 radeon_get_encoder_id
1912 ATOM_DEVICE_DFP1_SUPPORT,
1914 ATOM_DEVICE_DFP1_SUPPORT);
1915 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1917 radeon_add_legacy_connector(dev,
1920 legacy_connector_convert
1923 connector_object_id);
1925 case CONNECTOR_DVI_D_LEGACY:
1926 if ((tmp >> 4) & 0x1) {
1927 devices = ATOM_DEVICE_DFP2_SUPPORT;
1928 connector_object_id = combios_check_dl_dvi(dev, 1);
1930 devices = ATOM_DEVICE_DFP1_SUPPORT;
1931 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1933 radeon_add_legacy_encoder(dev,
1934 radeon_get_encoder_id
1937 radeon_add_legacy_connector(dev, i, devices,
1938 legacy_connector_convert
1941 connector_object_id);
1943 case CONNECTOR_CTV_LEGACY:
1944 case CONNECTOR_STV_LEGACY:
1945 radeon_add_legacy_encoder(dev,
1946 radeon_get_encoder_id
1948 ATOM_DEVICE_TV1_SUPPORT,
1950 ATOM_DEVICE_TV1_SUPPORT);
1951 radeon_add_legacy_connector(dev, i,
1952 ATOM_DEVICE_TV1_SUPPORT,
1953 legacy_connector_convert
1956 CONNECTOR_OBJECT_ID_SVIDEO);
1959 DRM_ERROR("Unknown connector type: %d\n",
1966 uint16_t tmds_info =
1967 combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1969 DRM_DEBUG("Found DFP table, assuming DVI connector\n");
1971 radeon_add_legacy_encoder(dev,
1972 radeon_get_encoder_id(dev,
1973 ATOM_DEVICE_CRT1_SUPPORT,
1975 ATOM_DEVICE_CRT1_SUPPORT);
1976 radeon_add_legacy_encoder(dev,
1977 radeon_get_encoder_id(dev,
1978 ATOM_DEVICE_DFP1_SUPPORT,
1980 ATOM_DEVICE_DFP1_SUPPORT);
1982 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1983 radeon_add_legacy_connector(dev,
1985 ATOM_DEVICE_CRT1_SUPPORT |
1986 ATOM_DEVICE_DFP1_SUPPORT,
1987 DRM_MODE_CONNECTOR_DVII,
1989 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I);
1992 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
1993 DRM_DEBUG("Found CRT table, assuming VGA connector\n");
1995 radeon_add_legacy_encoder(dev,
1996 radeon_get_encoder_id(dev,
1997 ATOM_DEVICE_CRT1_SUPPORT,
1999 ATOM_DEVICE_CRT1_SUPPORT);
2000 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2001 radeon_add_legacy_connector(dev,
2003 ATOM_DEVICE_CRT1_SUPPORT,
2004 DRM_MODE_CONNECTOR_VGA,
2006 CONNECTOR_OBJECT_ID_VGA);
2008 DRM_DEBUG("No connector info found\n");
2014 if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
2016 combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
2018 uint16_t lcd_ddc_info =
2019 combios_get_table_offset(dev,
2020 COMBIOS_LCD_DDC_INFO_TABLE);
2022 radeon_add_legacy_encoder(dev,
2023 radeon_get_encoder_id(dev,
2024 ATOM_DEVICE_LCD1_SUPPORT,
2026 ATOM_DEVICE_LCD1_SUPPORT);
2029 ddc_type = RBIOS8(lcd_ddc_info + 2);
2033 combios_setup_i2c_bus
2034 (rdev, RADEON_GPIO_MONID);
2038 combios_setup_i2c_bus
2039 (rdev, RADEON_GPIO_DVI_DDC);
2043 combios_setup_i2c_bus
2044 (rdev, RADEON_GPIO_VGA_DDC);
2048 combios_setup_i2c_bus
2049 (rdev, RADEON_GPIO_CRT2_DDC);
2053 combios_setup_i2c_bus
2054 (rdev, RADEON_GPIOPAD_MASK);
2055 ddc_i2c.mask_clk_mask =
2056 RBIOS32(lcd_ddc_info + 3);
2057 ddc_i2c.mask_data_mask =
2058 RBIOS32(lcd_ddc_info + 7);
2059 ddc_i2c.a_clk_mask =
2060 RBIOS32(lcd_ddc_info + 3);
2061 ddc_i2c.a_data_mask =
2062 RBIOS32(lcd_ddc_info + 7);
2063 ddc_i2c.en_clk_mask =
2064 RBIOS32(lcd_ddc_info + 3);
2065 ddc_i2c.en_data_mask =
2066 RBIOS32(lcd_ddc_info + 7);
2067 ddc_i2c.y_clk_mask =
2068 RBIOS32(lcd_ddc_info + 3);
2069 ddc_i2c.y_data_mask =
2070 RBIOS32(lcd_ddc_info + 7);
2074 combios_setup_i2c_bus
2075 (rdev, RADEON_MDGPIO_MASK);
2076 ddc_i2c.mask_clk_mask =
2077 RBIOS32(lcd_ddc_info + 3);
2078 ddc_i2c.mask_data_mask =
2079 RBIOS32(lcd_ddc_info + 7);
2080 ddc_i2c.a_clk_mask =
2081 RBIOS32(lcd_ddc_info + 3);
2082 ddc_i2c.a_data_mask =
2083 RBIOS32(lcd_ddc_info + 7);
2084 ddc_i2c.en_clk_mask =
2085 RBIOS32(lcd_ddc_info + 3);
2086 ddc_i2c.en_data_mask =
2087 RBIOS32(lcd_ddc_info + 7);
2088 ddc_i2c.y_clk_mask =
2089 RBIOS32(lcd_ddc_info + 3);
2090 ddc_i2c.y_data_mask =
2091 RBIOS32(lcd_ddc_info + 7);
2094 ddc_i2c.valid = false;
2097 DRM_DEBUG("LCD DDC Info Table found!\n");
2099 ddc_i2c.valid = false;
2101 radeon_add_legacy_connector(dev,
2103 ATOM_DEVICE_LCD1_SUPPORT,
2104 DRM_MODE_CONNECTOR_LVDS,
2106 CONNECTOR_OBJECT_ID_LVDS);
2110 /* check TV table */
2111 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
2113 combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
2115 if (RBIOS8(tv_info + 6) == 'T') {
2116 if (radeon_apply_legacy_tv_quirks(dev)) {
2117 radeon_add_legacy_encoder(dev,
2118 radeon_get_encoder_id
2120 ATOM_DEVICE_TV1_SUPPORT,
2122 ATOM_DEVICE_TV1_SUPPORT);
2123 radeon_add_legacy_connector(dev, 6,
2124 ATOM_DEVICE_TV1_SUPPORT,
2125 DRM_MODE_CONNECTOR_SVIDEO,
2127 CONNECTOR_OBJECT_ID_SVIDEO);
2133 radeon_link_encoder_connector(dev);
2138 void radeon_external_tmds_setup(struct drm_encoder *encoder)
2140 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2141 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2146 switch (tmds->dvo_chip) {
2149 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2150 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2153 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2156 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2159 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2162 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2165 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2168 /* sil 1178 - untested */
2187 bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2189 struct drm_device *dev = encoder->dev;
2190 struct radeon_device *rdev = dev->dev_private;
2191 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2193 uint8_t blocks, slave_addr, rev;
2195 uint32_t reg, val, and_mask, or_mask;
2196 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2198 if (rdev->bios == NULL)
2204 if (rdev->flags & RADEON_IS_IGP) {
2205 offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
2206 rev = RBIOS8(offset);
2208 rev = RBIOS8(offset);
2210 blocks = RBIOS8(offset + 3);
2212 while (blocks > 0) {
2213 id = RBIOS16(index);
2217 reg = (id & 0x1fff) * 4;
2218 val = RBIOS32(index);
2223 reg = (id & 0x1fff) * 4;
2224 and_mask = RBIOS32(index);
2226 or_mask = RBIOS32(index);
2229 val = (val & and_mask) | or_mask;
2233 val = RBIOS16(index);
2238 val = RBIOS16(index);
2243 slave_addr = id & 0xff;
2244 slave_addr >>= 1; /* 7 bit addressing */
2246 reg = RBIOS8(index);
2248 val = RBIOS8(index);
2250 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2251 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2254 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2257 DRM_ERROR("Unknown id %d\n", id >> 13);
2266 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2268 index = offset + 10;
2269 id = RBIOS16(index);
2270 while (id != 0xffff) {
2274 reg = (id & 0x1fff) * 4;
2275 val = RBIOS32(index);
2279 reg = (id & 0x1fff) * 4;
2280 and_mask = RBIOS32(index);
2282 or_mask = RBIOS32(index);
2285 val = (val & and_mask) | or_mask;
2289 val = RBIOS16(index);
2295 and_mask = RBIOS32(index);
2297 or_mask = RBIOS32(index);
2299 val = RREG32_PLL(reg);
2300 val = (val & and_mask) | or_mask;
2301 WREG32_PLL(reg, val);
2305 val = RBIOS8(index);
2307 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2308 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2311 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2314 DRM_ERROR("Unknown id %d\n", id >> 13);
2317 id = RBIOS16(index);
2325 static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
2327 struct radeon_device *rdev = dev->dev_private;
2330 while (RBIOS16(offset)) {
2331 uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
2332 uint32_t addr = (RBIOS16(offset) & 0x1fff);
2333 uint32_t val, and_mask, or_mask;
2339 val = RBIOS32(offset);
2344 val = RBIOS32(offset);
2349 and_mask = RBIOS32(offset);
2351 or_mask = RBIOS32(offset);
2359 and_mask = RBIOS32(offset);
2361 or_mask = RBIOS32(offset);
2369 val = RBIOS16(offset);
2374 val = RBIOS16(offset);
2381 (RADEON_CLK_PWRMGT_CNTL) &
2388 if ((RREG32(RADEON_MC_STATUS) &
2404 static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
2406 struct radeon_device *rdev = dev->dev_private;
2409 while (RBIOS8(offset)) {
2410 uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
2411 uint8_t addr = (RBIOS8(offset) & 0x3f);
2412 uint32_t val, shift, tmp;
2413 uint32_t and_mask, or_mask;
2418 val = RBIOS32(offset);
2420 WREG32_PLL(addr, val);
2423 shift = RBIOS8(offset) * 8;
2425 and_mask = RBIOS8(offset) << shift;
2426 and_mask |= ~(0xff << shift);
2428 or_mask = RBIOS8(offset) << shift;
2430 tmp = RREG32_PLL(addr);
2433 WREG32_PLL(addr, tmp);
2449 (RADEON_CLK_PWRMGT_CNTL) &
2457 (RADEON_CLK_PWRMGT_CNTL) &
2464 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
2465 if (tmp & RADEON_CG_NO1_DEBUG_0) {
2467 uint32_t mclk_cntl =
2470 mclk_cntl &= 0xffff0000;
2471 /*mclk_cntl |= 0x00001111;*//* ??? */
2472 WREG32_PLL(RADEON_MCLK_CNTL,
2477 (RADEON_CLK_PWRMGT_CNTL,
2479 ~RADEON_CG_NO1_DEBUG_0);
2494 static void combios_parse_ram_reset_table(struct drm_device *dev,
2497 struct radeon_device *rdev = dev->dev_private;
2501 uint8_t val = RBIOS8(offset);
2502 while (val != 0xff) {
2506 uint32_t channel_complete_mask;
2508 if (ASIC_IS_R300(rdev))
2509 channel_complete_mask =
2510 R300_MEM_PWRUP_COMPLETE;
2512 channel_complete_mask =
2513 RADEON_MEM_PWRUP_COMPLETE;
2516 if ((RREG32(RADEON_MEM_STR_CNTL) &
2517 channel_complete_mask) ==
2518 channel_complete_mask)
2522 uint32_t or_mask = RBIOS16(offset);
2525 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2526 tmp &= RADEON_SDRAM_MODE_MASK;
2528 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2530 or_mask = val << 24;
2531 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2532 tmp &= RADEON_B3MEM_RESET_MASK;
2534 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2536 val = RBIOS8(offset);
2541 static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
2542 int mem_addr_mapping)
2544 struct radeon_device *rdev = dev->dev_private;
2549 mem_cntl = RREG32(RADEON_MEM_CNTL);
2550 if (mem_cntl & RV100_HALF_MODE)
2553 mem_cntl &= ~(0xff << 8);
2554 mem_cntl |= (mem_addr_mapping & 0xff) << 8;
2555 WREG32(RADEON_MEM_CNTL, mem_cntl);
2556 RREG32(RADEON_MEM_CNTL);
2560 /* something like this???? */
2562 addr = ram * 1024 * 1024;
2563 /* write to each page */
2564 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2565 WREG32(RADEON_MM_DATA, 0xdeadbeef);
2566 /* read back and verify */
2567 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2568 if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
2575 static void combios_write_ram_size(struct drm_device *dev)
2577 struct radeon_device *rdev = dev->dev_private;
2580 uint32_t mem_size = 0;
2581 uint32_t mem_cntl = 0;
2583 /* should do something smarter here I guess... */
2584 if (rdev->flags & RADEON_IS_IGP)
2587 /* first check detected mem table */
2588 offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
2590 rev = RBIOS8(offset);
2592 mem_cntl = RBIOS32(offset + 1);
2593 mem_size = RBIOS16(offset + 5);
2594 if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) &&
2595 ((dev->pdev->device != 0x515e)
2596 && (dev->pdev->device != 0x5969)))
2597 WREG32(RADEON_MEM_CNTL, mem_cntl);
2603 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
2605 rev = RBIOS8(offset - 1);
2607 if (((rdev->flags & RADEON_FAMILY_MASK) <
2609 && ((dev->pdev->device != 0x515e)
2610 && (dev->pdev->device != 0x5969))) {
2612 int mem_addr_mapping = 0;
2614 while (RBIOS8(offset)) {
2615 ram = RBIOS8(offset);
2618 if (mem_addr_mapping != 0x25)
2621 combios_detect_ram(dev, ram,
2628 mem_size = RBIOS8(offset);
2630 mem_size = RBIOS8(offset);
2631 mem_size *= 2; /* convert to MB */
2636 mem_size *= (1024 * 1024); /* convert to bytes */
2637 WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
2640 void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
2642 uint16_t dyn_clk_info =
2643 combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2646 combios_parse_pll_table(dev, dyn_clk_info);
2649 void radeon_combios_asic_init(struct drm_device *dev)
2651 struct radeon_device *rdev = dev->dev_private;
2654 /* port hardcoded mac stuff from radeonfb */
2655 if (rdev->bios == NULL)
2659 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
2661 combios_parse_mmio_table(dev, table);
2664 table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
2666 combios_parse_pll_table(dev, table);
2669 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
2671 combios_parse_mmio_table(dev, table);
2673 if (!(rdev->flags & RADEON_IS_IGP)) {
2676 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
2678 combios_parse_mmio_table(dev, table);
2681 table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
2683 combios_parse_ram_reset_table(dev, table);
2687 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
2689 combios_parse_mmio_table(dev, table);
2691 /* write CONFIG_MEMSIZE */
2692 combios_write_ram_size(dev);
2696 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2698 combios_parse_pll_table(dev, table);
2702 void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
2704 struct radeon_device *rdev = dev->dev_private;
2705 uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
2707 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
2708 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2709 bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
2711 /* let the bios control the backlight */
2712 bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
2714 /* tell the bios not to handle mode switching */
2715 bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
2716 RADEON_ACC_MODE_CHANGE);
2718 /* tell the bios a driver is loaded */
2719 bios_7_scratch |= RADEON_DRV_LOADED;
2721 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
2722 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2723 WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
2726 void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
2728 struct drm_device *dev = encoder->dev;
2729 struct radeon_device *rdev = dev->dev_private;
2730 uint32_t bios_6_scratch;
2732 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2735 bios_6_scratch |= RADEON_DRIVER_CRITICAL;
2737 bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
2739 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2743 radeon_combios_connected_scratch_regs(struct drm_connector *connector,
2744 struct drm_encoder *encoder,
2747 struct drm_device *dev = connector->dev;
2748 struct radeon_device *rdev = dev->dev_private;
2749 struct radeon_connector *radeon_connector =
2750 to_radeon_connector(connector);
2751 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2752 uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
2753 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
2755 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
2756 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
2758 DRM_DEBUG("TV1 connected\n");
2760 bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
2761 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
2762 bios_5_scratch |= RADEON_TV1_ON;
2763 bios_5_scratch |= RADEON_ACC_REQ_TV1;
2765 DRM_DEBUG("TV1 disconnected\n");
2766 bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
2767 bios_5_scratch &= ~RADEON_TV1_ON;
2768 bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
2771 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
2772 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
2774 DRM_DEBUG("LCD1 connected\n");
2775 bios_4_scratch |= RADEON_LCD1_ATTACHED;
2776 bios_5_scratch |= RADEON_LCD1_ON;
2777 bios_5_scratch |= RADEON_ACC_REQ_LCD1;
2779 DRM_DEBUG("LCD1 disconnected\n");
2780 bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
2781 bios_5_scratch &= ~RADEON_LCD1_ON;
2782 bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
2785 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
2786 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
2788 DRM_DEBUG("CRT1 connected\n");
2789 bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
2790 bios_5_scratch |= RADEON_CRT1_ON;
2791 bios_5_scratch |= RADEON_ACC_REQ_CRT1;
2793 DRM_DEBUG("CRT1 disconnected\n");
2794 bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
2795 bios_5_scratch &= ~RADEON_CRT1_ON;
2796 bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
2799 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
2800 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
2802 DRM_DEBUG("CRT2 connected\n");
2803 bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
2804 bios_5_scratch |= RADEON_CRT2_ON;
2805 bios_5_scratch |= RADEON_ACC_REQ_CRT2;
2807 DRM_DEBUG("CRT2 disconnected\n");
2808 bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
2809 bios_5_scratch &= ~RADEON_CRT2_ON;
2810 bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
2813 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
2814 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
2816 DRM_DEBUG("DFP1 connected\n");
2817 bios_4_scratch |= RADEON_DFP1_ATTACHED;
2818 bios_5_scratch |= RADEON_DFP1_ON;
2819 bios_5_scratch |= RADEON_ACC_REQ_DFP1;
2821 DRM_DEBUG("DFP1 disconnected\n");
2822 bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
2823 bios_5_scratch &= ~RADEON_DFP1_ON;
2824 bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
2827 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
2828 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
2830 DRM_DEBUG("DFP2 connected\n");
2831 bios_4_scratch |= RADEON_DFP2_ATTACHED;
2832 bios_5_scratch |= RADEON_DFP2_ON;
2833 bios_5_scratch |= RADEON_ACC_REQ_DFP2;
2835 DRM_DEBUG("DFP2 disconnected\n");
2836 bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
2837 bios_5_scratch &= ~RADEON_DFP2_ON;
2838 bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
2841 WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
2842 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
2846 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
2848 struct drm_device *dev = encoder->dev;
2849 struct radeon_device *rdev = dev->dev_private;
2850 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2851 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
2853 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
2854 bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
2855 bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
2857 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
2858 bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
2859 bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
2861 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
2862 bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
2863 bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
2865 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
2866 bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
2867 bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
2869 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
2870 bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
2871 bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
2873 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
2874 bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
2875 bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
2877 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
2881 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
2883 struct drm_device *dev = encoder->dev;
2884 struct radeon_device *rdev = dev->dev_private;
2885 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2886 uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2888 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
2890 bios_6_scratch |= RADEON_TV_DPMS_ON;
2892 bios_6_scratch &= ~RADEON_TV_DPMS_ON;
2894 if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
2896 bios_6_scratch |= RADEON_CRT_DPMS_ON;
2898 bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
2900 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
2902 bios_6_scratch |= RADEON_LCD_DPMS_ON;
2904 bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
2906 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
2908 bios_6_scratch |= RADEON_DFP_DPMS_ON;
2910 bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
2912 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);