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;
157 /* absolute offset tables */
158 case COMBIOS_ASIC_INIT_1_TABLE:
159 check_offset = RBIOS16(rdev->bios_header_start + 0xc);
161 offset = check_offset;
163 case COMBIOS_BIOS_SUPPORT_TABLE:
164 check_offset = RBIOS16(rdev->bios_header_start + 0x14);
166 offset = check_offset;
168 case COMBIOS_DAC_PROGRAMMING_TABLE:
169 check_offset = RBIOS16(rdev->bios_header_start + 0x2a);
171 offset = check_offset;
173 case COMBIOS_MAX_COLOR_DEPTH_TABLE:
174 check_offset = RBIOS16(rdev->bios_header_start + 0x2c);
176 offset = check_offset;
178 case COMBIOS_CRTC_INFO_TABLE:
179 check_offset = RBIOS16(rdev->bios_header_start + 0x2e);
181 offset = check_offset;
183 case COMBIOS_PLL_INFO_TABLE:
184 check_offset = RBIOS16(rdev->bios_header_start + 0x30);
186 offset = check_offset;
188 case COMBIOS_TV_INFO_TABLE:
189 check_offset = RBIOS16(rdev->bios_header_start + 0x32);
191 offset = check_offset;
193 case COMBIOS_DFP_INFO_TABLE:
194 check_offset = RBIOS16(rdev->bios_header_start + 0x34);
196 offset = check_offset;
198 case COMBIOS_HW_CONFIG_INFO_TABLE:
199 check_offset = RBIOS16(rdev->bios_header_start + 0x36);
201 offset = check_offset;
203 case COMBIOS_MULTIMEDIA_INFO_TABLE:
204 check_offset = RBIOS16(rdev->bios_header_start + 0x38);
206 offset = check_offset;
208 case COMBIOS_TV_STD_PATCH_TABLE:
209 check_offset = RBIOS16(rdev->bios_header_start + 0x3e);
211 offset = check_offset;
213 case COMBIOS_LCD_INFO_TABLE:
214 check_offset = RBIOS16(rdev->bios_header_start + 0x40);
216 offset = check_offset;
218 case COMBIOS_MOBILE_INFO_TABLE:
219 check_offset = RBIOS16(rdev->bios_header_start + 0x42);
221 offset = check_offset;
223 case COMBIOS_PLL_INIT_TABLE:
224 check_offset = RBIOS16(rdev->bios_header_start + 0x46);
226 offset = check_offset;
228 case COMBIOS_MEM_CONFIG_TABLE:
229 check_offset = RBIOS16(rdev->bios_header_start + 0x48);
231 offset = check_offset;
233 case COMBIOS_SAVE_MASK_TABLE:
234 check_offset = RBIOS16(rdev->bios_header_start + 0x4a);
236 offset = check_offset;
238 case COMBIOS_HARDCODED_EDID_TABLE:
239 check_offset = RBIOS16(rdev->bios_header_start + 0x4c);
241 offset = check_offset;
243 case COMBIOS_ASIC_INIT_2_TABLE:
244 check_offset = RBIOS16(rdev->bios_header_start + 0x4e);
246 offset = check_offset;
248 case COMBIOS_CONNECTOR_INFO_TABLE:
249 check_offset = RBIOS16(rdev->bios_header_start + 0x50);
251 offset = check_offset;
253 case COMBIOS_DYN_CLK_1_TABLE:
254 check_offset = RBIOS16(rdev->bios_header_start + 0x52);
256 offset = check_offset;
258 case COMBIOS_RESERVED_MEM_TABLE:
259 check_offset = RBIOS16(rdev->bios_header_start + 0x54);
261 offset = check_offset;
263 case COMBIOS_EXT_TMDS_INFO_TABLE:
264 check_offset = RBIOS16(rdev->bios_header_start + 0x58);
266 offset = check_offset;
268 case COMBIOS_MEM_CLK_INFO_TABLE:
269 check_offset = RBIOS16(rdev->bios_header_start + 0x5a);
271 offset = check_offset;
273 case COMBIOS_EXT_DAC_INFO_TABLE:
274 check_offset = RBIOS16(rdev->bios_header_start + 0x5c);
276 offset = check_offset;
278 case COMBIOS_MISC_INFO_TABLE:
279 check_offset = RBIOS16(rdev->bios_header_start + 0x5e);
281 offset = check_offset;
283 case COMBIOS_CRT_INFO_TABLE:
284 check_offset = RBIOS16(rdev->bios_header_start + 0x60);
286 offset = check_offset;
288 case COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE:
289 check_offset = RBIOS16(rdev->bios_header_start + 0x62);
291 offset = check_offset;
293 case COMBIOS_COMPONENT_VIDEO_INFO_TABLE:
294 check_offset = RBIOS16(rdev->bios_header_start + 0x64);
296 offset = check_offset;
298 case COMBIOS_FAN_SPEED_INFO_TABLE:
299 check_offset = RBIOS16(rdev->bios_header_start + 0x66);
301 offset = check_offset;
303 case COMBIOS_OVERDRIVE_INFO_TABLE:
304 check_offset = RBIOS16(rdev->bios_header_start + 0x68);
306 offset = check_offset;
308 case COMBIOS_OEM_INFO_TABLE:
309 check_offset = RBIOS16(rdev->bios_header_start + 0x6a);
311 offset = check_offset;
313 case COMBIOS_DYN_CLK_2_TABLE:
314 check_offset = RBIOS16(rdev->bios_header_start + 0x6c);
316 offset = check_offset;
318 case COMBIOS_POWER_CONNECTOR_INFO_TABLE:
319 check_offset = RBIOS16(rdev->bios_header_start + 0x6e);
321 offset = check_offset;
323 case COMBIOS_I2C_INFO_TABLE:
324 check_offset = RBIOS16(rdev->bios_header_start + 0x70);
326 offset = check_offset;
328 /* relative offset tables */
329 case COMBIOS_ASIC_INIT_3_TABLE: /* offset from misc info */
331 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
333 rev = RBIOS8(check_offset);
335 check_offset = RBIOS16(check_offset + 0x3);
337 offset = check_offset;
341 case COMBIOS_ASIC_INIT_4_TABLE: /* offset from misc info */
343 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
345 rev = RBIOS8(check_offset);
347 check_offset = RBIOS16(check_offset + 0x5);
349 offset = check_offset;
353 case COMBIOS_DETECTED_MEM_TABLE: /* offset from misc info */
355 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
357 rev = RBIOS8(check_offset);
359 check_offset = RBIOS16(check_offset + 0x7);
361 offset = check_offset;
365 case COMBIOS_ASIC_INIT_5_TABLE: /* offset from misc info */
367 combios_get_table_offset(dev, COMBIOS_MISC_INFO_TABLE);
369 rev = RBIOS8(check_offset);
371 check_offset = RBIOS16(check_offset + 0x9);
373 offset = check_offset;
377 case COMBIOS_RAM_RESET_TABLE: /* offset from mem config */
379 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
381 while (RBIOS8(check_offset++));
384 offset = check_offset;
387 case COMBIOS_POWERPLAY_INFO_TABLE: /* offset from mobile info */
389 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
391 check_offset = RBIOS16(check_offset + 0x11);
393 offset = check_offset;
396 case COMBIOS_GPIO_INFO_TABLE: /* offset from mobile info */
398 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
400 check_offset = RBIOS16(check_offset + 0x13);
402 offset = check_offset;
405 case COMBIOS_LCD_DDC_INFO_TABLE: /* offset from mobile info */
407 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
409 check_offset = RBIOS16(check_offset + 0x15);
411 offset = check_offset;
414 case COMBIOS_TMDS_POWER_TABLE: /* offset from mobile info */
416 combios_get_table_offset(dev, COMBIOS_MOBILE_INFO_TABLE);
418 check_offset = RBIOS16(check_offset + 0x17);
420 offset = check_offset;
423 case COMBIOS_TMDS_POWER_ON_TABLE: /* offset from tmds power */
425 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
427 check_offset = RBIOS16(check_offset + 0x2);
429 offset = check_offset;
432 case COMBIOS_TMDS_POWER_OFF_TABLE: /* offset from tmds power */
434 combios_get_table_offset(dev, COMBIOS_TMDS_POWER_TABLE);
436 check_offset = RBIOS16(check_offset + 0x4);
438 offset = check_offset;
449 bool radeon_combios_check_hardcoded_edid(struct radeon_device *rdev)
453 edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
457 edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1),
462 memcpy((unsigned char *)edid,
463 (unsigned char *)(rdev->bios + edid_info), EDID_LENGTH);
465 if (!drm_edid_is_valid(edid)) {
470 rdev->mode_info.bios_hardcoded_edid = edid;
475 radeon_combios_get_hardcoded_edid(struct radeon_device *rdev)
477 if (rdev->mode_info.bios_hardcoded_edid)
478 return rdev->mode_info.bios_hardcoded_edid;
482 static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
485 struct radeon_i2c_bus_rec i2c;
487 if (ddc_line == RADEON_GPIOPAD_MASK) {
488 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
489 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
490 i2c.a_clk_reg = RADEON_GPIOPAD_A;
491 i2c.a_data_reg = RADEON_GPIOPAD_A;
492 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
493 i2c.en_data_reg = RADEON_GPIOPAD_EN;
494 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
495 i2c.y_data_reg = RADEON_GPIOPAD_Y;
496 } else if (ddc_line == RADEON_MDGPIO_MASK) {
497 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
498 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
499 i2c.a_clk_reg = RADEON_MDGPIO_A;
500 i2c.a_data_reg = RADEON_MDGPIO_A;
501 i2c.en_clk_reg = RADEON_MDGPIO_EN;
502 i2c.en_data_reg = RADEON_MDGPIO_EN;
503 i2c.y_clk_reg = RADEON_MDGPIO_Y;
504 i2c.y_data_reg = RADEON_MDGPIO_Y;
506 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
507 i2c.mask_data_mask = RADEON_GPIO_EN_0;
508 i2c.a_clk_mask = RADEON_GPIO_A_1;
509 i2c.a_data_mask = RADEON_GPIO_A_0;
510 i2c.en_clk_mask = RADEON_GPIO_EN_1;
511 i2c.en_data_mask = RADEON_GPIO_EN_0;
512 i2c.y_clk_mask = RADEON_GPIO_Y_1;
513 i2c.y_data_mask = RADEON_GPIO_Y_0;
515 i2c.mask_clk_reg = ddc_line;
516 i2c.mask_data_reg = ddc_line;
517 i2c.a_clk_reg = ddc_line;
518 i2c.a_data_reg = ddc_line;
519 i2c.en_clk_reg = ddc_line;
520 i2c.en_data_reg = ddc_line;
521 i2c.y_clk_reg = ddc_line;
522 i2c.y_data_reg = ddc_line;
525 switch (rdev->family) {
533 case RADEON_GPIO_DVI_DDC:
534 /* in theory this should be hw capable,
535 * but it doesn't seem to work
537 i2c.hw_capable = false;
540 i2c.hw_capable = false;
546 case RADEON_GPIO_DVI_DDC:
547 case RADEON_GPIO_MONID:
548 i2c.hw_capable = true;
551 i2c.hw_capable = false;
558 case RADEON_GPIO_VGA_DDC:
559 case RADEON_GPIO_DVI_DDC:
560 case RADEON_GPIO_CRT2_DDC:
561 i2c.hw_capable = true;
564 i2c.hw_capable = false;
571 case RADEON_GPIO_VGA_DDC:
572 case RADEON_GPIO_DVI_DDC:
573 i2c.hw_capable = true;
576 i2c.hw_capable = false;
585 case RADEON_GPIO_VGA_DDC:
586 case RADEON_GPIO_DVI_DDC:
587 i2c.hw_capable = true;
589 case RADEON_GPIO_MONID:
590 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
591 * reliably on some pre-r4xx hardware; not sure why.
593 i2c.hw_capable = false;
596 i2c.hw_capable = false;
601 i2c.hw_capable = false;
616 bool radeon_combios_get_clock_info(struct drm_device *dev)
618 struct radeon_device *rdev = dev->dev_private;
620 struct radeon_pll *p1pll = &rdev->clock.p1pll;
621 struct radeon_pll *p2pll = &rdev->clock.p2pll;
622 struct radeon_pll *spll = &rdev->clock.spll;
623 struct radeon_pll *mpll = &rdev->clock.mpll;
627 pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
629 rev = RBIOS8(pll_info);
632 p1pll->reference_freq = RBIOS16(pll_info + 0xe);
633 p1pll->reference_div = RBIOS16(pll_info + 0x10);
634 p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
635 p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
636 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
637 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
640 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
641 p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
643 p1pll->pll_in_min = 40;
644 p1pll->pll_in_max = 500;
649 spll->reference_freq = RBIOS16(pll_info + 0x1a);
650 spll->reference_div = RBIOS16(pll_info + 0x1c);
651 spll->pll_out_min = RBIOS32(pll_info + 0x1e);
652 spll->pll_out_max = RBIOS32(pll_info + 0x22);
655 spll->pll_in_min = RBIOS32(pll_info + 0x48);
656 spll->pll_in_max = RBIOS32(pll_info + 0x4c);
659 spll->pll_in_min = 40;
660 spll->pll_in_max = 500;
664 mpll->reference_freq = RBIOS16(pll_info + 0x26);
665 mpll->reference_div = RBIOS16(pll_info + 0x28);
666 mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
667 mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
670 mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
671 mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
674 mpll->pll_in_min = 40;
675 mpll->pll_in_max = 500;
678 /* default sclk/mclk */
679 sclk = RBIOS16(pll_info + 0xa);
680 mclk = RBIOS16(pll_info + 0x8);
686 rdev->clock.default_sclk = sclk;
687 rdev->clock.default_mclk = mclk;
694 bool radeon_combios_sideport_present(struct radeon_device *rdev)
696 struct drm_device *dev = rdev->ddev;
699 igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE);
702 if (RBIOS16(igp_info + 0x4))
708 static const uint32_t default_primarydac_adj[CHIP_LAST] = {
709 0x00000808, /* r100 */
710 0x00000808, /* rv100 */
711 0x00000808, /* rs100 */
712 0x00000808, /* rv200 */
713 0x00000808, /* rs200 */
714 0x00000808, /* r200 */
715 0x00000808, /* rv250 */
716 0x00000000, /* rs300 */
717 0x00000808, /* rv280 */
718 0x00000808, /* r300 */
719 0x00000808, /* r350 */
720 0x00000808, /* rv350 */
721 0x00000808, /* rv380 */
722 0x00000808, /* r420 */
723 0x00000808, /* r423 */
724 0x00000808, /* rv410 */
725 0x00000000, /* rs400 */
726 0x00000000, /* rs480 */
729 static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev,
730 struct radeon_encoder_primary_dac *p_dac)
732 p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family];
736 struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
740 struct drm_device *dev = encoder->base.dev;
741 struct radeon_device *rdev = dev->dev_private;
743 uint8_t rev, bg, dac;
744 struct radeon_encoder_primary_dac *p_dac = NULL;
747 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac),
753 /* check CRT table */
754 dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
756 rev = RBIOS8(dac_info) & 0x3;
758 bg = RBIOS8(dac_info + 0x2) & 0xf;
759 dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
760 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
762 bg = RBIOS8(dac_info + 0x2) & 0xf;
763 dac = RBIOS8(dac_info + 0x3) & 0xf;
764 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
769 if (!found) /* fallback to defaults */
770 radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
776 radeon_combios_get_tv_info(struct radeon_device *rdev)
778 struct drm_device *dev = rdev->ddev;
780 enum radeon_tv_std tv_std = TV_STD_NTSC;
782 tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
784 if (RBIOS8(tv_info + 6) == 'T') {
785 switch (RBIOS8(tv_info + 7) & 0xf) {
787 tv_std = TV_STD_NTSC;
788 DRM_INFO("Default TV standard: NTSC\n");
792 DRM_INFO("Default TV standard: PAL\n");
795 tv_std = TV_STD_PAL_M;
796 DRM_INFO("Default TV standard: PAL-M\n");
799 tv_std = TV_STD_PAL_60;
800 DRM_INFO("Default TV standard: PAL-60\n");
803 tv_std = TV_STD_NTSC_J;
804 DRM_INFO("Default TV standard: NTSC-J\n");
807 tv_std = TV_STD_SCART_PAL;
808 DRM_INFO("Default TV standard: SCART-PAL\n");
811 tv_std = TV_STD_NTSC;
813 ("Unknown TV standard; defaulting to NTSC\n");
817 switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
819 DRM_INFO("29.498928713 MHz TV ref clk\n");
822 DRM_INFO("28.636360000 MHz TV ref clk\n");
825 DRM_INFO("14.318180000 MHz TV ref clk\n");
828 DRM_INFO("27.000000000 MHz TV ref clk\n");
838 static const uint32_t default_tvdac_adj[CHIP_LAST] = {
839 0x00000000, /* r100 */
840 0x00280000, /* rv100 */
841 0x00000000, /* rs100 */
842 0x00880000, /* rv200 */
843 0x00000000, /* rs200 */
844 0x00000000, /* r200 */
845 0x00770000, /* rv250 */
846 0x00290000, /* rs300 */
847 0x00560000, /* rv280 */
848 0x00780000, /* r300 */
849 0x00770000, /* r350 */
850 0x00780000, /* rv350 */
851 0x00780000, /* rv380 */
852 0x01080000, /* r420 */
853 0x01080000, /* r423 */
854 0x01080000, /* rv410 */
855 0x00780000, /* rs400 */
856 0x00780000, /* rs480 */
859 static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
860 struct radeon_encoder_tv_dac *tv_dac)
862 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
863 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
864 tv_dac->ps2_tvdac_adj = 0x00880000;
865 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
866 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
870 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
874 struct drm_device *dev = encoder->base.dev;
875 struct radeon_device *rdev = dev->dev_private;
877 uint8_t rev, bg, dac;
878 struct radeon_encoder_tv_dac *tv_dac = NULL;
881 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
885 /* first check TV table */
886 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
888 rev = RBIOS8(dac_info + 0x3);
890 bg = RBIOS8(dac_info + 0xc) & 0xf;
891 dac = RBIOS8(dac_info + 0xd) & 0xf;
892 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
894 bg = RBIOS8(dac_info + 0xe) & 0xf;
895 dac = RBIOS8(dac_info + 0xf) & 0xf;
896 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
898 bg = RBIOS8(dac_info + 0x10) & 0xf;
899 dac = RBIOS8(dac_info + 0x11) & 0xf;
900 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
902 } else if (rev > 1) {
903 bg = RBIOS8(dac_info + 0xc) & 0xf;
904 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
905 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
907 bg = RBIOS8(dac_info + 0xd) & 0xf;
908 dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
909 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
911 bg = RBIOS8(dac_info + 0xe) & 0xf;
912 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
913 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
916 tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
919 /* then check CRT table */
921 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
923 rev = RBIOS8(dac_info) & 0x3;
925 bg = RBIOS8(dac_info + 0x3) & 0xf;
926 dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
927 tv_dac->ps2_tvdac_adj =
928 (bg << 16) | (dac << 20);
929 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
930 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
933 bg = RBIOS8(dac_info + 0x4) & 0xf;
934 dac = RBIOS8(dac_info + 0x5) & 0xf;
935 tv_dac->ps2_tvdac_adj =
936 (bg << 16) | (dac << 20);
937 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
938 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
942 DRM_INFO("No TV DAC info found in BIOS\n");
946 if (!found) /* fallback to defaults */
947 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
952 static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
956 struct radeon_encoder_lvds *lvds = NULL;
957 uint32_t fp_vert_stretch, fp_horz_stretch;
958 uint32_t ppll_div_sel, ppll_val;
959 uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
961 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
966 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
967 fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
969 /* These should be fail-safe defaults, fingers crossed */
970 lvds->panel_pwr_delay = 200;
971 lvds->panel_vcc_delay = 2000;
973 lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
974 lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
975 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
977 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
978 lvds->native_mode.vdisplay =
979 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
980 RADEON_VERT_PANEL_SHIFT) + 1;
982 lvds->native_mode.vdisplay =
983 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
985 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
986 lvds->native_mode.hdisplay =
987 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
988 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
990 lvds->native_mode.hdisplay =
991 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
993 if ((lvds->native_mode.hdisplay < 640) ||
994 (lvds->native_mode.vdisplay < 480)) {
995 lvds->native_mode.hdisplay = 640;
996 lvds->native_mode.vdisplay = 480;
999 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
1000 ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
1001 if ((ppll_val & 0x000707ff) == 0x1bb)
1002 lvds->use_bios_dividers = false;
1004 lvds->panel_ref_divider =
1005 RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
1006 lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
1007 lvds->panel_fb_divider = ppll_val & 0x7ff;
1009 if ((lvds->panel_ref_divider != 0) &&
1010 (lvds->panel_fb_divider > 3))
1011 lvds->use_bios_dividers = true;
1013 lvds->panel_vcc_delay = 200;
1015 DRM_INFO("Panel info derived from registers\n");
1016 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1017 lvds->native_mode.vdisplay);
1022 struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
1025 struct drm_device *dev = encoder->base.dev;
1026 struct radeon_device *rdev = dev->dev_private;
1028 uint32_t panel_setup;
1031 struct radeon_encoder_lvds *lvds = NULL;
1033 lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
1036 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
1041 for (i = 0; i < 24; i++)
1042 stmp[i] = RBIOS8(lcd_info + i + 1);
1045 DRM_INFO("Panel ID String: %s\n", stmp);
1047 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
1048 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
1050 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1051 lvds->native_mode.vdisplay);
1053 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
1054 lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000);
1056 lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
1057 lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
1058 lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
1060 lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
1061 lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
1062 lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
1063 if ((lvds->panel_ref_divider != 0) &&
1064 (lvds->panel_fb_divider > 3))
1065 lvds->use_bios_dividers = true;
1067 panel_setup = RBIOS32(lcd_info + 0x39);
1068 lvds->lvds_gen_cntl = 0xff00;
1069 if (panel_setup & 0x1)
1070 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
1072 if ((panel_setup >> 4) & 0x1)
1073 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
1075 switch ((panel_setup >> 8) & 0x7) {
1077 lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
1080 lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
1083 lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
1089 if ((panel_setup >> 16) & 0x1)
1090 lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
1092 if ((panel_setup >> 17) & 0x1)
1093 lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
1095 if ((panel_setup >> 18) & 0x1)
1096 lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
1098 if ((panel_setup >> 23) & 0x1)
1099 lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
1101 lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
1103 for (i = 0; i < 32; i++) {
1104 tmp = RBIOS16(lcd_info + 64 + i * 2);
1108 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
1109 (RBIOS16(tmp + 2) ==
1110 lvds->native_mode.vdisplay)) {
1111 lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
1112 lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
1113 lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
1114 RBIOS16(tmp + 21)) * 8;
1116 lvds->native_mode.vtotal = RBIOS16(tmp + 24);
1117 lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
1118 lvds->native_mode.vsync_end =
1119 ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
1120 (RBIOS16(tmp + 28) & 0x7ff);
1122 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
1123 lvds->native_mode.flags = 0;
1124 /* set crtc values */
1125 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1130 DRM_INFO("No panel info found in BIOS\n");
1131 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
1135 encoder->native_mode = lvds->native_mode;
1139 static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
1140 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1141 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1142 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1143 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1144 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1145 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1146 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1147 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1148 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1149 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1150 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1151 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1152 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1153 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1154 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1155 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
1156 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1157 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
1160 bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
1161 struct radeon_encoder_int_tmds *tmds)
1163 struct drm_device *dev = encoder->base.dev;
1164 struct radeon_device *rdev = dev->dev_private;
1167 for (i = 0; i < 4; i++) {
1168 tmds->tmds_pll[i].value =
1169 default_tmds_pll[rdev->family][i].value;
1170 tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
1176 bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
1177 struct radeon_encoder_int_tmds *tmds)
1179 struct drm_device *dev = encoder->base.dev;
1180 struct radeon_device *rdev = dev->dev_private;
1185 tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1188 ver = RBIOS8(tmds_info);
1189 DRM_INFO("DFP table revision: %d\n", ver);
1191 n = RBIOS8(tmds_info + 5) + 1;
1194 for (i = 0; i < n; i++) {
1195 tmds->tmds_pll[i].value =
1196 RBIOS32(tmds_info + i * 10 + 0x08);
1197 tmds->tmds_pll[i].freq =
1198 RBIOS16(tmds_info + i * 10 + 0x10);
1199 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1200 tmds->tmds_pll[i].freq,
1201 tmds->tmds_pll[i].value);
1203 } else if (ver == 4) {
1205 n = RBIOS8(tmds_info + 5) + 1;
1208 for (i = 0; i < n; i++) {
1209 tmds->tmds_pll[i].value =
1210 RBIOS32(tmds_info + stride + 0x08);
1211 tmds->tmds_pll[i].freq =
1212 RBIOS16(tmds_info + stride + 0x10);
1217 DRM_DEBUG("TMDS PLL From COMBIOS %u %x\n",
1218 tmds->tmds_pll[i].freq,
1219 tmds->tmds_pll[i].value);
1223 DRM_INFO("No TMDS info found in BIOS\n");
1229 bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1230 struct radeon_encoder_ext_tmds *tmds)
1232 struct drm_device *dev = encoder->base.dev;
1233 struct radeon_device *rdev = dev->dev_private;
1234 struct radeon_i2c_bus_rec i2c_bus;
1236 /* default for macs */
1237 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1238 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1240 /* XXX some macs have duallink chips */
1241 switch (rdev->mode_info.connector_table) {
1242 case CT_POWERBOOK_EXTERNAL:
1243 case CT_MINI_EXTERNAL:
1245 tmds->dvo_chip = DVO_SIL164;
1246 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1253 bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
1254 struct radeon_encoder_ext_tmds *tmds)
1256 struct drm_device *dev = encoder->base.dev;
1257 struct radeon_device *rdev = dev->dev_private;
1259 uint8_t ver, id, blocks, clk, data;
1261 enum radeon_combios_ddc gpio;
1262 struct radeon_i2c_bus_rec i2c_bus;
1264 tmds->i2c_bus = NULL;
1265 if (rdev->flags & RADEON_IS_IGP) {
1266 offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
1268 ver = RBIOS8(offset);
1269 DRM_INFO("GPIO Table revision: %d\n", ver);
1270 blocks = RBIOS8(offset + 2);
1271 for (i = 0; i < blocks; i++) {
1272 id = RBIOS8(offset + 3 + (i * 5) + 0);
1274 clk = RBIOS8(offset + 3 + (i * 5) + 3);
1275 data = RBIOS8(offset + 3 + (i * 5) + 4);
1276 i2c_bus.valid = true;
1277 i2c_bus.mask_clk_mask = (1 << clk);
1278 i2c_bus.mask_data_mask = (1 << data);
1279 i2c_bus.a_clk_mask = (1 << clk);
1280 i2c_bus.a_data_mask = (1 << data);
1281 i2c_bus.en_clk_mask = (1 << clk);
1282 i2c_bus.en_data_mask = (1 << data);
1283 i2c_bus.y_clk_mask = (1 << clk);
1284 i2c_bus.y_data_mask = (1 << data);
1285 i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
1286 i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
1287 i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
1288 i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
1289 i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
1290 i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
1291 i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
1292 i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
1293 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1294 tmds->dvo_chip = DVO_SIL164;
1295 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1301 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1303 ver = RBIOS8(offset);
1304 DRM_INFO("External TMDS Table revision: %d\n", ver);
1305 tmds->slave_addr = RBIOS8(offset + 4 + 2);
1306 tmds->slave_addr >>= 1; /* 7 bit addressing */
1307 gpio = RBIOS8(offset + 4 + 3);
1310 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1311 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1314 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1315 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1318 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1319 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1322 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1323 if (rdev->family >= CHIP_R300)
1324 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1326 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1327 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1329 case DDC_LCD: /* MM i2c */
1330 i2c_bus.valid = true;
1331 i2c_bus.hw_capable = true;
1332 i2c_bus.mm_i2c = true;
1333 tmds->i2c_bus = radeon_i2c_create(dev, &i2c_bus, "DVO");
1336 DRM_ERROR("Unsupported gpio %d\n", gpio);
1342 if (!tmds->i2c_bus) {
1343 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1350 bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1352 struct radeon_device *rdev = dev->dev_private;
1353 struct radeon_i2c_bus_rec ddc_i2c;
1354 struct radeon_hpd hpd;
1356 rdev->mode_info.connector_table = radeon_connector_table;
1357 if (rdev->mode_info.connector_table == CT_NONE) {
1358 #ifdef CONFIG_PPC_PMAC
1359 if (machine_is_compatible("PowerBook3,3")) {
1360 /* powerbook with VGA */
1361 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
1362 } else if (machine_is_compatible("PowerBook3,4") ||
1363 machine_is_compatible("PowerBook3,5")) {
1364 /* powerbook with internal tmds */
1365 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
1366 } else if (machine_is_compatible("PowerBook5,1") ||
1367 machine_is_compatible("PowerBook5,2") ||
1368 machine_is_compatible("PowerBook5,3") ||
1369 machine_is_compatible("PowerBook5,4") ||
1370 machine_is_compatible("PowerBook5,5")) {
1371 /* powerbook with external single link tmds (sil164) */
1372 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1373 } else if (machine_is_compatible("PowerBook5,6")) {
1374 /* powerbook with external dual or single link tmds */
1375 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1376 } else if (machine_is_compatible("PowerBook5,7") ||
1377 machine_is_compatible("PowerBook5,8") ||
1378 machine_is_compatible("PowerBook5,9")) {
1379 /* PowerBook6,2 ? */
1380 /* powerbook with external dual link tmds (sil1178?) */
1381 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1382 } else if (machine_is_compatible("PowerBook4,1") ||
1383 machine_is_compatible("PowerBook4,2") ||
1384 machine_is_compatible("PowerBook4,3") ||
1385 machine_is_compatible("PowerBook6,3") ||
1386 machine_is_compatible("PowerBook6,5") ||
1387 machine_is_compatible("PowerBook6,7")) {
1389 rdev->mode_info.connector_table = CT_IBOOK;
1390 } else if (machine_is_compatible("PowerMac4,4")) {
1392 rdev->mode_info.connector_table = CT_EMAC;
1393 } else if (machine_is_compatible("PowerMac10,1")) {
1394 /* mini with internal tmds */
1395 rdev->mode_info.connector_table = CT_MINI_INTERNAL;
1396 } else if (machine_is_compatible("PowerMac10,2")) {
1397 /* mini with external tmds */
1398 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
1399 } else if (machine_is_compatible("PowerMac12,1")) {
1401 /* imac g5 isight */
1402 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1404 #endif /* CONFIG_PPC_PMAC */
1405 rdev->mode_info.connector_table = CT_GENERIC;
1408 switch (rdev->mode_info.connector_table) {
1410 DRM_INFO("Connector Table: %d (generic)\n",
1411 rdev->mode_info.connector_table);
1412 /* these are the most common settings */
1413 if (rdev->flags & RADEON_SINGLE_CRTC) {
1414 /* VGA - primary dac */
1415 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1416 hpd.hpd = RADEON_HPD_NONE;
1417 radeon_add_legacy_encoder(dev,
1418 radeon_get_encoder_id(dev,
1419 ATOM_DEVICE_CRT1_SUPPORT,
1421 ATOM_DEVICE_CRT1_SUPPORT);
1422 radeon_add_legacy_connector(dev, 0,
1423 ATOM_DEVICE_CRT1_SUPPORT,
1424 DRM_MODE_CONNECTOR_VGA,
1426 CONNECTOR_OBJECT_ID_VGA,
1428 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1430 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
1431 hpd.hpd = RADEON_HPD_NONE;
1432 radeon_add_legacy_encoder(dev,
1433 radeon_get_encoder_id(dev,
1434 ATOM_DEVICE_LCD1_SUPPORT,
1436 ATOM_DEVICE_LCD1_SUPPORT);
1437 radeon_add_legacy_connector(dev, 0,
1438 ATOM_DEVICE_LCD1_SUPPORT,
1439 DRM_MODE_CONNECTOR_LVDS,
1441 CONNECTOR_OBJECT_ID_LVDS,
1444 /* VGA - primary dac */
1445 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1446 hpd.hpd = RADEON_HPD_NONE;
1447 radeon_add_legacy_encoder(dev,
1448 radeon_get_encoder_id(dev,
1449 ATOM_DEVICE_CRT1_SUPPORT,
1451 ATOM_DEVICE_CRT1_SUPPORT);
1452 radeon_add_legacy_connector(dev, 1,
1453 ATOM_DEVICE_CRT1_SUPPORT,
1454 DRM_MODE_CONNECTOR_VGA,
1456 CONNECTOR_OBJECT_ID_VGA,
1459 /* DVI-I - tv dac, int tmds */
1460 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1461 hpd.hpd = RADEON_HPD_1;
1462 radeon_add_legacy_encoder(dev,
1463 radeon_get_encoder_id(dev,
1464 ATOM_DEVICE_DFP1_SUPPORT,
1466 ATOM_DEVICE_DFP1_SUPPORT);
1467 radeon_add_legacy_encoder(dev,
1468 radeon_get_encoder_id(dev,
1469 ATOM_DEVICE_CRT2_SUPPORT,
1471 ATOM_DEVICE_CRT2_SUPPORT);
1472 radeon_add_legacy_connector(dev, 0,
1473 ATOM_DEVICE_DFP1_SUPPORT |
1474 ATOM_DEVICE_CRT2_SUPPORT,
1475 DRM_MODE_CONNECTOR_DVII,
1477 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1480 /* VGA - primary dac */
1481 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1482 hpd.hpd = RADEON_HPD_NONE;
1483 radeon_add_legacy_encoder(dev,
1484 radeon_get_encoder_id(dev,
1485 ATOM_DEVICE_CRT1_SUPPORT,
1487 ATOM_DEVICE_CRT1_SUPPORT);
1488 radeon_add_legacy_connector(dev, 1,
1489 ATOM_DEVICE_CRT1_SUPPORT,
1490 DRM_MODE_CONNECTOR_VGA,
1492 CONNECTOR_OBJECT_ID_VGA,
1496 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
1498 ddc_i2c.valid = false;
1499 hpd.hpd = RADEON_HPD_NONE;
1500 radeon_add_legacy_encoder(dev,
1501 radeon_get_encoder_id(dev,
1502 ATOM_DEVICE_TV1_SUPPORT,
1504 ATOM_DEVICE_TV1_SUPPORT);
1505 radeon_add_legacy_connector(dev, 2,
1506 ATOM_DEVICE_TV1_SUPPORT,
1507 DRM_MODE_CONNECTOR_SVIDEO,
1509 CONNECTOR_OBJECT_ID_SVIDEO,
1514 DRM_INFO("Connector Table: %d (ibook)\n",
1515 rdev->mode_info.connector_table);
1517 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1518 hpd.hpd = RADEON_HPD_NONE;
1519 radeon_add_legacy_encoder(dev,
1520 radeon_get_encoder_id(dev,
1521 ATOM_DEVICE_LCD1_SUPPORT,
1523 ATOM_DEVICE_LCD1_SUPPORT);
1524 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1525 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1526 CONNECTOR_OBJECT_ID_LVDS,
1529 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1530 hpd.hpd = RADEON_HPD_NONE;
1531 radeon_add_legacy_encoder(dev,
1532 radeon_get_encoder_id(dev,
1533 ATOM_DEVICE_CRT2_SUPPORT,
1535 ATOM_DEVICE_CRT2_SUPPORT);
1536 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1537 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1538 CONNECTOR_OBJECT_ID_VGA,
1541 ddc_i2c.valid = false;
1542 hpd.hpd = RADEON_HPD_NONE;
1543 radeon_add_legacy_encoder(dev,
1544 radeon_get_encoder_id(dev,
1545 ATOM_DEVICE_TV1_SUPPORT,
1547 ATOM_DEVICE_TV1_SUPPORT);
1548 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1549 DRM_MODE_CONNECTOR_SVIDEO,
1551 CONNECTOR_OBJECT_ID_SVIDEO,
1554 case CT_POWERBOOK_EXTERNAL:
1555 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1556 rdev->mode_info.connector_table);
1558 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1559 hpd.hpd = RADEON_HPD_NONE;
1560 radeon_add_legacy_encoder(dev,
1561 radeon_get_encoder_id(dev,
1562 ATOM_DEVICE_LCD1_SUPPORT,
1564 ATOM_DEVICE_LCD1_SUPPORT);
1565 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1566 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1567 CONNECTOR_OBJECT_ID_LVDS,
1569 /* DVI-I - primary dac, ext tmds */
1570 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1571 hpd.hpd = RADEON_HPD_2; /* ??? */
1572 radeon_add_legacy_encoder(dev,
1573 radeon_get_encoder_id(dev,
1574 ATOM_DEVICE_DFP2_SUPPORT,
1576 ATOM_DEVICE_DFP2_SUPPORT);
1577 radeon_add_legacy_encoder(dev,
1578 radeon_get_encoder_id(dev,
1579 ATOM_DEVICE_CRT1_SUPPORT,
1581 ATOM_DEVICE_CRT1_SUPPORT);
1582 /* XXX some are SL */
1583 radeon_add_legacy_connector(dev, 1,
1584 ATOM_DEVICE_DFP2_SUPPORT |
1585 ATOM_DEVICE_CRT1_SUPPORT,
1586 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1587 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
1590 ddc_i2c.valid = false;
1591 hpd.hpd = RADEON_HPD_NONE;
1592 radeon_add_legacy_encoder(dev,
1593 radeon_get_encoder_id(dev,
1594 ATOM_DEVICE_TV1_SUPPORT,
1596 ATOM_DEVICE_TV1_SUPPORT);
1597 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1598 DRM_MODE_CONNECTOR_SVIDEO,
1600 CONNECTOR_OBJECT_ID_SVIDEO,
1603 case CT_POWERBOOK_INTERNAL:
1604 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1605 rdev->mode_info.connector_table);
1607 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1608 hpd.hpd = RADEON_HPD_NONE;
1609 radeon_add_legacy_encoder(dev,
1610 radeon_get_encoder_id(dev,
1611 ATOM_DEVICE_LCD1_SUPPORT,
1613 ATOM_DEVICE_LCD1_SUPPORT);
1614 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1615 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1616 CONNECTOR_OBJECT_ID_LVDS,
1618 /* DVI-I - primary dac, int tmds */
1619 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1620 hpd.hpd = RADEON_HPD_1; /* ??? */
1621 radeon_add_legacy_encoder(dev,
1622 radeon_get_encoder_id(dev,
1623 ATOM_DEVICE_DFP1_SUPPORT,
1625 ATOM_DEVICE_DFP1_SUPPORT);
1626 radeon_add_legacy_encoder(dev,
1627 radeon_get_encoder_id(dev,
1628 ATOM_DEVICE_CRT1_SUPPORT,
1630 ATOM_DEVICE_CRT1_SUPPORT);
1631 radeon_add_legacy_connector(dev, 1,
1632 ATOM_DEVICE_DFP1_SUPPORT |
1633 ATOM_DEVICE_CRT1_SUPPORT,
1634 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1635 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1638 ddc_i2c.valid = false;
1639 hpd.hpd = RADEON_HPD_NONE;
1640 radeon_add_legacy_encoder(dev,
1641 radeon_get_encoder_id(dev,
1642 ATOM_DEVICE_TV1_SUPPORT,
1644 ATOM_DEVICE_TV1_SUPPORT);
1645 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1646 DRM_MODE_CONNECTOR_SVIDEO,
1648 CONNECTOR_OBJECT_ID_SVIDEO,
1651 case CT_POWERBOOK_VGA:
1652 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1653 rdev->mode_info.connector_table);
1655 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1656 hpd.hpd = RADEON_HPD_NONE;
1657 radeon_add_legacy_encoder(dev,
1658 radeon_get_encoder_id(dev,
1659 ATOM_DEVICE_LCD1_SUPPORT,
1661 ATOM_DEVICE_LCD1_SUPPORT);
1662 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1663 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1664 CONNECTOR_OBJECT_ID_LVDS,
1666 /* VGA - primary dac */
1667 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1668 hpd.hpd = RADEON_HPD_NONE;
1669 radeon_add_legacy_encoder(dev,
1670 radeon_get_encoder_id(dev,
1671 ATOM_DEVICE_CRT1_SUPPORT,
1673 ATOM_DEVICE_CRT1_SUPPORT);
1674 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
1675 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1676 CONNECTOR_OBJECT_ID_VGA,
1679 ddc_i2c.valid = false;
1680 hpd.hpd = RADEON_HPD_NONE;
1681 radeon_add_legacy_encoder(dev,
1682 radeon_get_encoder_id(dev,
1683 ATOM_DEVICE_TV1_SUPPORT,
1685 ATOM_DEVICE_TV1_SUPPORT);
1686 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1687 DRM_MODE_CONNECTOR_SVIDEO,
1689 CONNECTOR_OBJECT_ID_SVIDEO,
1692 case CT_MINI_EXTERNAL:
1693 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1694 rdev->mode_info.connector_table);
1695 /* DVI-I - tv dac, ext tmds */
1696 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1697 hpd.hpd = RADEON_HPD_2; /* ??? */
1698 radeon_add_legacy_encoder(dev,
1699 radeon_get_encoder_id(dev,
1700 ATOM_DEVICE_DFP2_SUPPORT,
1702 ATOM_DEVICE_DFP2_SUPPORT);
1703 radeon_add_legacy_encoder(dev,
1704 radeon_get_encoder_id(dev,
1705 ATOM_DEVICE_CRT2_SUPPORT,
1707 ATOM_DEVICE_CRT2_SUPPORT);
1708 /* XXX are any DL? */
1709 radeon_add_legacy_connector(dev, 0,
1710 ATOM_DEVICE_DFP2_SUPPORT |
1711 ATOM_DEVICE_CRT2_SUPPORT,
1712 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1713 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1716 ddc_i2c.valid = false;
1717 hpd.hpd = RADEON_HPD_NONE;
1718 radeon_add_legacy_encoder(dev,
1719 radeon_get_encoder_id(dev,
1720 ATOM_DEVICE_TV1_SUPPORT,
1722 ATOM_DEVICE_TV1_SUPPORT);
1723 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1724 DRM_MODE_CONNECTOR_SVIDEO,
1726 CONNECTOR_OBJECT_ID_SVIDEO,
1729 case CT_MINI_INTERNAL:
1730 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1731 rdev->mode_info.connector_table);
1732 /* DVI-I - tv dac, int tmds */
1733 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1734 hpd.hpd = RADEON_HPD_1; /* ??? */
1735 radeon_add_legacy_encoder(dev,
1736 radeon_get_encoder_id(dev,
1737 ATOM_DEVICE_DFP1_SUPPORT,
1739 ATOM_DEVICE_DFP1_SUPPORT);
1740 radeon_add_legacy_encoder(dev,
1741 radeon_get_encoder_id(dev,
1742 ATOM_DEVICE_CRT2_SUPPORT,
1744 ATOM_DEVICE_CRT2_SUPPORT);
1745 radeon_add_legacy_connector(dev, 0,
1746 ATOM_DEVICE_DFP1_SUPPORT |
1747 ATOM_DEVICE_CRT2_SUPPORT,
1748 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1749 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1752 ddc_i2c.valid = false;
1753 hpd.hpd = RADEON_HPD_NONE;
1754 radeon_add_legacy_encoder(dev,
1755 radeon_get_encoder_id(dev,
1756 ATOM_DEVICE_TV1_SUPPORT,
1758 ATOM_DEVICE_TV1_SUPPORT);
1759 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1760 DRM_MODE_CONNECTOR_SVIDEO,
1762 CONNECTOR_OBJECT_ID_SVIDEO,
1765 case CT_IMAC_G5_ISIGHT:
1766 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1767 rdev->mode_info.connector_table);
1768 /* DVI-D - int tmds */
1769 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1770 hpd.hpd = RADEON_HPD_1; /* ??? */
1771 radeon_add_legacy_encoder(dev,
1772 radeon_get_encoder_id(dev,
1773 ATOM_DEVICE_DFP1_SUPPORT,
1775 ATOM_DEVICE_DFP1_SUPPORT);
1776 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
1777 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
1778 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
1781 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1782 hpd.hpd = RADEON_HPD_NONE;
1783 radeon_add_legacy_encoder(dev,
1784 radeon_get_encoder_id(dev,
1785 ATOM_DEVICE_CRT2_SUPPORT,
1787 ATOM_DEVICE_CRT2_SUPPORT);
1788 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1789 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1790 CONNECTOR_OBJECT_ID_VGA,
1793 ddc_i2c.valid = false;
1794 hpd.hpd = RADEON_HPD_NONE;
1795 radeon_add_legacy_encoder(dev,
1796 radeon_get_encoder_id(dev,
1797 ATOM_DEVICE_TV1_SUPPORT,
1799 ATOM_DEVICE_TV1_SUPPORT);
1800 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1801 DRM_MODE_CONNECTOR_SVIDEO,
1803 CONNECTOR_OBJECT_ID_SVIDEO,
1807 DRM_INFO("Connector Table: %d (emac)\n",
1808 rdev->mode_info.connector_table);
1809 /* VGA - primary dac */
1810 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1811 hpd.hpd = RADEON_HPD_NONE;
1812 radeon_add_legacy_encoder(dev,
1813 radeon_get_encoder_id(dev,
1814 ATOM_DEVICE_CRT1_SUPPORT,
1816 ATOM_DEVICE_CRT1_SUPPORT);
1817 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1818 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1819 CONNECTOR_OBJECT_ID_VGA,
1822 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1823 hpd.hpd = RADEON_HPD_NONE;
1824 radeon_add_legacy_encoder(dev,
1825 radeon_get_encoder_id(dev,
1826 ATOM_DEVICE_CRT2_SUPPORT,
1828 ATOM_DEVICE_CRT2_SUPPORT);
1829 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1830 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1831 CONNECTOR_OBJECT_ID_VGA,
1834 ddc_i2c.valid = false;
1835 hpd.hpd = RADEON_HPD_NONE;
1836 radeon_add_legacy_encoder(dev,
1837 radeon_get_encoder_id(dev,
1838 ATOM_DEVICE_TV1_SUPPORT,
1840 ATOM_DEVICE_TV1_SUPPORT);
1841 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1842 DRM_MODE_CONNECTOR_SVIDEO,
1844 CONNECTOR_OBJECT_ID_SVIDEO,
1848 DRM_INFO("Connector table: %d (invalid)\n",
1849 rdev->mode_info.connector_table);
1853 radeon_link_encoder_connector(dev);
1858 static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1860 enum radeon_combios_connector
1862 struct radeon_i2c_bus_rec *ddc_i2c,
1863 struct radeon_hpd *hpd)
1865 struct radeon_device *rdev = dev->dev_private;
1867 /* XPRESS DDC quirks */
1868 if ((rdev->family == CHIP_RS400 ||
1869 rdev->family == CHIP_RS480) &&
1870 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1871 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1872 else if ((rdev->family == CHIP_RS400 ||
1873 rdev->family == CHIP_RS480) &&
1874 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
1875 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
1876 ddc_i2c->mask_clk_mask = (0x20 << 8);
1877 ddc_i2c->mask_data_mask = 0x80;
1878 ddc_i2c->a_clk_mask = (0x20 << 8);
1879 ddc_i2c->a_data_mask = 0x80;
1880 ddc_i2c->en_clk_mask = (0x20 << 8);
1881 ddc_i2c->en_data_mask = 0x80;
1882 ddc_i2c->y_clk_mask = (0x20 << 8);
1883 ddc_i2c->y_data_mask = 0x80;
1886 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1887 if ((rdev->family >= CHIP_R300) &&
1888 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1889 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1891 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1892 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
1893 if (dev->pdev->device == 0x515e &&
1894 dev->pdev->subsystem_vendor == 0x1014) {
1895 if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
1896 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1900 /* Some RV100 cards with 2 VGA ports show up with DVI+VGA */
1901 if (dev->pdev->device == 0x5159 &&
1902 dev->pdev->subsystem_vendor == 0x1002 &&
1903 dev->pdev->subsystem_device == 0x013a) {
1904 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1905 *legacy_connector = CONNECTOR_CRT_LEGACY;
1909 /* X300 card with extra non-existent DVI port */
1910 if (dev->pdev->device == 0x5B60 &&
1911 dev->pdev->subsystem_vendor == 0x17af &&
1912 dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
1913 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
1920 static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
1922 /* Acer 5102 has non-existent TV port */
1923 if (dev->pdev->device == 0x5975 &&
1924 dev->pdev->subsystem_vendor == 0x1025 &&
1925 dev->pdev->subsystem_device == 0x009f)
1928 /* HP dc5750 has non-existent TV port */
1929 if (dev->pdev->device == 0x5974 &&
1930 dev->pdev->subsystem_vendor == 0x103c &&
1931 dev->pdev->subsystem_device == 0x280a)
1934 /* MSI S270 has non-existent TV port */
1935 if (dev->pdev->device == 0x5955 &&
1936 dev->pdev->subsystem_vendor == 0x1462 &&
1937 dev->pdev->subsystem_device == 0x0131)
1943 static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
1945 struct radeon_device *rdev = dev->dev_private;
1946 uint32_t ext_tmds_info;
1948 if (rdev->flags & RADEON_IS_IGP) {
1950 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1952 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1954 ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1955 if (ext_tmds_info) {
1956 uint8_t rev = RBIOS8(ext_tmds_info);
1957 uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
1960 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1962 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1966 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
1968 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
1973 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
1975 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
1978 bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
1980 struct radeon_device *rdev = dev->dev_private;
1981 uint32_t conn_info, entry, devices;
1982 uint16_t tmp, connector_object_id;
1983 enum radeon_combios_ddc ddc_type;
1984 enum radeon_combios_connector connector;
1986 struct radeon_i2c_bus_rec ddc_i2c;
1987 struct radeon_hpd hpd;
1989 conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
1991 for (i = 0; i < 4; i++) {
1992 entry = conn_info + 2 + i * 2;
1994 if (!RBIOS16(entry))
1997 tmp = RBIOS16(entry);
1999 connector = (tmp >> 12) & 0xf;
2001 ddc_type = (tmp >> 8) & 0xf;
2005 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
2009 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
2013 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2017 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
2023 switch (connector) {
2024 case CONNECTOR_PROPRIETARY_LEGACY:
2025 case CONNECTOR_DVI_I_LEGACY:
2026 case CONNECTOR_DVI_D_LEGACY:
2027 if ((tmp >> 4) & 0x1)
2028 hpd.hpd = RADEON_HPD_2;
2030 hpd.hpd = RADEON_HPD_1;
2033 hpd.hpd = RADEON_HPD_NONE;
2037 if (!radeon_apply_legacy_quirks(dev, i, &connector,
2041 switch (connector) {
2042 case CONNECTOR_PROPRIETARY_LEGACY:
2043 if ((tmp >> 4) & 0x1)
2044 devices = ATOM_DEVICE_DFP2_SUPPORT;
2046 devices = ATOM_DEVICE_DFP1_SUPPORT;
2047 radeon_add_legacy_encoder(dev,
2048 radeon_get_encoder_id
2051 radeon_add_legacy_connector(dev, i, devices,
2052 legacy_connector_convert
2055 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
2058 case CONNECTOR_CRT_LEGACY:
2060 devices = ATOM_DEVICE_CRT2_SUPPORT;
2061 radeon_add_legacy_encoder(dev,
2062 radeon_get_encoder_id
2064 ATOM_DEVICE_CRT2_SUPPORT,
2066 ATOM_DEVICE_CRT2_SUPPORT);
2068 devices = ATOM_DEVICE_CRT1_SUPPORT;
2069 radeon_add_legacy_encoder(dev,
2070 radeon_get_encoder_id
2072 ATOM_DEVICE_CRT1_SUPPORT,
2074 ATOM_DEVICE_CRT1_SUPPORT);
2076 radeon_add_legacy_connector(dev,
2079 legacy_connector_convert
2082 CONNECTOR_OBJECT_ID_VGA,
2085 case CONNECTOR_DVI_I_LEGACY:
2088 devices |= ATOM_DEVICE_CRT2_SUPPORT;
2089 radeon_add_legacy_encoder(dev,
2090 radeon_get_encoder_id
2092 ATOM_DEVICE_CRT2_SUPPORT,
2094 ATOM_DEVICE_CRT2_SUPPORT);
2096 devices |= ATOM_DEVICE_CRT1_SUPPORT;
2097 radeon_add_legacy_encoder(dev,
2098 radeon_get_encoder_id
2100 ATOM_DEVICE_CRT1_SUPPORT,
2102 ATOM_DEVICE_CRT1_SUPPORT);
2104 if ((tmp >> 4) & 0x1) {
2105 devices |= ATOM_DEVICE_DFP2_SUPPORT;
2106 radeon_add_legacy_encoder(dev,
2107 radeon_get_encoder_id
2109 ATOM_DEVICE_DFP2_SUPPORT,
2111 ATOM_DEVICE_DFP2_SUPPORT);
2112 connector_object_id = combios_check_dl_dvi(dev, 0);
2114 devices |= ATOM_DEVICE_DFP1_SUPPORT;
2115 radeon_add_legacy_encoder(dev,
2116 radeon_get_encoder_id
2118 ATOM_DEVICE_DFP1_SUPPORT,
2120 ATOM_DEVICE_DFP1_SUPPORT);
2121 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2123 radeon_add_legacy_connector(dev,
2126 legacy_connector_convert
2129 connector_object_id,
2132 case CONNECTOR_DVI_D_LEGACY:
2133 if ((tmp >> 4) & 0x1) {
2134 devices = ATOM_DEVICE_DFP2_SUPPORT;
2135 connector_object_id = combios_check_dl_dvi(dev, 1);
2137 devices = ATOM_DEVICE_DFP1_SUPPORT;
2138 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2140 radeon_add_legacy_encoder(dev,
2141 radeon_get_encoder_id
2144 radeon_add_legacy_connector(dev, i, devices,
2145 legacy_connector_convert
2148 connector_object_id,
2151 case CONNECTOR_CTV_LEGACY:
2152 case CONNECTOR_STV_LEGACY:
2153 radeon_add_legacy_encoder(dev,
2154 radeon_get_encoder_id
2156 ATOM_DEVICE_TV1_SUPPORT,
2158 ATOM_DEVICE_TV1_SUPPORT);
2159 radeon_add_legacy_connector(dev, i,
2160 ATOM_DEVICE_TV1_SUPPORT,
2161 legacy_connector_convert
2164 CONNECTOR_OBJECT_ID_SVIDEO,
2168 DRM_ERROR("Unknown connector type: %d\n",
2175 uint16_t tmds_info =
2176 combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
2178 DRM_DEBUG("Found DFP table, assuming DVI connector\n");
2180 radeon_add_legacy_encoder(dev,
2181 radeon_get_encoder_id(dev,
2182 ATOM_DEVICE_CRT1_SUPPORT,
2184 ATOM_DEVICE_CRT1_SUPPORT);
2185 radeon_add_legacy_encoder(dev,
2186 radeon_get_encoder_id(dev,
2187 ATOM_DEVICE_DFP1_SUPPORT,
2189 ATOM_DEVICE_DFP1_SUPPORT);
2191 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
2192 hpd.hpd = RADEON_HPD_NONE;
2193 radeon_add_legacy_connector(dev,
2195 ATOM_DEVICE_CRT1_SUPPORT |
2196 ATOM_DEVICE_DFP1_SUPPORT,
2197 DRM_MODE_CONNECTOR_DVII,
2199 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
2203 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
2204 DRM_DEBUG("Found CRT table, assuming VGA connector\n");
2206 radeon_add_legacy_encoder(dev,
2207 radeon_get_encoder_id(dev,
2208 ATOM_DEVICE_CRT1_SUPPORT,
2210 ATOM_DEVICE_CRT1_SUPPORT);
2211 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2212 hpd.hpd = RADEON_HPD_NONE;
2213 radeon_add_legacy_connector(dev,
2215 ATOM_DEVICE_CRT1_SUPPORT,
2216 DRM_MODE_CONNECTOR_VGA,
2218 CONNECTOR_OBJECT_ID_VGA,
2221 DRM_DEBUG("No connector info found\n");
2227 if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
2229 combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
2231 uint16_t lcd_ddc_info =
2232 combios_get_table_offset(dev,
2233 COMBIOS_LCD_DDC_INFO_TABLE);
2235 radeon_add_legacy_encoder(dev,
2236 radeon_get_encoder_id(dev,
2237 ATOM_DEVICE_LCD1_SUPPORT,
2239 ATOM_DEVICE_LCD1_SUPPORT);
2242 ddc_type = RBIOS8(lcd_ddc_info + 2);
2246 combios_setup_i2c_bus
2247 (rdev, RADEON_GPIO_MONID);
2251 combios_setup_i2c_bus
2252 (rdev, RADEON_GPIO_DVI_DDC);
2256 combios_setup_i2c_bus
2257 (rdev, RADEON_GPIO_VGA_DDC);
2261 combios_setup_i2c_bus
2262 (rdev, RADEON_GPIO_CRT2_DDC);
2266 combios_setup_i2c_bus
2267 (rdev, RADEON_GPIOPAD_MASK);
2268 ddc_i2c.mask_clk_mask =
2269 RBIOS32(lcd_ddc_info + 3);
2270 ddc_i2c.mask_data_mask =
2271 RBIOS32(lcd_ddc_info + 7);
2272 ddc_i2c.a_clk_mask =
2273 RBIOS32(lcd_ddc_info + 3);
2274 ddc_i2c.a_data_mask =
2275 RBIOS32(lcd_ddc_info + 7);
2276 ddc_i2c.en_clk_mask =
2277 RBIOS32(lcd_ddc_info + 3);
2278 ddc_i2c.en_data_mask =
2279 RBIOS32(lcd_ddc_info + 7);
2280 ddc_i2c.y_clk_mask =
2281 RBIOS32(lcd_ddc_info + 3);
2282 ddc_i2c.y_data_mask =
2283 RBIOS32(lcd_ddc_info + 7);
2287 combios_setup_i2c_bus
2288 (rdev, RADEON_MDGPIO_MASK);
2289 ddc_i2c.mask_clk_mask =
2290 RBIOS32(lcd_ddc_info + 3);
2291 ddc_i2c.mask_data_mask =
2292 RBIOS32(lcd_ddc_info + 7);
2293 ddc_i2c.a_clk_mask =
2294 RBIOS32(lcd_ddc_info + 3);
2295 ddc_i2c.a_data_mask =
2296 RBIOS32(lcd_ddc_info + 7);
2297 ddc_i2c.en_clk_mask =
2298 RBIOS32(lcd_ddc_info + 3);
2299 ddc_i2c.en_data_mask =
2300 RBIOS32(lcd_ddc_info + 7);
2301 ddc_i2c.y_clk_mask =
2302 RBIOS32(lcd_ddc_info + 3);
2303 ddc_i2c.y_data_mask =
2304 RBIOS32(lcd_ddc_info + 7);
2307 ddc_i2c.valid = false;
2310 DRM_DEBUG("LCD DDC Info Table found!\n");
2312 ddc_i2c.valid = false;
2314 hpd.hpd = RADEON_HPD_NONE;
2315 radeon_add_legacy_connector(dev,
2317 ATOM_DEVICE_LCD1_SUPPORT,
2318 DRM_MODE_CONNECTOR_LVDS,
2320 CONNECTOR_OBJECT_ID_LVDS,
2325 /* check TV table */
2326 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
2328 combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
2330 if (RBIOS8(tv_info + 6) == 'T') {
2331 if (radeon_apply_legacy_tv_quirks(dev)) {
2332 hpd.hpd = RADEON_HPD_NONE;
2333 radeon_add_legacy_encoder(dev,
2334 radeon_get_encoder_id
2336 ATOM_DEVICE_TV1_SUPPORT,
2338 ATOM_DEVICE_TV1_SUPPORT);
2339 radeon_add_legacy_connector(dev, 6,
2340 ATOM_DEVICE_TV1_SUPPORT,
2341 DRM_MODE_CONNECTOR_SVIDEO,
2343 CONNECTOR_OBJECT_ID_SVIDEO,
2350 radeon_link_encoder_connector(dev);
2355 void radeon_combios_get_power_modes(struct radeon_device *rdev)
2357 struct drm_device *dev = rdev->ddev;
2358 u16 offset, misc, misc2 = 0;
2359 u8 rev, blocks, tmp;
2360 int state_index = 0;
2362 rdev->pm.default_power_state = NULL;
2364 if (rdev->flags & RADEON_IS_MOBILITY) {
2365 offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
2367 rev = RBIOS8(offset);
2368 blocks = RBIOS8(offset + 0x2);
2369 /* power mode 0 tends to be the only valid one */
2370 rdev->pm.power_state[state_index].num_clock_modes = 1;
2371 rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2);
2372 rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6);
2373 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
2374 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
2376 /* skip overclock modes for now */
2377 if ((rdev->pm.power_state[state_index].clock_info[0].mclk >
2378 rdev->clock.default_mclk + RADEON_MODE_OVERCLOCK_MARGIN) ||
2379 (rdev->pm.power_state[state_index].clock_info[0].sclk >
2380 rdev->clock.default_sclk + RADEON_MODE_OVERCLOCK_MARGIN))
2382 rdev->pm.power_state[state_index].type =
2383 POWER_STATE_TYPE_BATTERY;
2384 misc = RBIOS16(offset + 0x5 + 0x0);
2386 misc2 = RBIOS16(offset + 0x5 + 0xe);
2388 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO;
2390 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2393 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2395 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true;
2397 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2398 RBIOS16(offset + 0x5 + 0xb) * 4;
2399 tmp = RBIOS8(offset + 0x5 + 0xd);
2400 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2402 u8 entries = RBIOS8(offset + 0x5 + 0xb);
2403 u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc);
2404 if (entries && voltage_table_offset) {
2405 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2406 RBIOS16(voltage_table_offset) * 4;
2407 tmp = RBIOS8(voltage_table_offset + 0x2);
2408 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2410 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false;
2412 switch ((misc2 & 0x700) >> 8) {
2415 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0;
2418 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33;
2421 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66;
2424 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99;
2427 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132;
2431 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2433 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes =
2434 RBIOS8(offset + 0x5 + 0x10);
2437 /* XXX figure out some good default low power mode for mobility cards w/out power tables */
2440 /* XXX figure out some good default low power mode for desktop cards */
2444 /* add the default mode */
2445 rdev->pm.power_state[state_index].type =
2446 POWER_STATE_TYPE_DEFAULT;
2447 rdev->pm.power_state[state_index].num_clock_modes = 1;
2448 rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
2449 rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
2450 rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
2451 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2452 if (rdev->asic->get_pcie_lanes)
2453 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = radeon_get_pcie_lanes(rdev);
2455 rdev->pm.power_state[state_index].non_clock_info.pcie_lanes = 16;
2456 rdev->pm.default_power_state = &rdev->pm.power_state[state_index];
2457 rdev->pm.num_power_states = state_index + 1;
2459 rdev->pm.current_power_state = rdev->pm.default_power_state;
2460 rdev->pm.current_clock_mode =
2461 rdev->pm.default_power_state->default_clock_mode;
2464 void radeon_external_tmds_setup(struct drm_encoder *encoder)
2466 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2467 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2472 switch (tmds->dvo_chip) {
2475 radeon_i2c_put_byte(tmds->i2c_bus,
2478 radeon_i2c_put_byte(tmds->i2c_bus,
2481 radeon_i2c_put_byte(tmds->i2c_bus,
2484 radeon_i2c_put_byte(tmds->i2c_bus,
2487 radeon_i2c_put_byte(tmds->i2c_bus,
2492 /* sil 1178 - untested */
2511 bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2513 struct drm_device *dev = encoder->dev;
2514 struct radeon_device *rdev = dev->dev_private;
2515 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2517 uint8_t blocks, slave_addr, rev;
2519 uint32_t reg, val, and_mask, or_mask;
2520 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2525 if (rdev->flags & RADEON_IS_IGP) {
2526 offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
2527 rev = RBIOS8(offset);
2529 rev = RBIOS8(offset);
2531 blocks = RBIOS8(offset + 3);
2533 while (blocks > 0) {
2534 id = RBIOS16(index);
2538 reg = (id & 0x1fff) * 4;
2539 val = RBIOS32(index);
2544 reg = (id & 0x1fff) * 4;
2545 and_mask = RBIOS32(index);
2547 or_mask = RBIOS32(index);
2550 val = (val & and_mask) | or_mask;
2554 val = RBIOS16(index);
2559 val = RBIOS16(index);
2564 slave_addr = id & 0xff;
2565 slave_addr >>= 1; /* 7 bit addressing */
2567 reg = RBIOS8(index);
2569 val = RBIOS8(index);
2571 radeon_i2c_put_byte(tmds->i2c_bus,
2576 DRM_ERROR("Unknown id %d\n", id >> 13);
2585 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2587 index = offset + 10;
2588 id = RBIOS16(index);
2589 while (id != 0xffff) {
2593 reg = (id & 0x1fff) * 4;
2594 val = RBIOS32(index);
2598 reg = (id & 0x1fff) * 4;
2599 and_mask = RBIOS32(index);
2601 or_mask = RBIOS32(index);
2604 val = (val & and_mask) | or_mask;
2608 val = RBIOS16(index);
2614 and_mask = RBIOS32(index);
2616 or_mask = RBIOS32(index);
2618 val = RREG32_PLL(reg);
2619 val = (val & and_mask) | or_mask;
2620 WREG32_PLL(reg, val);
2624 val = RBIOS8(index);
2626 radeon_i2c_put_byte(tmds->i2c_bus,
2631 DRM_ERROR("Unknown id %d\n", id >> 13);
2634 id = RBIOS16(index);
2642 static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
2644 struct radeon_device *rdev = dev->dev_private;
2647 while (RBIOS16(offset)) {
2648 uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
2649 uint32_t addr = (RBIOS16(offset) & 0x1fff);
2650 uint32_t val, and_mask, or_mask;
2656 val = RBIOS32(offset);
2661 val = RBIOS32(offset);
2666 and_mask = RBIOS32(offset);
2668 or_mask = RBIOS32(offset);
2676 and_mask = RBIOS32(offset);
2678 or_mask = RBIOS32(offset);
2686 val = RBIOS16(offset);
2691 val = RBIOS16(offset);
2698 (RADEON_CLK_PWRMGT_CNTL) &
2705 if ((RREG32(RADEON_MC_STATUS) &
2721 static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
2723 struct radeon_device *rdev = dev->dev_private;
2726 while (RBIOS8(offset)) {
2727 uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
2728 uint8_t addr = (RBIOS8(offset) & 0x3f);
2729 uint32_t val, shift, tmp;
2730 uint32_t and_mask, or_mask;
2735 val = RBIOS32(offset);
2737 WREG32_PLL(addr, val);
2740 shift = RBIOS8(offset) * 8;
2742 and_mask = RBIOS8(offset) << shift;
2743 and_mask |= ~(0xff << shift);
2745 or_mask = RBIOS8(offset) << shift;
2747 tmp = RREG32_PLL(addr);
2750 WREG32_PLL(addr, tmp);
2766 (RADEON_CLK_PWRMGT_CNTL) &
2774 (RADEON_CLK_PWRMGT_CNTL) &
2781 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
2782 if (tmp & RADEON_CG_NO1_DEBUG_0) {
2784 uint32_t mclk_cntl =
2787 mclk_cntl &= 0xffff0000;
2788 /*mclk_cntl |= 0x00001111;*//* ??? */
2789 WREG32_PLL(RADEON_MCLK_CNTL,
2794 (RADEON_CLK_PWRMGT_CNTL,
2796 ~RADEON_CG_NO1_DEBUG_0);
2811 static void combios_parse_ram_reset_table(struct drm_device *dev,
2814 struct radeon_device *rdev = dev->dev_private;
2818 uint8_t val = RBIOS8(offset);
2819 while (val != 0xff) {
2823 uint32_t channel_complete_mask;
2825 if (ASIC_IS_R300(rdev))
2826 channel_complete_mask =
2827 R300_MEM_PWRUP_COMPLETE;
2829 channel_complete_mask =
2830 RADEON_MEM_PWRUP_COMPLETE;
2833 if ((RREG32(RADEON_MEM_STR_CNTL) &
2834 channel_complete_mask) ==
2835 channel_complete_mask)
2839 uint32_t or_mask = RBIOS16(offset);
2842 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2843 tmp &= RADEON_SDRAM_MODE_MASK;
2845 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2847 or_mask = val << 24;
2848 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2849 tmp &= RADEON_B3MEM_RESET_MASK;
2851 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2853 val = RBIOS8(offset);
2858 static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
2859 int mem_addr_mapping)
2861 struct radeon_device *rdev = dev->dev_private;
2866 mem_cntl = RREG32(RADEON_MEM_CNTL);
2867 if (mem_cntl & RV100_HALF_MODE)
2870 mem_cntl &= ~(0xff << 8);
2871 mem_cntl |= (mem_addr_mapping & 0xff) << 8;
2872 WREG32(RADEON_MEM_CNTL, mem_cntl);
2873 RREG32(RADEON_MEM_CNTL);
2877 /* something like this???? */
2879 addr = ram * 1024 * 1024;
2880 /* write to each page */
2881 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2882 WREG32(RADEON_MM_DATA, 0xdeadbeef);
2883 /* read back and verify */
2884 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2885 if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
2892 static void combios_write_ram_size(struct drm_device *dev)
2894 struct radeon_device *rdev = dev->dev_private;
2897 uint32_t mem_size = 0;
2898 uint32_t mem_cntl = 0;
2900 /* should do something smarter here I guess... */
2901 if (rdev->flags & RADEON_IS_IGP)
2904 /* first check detected mem table */
2905 offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
2907 rev = RBIOS8(offset);
2909 mem_cntl = RBIOS32(offset + 1);
2910 mem_size = RBIOS16(offset + 5);
2911 if (((rdev->flags & RADEON_FAMILY_MASK) < CHIP_R200) &&
2912 ((dev->pdev->device != 0x515e)
2913 && (dev->pdev->device != 0x5969)))
2914 WREG32(RADEON_MEM_CNTL, mem_cntl);
2920 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
2922 rev = RBIOS8(offset - 1);
2924 if (((rdev->flags & RADEON_FAMILY_MASK) <
2926 && ((dev->pdev->device != 0x515e)
2927 && (dev->pdev->device != 0x5969))) {
2929 int mem_addr_mapping = 0;
2931 while (RBIOS8(offset)) {
2932 ram = RBIOS8(offset);
2935 if (mem_addr_mapping != 0x25)
2938 combios_detect_ram(dev, ram,
2945 mem_size = RBIOS8(offset);
2947 mem_size = RBIOS8(offset);
2948 mem_size *= 2; /* convert to MB */
2953 mem_size *= (1024 * 1024); /* convert to bytes */
2954 WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
2957 void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
2959 uint16_t dyn_clk_info =
2960 combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
2963 combios_parse_pll_table(dev, dyn_clk_info);
2966 void radeon_combios_asic_init(struct drm_device *dev)
2968 struct radeon_device *rdev = dev->dev_private;
2971 /* port hardcoded mac stuff from radeonfb */
2972 if (rdev->bios == NULL)
2976 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
2978 combios_parse_mmio_table(dev, table);
2981 table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
2983 combios_parse_pll_table(dev, table);
2986 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
2988 combios_parse_mmio_table(dev, table);
2990 if (!(rdev->flags & RADEON_IS_IGP)) {
2993 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
2995 combios_parse_mmio_table(dev, table);
2998 table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
3000 combios_parse_ram_reset_table(dev, table);
3004 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
3006 combios_parse_mmio_table(dev, table);
3008 /* write CONFIG_MEMSIZE */
3009 combios_write_ram_size(dev);
3013 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
3015 combios_parse_pll_table(dev, table);
3019 void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
3021 struct radeon_device *rdev = dev->dev_private;
3022 uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
3024 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
3025 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3026 bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
3028 /* let the bios control the backlight */
3029 bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
3031 /* tell the bios not to handle mode switching */
3032 bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
3033 RADEON_ACC_MODE_CHANGE);
3035 /* tell the bios a driver is loaded */
3036 bios_7_scratch |= RADEON_DRV_LOADED;
3038 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
3039 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3040 WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
3043 void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
3045 struct drm_device *dev = encoder->dev;
3046 struct radeon_device *rdev = dev->dev_private;
3047 uint32_t bios_6_scratch;
3049 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3052 bios_6_scratch |= RADEON_DRIVER_CRITICAL;
3054 bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
3056 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3060 radeon_combios_connected_scratch_regs(struct drm_connector *connector,
3061 struct drm_encoder *encoder,
3064 struct drm_device *dev = connector->dev;
3065 struct radeon_device *rdev = dev->dev_private;
3066 struct radeon_connector *radeon_connector =
3067 to_radeon_connector(connector);
3068 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3069 uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
3070 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3072 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
3073 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
3075 DRM_DEBUG("TV1 connected\n");
3077 bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
3078 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
3079 bios_5_scratch |= RADEON_TV1_ON;
3080 bios_5_scratch |= RADEON_ACC_REQ_TV1;
3082 DRM_DEBUG("TV1 disconnected\n");
3083 bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
3084 bios_5_scratch &= ~RADEON_TV1_ON;
3085 bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
3088 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
3089 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
3091 DRM_DEBUG("LCD1 connected\n");
3092 bios_4_scratch |= RADEON_LCD1_ATTACHED;
3093 bios_5_scratch |= RADEON_LCD1_ON;
3094 bios_5_scratch |= RADEON_ACC_REQ_LCD1;
3096 DRM_DEBUG("LCD1 disconnected\n");
3097 bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
3098 bios_5_scratch &= ~RADEON_LCD1_ON;
3099 bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
3102 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
3103 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
3105 DRM_DEBUG("CRT1 connected\n");
3106 bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
3107 bios_5_scratch |= RADEON_CRT1_ON;
3108 bios_5_scratch |= RADEON_ACC_REQ_CRT1;
3110 DRM_DEBUG("CRT1 disconnected\n");
3111 bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
3112 bios_5_scratch &= ~RADEON_CRT1_ON;
3113 bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
3116 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
3117 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
3119 DRM_DEBUG("CRT2 connected\n");
3120 bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
3121 bios_5_scratch |= RADEON_CRT2_ON;
3122 bios_5_scratch |= RADEON_ACC_REQ_CRT2;
3124 DRM_DEBUG("CRT2 disconnected\n");
3125 bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
3126 bios_5_scratch &= ~RADEON_CRT2_ON;
3127 bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
3130 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
3131 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
3133 DRM_DEBUG("DFP1 connected\n");
3134 bios_4_scratch |= RADEON_DFP1_ATTACHED;
3135 bios_5_scratch |= RADEON_DFP1_ON;
3136 bios_5_scratch |= RADEON_ACC_REQ_DFP1;
3138 DRM_DEBUG("DFP1 disconnected\n");
3139 bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
3140 bios_5_scratch &= ~RADEON_DFP1_ON;
3141 bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
3144 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
3145 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
3147 DRM_DEBUG("DFP2 connected\n");
3148 bios_4_scratch |= RADEON_DFP2_ATTACHED;
3149 bios_5_scratch |= RADEON_DFP2_ON;
3150 bios_5_scratch |= RADEON_ACC_REQ_DFP2;
3152 DRM_DEBUG("DFP2 disconnected\n");
3153 bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
3154 bios_5_scratch &= ~RADEON_DFP2_ON;
3155 bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
3158 WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
3159 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3163 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
3165 struct drm_device *dev = encoder->dev;
3166 struct radeon_device *rdev = dev->dev_private;
3167 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3168 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3170 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
3171 bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
3172 bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
3174 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
3175 bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
3176 bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
3178 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
3179 bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
3180 bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
3182 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
3183 bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
3184 bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
3186 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
3187 bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
3188 bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
3190 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
3191 bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
3192 bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
3194 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3198 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
3200 struct drm_device *dev = encoder->dev;
3201 struct radeon_device *rdev = dev->dev_private;
3202 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3203 uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3205 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
3207 bios_6_scratch |= RADEON_TV_DPMS_ON;
3209 bios_6_scratch &= ~RADEON_TV_DPMS_ON;
3211 if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
3213 bios_6_scratch |= RADEON_CRT_DPMS_ON;
3215 bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
3217 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
3219 bios_6_scratch |= RADEON_LCD_DPMS_ON;
3221 bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
3223 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
3225 bios_6_scratch |= RADEON_DFP_DPMS_ON;
3227 bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
3229 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);