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,
54 struct radeon_hpd *hpd);
56 /* from radeon_legacy_encoder.c */
58 radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id,
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;
154 /* absolute offset tables */
155 case COMBIOS_ASIC_INIT_1_TABLE:
156 check_offset = RBIOS16(rdev->bios_header_start + 0xc);
158 offset = check_offset;
160 case COMBIOS_BIOS_SUPPORT_TABLE:
161 check_offset = RBIOS16(rdev->bios_header_start + 0x14);
163 offset = check_offset;
165 case COMBIOS_DAC_PROGRAMMING_TABLE:
166 check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
168 offset = check_offset;
170 case COMBIOS_MAX_COLOR_DEPTH_TABLE:
171 check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
173 offset = check_offset;
175 case COMBIOS_CRTC_INFO_TABLE:
176 check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
178 offset = check_offset;
180 case COMBIOS_PLL_INFO_TABLE:
181 check_offset = RBIOS16(rdev->bios_header_start + 0x30);
183 offset = check_offset;
185 case COMBIOS_TV_INFO_TABLE:
186 check_offset = RBIOS16(rdev->bios_header_start + 0x32);
188 offset = check_offset;
190 case COMBIOS_DFP_INFO_TABLE:
191 check_offset = RBIOS16(rdev->bios_header_start + 0x34);
193 offset = check_offset;
195 case COMBIOS_HW_CONFIG_INFO_TABLE:
196 check_offset = RBIOS16(rdev->bios_header_start + 0x36);
198 offset = check_offset;
200 case COMBIOS_MULTIMEDIA_INFO_TABLE:
201 check_offset = RBIOS16(rdev->bios_header_start + 0x38);
203 offset = check_offset;
205 case COMBIOS_TV_STD_PATCH_TABLE:
206 check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
208 offset = check_offset;
210 case COMBIOS_LCD_INFO_TABLE:
211 check_offset = RBIOS16(rdev->bios_header_start + 0x40);
213 offset = check_offset;
215 case COMBIOS_MOBILE_INFO_TABLE:
216 check_offset = RBIOS16(rdev->bios_header_start + 0x42);
218 offset = check_offset;
220 case COMBIOS_PLL_INIT_TABLE:
221 check_offset = RBIOS16(rdev->bios_header_start + 0x46);
223 offset = check_offset;
225 case COMBIOS_MEM_CONFIG_TABLE:
226 check_offset = RBIOS16(rdev->bios_header_start + 0x48);
228 offset = check_offset;
230 case COMBIOS_SAVE_MASK_TABLE:
231 check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
233 offset = check_offset;
235 case COMBIOS_HARDCODED_EDID_TABLE:
236 check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
238 offset = check_offset;
240 case COMBIOS_ASIC_INIT_2_TABLE:
241 check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
243 offset = check_offset;
245 case COMBIOS_CONNECTOR_INFO_TABLE:
246 check_offset = RBIOS16(rdev->bios_header_start + 0x50);
248 offset = check_offset;
250 case COMBIOS_DYN_CLK_1_TABLE:
251 check_offset = RBIOS16(rdev->bios_header_start + 0x52);
253 offset = check_offset;
255 case COMBIOS_RESERVED_MEM_TABLE:
256 check_offset = RBIOS16(rdev->bios_header_start + 0x54);
258 offset = check_offset;
260 case COMBIOS_EXT_TMDS_INFO_TABLE:
261 check_offset = RBIOS16(rdev->bios_header_start + 0x58);
263 offset = check_offset;
265 case COMBIOS_MEM_CLK_INFO_TABLE:
266 check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
268 offset = check_offset;
270 case COMBIOS_EXT_DAC_INFO_TABLE:
271 check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
273 offset = check_offset;
275 case COMBIOS_MISC_INFO_TABLE:
276 check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
278 offset = check_offset;
280 case COMBIOS_CRT_INFO_TABLE:
281 check_offset = RBIOS16(rdev->bios_header_start + 0x60);
283 offset = check_offset;
285 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
286 check_offset = RBIOS16(rdev->bios_header_start + 0x62);
288 offset = check_offset;
290 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
291 check_offset = RBIOS16(rdev->bios_header_start + 0x64);
293 offset = check_offset;
295 case COMBIOS_FAN_SPEED_INFO_TABLE:
296 check_offset = RBIOS16(rdev->bios_header_start + 0x66);
298 offset = check_offset;
300 case COMBIOS_OVERDRIVE_INFO_TABLE:
301 check_offset = RBIOS16(rdev->bios_header_start + 0x68);
303 offset = check_offset;
305 case COMBIOS_OEM_INFO_TABLE:
306 check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
308 offset = check_offset;
310 case COMBIOS_DYN_CLK_2_TABLE:
311 check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
313 offset = check_offset;
315 case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
316 check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
318 offset = check_offset;
320 case COMBIOS_I2C_INFO_TABLE:
321 check_offset = RBIOS16(rdev->bios_header_start + 0x70);
323 offset = check_offset;
325 /* relative offset tables */
326 case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
328 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
330 rev = RBIOS8(check_offset);
332 check_offset = RBIOS16(check_offset + 0x3);
334 offset = check_offset;
338 case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */
340 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
342 rev = RBIOS8(check_offset);
344 check_offset = RBIOS16(check_offset + 0x5);
346 offset = check_offset;
350 case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */
352 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
354 rev = RBIOS8(check_offset);
356 check_offset = RBIOS16(check_offset + 0x7);
358 offset = check_offset;
362 case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */
364 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
366 rev = RBIOS8(check_offset);
368 check_offset = RBIOS16(check_offset + 0x9);
370 offset = check_offset;
374 case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */
376 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
378 while (RBIOS8(check_offset++));
381 offset = check_offset;
384 case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */
386 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
388 check_offset = RBIOS16(check_offset + 0x11);
390 offset = check_offset;
393 case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */
395 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
397 check_offset = RBIOS16(check_offset + 0x13);
399 offset = check_offset;
402 case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */
404 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
406 check_offset = RBIOS16(check_offset + 0x15);
408 offset = check_offset;
411 case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */
413 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
415 check_offset = RBIOS16(check_offset + 0x17);
417 offset = check_offset;
420 case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */
422 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
424 check_offset = RBIOS16(check_offset + 0x2);
426 offset = check_offset;
429 case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */
431 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
433 check_offset = RBIOS16(check_offset + 0x4);
435 offset = check_offset;
446 static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
449 struct radeon_i2c_bus_rec i2c;
451 if (ddc_line == RADEON_GPIOPAD_MASK) {
452 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
453 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
454 i2c.a_clk_reg = RADEON_GPIOPAD_A;
455 i2c.a_data_reg = RADEON_GPIOPAD_A;
456 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
457 i2c.en_data_reg = RADEON_GPIOPAD_EN;
458 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
459 i2c.y_data_reg = RADEON_GPIOPAD_Y;
460 } else if (ddc_line == RADEON_MDGPIO_MASK) {
461 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
462 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
463 i2c.a_clk_reg = RADEON_MDGPIO_A;
464 i2c.a_data_reg = RADEON_MDGPIO_A;
465 i2c.en_clk_reg = RADEON_MDGPIO_EN;
466 i2c.en_data_reg = RADEON_MDGPIO_EN;
467 i2c.y_clk_reg = RADEON_MDGPIO_Y;
468 i2c.y_data_reg = RADEON_MDGPIO_Y;
470 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
471 i2c.mask_data_mask = RADEON_GPIO_EN_0;
472 i2c.a_clk_mask = RADEON_GPIO_A_1;
473 i2c.a_data_mask = RADEON_GPIO_A_0;
474 i2c.en_clk_mask = RADEON_GPIO_EN_1;
475 i2c.en_data_mask = RADEON_GPIO_EN_0;
476 i2c.y_clk_mask = RADEON_GPIO_Y_1;
477 i2c.y_data_mask = RADEON_GPIO_Y_0;
479 i2c.mask_clk_reg = ddc_line;
480 i2c.mask_data_reg = ddc_line;
481 i2c.a_clk_reg = ddc_line;
482 i2c.a_data_reg = ddc_line;
483 i2c.en_clk_reg = ddc_line;
484 i2c.en_data_reg = ddc_line;
485 i2c.y_clk_reg = ddc_line;
486 i2c.y_data_reg = ddc_line;
489 if (rdev->family < CHIP_R200)
490 i2c.hw_capable = false;
493 case RADEON_GPIO_VGA_DDC:
494 case RADEON_GPIO_DVI_DDC:
495 i2c.hw_capable = true;
497 case RADEON_GPIO_MONID:
498 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
499 * reliably on some pre-r4xx hardware; not sure why.
501 i2c.hw_capable = false;
504 i2c.hw_capable = false;
519 bool radeon_combios_get_clock_info(struct drm_device *dev)
521 struct radeon_device *rdev = dev->dev_private;
523 struct radeon_pll *p1pll = &rdev->clock.p1pll;
524 struct radeon_pll *p2pll = &rdev->clock.p2pll;
525 struct radeon_pll *spll = &rdev->clock.spll;
526 struct radeon_pll *mpll = &rdev->clock.mpll;
530 if (rdev->bios == NULL)
533 pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
535 rev = RBIOS8(pll_info);
538 p1pll->reference_freq = RBIOS16(pll_info + 0xe);
539 p1pll->reference_div = RBIOS16(pll_info + 0x10);
540 p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
541 p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
544 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
545 p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
547 p1pll->pll_in_min = 40;
548 p1pll->pll_in_max = 500;
553 spll->reference_freq = RBIOS16(pll_info + 0x1a);
554 spll->reference_div = RBIOS16(pll_info + 0x1c);
555 spll->pll_out_min = RBIOS32(pll_info + 0x1e);
556 spll->pll_out_max = RBIOS32(pll_info + 0x22);
559 spll->pll_in_min = RBIOS32(pll_info + 0x48);
560 spll->pll_in_max = RBIOS32(pll_info + 0x4c);
563 spll->pll_in_min = 40;
564 spll->pll_in_max = 500;
568 mpll->reference_freq = RBIOS16(pll_info + 0x26);
569 mpll->reference_div = RBIOS16(pll_info + 0x28);
570 mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
571 mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
574 mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
575 mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
578 mpll->pll_in_min = 40;
579 mpll->pll_in_max = 500;
582 /* default sclk/mclk */
583 sclk = RBIOS16(pll_info + 0xa);
584 mclk = RBIOS16(pll_info + 0x8);
590 rdev->clock.default_sclk = sclk;
591 rdev->clock.default_mclk = mclk;
598 bool radeon_combios_sideport_present(struct radeon_device *rdev)
600 struct drm_device *dev = rdev->ddev;
603 igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE);
606 if (RBIOS16(igp_info + 0x4))
612 static const uint32_t default_primarydac_adj[CHIP_LAST] = {
613 0x00000808, /* r100 */
614 0x00000808, /* rv100 */
615 0x00000808, /* rs100 */
616 0x00000808, /* rv200 */
617 0x00000808, /* rs200 */
618 0x00000808, /* r200 */
619 0x00000808, /* rv250 */
620 0x00000000, /* rs300 */
621 0x00000808, /* rv280 */
622 0x00000808, /* r300 */
623 0x00000808, /* r350 */
624 0x00000808, /* rv350 */
625 0x00000808, /* rv380 */
626 0x00000808, /* r420 */
627 0x00000808, /* r423 */
628 0x00000808, /* rv410 */
629 0x00000000, /* rs400 */
630 0x00000000, /* rs480 */
633 static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev,
634 struct radeon_encoder_primary_dac *p_dac)
636 p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family];
640 struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
644 struct drm_device *dev = encoder->base.dev;
645 struct radeon_device *rdev = dev->dev_private;
647 uint8_t rev, bg, dac;
648 struct radeon_encoder_primary_dac *p_dac = NULL;
651 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac),
657 if (rdev->bios == NULL)
660 /* check CRT table */
661 dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
663 rev = RBIOS8(dac_info) & 0x3;
665 bg = RBIOS8(dac_info + 0x2) & 0xf;
666 dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
667 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
669 bg = RBIOS8(dac_info + 0x2) & 0xf;
670 dac = RBIOS8(dac_info + 0x3) & 0xf;
671 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
677 if (!found) /* fallback to defaults */
678 radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
684 radeon_combios_get_tv_info(struct radeon_device *rdev)
686 struct drm_device *dev = rdev->ddev;
688 enum radeon_tv_std tv_std = TV_STD_NTSC;
690 tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
692 if (RBIOS8(tv_info + 6) == 'T') {
693 switch (RBIOS8(tv_info + 7) & 0xf) {
695 tv_std = TV_STD_NTSC;
696 DRM_INFO("Default TV standard: NTSC\n");
700 DRM_INFO("Default TV standard: PAL\n");
703 tv_std = TV_STD_PAL_M;
704 DRM_INFO("Default TV standard: PAL-M\n");
707 tv_std = TV_STD_PAL_60;
708 DRM_INFO("Default TV standard: PAL-60\n");
711 tv_std = TV_STD_NTSC_J;
712 DRM_INFO("Default TV standard: NTSC-J\n");
715 tv_std = TV_STD_SCART_PAL;
716 DRM_INFO("Default TV standard: SCART-PAL\n");
719 tv_std = TV_STD_NTSC;
721 ("Unknown TV standard; defaulting to NTSC\n");
725 switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
727 DRM_INFO("29.498928713 MHz TV ref clk\n");
730 DRM_INFO("28.636360000 MHz TV ref clk\n");
733 DRM_INFO("14.318180000 MHz TV ref clk\n");
736 DRM_INFO("27.000000000 MHz TV ref clk\n");
746 static const uint32_t default_tvdac_adj[CHIP_LAST] = {
747 0x00000000, /* r100 */
748 0x00280000, /* rv100 */
749 0x00000000, /* rs100 */
750 0x00880000, /* rv200 */
751 0x00000000, /* rs200 */
752 0x00000000, /* r200 */
753 0x00770000, /* rv250 */
754 0x00290000, /* rs300 */
755 0x00560000, /* rv280 */
756 0x00780000, /* r300 */
757 0x00770000, /* r350 */
758 0x00780000, /* rv350 */
759 0x00780000, /* rv380 */
760 0x01080000, /* r420 */
761 0x01080000, /* r423 */
762 0x01080000, /* rv410 */
763 0x00780000, /* rs400 */
764 0x00780000, /* rs480 */
767 static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
768 struct radeon_encoder_tv_dac *tv_dac)
770 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
771 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
772 tv_dac->ps2_tvdac_adj = 0x00880000;
773 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
774 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
778 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
782 struct drm_device *dev = encoder->base.dev;
783 struct radeon_device *rdev = dev->dev_private;
785 uint8_t rev, bg, dac;
786 struct radeon_encoder_tv_dac *tv_dac = NULL;
789 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
793 if (rdev->bios == NULL)
796 /* first check TV table */
797 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
799 rev = RBIOS8(dac_info + 0x3);
801 bg = RBIOS8(dac_info + 0xc) & 0xf;
802 dac = RBIOS8(dac_info + 0xd) & 0xf;
803 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
805 bg = RBIOS8(dac_info + 0xe) & 0xf;
806 dac = RBIOS8(dac_info + 0xf) & 0xf;
807 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
809 bg = RBIOS8(dac_info + 0x10) & 0xf;
810 dac = RBIOS8(dac_info + 0x11) & 0xf;
811 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
813 } else if (rev > 1) {
814 bg = RBIOS8(dac_info + 0xc) & 0xf;
815 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
816 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
818 bg = RBIOS8(dac_info + 0xd) & 0xf;
819 dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
820 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
822 bg = RBIOS8(dac_info + 0xe) & 0xf;
823 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
824 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
827 tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
830 /* then check CRT table */
832 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
834 rev = RBIOS8(dac_info) & 0x3;
836 bg = RBIOS8(dac_info + 0x3) & 0xf;
837 dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
838 tv_dac->ps2_tvdac_adj =
839 (bg << 16) | (dac << 20);
840 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
841 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
844 bg = RBIOS8(dac_info + 0x4) & 0xf;
845 dac = RBIOS8(dac_info + 0x5) & 0xf;
846 tv_dac->ps2_tvdac_adj =
847 (bg << 16) | (dac << 20);
848 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
849 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
853 DRM_INFO("No TV DAC info found in BIOS\n");
858 if (!found) /* fallback to defaults */
859 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
864 static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
868 struct radeon_encoder_lvds *lvds = NULL;
869 uint32_t fp_vert_stretch, fp_horz_stretch;
870 uint32_t ppll_div_sel, ppll_val;
871 uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
873 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
878 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
879 fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
881 /* These should be fail-safe defaults, fingers crossed */
882 lvds->panel_pwr_delay = 200;
883 lvds->panel_vcc_delay = 2000;
885 lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
886 lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
887 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
889 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
890 lvds->native_mode.vdisplay =
891 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
892 RADEON_VERT_PANEL_SHIFT) + 1;
894 lvds->native_mode.vdisplay =
895 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
897 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
898 lvds->native_mode.hdisplay =
899 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
900 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
902 lvds->native_mode.hdisplay =
903 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
905 if ((lvds->native_mode.hdisplay < 640) ||
906 (lvds->native_mode.vdisplay < 480)) {
907 lvds->native_mode.hdisplay = 640;
908 lvds->native_mode.vdisplay = 480;
911 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
912 ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
913 if ((ppll_val & 0x000707ff) == 0x1bb)
914 lvds->use_bios_dividers = false;
916 lvds->panel_ref_divider =
917 RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
918 lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
919 lvds->panel_fb_divider = ppll_val & 0x7ff;
921 if ((lvds->panel_ref_divider != 0) &&
922 (lvds->panel_fb_divider > 3))
923 lvds->use_bios_dividers = true;
925 lvds->panel_vcc_delay = 200;
927 DRM_INFO("Panel info derived from registers\n");
928 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
929 lvds->native_mode.vdisplay);
934 struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
937 struct drm_device *dev = encoder->base.dev;
938 struct radeon_device *rdev = dev->dev_private;
940 uint32_t panel_setup;
943 struct radeon_encoder_lvds *lvds = NULL;
945 if (rdev->bios == NULL) {
946 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
950 lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
953 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
958 for (i = 0; i < 24; i++)
959 stmp[i] = RBIOS8(lcd_info + i + 1);
962 DRM_INFO("Panel ID String: %s\n", stmp);
964 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
965 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
967 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
968 lvds->native_mode.vdisplay);
970 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
971 if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0)
972 lvds->panel_vcc_delay = 2000;
974 lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
975 lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
976 lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
978 lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
979 lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
980 lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
981 if ((lvds->panel_ref_divider != 0) &&
982 (lvds->panel_fb_divider > 3))
983 lvds->use_bios_dividers = true;
985 panel_setup = RBIOS32(lcd_info + 0x39);
986 lvds->lvds_gen_cntl = 0xff00;
987 if (panel_setup & 0x1)
988 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
990 if ((panel_setup >> 4) & 0x1)
991 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
993 switch ((panel_setup >> 8) & 0x7) {
995 lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
998 lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
1001 lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
1007 if ((panel_setup >> 16) & 0x1)
1008 lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
1010 if ((panel_setup >> 17) & 0x1)
1011 lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
1013 if ((panel_setup >> 18) & 0x1)
1014 lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
1016 if ((panel_setup >> 23) & 0x1)
1017 lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
1019 lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
1021 for (i = 0; i < 32; i++) {
1022 tmp = RBIOS16(lcd_info + 64 + i * 2);
1026 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
1027 (RBIOS16(tmp + 2) ==
1028 lvds->native_mode.vdisplay)) {
1029 lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
1030 lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
1031 lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
1032 RBIOS16(tmp + 21)) * 8;
1034 lvds->native_mode.vtotal = RBIOS16(tmp + 24);
1035 lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
1036 lvds->native_mode.vsync_end =
1037 ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
1038 (RBIOS16(tmp + 28) & 0x7ff);
1040 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
1041 lvds->native_mode.flags = 0;
1042 /* set crtc values */
1043 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1048 DRM_INFO("No panel info found in BIOS\n");
1049 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
1053 encoder->native_mode = lvds->native_mode;
1057 static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
1058 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1059 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1060 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1061 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1062 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1063 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1064 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1065 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1066 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1067 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1068 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1069 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1070 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1071 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1072 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1073 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
1074 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1075 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
1078 bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
1079 struct radeon_encoder_int_tmds *tmds)
1081 struct drm_device *dev = encoder->base.dev;
1082 struct radeon_device *rdev = dev->dev_private;
1085 for (i = 0; i < 4; i++) {
1086 tmds->tmds_pll[i].value =
1087 default_tmds_pll[rdev->family][i].value;
1088 tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
1094 bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
1095 struct radeon_encoder_int_tmds *tmds)
1097 struct drm_device *dev = encoder->base.dev;
1098 struct radeon_device *rdev = dev->dev_private;
1103 if (rdev->bios == NULL)
1106 tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1109 ver = RBIOS8(tmds_info);
1110 DRM_INFO("DFP table revision: %d\n", ver);
1112 n = RBIOS8(tmds_info + 5) + 1;
1115 for (i = 0; i < n; i++) {
1116 tmds->tmds_pll[i].value =
1117 RBIOS32(tmds_info + i * 10 + 0x08);
1118 tmds->tmds_pll[i].freq =
1119 RBIOS16(tmds_info + i * 10 + 0x10);
1120 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1121 tmds->tmds_pll[i].freq,
1122 tmds->tmds_pll[i].value);
1124 } else if (ver == 4) {
1126 n = RBIOS8(tmds_info + 5) + 1;
1129 for (i = 0; i < n; i++) {
1130 tmds->tmds_pll[i].value =
1131 RBIOS32(tmds_info + stride + 0x08);
1132 tmds->tmds_pll[i].freq =
1133 RBIOS16(tmds_info + stride + 0x10);
1138 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1139 tmds->tmds_pll[i].freq,
1140 tmds->tmds_pll[i].value);
1144 DRM_INFO("No TMDS info found in BIOS\n");
1150 bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1151 struct radeon_encoder_ext_tmds *tmds)
1153 struct drm_device *dev = encoder->base.dev;
1154 struct radeon_device *rdev = dev->dev_private;
1155 struct radeon_i2c_bus_rec i2c_bus;
1157 /* default for macs */
1158 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1159 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1161 /* XXX some macs have duallink chips */
1162 switch (rdev->mode_info.connector_table) {
1163 case CT_POWERBOOK_EXTERNAL:
1164 case CT_MINI_EXTERNAL:
1166 tmds->dvo_chip = DVO_SIL164;
1167 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1174 bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
1175 struct radeon_encoder_ext_tmds *tmds)
1177 struct drm_device *dev = encoder->base.dev;
1178 struct radeon_device *rdev = dev->dev_private;
1180 uint8_t ver, id, blocks, clk, data;
1182 enum radeon_combios_ddc gpio;
1183 struct radeon_i2c_bus_rec i2c_bus;
1185 if (rdev->bios == NULL)
1188 tmds->i2c_bus = NULL;
1189 if (rdev->flags & RADEON_IS_IGP) {
1190 offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
1192 ver = RBIOS8(offset);
1193 DRM_INFO("GPIO Table revision: %d\n", ver);
1194 blocks = RBIOS8(offset + 2);
1195 for (i = 0; i < blocks; i++) {
1196 id = RBIOS8(offset + 3 + (i * 5) + 0);
1198 clk = RBIOS8(offset + 3 + (i * 5) + 3);
1199 data = RBIOS8(offset + 3 + (i * 5) + 4);
1200 i2c_bus.valid = true;
1201 i2c_bus.mask_clk_mask = (1 << clk);
1202 i2c_bus.mask_data_mask = (1 << data);
1203 i2c_bus.a_clk_mask = (1 << clk);
1204 i2c_bus.a_data_mask = (1 << data);
1205 i2c_bus.en_clk_mask = (1 << clk);
1206 i2c_bus.en_data_mask = (1 << data);
1207 i2c_bus.y_clk_mask = (1 << clk);
1208 i2c_bus.y_data_mask = (1 << data);
1209 i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
1210 i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
1211 i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
1212 i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
1213 i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
1214 i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
1215 i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
1216 i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
1217 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1218 tmds->dvo_chip = DVO_SIL164;
1219 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1225 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1227 ver = RBIOS8(offset);
1228 DRM_INFO("External TMDS Table revision: %d\n", ver);
1229 tmds->slave_addr = RBIOS8(offset + 4 + 2);
1230 tmds->slave_addr >>= 1; /* 7 bit addressing */
1231 gpio = RBIOS8(offset + 4 + 3);
1234 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1235 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1238 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1239 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1242 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1243 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1246 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1247 if (rdev->family >= CHIP_R300)
1248 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1250 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1251 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1253 case DDC_LCD: /* MM i2c */
1254 DRM_ERROR("MM i2c requires hw i2c engine\n");
1257 DRM_ERROR("Unsupported gpio %d\n", gpio);
1263 if (!tmds->i2c_bus) {
1264 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1271 bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1273 struct radeon_device *rdev = dev->dev_private;
1274 struct radeon_i2c_bus_rec ddc_i2c;
1275 struct radeon_hpd hpd;
1277 rdev->mode_info.connector_table = radeon_connector_table;
1278 if (rdev->mode_info.connector_table == CT_NONE) {
1279 #ifdef CONFIG_PPC_PMAC
1280 if (machine_is_compatible("PowerBook3,3")) {
1281 /* powerbook with VGA */
1282 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
1283 } else if (machine_is_compatible("PowerBook3,4") ||
1284 machine_is_compatible("PowerBook3,5")) {
1285 /* powerbook with internal tmds */
1286 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
1287 } else if (machine_is_compatible("PowerBook5,1") ||
1288 machine_is_compatible("PowerBook5,2") ||
1289 machine_is_compatible("PowerBook5,3") ||
1290 machine_is_compatible("PowerBook5,4") ||
1291 machine_is_compatible("PowerBook5,5")) {
1292 /* powerbook with external single link tmds (sil164) */
1293 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1294 } else if (machine_is_compatible("PowerBook5,6")) {
1295 /* powerbook with external dual or single link tmds */
1296 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1297 } else if (machine_is_compatible("PowerBook5,7") ||
1298 machine_is_compatible("PowerBook5,8") ||
1299 machine_is_compatible("PowerBook5,9")) {
1300 /* PowerBook6,2 ? */
1301 /* powerbook with external dual link tmds (sil1178?) */
1302 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1303 } else if (machine_is_compatible("PowerBook4,1") ||
1304 machine_is_compatible("PowerBook4,2") ||
1305 machine_is_compatible("PowerBook4,3") ||
1306 machine_is_compatible("PowerBook6,3") ||
1307 machine_is_compatible("PowerBook6,5") ||
1308 machine_is_compatible("PowerBook6,7")) {
1310 rdev->mode_info.connector_table = CT_IBOOK;
1311 } else if (machine_is_compatible("PowerMac4,4")) {
1313 rdev->mode_info.connector_table = CT_EMAC;
1314 } else if (machine_is_compatible("PowerMac10,1")) {
1315 /* mini with internal tmds */
1316 rdev->mode_info.connector_table = CT_MINI_INTERNAL;
1317 } else if (machine_is_compatible("PowerMac10,2")) {
1318 /* mini with external tmds */
1319 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
1320 } else if (machine_is_compatible("PowerMac12,1")) {
1322 /* imac g5 isight */
1323 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1325 #endif /* CONFIG_PPC_PMAC */
1326 rdev->mode_info.connector_table = CT_GENERIC;
1329 switch (rdev->mode_info.connector_table) {
1331 DRM_INFO("Connector Table: %d (generic)\n",
1332 rdev->mode_info.connector_table);
1333 /* these are the most common settings */
1334 if (rdev->flags & RADEON_SINGLE_CRTC) {
1335 /* VGA - primary dac */
1336 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1337 hpd.hpd = RADEON_HPD_NONE;
1338 radeon_add_legacy_encoder(dev,
1339 radeon_get_encoder_id(dev,
1340 ATOM_DEVICE_CRT1_SUPPORT,
1342 ATOM_DEVICE_CRT1_SUPPORT);
1343 radeon_add_legacy_connector(dev, 0,
1344 ATOM_DEVICE_CRT1_SUPPORT,
1345 DRM_MODE_CONNECTOR_VGA,
1347 CONNECTOR_OBJECT_ID_VGA,
1349 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1351 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
1352 hpd.hpd = RADEON_HPD_NONE;
1353 radeon_add_legacy_encoder(dev,
1354 radeon_get_encoder_id(dev,
1355 ATOM_DEVICE_LCD1_SUPPORT,
1357 ATOM_DEVICE_LCD1_SUPPORT);
1358 radeon_add_legacy_connector(dev, 0,
1359 ATOM_DEVICE_LCD1_SUPPORT,
1360 DRM_MODE_CONNECTOR_LVDS,
1362 CONNECTOR_OBJECT_ID_LVDS,
1365 /* VGA - primary dac */
1366 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1367 hpd.hpd = RADEON_HPD_NONE;
1368 radeon_add_legacy_encoder(dev,
1369 radeon_get_encoder_id(dev,
1370 ATOM_DEVICE_CRT1_SUPPORT,
1372 ATOM_DEVICE_CRT1_SUPPORT);
1373 radeon_add_legacy_connector(dev, 1,
1374 ATOM_DEVICE_CRT1_SUPPORT,
1375 DRM_MODE_CONNECTOR_VGA,
1377 CONNECTOR_OBJECT_ID_VGA,
1380 /* DVI-I - tv dac, int tmds */
1381 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1382 hpd.hpd = RADEON_HPD_1;
1383 radeon_add_legacy_encoder(dev,
1384 radeon_get_encoder_id(dev,
1385 ATOM_DEVICE_DFP1_SUPPORT,
1387 ATOM_DEVICE_DFP1_SUPPORT);
1388 radeon_add_legacy_encoder(dev,
1389 radeon_get_encoder_id(dev,
1390 ATOM_DEVICE_CRT2_SUPPORT,
1392 ATOM_DEVICE_CRT2_SUPPORT);
1393 radeon_add_legacy_connector(dev, 0,
1394 ATOM_DEVICE_DFP1_SUPPORT |
1395 ATOM_DEVICE_CRT2_SUPPORT,
1396 DRM_MODE_CONNECTOR_DVII,
1398 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1401 /* VGA - primary dac */
1402 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1403 hpd.hpd = RADEON_HPD_NONE;
1404 radeon_add_legacy_encoder(dev,
1405 radeon_get_encoder_id(dev,
1406 ATOM_DEVICE_CRT1_SUPPORT,
1408 ATOM_DEVICE_CRT1_SUPPORT);
1409 radeon_add_legacy_connector(dev, 1,
1410 ATOM_DEVICE_CRT1_SUPPORT,
1411 DRM_MODE_CONNECTOR_VGA,
1413 CONNECTOR_OBJECT_ID_VGA,
1417 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
1419 ddc_i2c.valid = false;
1420 hpd.hpd = RADEON_HPD_NONE;
1421 radeon_add_legacy_encoder(dev,
1422 radeon_get_encoder_id(dev,
1423 ATOM_DEVICE_TV1_SUPPORT,
1425 ATOM_DEVICE_TV1_SUPPORT);
1426 radeon_add_legacy_connector(dev, 2,
1427 ATOM_DEVICE_TV1_SUPPORT,
1428 DRM_MODE_CONNECTOR_SVIDEO,
1430 CONNECTOR_OBJECT_ID_SVIDEO,
1435 DRM_INFO("Connector Table: %d (ibook)\n",
1436 rdev->mode_info.connector_table);
1438 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1439 hpd.hpd = RADEON_HPD_NONE;
1440 radeon_add_legacy_encoder(dev,
1441 radeon_get_encoder_id(dev,
1442 ATOM_DEVICE_LCD1_SUPPORT,
1444 ATOM_DEVICE_LCD1_SUPPORT);
1445 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1446 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1447 CONNECTOR_OBJECT_ID_LVDS,
1450 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1451 hpd.hpd = RADEON_HPD_NONE;
1452 radeon_add_legacy_encoder(dev,
1453 radeon_get_encoder_id(dev,
1454 ATOM_DEVICE_CRT2_SUPPORT,
1456 ATOM_DEVICE_CRT2_SUPPORT);
1457 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1458 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1459 CONNECTOR_OBJECT_ID_VGA,
1462 ddc_i2c.valid = false;
1463 hpd.hpd = RADEON_HPD_NONE;
1464 radeon_add_legacy_encoder(dev,
1465 radeon_get_encoder_id(dev,
1466 ATOM_DEVICE_TV1_SUPPORT,
1468 ATOM_DEVICE_TV1_SUPPORT);
1469 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1470 DRM_MODE_CONNECTOR_SVIDEO,
1472 CONNECTOR_OBJECT_ID_SVIDEO,
1475 case CT_POWERBOOK_EXTERNAL:
1476 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1477 rdev->mode_info.connector_table);
1479 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1480 hpd.hpd = RADEON_HPD_NONE;
1481 radeon_add_legacy_encoder(dev,
1482 radeon_get_encoder_id(dev,
1483 ATOM_DEVICE_LCD1_SUPPORT,
1485 ATOM_DEVICE_LCD1_SUPPORT);
1486 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1487 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1488 CONNECTOR_OBJECT_ID_LVDS,
1490 /* DVI-I - primary dac, ext tmds */
1491 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1492 hpd.hpd = RADEON_HPD_2; /* ??? */
1493 radeon_add_legacy_encoder(dev,
1494 radeon_get_encoder_id(dev,
1495 ATOM_DEVICE_DFP2_SUPPORT,
1497 ATOM_DEVICE_DFP2_SUPPORT);
1498 radeon_add_legacy_encoder(dev,
1499 radeon_get_encoder_id(dev,
1500 ATOM_DEVICE_CRT1_SUPPORT,
1502 ATOM_DEVICE_CRT1_SUPPORT);
1503 /* XXX some are SL */
1504 radeon_add_legacy_connector(dev, 1,
1505 ATOM_DEVICE_DFP2_SUPPORT |
1506 ATOM_DEVICE_CRT1_SUPPORT,
1507 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1508 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
1511 ddc_i2c.valid = false;
1512 hpd.hpd = RADEON_HPD_NONE;
1513 radeon_add_legacy_encoder(dev,
1514 radeon_get_encoder_id(dev,
1515 ATOM_DEVICE_TV1_SUPPORT,
1517 ATOM_DEVICE_TV1_SUPPORT);
1518 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1519 DRM_MODE_CONNECTOR_SVIDEO,
1521 CONNECTOR_OBJECT_ID_SVIDEO,
1524 case CT_POWERBOOK_INTERNAL:
1525 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1526 rdev->mode_info.connector_table);
1528 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1529 hpd.hpd = RADEON_HPD_NONE;
1530 radeon_add_legacy_encoder(dev,
1531 radeon_get_encoder_id(dev,
1532 ATOM_DEVICE_LCD1_SUPPORT,
1534 ATOM_DEVICE_LCD1_SUPPORT);
1535 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1536 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1537 CONNECTOR_OBJECT_ID_LVDS,
1539 /* DVI-I - primary dac, int tmds */
1540 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1541 hpd.hpd = RADEON_HPD_1; /* ??? */
1542 radeon_add_legacy_encoder(dev,
1543 radeon_get_encoder_id(dev,
1544 ATOM_DEVICE_DFP1_SUPPORT,
1546 ATOM_DEVICE_DFP1_SUPPORT);
1547 radeon_add_legacy_encoder(dev,
1548 radeon_get_encoder_id(dev,
1549 ATOM_DEVICE_CRT1_SUPPORT,
1551 ATOM_DEVICE_CRT1_SUPPORT);
1552 radeon_add_legacy_connector(dev, 1,
1553 ATOM_DEVICE_DFP1_SUPPORT |
1554 ATOM_DEVICE_CRT1_SUPPORT,
1555 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1556 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1559 ddc_i2c.valid = false;
1560 hpd.hpd = RADEON_HPD_NONE;
1561 radeon_add_legacy_encoder(dev,
1562 radeon_get_encoder_id(dev,
1563 ATOM_DEVICE_TV1_SUPPORT,
1565 ATOM_DEVICE_TV1_SUPPORT);
1566 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1567 DRM_MODE_CONNECTOR_SVIDEO,
1569 CONNECTOR_OBJECT_ID_SVIDEO,
1572 case CT_POWERBOOK_VGA:
1573 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1574 rdev->mode_info.connector_table);
1576 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1577 hpd.hpd = RADEON_HPD_NONE;
1578 radeon_add_legacy_encoder(dev,
1579 radeon_get_encoder_id(dev,
1580 ATOM_DEVICE_LCD1_SUPPORT,
1582 ATOM_DEVICE_LCD1_SUPPORT);
1583 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1584 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1585 CONNECTOR_OBJECT_ID_LVDS,
1587 /* VGA - primary dac */
1588 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1589 hpd.hpd = RADEON_HPD_NONE;
1590 radeon_add_legacy_encoder(dev,
1591 radeon_get_encoder_id(dev,
1592 ATOM_DEVICE_CRT1_SUPPORT,
1594 ATOM_DEVICE_CRT1_SUPPORT);
1595 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
1596 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1597 CONNECTOR_OBJECT_ID_VGA,
1600 ddc_i2c.valid = false;
1601 hpd.hpd = RADEON_HPD_NONE;
1602 radeon_add_legacy_encoder(dev,
1603 radeon_get_encoder_id(dev,
1604 ATOM_DEVICE_TV1_SUPPORT,
1606 ATOM_DEVICE_TV1_SUPPORT);
1607 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1608 DRM_MODE_CONNECTOR_SVIDEO,
1610 CONNECTOR_OBJECT_ID_SVIDEO,
1613 case CT_MINI_EXTERNAL:
1614 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1615 rdev->mode_info.connector_table);
1616 /* DVI-I - tv dac, ext tmds */
1617 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1618 hpd.hpd = RADEON_HPD_2; /* ??? */
1619 radeon_add_legacy_encoder(dev,
1620 radeon_get_encoder_id(dev,
1621 ATOM_DEVICE_DFP2_SUPPORT,
1623 ATOM_DEVICE_DFP2_SUPPORT);
1624 radeon_add_legacy_encoder(dev,
1625 radeon_get_encoder_id(dev,
1626 ATOM_DEVICE_CRT2_SUPPORT,
1628 ATOM_DEVICE_CRT2_SUPPORT);
1629 /* XXX are any DL? */
1630 radeon_add_legacy_connector(dev, 0,
1631 ATOM_DEVICE_DFP2_SUPPORT |
1632 ATOM_DEVICE_CRT2_SUPPORT,
1633 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1634 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1637 ddc_i2c.valid = false;
1638 hpd.hpd = RADEON_HPD_NONE;
1639 radeon_add_legacy_encoder(dev,
1640 radeon_get_encoder_id(dev,
1641 ATOM_DEVICE_TV1_SUPPORT,
1643 ATOM_DEVICE_TV1_SUPPORT);
1644 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1645 DRM_MODE_CONNECTOR_SVIDEO,
1647 CONNECTOR_OBJECT_ID_SVIDEO,
1650 case CT_MINI_INTERNAL:
1651 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1652 rdev->mode_info.connector_table);
1653 /* DVI-I - tv dac, int tmds */
1654 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1655 hpd.hpd = RADEON_HPD_1; /* ??? */
1656 radeon_add_legacy_encoder(dev,
1657 radeon_get_encoder_id(dev,
1658 ATOM_DEVICE_DFP1_SUPPORT,
1660 ATOM_DEVICE_DFP1_SUPPORT);
1661 radeon_add_legacy_encoder(dev,
1662 radeon_get_encoder_id(dev,
1663 ATOM_DEVICE_CRT2_SUPPORT,
1665 ATOM_DEVICE_CRT2_SUPPORT);
1666 radeon_add_legacy_connector(dev, 0,
1667 ATOM_DEVICE_DFP1_SUPPORT |
1668 ATOM_DEVICE_CRT2_SUPPORT,
1669 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1670 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1673 ddc_i2c.valid = false;
1674 hpd.hpd = RADEON_HPD_NONE;
1675 radeon_add_legacy_encoder(dev,
1676 radeon_get_encoder_id(dev,
1677 ATOM_DEVICE_TV1_SUPPORT,
1679 ATOM_DEVICE_TV1_SUPPORT);
1680 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1681 DRM_MODE_CONNECTOR_SVIDEO,
1683 CONNECTOR_OBJECT_ID_SVIDEO,
1686 case CT_IMAC_G5_ISIGHT:
1687 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1688 rdev->mode_info.connector_table);
1689 /* DVI-D - int tmds */
1690 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1691 hpd.hpd = RADEON_HPD_1; /* ??? */
1692 radeon_add_legacy_encoder(dev,
1693 radeon_get_encoder_id(dev,
1694 ATOM_DEVICE_DFP1_SUPPORT,
1696 ATOM_DEVICE_DFP1_SUPPORT);
1697 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
1698 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
1699 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
1702 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1703 hpd.hpd = RADEON_HPD_NONE;
1704 radeon_add_legacy_encoder(dev,
1705 radeon_get_encoder_id(dev,
1706 ATOM_DEVICE_CRT2_SUPPORT,
1708 ATOM_DEVICE_CRT2_SUPPORT);
1709 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1710 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1711 CONNECTOR_OBJECT_ID_VGA,
1714 ddc_i2c.valid = false;
1715 hpd.hpd = RADEON_HPD_NONE;
1716 radeon_add_legacy_encoder(dev,
1717 radeon_get_encoder_id(dev,
1718 ATOM_DEVICE_TV1_SUPPORT,
1720 ATOM_DEVICE_TV1_SUPPORT);
1721 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1722 DRM_MODE_CONNECTOR_SVIDEO,
1724 CONNECTOR_OBJECT_ID_SVIDEO,
1728 DRM_INFO("Connector Table: %d (emac)\n",
1729 rdev->mode_info.connector_table);
1730 /* VGA - primary dac */
1731 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1732 hpd.hpd = RADEON_HPD_NONE;
1733 radeon_add_legacy_encoder(dev,
1734 radeon_get_encoder_id(dev,
1735 ATOM_DEVICE_CRT1_SUPPORT,
1737 ATOM_DEVICE_CRT1_SUPPORT);
1738 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1739 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1740 CONNECTOR_OBJECT_ID_VGA,
1743 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1744 hpd.hpd = RADEON_HPD_NONE;
1745 radeon_add_legacy_encoder(dev,
1746 radeon_get_encoder_id(dev,
1747 ATOM_DEVICE_CRT2_SUPPORT,
1749 ATOM_DEVICE_CRT2_SUPPORT);
1750 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1751 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1752 CONNECTOR_OBJECT_ID_VGA,
1755 ddc_i2c.valid = false;
1756 hpd.hpd = RADEON_HPD_NONE;
1757 radeon_add_legacy_encoder(dev,
1758 radeon_get_encoder_id(dev,
1759 ATOM_DEVICE_TV1_SUPPORT,
1761 ATOM_DEVICE_TV1_SUPPORT);
1762 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1763 DRM_MODE_CONNECTOR_SVIDEO,
1765 CONNECTOR_OBJECT_ID_SVIDEO,
1769 DRM_INFO("Connector table: %d (invalid)\n",
1770 rdev->mode_info.connector_table);
1774 radeon_link_encoder_connector(dev);
1779 static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1781 enum radeon_combios_connector
1783 struct radeon_i2c_bus_rec *ddc_i2c,
1784 struct radeon_hpd *hpd)
1786 struct radeon_device *rdev = dev->dev_private;
1788 /* XPRESS DDC quirks */
1789 if ((rdev->family == CHIP_RS400 ||
1790 rdev->family == CHIP_RS480) &&
1791 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1792 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1793 else if ((rdev->family == CHIP_RS400 ||
1794 rdev->family == CHIP_RS480) &&
1795 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
1796 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
1797 ddc_i2c->mask_clk_mask = (0x20 << 8);
1798 ddc_i2c->mask_data_mask = 0x80;
1799 ddc_i2c->a_clk_mask = (0x20 << 8);
1800 ddc_i2c->a_data_mask = 0x80;
1801 ddc_i2c->en_clk_mask = (0x20 << 8);
1802 ddc_i2c->en_data_mask = 0x80;
1803 ddc_i2c->y_clk_mask = (0x20 << 8);
1804 ddc_i2c->y_data_mask = 0x80;
1807 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1808 if ((rdev->family >= CHIP_R300) &&
1809 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1810 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1812 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1813 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
1814 if (dev->pdev->device == 0x515e &&
1815 dev->pdev->subsystem_vendor == 0x1014) {
1816 if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
1817 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1821 /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
1822 if (dev->pdev->device == 0x5159 &&
1823 dev->pdev->subsystem_vendor == 0x1002 &&
1824 dev->pdev->subsystem_device == 0x013a) {
1825 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1826 *legacy_connector = CONNECTOR_CRT_LEGACY;
1830 /* X300 card with extra non-existent DVI port */
1831 if (dev->pdev->device == 0x5B60 &&
1832 dev->pdev->subsystem_vendor == 0x17af &&
1833 dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
1834 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1841 static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
1843 /* Acer 5102 has non-existent TV port */
1844 if (dev->pdev->device == 0x5975 &&
1845 dev->pdev->subsystem_vendor == 0x1025 &&
1846 dev->pdev->subsystem_device == 0x009f)
1849 /* HP dc5750 has non-existent TV port */
1850 if (dev->pdev->device == 0x5974 &&
1851 dev->pdev->subsystem_vendor == 0x103c &&
1852 dev->pdev->subsystem_device == 0x280a)
1855 /* MSI S270 has non-existent TV port */
1856 if (dev->pdev->device == 0x5955 &&
1857 dev->pdev->subsystem_vendor == 0x1462 &&
1858 dev->pdev->subsystem_device == 0x0131)
1864 static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
1866 struct radeon_device *rdev = dev->dev_private;
1867 uint32_t ext_tmds_info;
1869 if (rdev->flags & RADEON_IS_IGP) {
1871 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1873 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1875 ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1876 if (ext_tmds_info) {
1877 uint8_t rev = RBIOS8(ext_tmds_info);
1878 uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
1881 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1883 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1887 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1889 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1894 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1896 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1899 bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1901 struct radeon_device *rdev = dev->dev_private;
1902 uint32_t conn_info, entry, devices;
1903 uint16_t tmp, connector_object_id;
1904 enum radeon_combios_ddc ddc_type;
1905 enum radeon_combios_connector connector;
1907 struct radeon_i2c_bus_rec ddc_i2c;
1908 struct radeon_hpd hpd;
1910 if (rdev->bios == NULL)
1913 conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
1915 for (i = 0; i < 4; i++) {
1916 entry = conn_info + 2 + i * 2;
1918 if (!RBIOS16(entry))
1921 tmp = RBIOS16(entry);
1923 connector = (tmp >> 12) & 0xf;
1925 ddc_type = (tmp >> 8) & 0xf;
1929 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1933 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1937 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1941 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1947 switch (connector) {
1948 case CONNECTOR_PROPRIETARY_LEGACY:
1949 case CONNECTOR_DVI_I_LEGACY:
1950 case CONNECTOR_DVI_D_LEGACY:
1951 if ((tmp >> 4) & 0x1)
1952 hpd.hpd = RADEON_HPD_2;
1954 hpd.hpd = RADEON_HPD_1;
1957 hpd.hpd = RADEON_HPD_NONE;
1961 if (!radeon_apply_legacy_quirks(dev, i, &connector,
1965 switch (connector) {
1966 case CONNECTOR_PROPRIETARY_LEGACY:
1967 if ((tmp >> 4) & 0x1)
1968 devices = ATOM_DEVICE_DFP2_SUPPORT;
1970 devices = ATOM_DEVICE_DFP1_SUPPORT;
1971 radeon_add_legacy_encoder(dev,
1972 radeon_get_encoder_id
1975 radeon_add_legacy_connector(dev, i, devices,
1976 legacy_connector_convert
1979 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
1982 case CONNECTOR_CRT_LEGACY:
1984 devices = ATOM_DEVICE_CRT2_SUPPORT;
1985 radeon_add_legacy_encoder(dev,
1986 radeon_get_encoder_id
1988 ATOM_DEVICE_CRT2_SUPPORT,
1990 ATOM_DEVICE_CRT2_SUPPORT);
1992 devices = ATOM_DEVICE_CRT1_SUPPORT;
1993 radeon_add_legacy_encoder(dev,
1994 radeon_get_encoder_id
1996 ATOM_DEVICE_CRT1_SUPPORT,
1998 ATOM_DEVICE_CRT1_SUPPORT);
2000 radeon_add_legacy_connector(dev,
2003 legacy_connector_convert
2006 CONNECTOR_OBJECT_ID_VGA,
2009 case CONNECTOR_DVI_I_LEGACY:
2012 devices |= ATOM_DEVICE_CRT2_SUPPORT;
2013 radeon_add_legacy_encoder(dev,
2014 radeon_get_encoder_id
2016 ATOM_DEVICE_CRT2_SUPPORT,
2018 ATOM_DEVICE_CRT2_SUPPORT);
2020 devices |= ATOM_DEVICE_CRT1_SUPPORT;
2021 radeon_add_legacy_encoder(dev,
2022 radeon_get_encoder_id
2024 ATOM_DEVICE_CRT1_SUPPORT,
2026 ATOM_DEVICE_CRT1_SUPPORT);
2028 if ((tmp >> 4) & 0x1) {
2029 devices |= ATOM_DEVICE_DFP2_SUPPORT;
2030 radeon_add_legacy_encoder(dev,
2031 radeon_get_encoder_id
2033 ATOM_DEVICE_DFP2_SUPPORT,
2035 ATOM_DEVICE_DFP2_SUPPORT);
2036 connector_object_id = combios_check_dl_dvi(dev, 0);
2038 devices |= ATOM_DEVICE_DFP1_SUPPORT;
2039 radeon_add_legacy_encoder(dev,
2040 radeon_get_encoder_id
2042 ATOM_DEVICE_DFP1_SUPPORT,
2044 ATOM_DEVICE_DFP1_SUPPORT);
2045 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2047 radeon_add_legacy_connector(dev,
2050 legacy_connector_convert
2053 connector_object_id,
2056 case CONNECTOR_DVI_D_LEGACY:
2057 if ((tmp >> 4) & 0x1) {
2058 devices = ATOM_DEVICE_DFP2_SUPPORT;
2059 connector_object_id = combios_check_dl_dvi(dev, 1);
2061 devices = ATOM_DEVICE_DFP1_SUPPORT;
2062 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2064 radeon_add_legacy_encoder(dev,
2065 radeon_get_encoder_id
2068 radeon_add_legacy_connector(dev, i, devices,
2069 legacy_connector_convert
2072 connector_object_id,
2075 case CONNECTOR_CTV_LEGACY:
2076 case CONNECTOR_STV_LEGACY:
2077 radeon_add_legacy_encoder(dev,
2078 radeon_get_encoder_id
2080 ATOM_DEVICE_TV1_SUPPORT,
2082 ATOM_DEVICE_TV1_SUPPORT);
2083 radeon_add_legacy_connector(dev, i,
2084 ATOM_DEVICE_TV1_SUPPORT,
2085 legacy_connector_convert
2088 CONNECTOR_OBJECT_ID_SVIDEO,
2092 DRM_ERROR("Unknown connector type: %d\n",
2099 uint16_t tmds_info =
2100 combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
2102 DRM_DEBUG("Found DFP table, assuming DVI connector\n");
2104 radeon_add_legacy_encoder(dev,
2105 radeon_get_encoder_id(dev,
2106 ATOM_DEVICE_CRT1_SUPPORT,
2108 ATOM_DEVICE_CRT1_SUPPORT);
2109 radeon_add_legacy_encoder(dev,
2110 radeon_get_encoder_id(dev,
2111 ATOM_DEVICE_DFP1_SUPPORT,
2113 ATOM_DEVICE_DFP1_SUPPORT);
2115 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
2116 hpd.hpd = RADEON_HPD_NONE;
2117 radeon_add_legacy_connector(dev,
2119 ATOM_DEVICE_CRT1_SUPPORT |
2120 ATOM_DEVICE_DFP1_SUPPORT,
2121 DRM_MODE_CONNECTOR_DVII,
2123 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
2127 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
2128 DRM_DEBUG("Found CRT table, assuming VGA connector\n");
2130 radeon_add_legacy_encoder(dev,
2131 radeon_get_encoder_id(dev,
2132 ATOM_DEVICE_CRT1_SUPPORT,
2134 ATOM_DEVICE_CRT1_SUPPORT);
2135 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2136 hpd.hpd = RADEON_HPD_NONE;
2137 radeon_add_legacy_connector(dev,
2139 ATOM_DEVICE_CRT1_SUPPORT,
2140 DRM_MODE_CONNECTOR_VGA,
2142 CONNECTOR_OBJECT_ID_VGA,
2145 DRM_DEBUG("No connector info found\n");
2151 if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
2153 combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
2155 uint16_t lcd_ddc_info =
2156 combios_get_table_offset(dev,
2157 COMBIOS_LCD_DDC_INFO_TABLE);
2159 radeon_add_legacy_encoder(dev,
2160 radeon_get_encoder_id(dev,
2161 ATOM_DEVICE_LCD1_SUPPORT,
2163 ATOM_DEVICE_LCD1_SUPPORT);
2166 ddc_type = RBIOS8(lcd_ddc_info + 2);
2170 combios_setup_i2c_bus
2171 (rdev, RADEON_GPIO_MONID);
2175 combios_setup_i2c_bus
2176 (rdev, RADEON_GPIO_DVI_DDC);
2180 combios_setup_i2c_bus
2181 (rdev, RADEON_GPIO_VGA_DDC);
2185 combios_setup_i2c_bus
2186 (rdev, RADEON_GPIO_CRT2_DDC);
2190 combios_setup_i2c_bus
2191 (rdev, RADEON_GPIOPAD_MASK);
2192 ddc_i2c.mask_clk_mask =
2193 RBIOS32(lcd_ddc_info + 3);
2194 ddc_i2c.mask_data_mask =
2195 RBIOS32(lcd_ddc_info + 7);
2196 ddc_i2c.a_clk_mask =
2197 RBIOS32(lcd_ddc_info + 3);
2198 ddc_i2c.a_data_mask =
2199 RBIOS32(lcd_ddc_info + 7);
2200 ddc_i2c.en_clk_mask =
2201 RBIOS32(lcd_ddc_info + 3);
2202 ddc_i2c.en_data_mask =
2203 RBIOS32(lcd_ddc_info + 7);
2204 ddc_i2c.y_clk_mask =
2205 RBIOS32(lcd_ddc_info + 3);
2206 ddc_i2c.y_data_mask =
2207 RBIOS32(lcd_ddc_info + 7);
2211 combios_setup_i2c_bus
2212 (rdev, RADEON_MDGPIO_MASK);
2213 ddc_i2c.mask_clk_mask =
2214 RBIOS32(lcd_ddc_info + 3);
2215 ddc_i2c.mask_data_mask =
2216 RBIOS32(lcd_ddc_info + 7);
2217 ddc_i2c.a_clk_mask =
2218 RBIOS32(lcd_ddc_info + 3);
2219 ddc_i2c.a_data_mask =
2220 RBIOS32(lcd_ddc_info + 7);
2221 ddc_i2c.en_clk_mask =
2222 RBIOS32(lcd_ddc_info + 3);
2223 ddc_i2c.en_data_mask =
2224 RBIOS32(lcd_ddc_info + 7);
2225 ddc_i2c.y_clk_mask =
2226 RBIOS32(lcd_ddc_info + 3);
2227 ddc_i2c.y_data_mask =
2228 RBIOS32(lcd_ddc_info + 7);
2231 ddc_i2c.valid = false;
2234 DRM_DEBUG("LCD DDC Info Table found!\n");
2236 ddc_i2c.valid = false;
2238 hpd.hpd = RADEON_HPD_NONE;
2239 radeon_add_legacy_connector(dev,
2241 ATOM_DEVICE_LCD1_SUPPORT,
2242 DRM_MODE_CONNECTOR_LVDS,
2244 CONNECTOR_OBJECT_ID_LVDS,
2249 /* check TV table */
2250 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
2252 combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
2254 if (RBIOS8(tv_info + 6) == 'T') {
2255 if (radeon_apply_legacy_tv_quirks(dev)) {
2256 hpd.hpd = RADEON_HPD_NONE;
2257 radeon_add_legacy_encoder(dev,
2258 radeon_get_encoder_id
2260 ATOM_DEVICE_TV1_SUPPORT,
2262 ATOM_DEVICE_TV1_SUPPORT);
2263 radeon_add_legacy_connector(dev, 6,
2264 ATOM_DEVICE_TV1_SUPPORT,
2265 DRM_MODE_CONNECTOR_SVIDEO,
2267 CONNECTOR_OBJECT_ID_SVIDEO,
2274 radeon_link_encoder_connector(dev);
2279 void radeon_external_tmds_setup(struct drm_encoder *encoder)
2281 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2282 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2287 switch (tmds->dvo_chip) {
2290 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2291 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2294 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2297 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2300 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2303 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2306 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2309 /* sil 1178 - untested */
2328 bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2330 struct drm_device *dev = encoder->dev;
2331 struct radeon_device *rdev = dev->dev_private;
2332 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2334 uint8_t blocks, slave_addr, rev;
2336 uint32_t reg, val, and_mask, or_mask;
2337 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2339 if (rdev->bios == NULL)
2345 if (rdev->flags & RADEON_IS_IGP) {
2346 offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
2347 rev = RBIOS8(offset);
2349 rev = RBIOS8(offset);
2351 blocks = RBIOS8(offset + 3);
2353 while (blocks > 0) {
2354 id = RBIOS16(index);
2358 reg = (id & 0x1fff) * 4;
2359 val = RBIOS32(index);
2364 reg = (id & 0x1fff) * 4;
2365 and_mask = RBIOS32(index);
2367 or_mask = RBIOS32(index);
2370 val = (val & and_mask) | or_mask;
2374 val = RBIOS16(index);
2379 val = RBIOS16(index);
2384 slave_addr = id & 0xff;
2385 slave_addr >>= 1; /* 7 bit addressing */
2387 reg = RBIOS8(index);
2389 val = RBIOS8(index);
2391 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2392 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2395 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2398 DRM_ERROR("Unknown id %d\n", id >> 13);
2407 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2409 index = offset + 10;
2410 id = RBIOS16(index);
2411 while (id != 0xffff) {
2415 reg = (id & 0x1fff) * 4;
2416 val = RBIOS32(index);
2420 reg = (id & 0x1fff) * 4;
2421 and_mask = RBIOS32(index);
2423 or_mask = RBIOS32(index);
2426 val = (val & and_mask) | or_mask;
2430 val = RBIOS16(index);
2436 and_mask = RBIOS32(index);
2438 or_mask = RBIOS32(index);
2440 val = RREG32_PLL(reg);
2441 val = (val & and_mask) | or_mask;
2442 WREG32_PLL(reg, val);
2446 val = RBIOS8(index);
2448 radeon_i2c_do_lock(tmds->i2c_bus, 1);
2449 radeon_i2c_sw_put_byte(tmds->i2c_bus,
2452 radeon_i2c_do_lock(tmds->i2c_bus, 0);
2455 DRM_ERROR("Unknown id %d\n", id >> 13);
2458 id = RBIOS16(index);
2466 static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
2468 struct radeon_device *rdev = dev->dev_private;
2471 while (RBIOS16(offset)) {
2472 uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
2473 uint32_t addr = (RBIOS16(offset) & 0x1fff);
2474 uint32_t val, and_mask, or_mask;
2480 val = RBIOS32(offset);
2485 val = RBIOS32(offset);
2490 and_mask = RBIOS32(offset);
2492 or_mask = RBIOS32(offset);
2500 and_mask = RBIOS32(offset);
2502 or_mask = RBIOS32(offset);
2510 val = RBIOS16(offset);
2515 val = RBIOS16(offset);
2522 (RADEON_CLK_PWRMGT_CNTL) &
2529 if ((RREG32(RADEON_MC_STATUS) &
2545 static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
2547 struct radeon_device *rdev = dev->dev_private;
2550 while (RBIOS8(offset)) {
2551 uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
2552 uint8_t addr = (RBIOS8(offset) & 0x3f);
2553 uint32_t val, shift, tmp;
2554 uint32_t and_mask, or_mask;
2559 val = RBIOS32(offset);
2561 WREG32_PLL(addr, val);
2564 shift = RBIOS8(offset) * 8;
2566 and_mask = RBIOS8(offset) << shift;
2567 and_mask |= ~(0xff << shift);
2569 or_mask = RBIOS8(offset) << shift;
2571 tmp = RREG32_PLL(addr);
2574 WREG32_PLL(addr, tmp);
2590 (RADEON_CLK_PWRMGT_CNTL) &
2598 (RADEON_CLK_PWRMGT_CNTL) &
2605 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
2606 if (tmp & RADEON_CG_NO1_DEBUG_0) {
2608 uint32_t mclk_cntl =
2611 mclk_cntl &= 0xffff0000;
2612 /*mclk_cntl |= 0x00001111;*//* ??? */
2613 WREG32_PLL(RADEON_MCLK_CNTL,
2618 (RADEON_CLK_PWRMGT_CNTL,
2620 ~RADEON_CG_NO1_DEBUG_0);
2635 static void combios_parse_ram_reset_table(struct drm_device *dev,
2638 struct radeon_device *rdev = dev->dev_private;
2642 uint8_t val = RBIOS8(offset);
2643 while (val != 0xff) {
2647 uint32_t channel_complete_mask;
2649 if (ASIC_IS_R300(rdev))
2650 channel_complete_mask =
2651 R300_MEM_PWRUP_COMPLETE;
2653 channel_complete_mask =
2654 RADEON_MEM_PWRUP_COMPLETE;
2657 if ((RREG32(RADEON_MEM_STR_CNTL) &
2658 channel_complete_mask) ==
2659 channel_complete_mask)
2663 uint32_t or_mask = RBIOS16(offset);
2666 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2667 tmp &= RADEON_SDRAM_MODE_MASK;
2669 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2671 or_mask = val << 24;
2672 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2673 tmp &= RADEON_B3MEM_RESET_MASK;
2675 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2677 val = RBIOS8(offset);
2682 static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
2683 int mem_addr_mapping)
2685 struct radeon_device *rdev = dev->dev_private;
2690 mem_cntl = RREG32(RADEON_MEM_CNTL);
2691 if (mem_cntl & RV100_HALF_MODE)
2694 mem_cntl &= ~(0xff << 8);
2695 mem_cntl |= (mem_addr_mapping & 0xff) << 8;
2696 WREG32(RADEON_MEM_CNTL, mem_cntl);
2697 RREG32(RADEON_MEM_CNTL);
2701 /* something like this???? */
2703 addr = ram * 1024 * 1024;
2704 /* write to each page */
2705 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2706 WREG32(RADEON_MM_DATA, 0xdeadbeef);
2707 /* read back and verify */
2708 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2709 if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
2716 static void combios_write_ram_size(struct drm_device *dev)
2718 struct radeon_device *rdev = dev->dev_private;
2721 uint32_t mem_size = 0;
2722 uint32_t mem_cntl = 0;
2724 /* should do something smarter here I guess... */
2725 if (rdev->flags & RADEON_IS_IGP)
2728 /* first check detected mem table */
2729 offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
2731 rev = RBIOS8(offset);
2733 mem_cntl = RBIOS32(offset + 1);
2734 mem_size = RBIOS16(offset + 5);
2735 if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) &&
2736 ((dev->pdev->device != 0x515e)
2737 && (dev->pdev->device != 0x5969)))
2738 WREG32(RADEON_MEM_CNTL, mem_cntl);
2744 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
2746 rev = RBIOS8(offset - 1);
2748 if (((rdev->flags & RADEON_FAMILY_MASK) <
2750 && ((dev->pdev->device != 0x515e)
2751 && (dev->pdev->device != 0x5969))) {
2753 int mem_addr_mapping = 0;
2755 while (RBIOS8(offset)) {
2756 ram = RBIOS8(offset);
2759 if (mem_addr_mapping != 0x25)
2762 combios_detect_ram(dev, ram,
2769 mem_size = RBIOS8(offset);
2771 mem_size = RBIOS8(offset);
2772 mem_size *= 2; /* convert to MB */
2777 mem_size *= (1024 * 1024); /* convert to bytes */
2778 WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
2781 void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
2783 uint16_t dyn_clk_info =
2784 combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2787 combios_parse_pll_table(dev, dyn_clk_info);
2790 void radeon_combios_asic_init(struct drm_device *dev)
2792 struct radeon_device *rdev = dev->dev_private;
2795 /* port hardcoded mac stuff from radeonfb */
2796 if (rdev->bios == NULL)
2800 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
2802 combios_parse_mmio_table(dev, table);
2805 table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
2807 combios_parse_pll_table(dev, table);
2810 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
2812 combios_parse_mmio_table(dev, table);
2814 if (!(rdev->flags & RADEON_IS_IGP)) {
2817 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
2819 combios_parse_mmio_table(dev, table);
2822 table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
2824 combios_parse_ram_reset_table(dev, table);
2828 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
2830 combios_parse_mmio_table(dev, table);
2832 /* write CONFIG_MEMSIZE */
2833 combios_write_ram_size(dev);
2837 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2839 combios_parse_pll_table(dev, table);
2843 void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
2845 struct radeon_device *rdev = dev->dev_private;
2846 uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
2848 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
2849 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2850 bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
2852 /* let the bios control the backlight */
2853 bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
2855 /* tell the bios not to handle mode switching */
2856 bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
2857 RADEON_ACC_MODE_CHANGE);
2859 /* tell the bios a driver is loaded */
2860 bios_7_scratch |= RADEON_DRV_LOADED;
2862 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
2863 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2864 WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
2867 void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
2869 struct drm_device *dev = encoder->dev;
2870 struct radeon_device *rdev = dev->dev_private;
2871 uint32_t bios_6_scratch;
2873 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
2876 bios_6_scratch |= RADEON_DRIVER_CRITICAL;
2878 bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
2880 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
2884 radeon_combios_connected_scratch_regs(struct drm_connector *connector,
2885 struct drm_encoder *encoder,
2888 struct drm_device *dev = connector->dev;
2889 struct radeon_device *rdev = dev->dev_private;
2890 struct radeon_connector *radeon_connector =
2891 to_radeon_connector(connector);
2892 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2893 uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
2894 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
2896 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
2897 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
2899 DRM_DEBUG("TV1 connected\n");
2901 bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
2902 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
2903 bios_5_scratch |= RADEON_TV1_ON;
2904 bios_5_scratch |= RADEON_ACC_REQ_TV1;
2906 DRM_DEBUG("TV1 disconnected\n");
2907 bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
2908 bios_5_scratch &= ~RADEON_TV1_ON;
2909 bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
2912 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
2913 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
2915 DRM_DEBUG("LCD1 connected\n");
2916 bios_4_scratch |= RADEON_LCD1_ATTACHED;
2917 bios_5_scratch |= RADEON_LCD1_ON;
2918 bios_5_scratch |= RADEON_ACC_REQ_LCD1;
2920 DRM_DEBUG("LCD1 disconnected\n");
2921 bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
2922 bios_5_scratch &= ~RADEON_LCD1_ON;
2923 bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
2926 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
2927 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
2929 DRM_DEBUG("CRT1 connected\n");
2930 bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
2931 bios_5_scratch |= RADEON_CRT1_ON;
2932 bios_5_scratch |= RADEON_ACC_REQ_CRT1;
2934 DRM_DEBUG("CRT1 disconnected\n");
2935 bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
2936 bios_5_scratch &= ~RADEON_CRT1_ON;
2937 bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
2940 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
2941 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
2943 DRM_DEBUG("CRT2 connected\n");
2944 bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
2945 bios_5_scratch |= RADEON_CRT2_ON;
2946 bios_5_scratch |= RADEON_ACC_REQ_CRT2;
2948 DRM_DEBUG("CRT2 disconnected\n");
2949 bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
2950 bios_5_scratch &= ~RADEON_CRT2_ON;
2951 bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
2954 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
2955 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
2957 DRM_DEBUG("DFP1 connected\n");
2958 bios_4_scratch |= RADEON_DFP1_ATTACHED;
2959 bios_5_scratch |= RADEON_DFP1_ON;
2960 bios_5_scratch |= RADEON_ACC_REQ_DFP1;
2962 DRM_DEBUG("DFP1 disconnected\n");
2963 bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
2964 bios_5_scratch &= ~RADEON_DFP1_ON;
2965 bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
2968 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
2969 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
2971 DRM_DEBUG("DFP2 connected\n");
2972 bios_4_scratch |= RADEON_DFP2_ATTACHED;
2973 bios_5_scratch |= RADEON_DFP2_ON;
2974 bios_5_scratch |= RADEON_ACC_REQ_DFP2;
2976 DRM_DEBUG("DFP2 disconnected\n");
2977 bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
2978 bios_5_scratch &= ~RADEON_DFP2_ON;
2979 bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
2982 WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
2983 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
2987 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
2989 struct drm_device *dev = encoder->dev;
2990 struct radeon_device *rdev = dev->dev_private;
2991 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2992 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
2994 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
2995 bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
2996 bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
2998 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
2999 bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
3000 bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
3002 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
3003 bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
3004 bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
3006 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
3007 bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
3008 bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
3010 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
3011 bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
3012 bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
3014 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
3015 bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
3016 bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
3018 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3022 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
3024 struct drm_device *dev = encoder->dev;
3025 struct radeon_device *rdev = dev->dev_private;
3026 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3027 uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3029 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
3031 bios_6_scratch |= RADEON_TV_DPMS_ON;
3033 bios_6_scratch &= ~RADEON_TV_DPMS_ON;
3035 if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
3037 bios_6_scratch |= RADEON_CRT_DPMS_ON;
3039 bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
3041 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
3043 bios_6_scratch |= RADEON_LCD_DPMS_ON;
3045 bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
3047 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
3049 bios_6_scratch |= RADEON_DFP_DPMS_ON;
3051 bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
3053 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);