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)
454 edid_info = combios_get_table_offset(rdev->ddev, COMBIOS_HARDCODED_EDID_TABLE);
458 raw = rdev->bios + edid_info;
459 edid = kmalloc(EDID_LENGTH * (raw[0x7e] + 1), GFP_KERNEL);
463 memcpy((unsigned char *)edid, raw, EDID_LENGTH * (raw[0x7e] + 1));
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 /* standard i2c gpio lines */
483 #define RADEON_I2C_MONID_ID 0
484 #define RADEON_I2C_DVI_ID 1
485 #define RADEON_I2C_VGA_ID 2
486 #define RADEON_I2C_CRT2_ID 3
487 #define RADEON_I2C_MM_ID 4
488 /* custom defined gpio lines */
489 #define RADEON_I2C_LCD_ID 5 /* ddc for laptop panels */
490 #define RADEON_I2C_GPIO_ID 6 /* rs4xx gpio ddc */
491 #define RADEON_I2C_DVO_ID 7 /* i2c bus for dvo */
493 static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rdev,
496 struct radeon_i2c_bus_rec i2c;
498 if (ddc_line == RADEON_GPIOPAD_MASK) {
499 i2c.mask_clk_reg = RADEON_GPIOPAD_MASK;
500 i2c.mask_data_reg = RADEON_GPIOPAD_MASK;
501 i2c.a_clk_reg = RADEON_GPIOPAD_A;
502 i2c.a_data_reg = RADEON_GPIOPAD_A;
503 i2c.en_clk_reg = RADEON_GPIOPAD_EN;
504 i2c.en_data_reg = RADEON_GPIOPAD_EN;
505 i2c.y_clk_reg = RADEON_GPIOPAD_Y;
506 i2c.y_data_reg = RADEON_GPIOPAD_Y;
507 } else if (ddc_line == RADEON_MDGPIO_MASK) {
508 i2c.mask_clk_reg = RADEON_MDGPIO_MASK;
509 i2c.mask_data_reg = RADEON_MDGPIO_MASK;
510 i2c.a_clk_reg = RADEON_MDGPIO_A;
511 i2c.a_data_reg = RADEON_MDGPIO_A;
512 i2c.en_clk_reg = RADEON_MDGPIO_EN;
513 i2c.en_data_reg = RADEON_MDGPIO_EN;
514 i2c.y_clk_reg = RADEON_MDGPIO_Y;
515 i2c.y_data_reg = RADEON_MDGPIO_Y;
517 i2c.mask_clk_mask = RADEON_GPIO_EN_1;
518 i2c.mask_data_mask = RADEON_GPIO_EN_0;
519 i2c.a_clk_mask = RADEON_GPIO_A_1;
520 i2c.a_data_mask = RADEON_GPIO_A_0;
521 i2c.en_clk_mask = RADEON_GPIO_EN_1;
522 i2c.en_data_mask = RADEON_GPIO_EN_0;
523 i2c.y_clk_mask = RADEON_GPIO_Y_1;
524 i2c.y_data_mask = RADEON_GPIO_Y_0;
526 i2c.mask_clk_reg = ddc_line;
527 i2c.mask_data_reg = ddc_line;
528 i2c.a_clk_reg = ddc_line;
529 i2c.a_data_reg = ddc_line;
530 i2c.en_clk_reg = ddc_line;
531 i2c.en_data_reg = ddc_line;
532 i2c.y_clk_reg = ddc_line;
533 i2c.y_data_reg = ddc_line;
536 switch (rdev->family) {
544 case RADEON_GPIO_DVI_DDC:
545 i2c.hw_capable = true;
548 i2c.hw_capable = false;
554 case RADEON_GPIO_DVI_DDC:
555 case RADEON_GPIO_MONID:
556 i2c.hw_capable = true;
559 i2c.hw_capable = false;
566 case RADEON_GPIO_VGA_DDC:
567 case RADEON_GPIO_DVI_DDC:
568 case RADEON_GPIO_CRT2_DDC:
569 i2c.hw_capable = true;
572 i2c.hw_capable = false;
579 case RADEON_GPIO_VGA_DDC:
580 case RADEON_GPIO_DVI_DDC:
581 i2c.hw_capable = true;
584 i2c.hw_capable = false;
593 case RADEON_GPIO_VGA_DDC:
594 case RADEON_GPIO_DVI_DDC:
595 i2c.hw_capable = true;
597 case RADEON_GPIO_MONID:
598 /* hw i2c on RADEON_GPIO_MONID doesn't seem to work
599 * reliably on some pre-r4xx hardware; not sure why.
601 i2c.hw_capable = false;
604 i2c.hw_capable = false;
609 i2c.hw_capable = false;
615 case RADEON_GPIO_MONID:
616 i2c.i2c_id = RADEON_I2C_MONID_ID;
618 case RADEON_GPIO_DVI_DDC:
619 i2c.i2c_id = RADEON_I2C_DVI_ID;
621 case RADEON_GPIO_VGA_DDC:
622 i2c.i2c_id = RADEON_I2C_VGA_ID;
624 case RADEON_GPIO_CRT2_DDC:
625 i2c.i2c_id = RADEON_I2C_CRT2_ID;
631 i2c.hpd = RADEON_HPD_NONE;
641 void radeon_combios_i2c_init(struct radeon_device *rdev)
643 struct drm_device *dev = rdev->ddev;
644 struct radeon_i2c_bus_rec i2c;
646 i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
647 rdev->i2c_bus[0] = radeon_i2c_create(dev, &i2c, "MONID");
649 i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
650 rdev->i2c_bus[1] = radeon_i2c_create(dev, &i2c, "DVI_DDC");
652 i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
653 rdev->i2c_bus[2] = radeon_i2c_create(dev, &i2c, "VGA_DDC");
655 i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
656 rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "CRT2_DDC");
659 i2c.hw_capable = true;
661 i2c.i2c_id = RADEON_I2C_MM_ID;
662 rdev->i2c_bus[4] = radeon_i2c_create(dev, &i2c, "MM_I2C");
665 bool radeon_combios_get_clock_info(struct drm_device *dev)
667 struct radeon_device *rdev = dev->dev_private;
669 struct radeon_pll *p1pll = &rdev->clock.p1pll;
670 struct radeon_pll *p2pll = &rdev->clock.p2pll;
671 struct radeon_pll *spll = &rdev->clock.spll;
672 struct radeon_pll *mpll = &rdev->clock.mpll;
676 pll_info = combios_get_table_offset(dev, COMBIOS_PLL_INFO_TABLE);
678 rev = RBIOS8(pll_info);
681 p1pll->reference_freq = RBIOS16(pll_info + 0xe);
682 p1pll->reference_div = RBIOS16(pll_info + 0x10);
683 p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
684 p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
685 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
686 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
689 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
690 p1pll->pll_in_max = RBIOS32(pll_info + 0x3a);
692 p1pll->pll_in_min = 40;
693 p1pll->pll_in_max = 500;
698 spll->reference_freq = RBIOS16(pll_info + 0x1a);
699 spll->reference_div = RBIOS16(pll_info + 0x1c);
700 spll->pll_out_min = RBIOS32(pll_info + 0x1e);
701 spll->pll_out_max = RBIOS32(pll_info + 0x22);
704 spll->pll_in_min = RBIOS32(pll_info + 0x48);
705 spll->pll_in_max = RBIOS32(pll_info + 0x4c);
708 spll->pll_in_min = 40;
709 spll->pll_in_max = 500;
713 mpll->reference_freq = RBIOS16(pll_info + 0x26);
714 mpll->reference_div = RBIOS16(pll_info + 0x28);
715 mpll->pll_out_min = RBIOS32(pll_info + 0x2a);
716 mpll->pll_out_max = RBIOS32(pll_info + 0x2e);
719 mpll->pll_in_min = RBIOS32(pll_info + 0x5a);
720 mpll->pll_in_max = RBIOS32(pll_info + 0x5e);
723 mpll->pll_in_min = 40;
724 mpll->pll_in_max = 500;
727 /* default sclk/mclk */
728 sclk = RBIOS16(pll_info + 0xa);
729 mclk = RBIOS16(pll_info + 0x8);
735 rdev->clock.default_sclk = sclk;
736 rdev->clock.default_mclk = mclk;
743 bool radeon_combios_sideport_present(struct radeon_device *rdev)
745 struct drm_device *dev = rdev->ddev;
748 /* sideport is AMD only */
749 if (rdev->family == CHIP_RS400)
752 igp_info = combios_get_table_offset(dev, COMBIOS_INTEGRATED_SYSTEM_INFO_TABLE);
755 if (RBIOS16(igp_info + 0x4))
761 static const uint32_t default_primarydac_adj[CHIP_LAST] = {
762 0x00000808, /* r100 */
763 0x00000808, /* rv100 */
764 0x00000808, /* rs100 */
765 0x00000808, /* rv200 */
766 0x00000808, /* rs200 */
767 0x00000808, /* r200 */
768 0x00000808, /* rv250 */
769 0x00000000, /* rs300 */
770 0x00000808, /* rv280 */
771 0x00000808, /* r300 */
772 0x00000808, /* r350 */
773 0x00000808, /* rv350 */
774 0x00000808, /* rv380 */
775 0x00000808, /* r420 */
776 0x00000808, /* r423 */
777 0x00000808, /* rv410 */
778 0x00000000, /* rs400 */
779 0x00000000, /* rs480 */
782 static void radeon_legacy_get_primary_dac_info_from_table(struct radeon_device *rdev,
783 struct radeon_encoder_primary_dac *p_dac)
785 p_dac->ps2_pdac_adj = default_primarydac_adj[rdev->family];
789 struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
793 struct drm_device *dev = encoder->base.dev;
794 struct radeon_device *rdev = dev->dev_private;
796 uint8_t rev, bg, dac;
797 struct radeon_encoder_primary_dac *p_dac = NULL;
800 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac),
806 /* check CRT table */
807 dac_info = combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
809 rev = RBIOS8(dac_info) & 0x3;
811 bg = RBIOS8(dac_info + 0x2) & 0xf;
812 dac = (RBIOS8(dac_info + 0x2) >> 4) & 0xf;
813 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
815 bg = RBIOS8(dac_info + 0x2) & 0xf;
816 dac = RBIOS8(dac_info + 0x3) & 0xf;
817 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
819 /* if the values are all zeros, use the table */
820 if (p_dac->ps2_pdac_adj)
824 if (!found) /* fallback to defaults */
825 radeon_legacy_get_primary_dac_info_from_table(rdev, p_dac);
831 radeon_combios_get_tv_info(struct radeon_device *rdev)
833 struct drm_device *dev = rdev->ddev;
835 enum radeon_tv_std tv_std = TV_STD_NTSC;
837 tv_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
839 if (RBIOS8(tv_info + 6) == 'T') {
840 switch (RBIOS8(tv_info + 7) & 0xf) {
842 tv_std = TV_STD_NTSC;
843 DRM_INFO("Default TV standard: NTSC\n");
847 DRM_INFO("Default TV standard: PAL\n");
850 tv_std = TV_STD_PAL_M;
851 DRM_INFO("Default TV standard: PAL-M\n");
854 tv_std = TV_STD_PAL_60;
855 DRM_INFO("Default TV standard: PAL-60\n");
858 tv_std = TV_STD_NTSC_J;
859 DRM_INFO("Default TV standard: NTSC-J\n");
862 tv_std = TV_STD_SCART_PAL;
863 DRM_INFO("Default TV standard: SCART-PAL\n");
866 tv_std = TV_STD_NTSC;
868 ("Unknown TV standard; defaulting to NTSC\n");
872 switch ((RBIOS8(tv_info + 9) >> 2) & 0x3) {
874 DRM_INFO("29.498928713 MHz TV ref clk\n");
877 DRM_INFO("28.636360000 MHz TV ref clk\n");
880 DRM_INFO("14.318180000 MHz TV ref clk\n");
883 DRM_INFO("27.000000000 MHz TV ref clk\n");
893 static const uint32_t default_tvdac_adj[CHIP_LAST] = {
894 0x00000000, /* r100 */
895 0x00280000, /* rv100 */
896 0x00000000, /* rs100 */
897 0x00880000, /* rv200 */
898 0x00000000, /* rs200 */
899 0x00000000, /* r200 */
900 0x00770000, /* rv250 */
901 0x00290000, /* rs300 */
902 0x00560000, /* rv280 */
903 0x00780000, /* r300 */
904 0x00770000, /* r350 */
905 0x00780000, /* rv350 */
906 0x00780000, /* rv380 */
907 0x01080000, /* r420 */
908 0x01080000, /* r423 */
909 0x01080000, /* rv410 */
910 0x00780000, /* rs400 */
911 0x00780000, /* rs480 */
914 static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
915 struct radeon_encoder_tv_dac *tv_dac)
917 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
918 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
919 tv_dac->ps2_tvdac_adj = 0x00880000;
920 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
921 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
925 struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
929 struct drm_device *dev = encoder->base.dev;
930 struct radeon_device *rdev = dev->dev_private;
932 uint8_t rev, bg, dac;
933 struct radeon_encoder_tv_dac *tv_dac = NULL;
936 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
940 /* first check TV table */
941 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
943 rev = RBIOS8(dac_info + 0x3);
945 bg = RBIOS8(dac_info + 0xc) & 0xf;
946 dac = RBIOS8(dac_info + 0xd) & 0xf;
947 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
949 bg = RBIOS8(dac_info + 0xe) & 0xf;
950 dac = RBIOS8(dac_info + 0xf) & 0xf;
951 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
953 bg = RBIOS8(dac_info + 0x10) & 0xf;
954 dac = RBIOS8(dac_info + 0x11) & 0xf;
955 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
956 /* if the values are all zeros, use the table */
957 if (tv_dac->ps2_tvdac_adj)
959 } else if (rev > 1) {
960 bg = RBIOS8(dac_info + 0xc) & 0xf;
961 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
962 tv_dac->ps2_tvdac_adj = (bg << 16) | (dac << 20);
964 bg = RBIOS8(dac_info + 0xd) & 0xf;
965 dac = (RBIOS8(dac_info + 0xd) >> 4) & 0xf;
966 tv_dac->pal_tvdac_adj = (bg << 16) | (dac << 20);
968 bg = RBIOS8(dac_info + 0xe) & 0xf;
969 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
970 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
971 /* if the values are all zeros, use the table */
972 if (tv_dac->ps2_tvdac_adj)
975 tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
978 /* then check CRT table */
980 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
982 rev = RBIOS8(dac_info) & 0x3;
984 bg = RBIOS8(dac_info + 0x3) & 0xf;
985 dac = (RBIOS8(dac_info + 0x3) >> 4) & 0xf;
986 tv_dac->ps2_tvdac_adj =
987 (bg << 16) | (dac << 20);
988 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
989 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
990 /* if the values are all zeros, use the table */
991 if (tv_dac->ps2_tvdac_adj)
994 bg = RBIOS8(dac_info + 0x4) & 0xf;
995 dac = RBIOS8(dac_info + 0x5) & 0xf;
996 tv_dac->ps2_tvdac_adj =
997 (bg << 16) | (dac << 20);
998 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
999 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
1000 /* if the values are all zeros, use the table */
1001 if (tv_dac->ps2_tvdac_adj)
1005 DRM_INFO("No TV DAC info found in BIOS\n");
1009 if (!found) /* fallback to defaults */
1010 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
1015 static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
1019 struct radeon_encoder_lvds *lvds = NULL;
1020 uint32_t fp_vert_stretch, fp_horz_stretch;
1021 uint32_t ppll_div_sel, ppll_val;
1022 uint32_t lvds_ss_gen_cntl = RREG32(RADEON_LVDS_SS_GEN_CNTL);
1024 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
1029 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH);
1030 fp_horz_stretch = RREG32(RADEON_FP_HORZ_STRETCH);
1032 /* These should be fail-safe defaults, fingers crossed */
1033 lvds->panel_pwr_delay = 200;
1034 lvds->panel_vcc_delay = 2000;
1036 lvds->lvds_gen_cntl = RREG32(RADEON_LVDS_GEN_CNTL);
1037 lvds->panel_digon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY1_SHIFT) & 0xf;
1038 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
1040 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
1041 lvds->native_mode.vdisplay =
1042 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
1043 RADEON_VERT_PANEL_SHIFT) + 1;
1045 lvds->native_mode.vdisplay =
1046 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
1048 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
1049 lvds->native_mode.hdisplay =
1050 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
1051 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
1053 lvds->native_mode.hdisplay =
1054 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
1056 if ((lvds->native_mode.hdisplay < 640) ||
1057 (lvds->native_mode.vdisplay < 480)) {
1058 lvds->native_mode.hdisplay = 640;
1059 lvds->native_mode.vdisplay = 480;
1062 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
1063 ppll_val = RREG32_PLL(RADEON_PPLL_DIV_0 + ppll_div_sel);
1064 if ((ppll_val & 0x000707ff) == 0x1bb)
1065 lvds->use_bios_dividers = false;
1067 lvds->panel_ref_divider =
1068 RREG32_PLL(RADEON_PPLL_REF_DIV) & 0x3ff;
1069 lvds->panel_post_divider = (ppll_val >> 16) & 0x7;
1070 lvds->panel_fb_divider = ppll_val & 0x7ff;
1072 if ((lvds->panel_ref_divider != 0) &&
1073 (lvds->panel_fb_divider > 3))
1074 lvds->use_bios_dividers = true;
1076 lvds->panel_vcc_delay = 200;
1078 DRM_INFO("Panel info derived from registers\n");
1079 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1080 lvds->native_mode.vdisplay);
1085 struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
1088 struct drm_device *dev = encoder->base.dev;
1089 struct radeon_device *rdev = dev->dev_private;
1091 uint32_t panel_setup;
1094 struct radeon_encoder_lvds *lvds = NULL;
1096 lcd_info = combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
1099 lvds = kzalloc(sizeof(struct radeon_encoder_lvds), GFP_KERNEL);
1104 for (i = 0; i < 24; i++)
1105 stmp[i] = RBIOS8(lcd_info + i + 1);
1108 DRM_INFO("Panel ID String: %s\n", stmp);
1110 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
1111 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
1113 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
1114 lvds->native_mode.vdisplay);
1116 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
1117 lvds->panel_vcc_delay = min_t(u16, lvds->panel_vcc_delay, 2000);
1119 lvds->panel_pwr_delay = RBIOS8(lcd_info + 0x24);
1120 lvds->panel_digon_delay = RBIOS16(lcd_info + 0x38) & 0xf;
1121 lvds->panel_blon_delay = (RBIOS16(lcd_info + 0x38) >> 4) & 0xf;
1123 lvds->panel_ref_divider = RBIOS16(lcd_info + 0x2e);
1124 lvds->panel_post_divider = RBIOS8(lcd_info + 0x30);
1125 lvds->panel_fb_divider = RBIOS16(lcd_info + 0x31);
1126 if ((lvds->panel_ref_divider != 0) &&
1127 (lvds->panel_fb_divider > 3))
1128 lvds->use_bios_dividers = true;
1130 panel_setup = RBIOS32(lcd_info + 0x39);
1131 lvds->lvds_gen_cntl = 0xff00;
1132 if (panel_setup & 0x1)
1133 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_FORMAT;
1135 if ((panel_setup >> 4) & 0x1)
1136 lvds->lvds_gen_cntl |= RADEON_LVDS_PANEL_TYPE;
1138 switch ((panel_setup >> 8) & 0x7) {
1140 lvds->lvds_gen_cntl |= RADEON_LVDS_NO_FM;
1143 lvds->lvds_gen_cntl |= RADEON_LVDS_2_GREY;
1146 lvds->lvds_gen_cntl |= RADEON_LVDS_4_GREY;
1152 if ((panel_setup >> 16) & 0x1)
1153 lvds->lvds_gen_cntl |= RADEON_LVDS_FP_POL_LOW;
1155 if ((panel_setup >> 17) & 0x1)
1156 lvds->lvds_gen_cntl |= RADEON_LVDS_LP_POL_LOW;
1158 if ((panel_setup >> 18) & 0x1)
1159 lvds->lvds_gen_cntl |= RADEON_LVDS_DTM_POL_LOW;
1161 if ((panel_setup >> 23) & 0x1)
1162 lvds->lvds_gen_cntl |= RADEON_LVDS_BL_CLK_SEL;
1164 lvds->lvds_gen_cntl |= (panel_setup & 0xf0000000);
1166 for (i = 0; i < 32; i++) {
1167 tmp = RBIOS16(lcd_info + 64 + i * 2);
1171 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
1172 (RBIOS16(tmp + 2) == lvds->native_mode.vdisplay)) {
1173 lvds->native_mode.htotal = lvds->native_mode.hdisplay +
1174 (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8;
1175 lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
1176 (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 1) * 8;
1177 lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
1178 (RBIOS8(tmp + 23) * 8);
1180 lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
1181 (RBIOS16(tmp + 24) - RBIOS16(tmp + 26));
1182 lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
1183 ((RBIOS16(tmp + 28) & 0x7ff) - RBIOS16(tmp + 26));
1184 lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
1185 ((RBIOS16(tmp + 28) & 0xf800) >> 11);
1187 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
1188 lvds->native_mode.flags = 0;
1189 /* set crtc values */
1190 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
1195 DRM_INFO("No panel info found in BIOS\n");
1196 lvds = radeon_legacy_get_lvds_info_from_regs(rdev);
1200 encoder->native_mode = lvds->native_mode;
1204 static const struct radeon_tmds_pll default_tmds_pll[CHIP_LAST][4] = {
1205 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R100 */
1206 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV100 */
1207 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS100 */
1208 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RV200 */
1209 {{12000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_RS200 */
1210 {{15000, 0xa1b}, {0xffffffff, 0xa3f}, {0, 0}, {0, 0}}, /* CHIP_R200 */
1211 {{15500, 0x81b}, {0xffffffff, 0x83f}, {0, 0}, {0, 0}}, /* CHIP_RV250 */
1212 {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RS300 */
1213 {{13000, 0x400f4}, {15000, 0x400f7}, {0xffffffff, 0x40111}, {0, 0}}, /* CHIP_RV280 */
1214 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R300 */
1215 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R350 */
1216 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV350 */
1217 {{15000, 0xb0155}, {0xffffffff, 0xb01cb}, {0, 0}, {0, 0}}, /* CHIP_RV380 */
1218 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R420 */
1219 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_R423 */
1220 {{0xffffffff, 0xb01cb}, {0, 0}, {0, 0}, {0, 0}}, /* CHIP_RV410 */
1221 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS400 */
1222 { {0, 0}, {0, 0}, {0, 0}, {0, 0} }, /* CHIP_RS480 */
1225 bool radeon_legacy_get_tmds_info_from_table(struct radeon_encoder *encoder,
1226 struct radeon_encoder_int_tmds *tmds)
1228 struct drm_device *dev = encoder->base.dev;
1229 struct radeon_device *rdev = dev->dev_private;
1232 for (i = 0; i < 4; i++) {
1233 tmds->tmds_pll[i].value =
1234 default_tmds_pll[rdev->family][i].value;
1235 tmds->tmds_pll[i].freq = default_tmds_pll[rdev->family][i].freq;
1241 bool radeon_legacy_get_tmds_info_from_combios(struct radeon_encoder *encoder,
1242 struct radeon_encoder_int_tmds *tmds)
1244 struct drm_device *dev = encoder->base.dev;
1245 struct radeon_device *rdev = dev->dev_private;
1250 tmds_info = combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
1253 ver = RBIOS8(tmds_info);
1254 DRM_INFO("DFP table revision: %d\n", ver);
1256 n = RBIOS8(tmds_info + 5) + 1;
1259 for (i = 0; i < n; i++) {
1260 tmds->tmds_pll[i].value =
1261 RBIOS32(tmds_info + i * 10 + 0x08);
1262 tmds->tmds_pll[i].freq =
1263 RBIOS16(tmds_info + i * 10 + 0x10);
1264 DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
1265 tmds->tmds_pll[i].freq,
1266 tmds->tmds_pll[i].value);
1268 } else if (ver == 4) {
1270 n = RBIOS8(tmds_info + 5) + 1;
1273 for (i = 0; i < n; i++) {
1274 tmds->tmds_pll[i].value =
1275 RBIOS32(tmds_info + stride + 0x08);
1276 tmds->tmds_pll[i].freq =
1277 RBIOS16(tmds_info + stride + 0x10);
1282 DRM_DEBUG_KMS("TMDS PLL From COMBIOS %u %x\n",
1283 tmds->tmds_pll[i].freq,
1284 tmds->tmds_pll[i].value);
1288 DRM_INFO("No TMDS info found in BIOS\n");
1294 bool radeon_legacy_get_ext_tmds_info_from_table(struct radeon_encoder *encoder,
1295 struct radeon_encoder_ext_tmds *tmds)
1297 struct drm_device *dev = encoder->base.dev;
1298 struct radeon_device *rdev = dev->dev_private;
1299 struct radeon_i2c_bus_rec i2c_bus;
1301 /* default for macs */
1302 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1303 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1305 /* XXX some macs have duallink chips */
1306 switch (rdev->mode_info.connector_table) {
1307 case CT_POWERBOOK_EXTERNAL:
1308 case CT_MINI_EXTERNAL:
1310 tmds->dvo_chip = DVO_SIL164;
1311 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1318 bool radeon_legacy_get_ext_tmds_info_from_combios(struct radeon_encoder *encoder,
1319 struct radeon_encoder_ext_tmds *tmds)
1321 struct drm_device *dev = encoder->base.dev;
1322 struct radeon_device *rdev = dev->dev_private;
1324 uint8_t ver, id, blocks, clk, data;
1326 enum radeon_combios_ddc gpio;
1327 struct radeon_i2c_bus_rec i2c_bus;
1329 tmds->i2c_bus = NULL;
1330 if (rdev->flags & RADEON_IS_IGP) {
1331 offset = combios_get_table_offset(dev, COMBIOS_I2C_INFO_TABLE);
1333 ver = RBIOS8(offset);
1334 DRM_INFO("GPIO Table revision: %d\n", ver);
1335 blocks = RBIOS8(offset + 2);
1336 for (i = 0; i < blocks; i++) {
1337 id = RBIOS8(offset + 3 + (i * 5) + 0);
1339 clk = RBIOS8(offset + 3 + (i * 5) + 3);
1340 data = RBIOS8(offset + 3 + (i * 5) + 4);
1341 i2c_bus.valid = true;
1342 i2c_bus.mask_clk_mask = (1 << clk);
1343 i2c_bus.mask_data_mask = (1 << data);
1344 i2c_bus.a_clk_mask = (1 << clk);
1345 i2c_bus.a_data_mask = (1 << data);
1346 i2c_bus.en_clk_mask = (1 << clk);
1347 i2c_bus.en_data_mask = (1 << data);
1348 i2c_bus.y_clk_mask = (1 << clk);
1349 i2c_bus.y_data_mask = (1 << data);
1350 i2c_bus.mask_clk_reg = RADEON_GPIOPAD_MASK;
1351 i2c_bus.mask_data_reg = RADEON_GPIOPAD_MASK;
1352 i2c_bus.a_clk_reg = RADEON_GPIOPAD_A;
1353 i2c_bus.a_data_reg = RADEON_GPIOPAD_A;
1354 i2c_bus.en_clk_reg = RADEON_GPIOPAD_EN;
1355 i2c_bus.en_data_reg = RADEON_GPIOPAD_EN;
1356 i2c_bus.y_clk_reg = RADEON_GPIOPAD_Y;
1357 i2c_bus.y_data_reg = RADEON_GPIOPAD_Y;
1358 i2c_bus.i2c_id = RADEON_I2C_DVO_ID;
1359 radeon_i2c_add(rdev, &i2c_bus, "DVO");
1360 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1361 tmds->dvo_chip = DVO_SIL164;
1362 tmds->slave_addr = 0x70 >> 1; /* 7 bit addressing */
1368 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
1370 ver = RBIOS8(offset);
1371 DRM_INFO("External TMDS Table revision: %d\n", ver);
1372 tmds->slave_addr = RBIOS8(offset + 4 + 2);
1373 tmds->slave_addr >>= 1; /* 7 bit addressing */
1374 gpio = RBIOS8(offset + 4 + 3);
1377 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1378 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1381 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1382 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1385 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1386 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1389 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1390 if (rdev->family >= CHIP_R300)
1391 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1393 i2c_bus = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1394 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1396 case DDC_LCD: /* MM i2c */
1397 i2c_bus.valid = true;
1398 i2c_bus.hw_capable = true;
1399 i2c_bus.mm_i2c = true;
1400 i2c_bus.i2c_id = RADEON_I2C_MM_ID;
1401 tmds->i2c_bus = radeon_i2c_lookup(rdev, &i2c_bus);
1404 DRM_ERROR("Unsupported gpio %d\n", gpio);
1410 if (!tmds->i2c_bus) {
1411 DRM_INFO("No valid Ext TMDS info found in BIOS\n");
1418 bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
1420 struct radeon_device *rdev = dev->dev_private;
1421 struct radeon_i2c_bus_rec ddc_i2c;
1422 struct radeon_hpd hpd;
1424 rdev->mode_info.connector_table = radeon_connector_table;
1425 if (rdev->mode_info.connector_table == CT_NONE) {
1426 #ifdef CONFIG_PPC_PMAC
1427 if (of_machine_is_compatible("PowerBook3,3")) {
1428 /* powerbook with VGA */
1429 rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
1430 } else if (of_machine_is_compatible("PowerBook3,4") ||
1431 of_machine_is_compatible("PowerBook3,5")) {
1432 /* powerbook with internal tmds */
1433 rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
1434 } else if (of_machine_is_compatible("PowerBook5,1") ||
1435 of_machine_is_compatible("PowerBook5,2") ||
1436 of_machine_is_compatible("PowerBook5,3") ||
1437 of_machine_is_compatible("PowerBook5,4") ||
1438 of_machine_is_compatible("PowerBook5,5")) {
1439 /* powerbook with external single link tmds (sil164) */
1440 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1441 } else if (of_machine_is_compatible("PowerBook5,6")) {
1442 /* powerbook with external dual or single link tmds */
1443 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1444 } else if (of_machine_is_compatible("PowerBook5,7") ||
1445 of_machine_is_compatible("PowerBook5,8") ||
1446 of_machine_is_compatible("PowerBook5,9")) {
1447 /* PowerBook6,2 ? */
1448 /* powerbook with external dual link tmds (sil1178?) */
1449 rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
1450 } else if (of_machine_is_compatible("PowerBook4,1") ||
1451 of_machine_is_compatible("PowerBook4,2") ||
1452 of_machine_is_compatible("PowerBook4,3") ||
1453 of_machine_is_compatible("PowerBook6,3") ||
1454 of_machine_is_compatible("PowerBook6,5") ||
1455 of_machine_is_compatible("PowerBook6,7")) {
1457 rdev->mode_info.connector_table = CT_IBOOK;
1458 } else if (of_machine_is_compatible("PowerMac4,4")) {
1460 rdev->mode_info.connector_table = CT_EMAC;
1461 } else if (of_machine_is_compatible("PowerMac10,1")) {
1462 /* mini with internal tmds */
1463 rdev->mode_info.connector_table = CT_MINI_INTERNAL;
1464 } else if (of_machine_is_compatible("PowerMac10,2")) {
1465 /* mini with external tmds */
1466 rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
1467 } else if (of_machine_is_compatible("PowerMac12,1")) {
1469 /* imac g5 isight */
1470 rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
1472 #endif /* CONFIG_PPC_PMAC */
1474 if (ASIC_IS_RN50(rdev))
1475 rdev->mode_info.connector_table = CT_RN50_POWER;
1478 rdev->mode_info.connector_table = CT_GENERIC;
1481 switch (rdev->mode_info.connector_table) {
1483 DRM_INFO("Connector Table: %d (generic)\n",
1484 rdev->mode_info.connector_table);
1485 /* these are the most common settings */
1486 if (rdev->flags & RADEON_SINGLE_CRTC) {
1487 /* VGA - primary dac */
1488 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1489 hpd.hpd = RADEON_HPD_NONE;
1490 radeon_add_legacy_encoder(dev,
1491 radeon_get_encoder_id(dev,
1492 ATOM_DEVICE_CRT1_SUPPORT,
1494 ATOM_DEVICE_CRT1_SUPPORT);
1495 radeon_add_legacy_connector(dev, 0,
1496 ATOM_DEVICE_CRT1_SUPPORT,
1497 DRM_MODE_CONNECTOR_VGA,
1499 CONNECTOR_OBJECT_ID_VGA,
1501 } else if (rdev->flags & RADEON_IS_MOBILITY) {
1503 ddc_i2c = combios_setup_i2c_bus(rdev, 0);
1504 hpd.hpd = RADEON_HPD_NONE;
1505 radeon_add_legacy_encoder(dev,
1506 radeon_get_encoder_id(dev,
1507 ATOM_DEVICE_LCD1_SUPPORT,
1509 ATOM_DEVICE_LCD1_SUPPORT);
1510 radeon_add_legacy_connector(dev, 0,
1511 ATOM_DEVICE_LCD1_SUPPORT,
1512 DRM_MODE_CONNECTOR_LVDS,
1514 CONNECTOR_OBJECT_ID_LVDS,
1517 /* VGA - primary dac */
1518 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1519 hpd.hpd = RADEON_HPD_NONE;
1520 radeon_add_legacy_encoder(dev,
1521 radeon_get_encoder_id(dev,
1522 ATOM_DEVICE_CRT1_SUPPORT,
1524 ATOM_DEVICE_CRT1_SUPPORT);
1525 radeon_add_legacy_connector(dev, 1,
1526 ATOM_DEVICE_CRT1_SUPPORT,
1527 DRM_MODE_CONNECTOR_VGA,
1529 CONNECTOR_OBJECT_ID_VGA,
1532 /* DVI-I - tv dac, int tmds */
1533 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1534 hpd.hpd = RADEON_HPD_1;
1535 radeon_add_legacy_encoder(dev,
1536 radeon_get_encoder_id(dev,
1537 ATOM_DEVICE_DFP1_SUPPORT,
1539 ATOM_DEVICE_DFP1_SUPPORT);
1540 radeon_add_legacy_encoder(dev,
1541 radeon_get_encoder_id(dev,
1542 ATOM_DEVICE_CRT2_SUPPORT,
1544 ATOM_DEVICE_CRT2_SUPPORT);
1545 radeon_add_legacy_connector(dev, 0,
1546 ATOM_DEVICE_DFP1_SUPPORT |
1547 ATOM_DEVICE_CRT2_SUPPORT,
1548 DRM_MODE_CONNECTOR_DVII,
1550 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1553 /* VGA - primary dac */
1554 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1555 hpd.hpd = RADEON_HPD_NONE;
1556 radeon_add_legacy_encoder(dev,
1557 radeon_get_encoder_id(dev,
1558 ATOM_DEVICE_CRT1_SUPPORT,
1560 ATOM_DEVICE_CRT1_SUPPORT);
1561 radeon_add_legacy_connector(dev, 1,
1562 ATOM_DEVICE_CRT1_SUPPORT,
1563 DRM_MODE_CONNECTOR_VGA,
1565 CONNECTOR_OBJECT_ID_VGA,
1569 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
1571 ddc_i2c.valid = false;
1572 hpd.hpd = RADEON_HPD_NONE;
1573 radeon_add_legacy_encoder(dev,
1574 radeon_get_encoder_id(dev,
1575 ATOM_DEVICE_TV1_SUPPORT,
1577 ATOM_DEVICE_TV1_SUPPORT);
1578 radeon_add_legacy_connector(dev, 2,
1579 ATOM_DEVICE_TV1_SUPPORT,
1580 DRM_MODE_CONNECTOR_SVIDEO,
1582 CONNECTOR_OBJECT_ID_SVIDEO,
1587 DRM_INFO("Connector Table: %d (ibook)\n",
1588 rdev->mode_info.connector_table);
1590 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1591 hpd.hpd = RADEON_HPD_NONE;
1592 radeon_add_legacy_encoder(dev,
1593 radeon_get_encoder_id(dev,
1594 ATOM_DEVICE_LCD1_SUPPORT,
1596 ATOM_DEVICE_LCD1_SUPPORT);
1597 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1598 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1599 CONNECTOR_OBJECT_ID_LVDS,
1602 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1603 hpd.hpd = RADEON_HPD_NONE;
1604 radeon_add_legacy_encoder(dev,
1605 radeon_get_encoder_id(dev,
1606 ATOM_DEVICE_CRT2_SUPPORT,
1608 ATOM_DEVICE_CRT2_SUPPORT);
1609 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1610 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1611 CONNECTOR_OBJECT_ID_VGA,
1614 ddc_i2c.valid = false;
1615 hpd.hpd = RADEON_HPD_NONE;
1616 radeon_add_legacy_encoder(dev,
1617 radeon_get_encoder_id(dev,
1618 ATOM_DEVICE_TV1_SUPPORT,
1620 ATOM_DEVICE_TV1_SUPPORT);
1621 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1622 DRM_MODE_CONNECTOR_SVIDEO,
1624 CONNECTOR_OBJECT_ID_SVIDEO,
1627 case CT_POWERBOOK_EXTERNAL:
1628 DRM_INFO("Connector Table: %d (powerbook external tmds)\n",
1629 rdev->mode_info.connector_table);
1631 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1632 hpd.hpd = RADEON_HPD_NONE;
1633 radeon_add_legacy_encoder(dev,
1634 radeon_get_encoder_id(dev,
1635 ATOM_DEVICE_LCD1_SUPPORT,
1637 ATOM_DEVICE_LCD1_SUPPORT);
1638 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1639 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1640 CONNECTOR_OBJECT_ID_LVDS,
1642 /* DVI-I - primary dac, ext tmds */
1643 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1644 hpd.hpd = RADEON_HPD_2; /* ??? */
1645 radeon_add_legacy_encoder(dev,
1646 radeon_get_encoder_id(dev,
1647 ATOM_DEVICE_DFP2_SUPPORT,
1649 ATOM_DEVICE_DFP2_SUPPORT);
1650 radeon_add_legacy_encoder(dev,
1651 radeon_get_encoder_id(dev,
1652 ATOM_DEVICE_CRT1_SUPPORT,
1654 ATOM_DEVICE_CRT1_SUPPORT);
1655 /* XXX some are SL */
1656 radeon_add_legacy_connector(dev, 1,
1657 ATOM_DEVICE_DFP2_SUPPORT |
1658 ATOM_DEVICE_CRT1_SUPPORT,
1659 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1660 CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I,
1663 ddc_i2c.valid = false;
1664 hpd.hpd = RADEON_HPD_NONE;
1665 radeon_add_legacy_encoder(dev,
1666 radeon_get_encoder_id(dev,
1667 ATOM_DEVICE_TV1_SUPPORT,
1669 ATOM_DEVICE_TV1_SUPPORT);
1670 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1671 DRM_MODE_CONNECTOR_SVIDEO,
1673 CONNECTOR_OBJECT_ID_SVIDEO,
1676 case CT_POWERBOOK_INTERNAL:
1677 DRM_INFO("Connector Table: %d (powerbook internal tmds)\n",
1678 rdev->mode_info.connector_table);
1680 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1681 hpd.hpd = RADEON_HPD_NONE;
1682 radeon_add_legacy_encoder(dev,
1683 radeon_get_encoder_id(dev,
1684 ATOM_DEVICE_LCD1_SUPPORT,
1686 ATOM_DEVICE_LCD1_SUPPORT);
1687 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1688 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1689 CONNECTOR_OBJECT_ID_LVDS,
1691 /* DVI-I - primary dac, int tmds */
1692 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1693 hpd.hpd = RADEON_HPD_1; /* ??? */
1694 radeon_add_legacy_encoder(dev,
1695 radeon_get_encoder_id(dev,
1696 ATOM_DEVICE_DFP1_SUPPORT,
1698 ATOM_DEVICE_DFP1_SUPPORT);
1699 radeon_add_legacy_encoder(dev,
1700 radeon_get_encoder_id(dev,
1701 ATOM_DEVICE_CRT1_SUPPORT,
1703 ATOM_DEVICE_CRT1_SUPPORT);
1704 radeon_add_legacy_connector(dev, 1,
1705 ATOM_DEVICE_DFP1_SUPPORT |
1706 ATOM_DEVICE_CRT1_SUPPORT,
1707 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1708 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1711 ddc_i2c.valid = false;
1712 hpd.hpd = RADEON_HPD_NONE;
1713 radeon_add_legacy_encoder(dev,
1714 radeon_get_encoder_id(dev,
1715 ATOM_DEVICE_TV1_SUPPORT,
1717 ATOM_DEVICE_TV1_SUPPORT);
1718 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1719 DRM_MODE_CONNECTOR_SVIDEO,
1721 CONNECTOR_OBJECT_ID_SVIDEO,
1724 case CT_POWERBOOK_VGA:
1725 DRM_INFO("Connector Table: %d (powerbook vga)\n",
1726 rdev->mode_info.connector_table);
1728 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1729 hpd.hpd = RADEON_HPD_NONE;
1730 radeon_add_legacy_encoder(dev,
1731 radeon_get_encoder_id(dev,
1732 ATOM_DEVICE_LCD1_SUPPORT,
1734 ATOM_DEVICE_LCD1_SUPPORT);
1735 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_LCD1_SUPPORT,
1736 DRM_MODE_CONNECTOR_LVDS, &ddc_i2c,
1737 CONNECTOR_OBJECT_ID_LVDS,
1739 /* VGA - primary dac */
1740 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1741 hpd.hpd = RADEON_HPD_NONE;
1742 radeon_add_legacy_encoder(dev,
1743 radeon_get_encoder_id(dev,
1744 ATOM_DEVICE_CRT1_SUPPORT,
1746 ATOM_DEVICE_CRT1_SUPPORT);
1747 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT1_SUPPORT,
1748 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1749 CONNECTOR_OBJECT_ID_VGA,
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, 2, ATOM_DEVICE_TV1_SUPPORT,
1760 DRM_MODE_CONNECTOR_SVIDEO,
1762 CONNECTOR_OBJECT_ID_SVIDEO,
1765 case CT_MINI_EXTERNAL:
1766 DRM_INFO("Connector Table: %d (mini external tmds)\n",
1767 rdev->mode_info.connector_table);
1768 /* DVI-I - tv dac, ext tmds */
1769 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1770 hpd.hpd = RADEON_HPD_2; /* ??? */
1771 radeon_add_legacy_encoder(dev,
1772 radeon_get_encoder_id(dev,
1773 ATOM_DEVICE_DFP2_SUPPORT,
1775 ATOM_DEVICE_DFP2_SUPPORT);
1776 radeon_add_legacy_encoder(dev,
1777 radeon_get_encoder_id(dev,
1778 ATOM_DEVICE_CRT2_SUPPORT,
1780 ATOM_DEVICE_CRT2_SUPPORT);
1781 /* XXX are any DL? */
1782 radeon_add_legacy_connector(dev, 0,
1783 ATOM_DEVICE_DFP2_SUPPORT |
1784 ATOM_DEVICE_CRT2_SUPPORT,
1785 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1786 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1789 ddc_i2c.valid = false;
1790 hpd.hpd = RADEON_HPD_NONE;
1791 radeon_add_legacy_encoder(dev,
1792 radeon_get_encoder_id(dev,
1793 ATOM_DEVICE_TV1_SUPPORT,
1795 ATOM_DEVICE_TV1_SUPPORT);
1796 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1797 DRM_MODE_CONNECTOR_SVIDEO,
1799 CONNECTOR_OBJECT_ID_SVIDEO,
1802 case CT_MINI_INTERNAL:
1803 DRM_INFO("Connector Table: %d (mini internal tmds)\n",
1804 rdev->mode_info.connector_table);
1805 /* DVI-I - tv dac, int tmds */
1806 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1807 hpd.hpd = RADEON_HPD_1; /* ??? */
1808 radeon_add_legacy_encoder(dev,
1809 radeon_get_encoder_id(dev,
1810 ATOM_DEVICE_DFP1_SUPPORT,
1812 ATOM_DEVICE_DFP1_SUPPORT);
1813 radeon_add_legacy_encoder(dev,
1814 radeon_get_encoder_id(dev,
1815 ATOM_DEVICE_CRT2_SUPPORT,
1817 ATOM_DEVICE_CRT2_SUPPORT);
1818 radeon_add_legacy_connector(dev, 0,
1819 ATOM_DEVICE_DFP1_SUPPORT |
1820 ATOM_DEVICE_CRT2_SUPPORT,
1821 DRM_MODE_CONNECTOR_DVII, &ddc_i2c,
1822 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
1825 ddc_i2c.valid = false;
1826 hpd.hpd = RADEON_HPD_NONE;
1827 radeon_add_legacy_encoder(dev,
1828 radeon_get_encoder_id(dev,
1829 ATOM_DEVICE_TV1_SUPPORT,
1831 ATOM_DEVICE_TV1_SUPPORT);
1832 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_TV1_SUPPORT,
1833 DRM_MODE_CONNECTOR_SVIDEO,
1835 CONNECTOR_OBJECT_ID_SVIDEO,
1838 case CT_IMAC_G5_ISIGHT:
1839 DRM_INFO("Connector Table: %d (imac g5 isight)\n",
1840 rdev->mode_info.connector_table);
1841 /* DVI-D - int tmds */
1842 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1843 hpd.hpd = RADEON_HPD_1; /* ??? */
1844 radeon_add_legacy_encoder(dev,
1845 radeon_get_encoder_id(dev,
1846 ATOM_DEVICE_DFP1_SUPPORT,
1848 ATOM_DEVICE_DFP1_SUPPORT);
1849 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_DFP1_SUPPORT,
1850 DRM_MODE_CONNECTOR_DVID, &ddc_i2c,
1851 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
1854 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1855 hpd.hpd = RADEON_HPD_NONE;
1856 radeon_add_legacy_encoder(dev,
1857 radeon_get_encoder_id(dev,
1858 ATOM_DEVICE_CRT2_SUPPORT,
1860 ATOM_DEVICE_CRT2_SUPPORT);
1861 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1862 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1863 CONNECTOR_OBJECT_ID_VGA,
1866 ddc_i2c.valid = false;
1867 hpd.hpd = RADEON_HPD_NONE;
1868 radeon_add_legacy_encoder(dev,
1869 radeon_get_encoder_id(dev,
1870 ATOM_DEVICE_TV1_SUPPORT,
1872 ATOM_DEVICE_TV1_SUPPORT);
1873 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1874 DRM_MODE_CONNECTOR_SVIDEO,
1876 CONNECTOR_OBJECT_ID_SVIDEO,
1880 DRM_INFO("Connector Table: %d (emac)\n",
1881 rdev->mode_info.connector_table);
1882 /* VGA - primary dac */
1883 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1884 hpd.hpd = RADEON_HPD_NONE;
1885 radeon_add_legacy_encoder(dev,
1886 radeon_get_encoder_id(dev,
1887 ATOM_DEVICE_CRT1_SUPPORT,
1889 ATOM_DEVICE_CRT1_SUPPORT);
1890 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1891 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1892 CONNECTOR_OBJECT_ID_VGA,
1895 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1896 hpd.hpd = RADEON_HPD_NONE;
1897 radeon_add_legacy_encoder(dev,
1898 radeon_get_encoder_id(dev,
1899 ATOM_DEVICE_CRT2_SUPPORT,
1901 ATOM_DEVICE_CRT2_SUPPORT);
1902 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1903 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1904 CONNECTOR_OBJECT_ID_VGA,
1907 ddc_i2c.valid = false;
1908 hpd.hpd = RADEON_HPD_NONE;
1909 radeon_add_legacy_encoder(dev,
1910 radeon_get_encoder_id(dev,
1911 ATOM_DEVICE_TV1_SUPPORT,
1913 ATOM_DEVICE_TV1_SUPPORT);
1914 radeon_add_legacy_connector(dev, 2, ATOM_DEVICE_TV1_SUPPORT,
1915 DRM_MODE_CONNECTOR_SVIDEO,
1917 CONNECTOR_OBJECT_ID_SVIDEO,
1921 DRM_INFO("Connector Table: %d (rn50-power)\n",
1922 rdev->mode_info.connector_table);
1923 /* VGA - primary dac */
1924 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
1925 hpd.hpd = RADEON_HPD_NONE;
1926 radeon_add_legacy_encoder(dev,
1927 radeon_get_encoder_id(dev,
1928 ATOM_DEVICE_CRT1_SUPPORT,
1930 ATOM_DEVICE_CRT1_SUPPORT);
1931 radeon_add_legacy_connector(dev, 0, ATOM_DEVICE_CRT1_SUPPORT,
1932 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1933 CONNECTOR_OBJECT_ID_VGA,
1935 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
1936 hpd.hpd = RADEON_HPD_NONE;
1937 radeon_add_legacy_encoder(dev,
1938 radeon_get_encoder_id(dev,
1939 ATOM_DEVICE_CRT2_SUPPORT,
1941 ATOM_DEVICE_CRT2_SUPPORT);
1942 radeon_add_legacy_connector(dev, 1, ATOM_DEVICE_CRT2_SUPPORT,
1943 DRM_MODE_CONNECTOR_VGA, &ddc_i2c,
1944 CONNECTOR_OBJECT_ID_VGA,
1948 DRM_INFO("Connector table: %d (invalid)\n",
1949 rdev->mode_info.connector_table);
1953 radeon_link_encoder_connector(dev);
1958 static bool radeon_apply_legacy_quirks(struct drm_device *dev,
1960 enum radeon_combios_connector
1962 struct radeon_i2c_bus_rec *ddc_i2c,
1963 struct radeon_hpd *hpd)
1965 struct radeon_device *rdev = dev->dev_private;
1967 /* XPRESS DDC quirks */
1968 if ((rdev->family == CHIP_RS400 ||
1969 rdev->family == CHIP_RS480) &&
1970 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1971 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
1972 else if ((rdev->family == CHIP_RS400 ||
1973 rdev->family == CHIP_RS480) &&
1974 ddc_i2c->mask_clk_reg == RADEON_GPIO_MONID) {
1975 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIOPAD_MASK);
1976 ddc_i2c->mask_clk_mask = (0x20 << 8);
1977 ddc_i2c->mask_data_mask = 0x80;
1978 ddc_i2c->a_clk_mask = (0x20 << 8);
1979 ddc_i2c->a_data_mask = 0x80;
1980 ddc_i2c->en_clk_mask = (0x20 << 8);
1981 ddc_i2c->en_data_mask = 0x80;
1982 ddc_i2c->y_clk_mask = (0x20 << 8);
1983 ddc_i2c->y_data_mask = 0x80;
1984 ddc_i2c->i2c_id = RADEON_I2C_GPIO_ID;
1985 radeon_i2c_add(rdev, ddc_i2c, "GPIO_DDC");
1988 /* R3xx+ chips don't have GPIO_CRT2_DDC gpio pad */
1989 if ((rdev->family >= CHIP_R300) &&
1990 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
1991 *ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
1993 /* Certain IBM chipset RN50s have a BIOS reporting two VGAs,
1994 one with VGA DDC and one with CRT2 DDC. - kill the CRT2 DDC one */
1995 if (dev->pdev->device == 0x515e &&
1996 dev->pdev->subsystem_vendor == 0x1014) {
1997 if (*legacy_connector == CONNECTOR_CRT_LEGACY &&
1998 ddc_i2c->mask_clk_reg == RADEON_GPIO_CRT2_DDC)
2002 /* X300 card with extra non-existent DVI port */
2003 if (dev->pdev->device == 0x5B60 &&
2004 dev->pdev->subsystem_vendor == 0x17af &&
2005 dev->pdev->subsystem_device == 0x201e && bios_index == 2) {
2006 if (*legacy_connector == CONNECTOR_DVI_I_LEGACY)
2013 static bool radeon_apply_legacy_tv_quirks(struct drm_device *dev)
2015 /* Acer 5102 has non-existent TV port */
2016 if (dev->pdev->device == 0x5975 &&
2017 dev->pdev->subsystem_vendor == 0x1025 &&
2018 dev->pdev->subsystem_device == 0x009f)
2021 /* HP dc5750 has non-existent TV port */
2022 if (dev->pdev->device == 0x5974 &&
2023 dev->pdev->subsystem_vendor == 0x103c &&
2024 dev->pdev->subsystem_device == 0x280a)
2027 /* MSI S270 has non-existent TV port */
2028 if (dev->pdev->device == 0x5955 &&
2029 dev->pdev->subsystem_vendor == 0x1462 &&
2030 dev->pdev->subsystem_device == 0x0131)
2036 static uint16_t combios_check_dl_dvi(struct drm_device *dev, int is_dvi_d)
2038 struct radeon_device *rdev = dev->dev_private;
2039 uint32_t ext_tmds_info;
2041 if (rdev->flags & RADEON_IS_IGP) {
2043 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
2045 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2047 ext_tmds_info = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2048 if (ext_tmds_info) {
2049 uint8_t rev = RBIOS8(ext_tmds_info);
2050 uint8_t flags = RBIOS8(ext_tmds_info + 4 + 5);
2053 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
2055 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
2059 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
2061 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
2066 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
2068 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2071 bool radeon_get_legacy_connector_info_from_bios(struct drm_device *dev)
2073 struct radeon_device *rdev = dev->dev_private;
2074 uint32_t conn_info, entry, devices;
2075 uint16_t tmp, connector_object_id;
2076 enum radeon_combios_ddc ddc_type;
2077 enum radeon_combios_connector connector;
2079 struct radeon_i2c_bus_rec ddc_i2c;
2080 struct radeon_hpd hpd;
2082 conn_info = combios_get_table_offset(dev, COMBIOS_CONNECTOR_INFO_TABLE);
2084 for (i = 0; i < 4; i++) {
2085 entry = conn_info + 2 + i * 2;
2087 if (!RBIOS16(entry))
2090 tmp = RBIOS16(entry);
2092 connector = (tmp >> 12) & 0xf;
2094 ddc_type = (tmp >> 8) & 0xf;
2098 combios_setup_i2c_bus(rdev, RADEON_GPIO_MONID);
2102 combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
2106 combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2110 combios_setup_i2c_bus(rdev, RADEON_GPIO_CRT2_DDC);
2113 ddc_i2c.valid = false;
2117 switch (connector) {
2118 case CONNECTOR_PROPRIETARY_LEGACY:
2119 case CONNECTOR_DVI_I_LEGACY:
2120 case CONNECTOR_DVI_D_LEGACY:
2121 if ((tmp >> 4) & 0x1)
2122 hpd.hpd = RADEON_HPD_2;
2124 hpd.hpd = RADEON_HPD_1;
2127 hpd.hpd = RADEON_HPD_NONE;
2131 if (!radeon_apply_legacy_quirks(dev, i, &connector,
2135 switch (connector) {
2136 case CONNECTOR_PROPRIETARY_LEGACY:
2137 if ((tmp >> 4) & 0x1)
2138 devices = ATOM_DEVICE_DFP2_SUPPORT;
2140 devices = ATOM_DEVICE_DFP1_SUPPORT;
2141 radeon_add_legacy_encoder(dev,
2142 radeon_get_encoder_id
2145 radeon_add_legacy_connector(dev, i, devices,
2146 legacy_connector_convert
2149 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D,
2152 case CONNECTOR_CRT_LEGACY:
2154 devices = ATOM_DEVICE_CRT2_SUPPORT;
2155 radeon_add_legacy_encoder(dev,
2156 radeon_get_encoder_id
2158 ATOM_DEVICE_CRT2_SUPPORT,
2160 ATOM_DEVICE_CRT2_SUPPORT);
2162 devices = ATOM_DEVICE_CRT1_SUPPORT;
2163 radeon_add_legacy_encoder(dev,
2164 radeon_get_encoder_id
2166 ATOM_DEVICE_CRT1_SUPPORT,
2168 ATOM_DEVICE_CRT1_SUPPORT);
2170 radeon_add_legacy_connector(dev,
2173 legacy_connector_convert
2176 CONNECTOR_OBJECT_ID_VGA,
2179 case CONNECTOR_DVI_I_LEGACY:
2182 devices |= ATOM_DEVICE_CRT2_SUPPORT;
2183 radeon_add_legacy_encoder(dev,
2184 radeon_get_encoder_id
2186 ATOM_DEVICE_CRT2_SUPPORT,
2188 ATOM_DEVICE_CRT2_SUPPORT);
2190 devices |= ATOM_DEVICE_CRT1_SUPPORT;
2191 radeon_add_legacy_encoder(dev,
2192 radeon_get_encoder_id
2194 ATOM_DEVICE_CRT1_SUPPORT,
2196 ATOM_DEVICE_CRT1_SUPPORT);
2198 if ((tmp >> 4) & 0x1) {
2199 devices |= ATOM_DEVICE_DFP2_SUPPORT;
2200 radeon_add_legacy_encoder(dev,
2201 radeon_get_encoder_id
2203 ATOM_DEVICE_DFP2_SUPPORT,
2205 ATOM_DEVICE_DFP2_SUPPORT);
2206 connector_object_id = combios_check_dl_dvi(dev, 0);
2208 devices |= ATOM_DEVICE_DFP1_SUPPORT;
2209 radeon_add_legacy_encoder(dev,
2210 radeon_get_encoder_id
2212 ATOM_DEVICE_DFP1_SUPPORT,
2214 ATOM_DEVICE_DFP1_SUPPORT);
2215 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2217 radeon_add_legacy_connector(dev,
2220 legacy_connector_convert
2223 connector_object_id,
2226 case CONNECTOR_DVI_D_LEGACY:
2227 if ((tmp >> 4) & 0x1) {
2228 devices = ATOM_DEVICE_DFP2_SUPPORT;
2229 connector_object_id = combios_check_dl_dvi(dev, 1);
2231 devices = ATOM_DEVICE_DFP1_SUPPORT;
2232 connector_object_id = CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
2234 radeon_add_legacy_encoder(dev,
2235 radeon_get_encoder_id
2238 radeon_add_legacy_connector(dev, i, devices,
2239 legacy_connector_convert
2242 connector_object_id,
2245 case CONNECTOR_CTV_LEGACY:
2246 case CONNECTOR_STV_LEGACY:
2247 radeon_add_legacy_encoder(dev,
2248 radeon_get_encoder_id
2250 ATOM_DEVICE_TV1_SUPPORT,
2252 ATOM_DEVICE_TV1_SUPPORT);
2253 radeon_add_legacy_connector(dev, i,
2254 ATOM_DEVICE_TV1_SUPPORT,
2255 legacy_connector_convert
2258 CONNECTOR_OBJECT_ID_SVIDEO,
2262 DRM_ERROR("Unknown connector type: %d\n",
2269 uint16_t tmds_info =
2270 combios_get_table_offset(dev, COMBIOS_DFP_INFO_TABLE);
2272 DRM_DEBUG_KMS("Found DFP table, assuming DVI connector\n");
2274 radeon_add_legacy_encoder(dev,
2275 radeon_get_encoder_id(dev,
2276 ATOM_DEVICE_CRT1_SUPPORT,
2278 ATOM_DEVICE_CRT1_SUPPORT);
2279 radeon_add_legacy_encoder(dev,
2280 radeon_get_encoder_id(dev,
2281 ATOM_DEVICE_DFP1_SUPPORT,
2283 ATOM_DEVICE_DFP1_SUPPORT);
2285 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_DVI_DDC);
2286 hpd.hpd = RADEON_HPD_1;
2287 radeon_add_legacy_connector(dev,
2289 ATOM_DEVICE_CRT1_SUPPORT |
2290 ATOM_DEVICE_DFP1_SUPPORT,
2291 DRM_MODE_CONNECTOR_DVII,
2293 CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I,
2297 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
2298 DRM_DEBUG_KMS("Found CRT table, assuming VGA connector\n");
2300 radeon_add_legacy_encoder(dev,
2301 radeon_get_encoder_id(dev,
2302 ATOM_DEVICE_CRT1_SUPPORT,
2304 ATOM_DEVICE_CRT1_SUPPORT);
2305 ddc_i2c = combios_setup_i2c_bus(rdev, RADEON_GPIO_VGA_DDC);
2306 hpd.hpd = RADEON_HPD_NONE;
2307 radeon_add_legacy_connector(dev,
2309 ATOM_DEVICE_CRT1_SUPPORT,
2310 DRM_MODE_CONNECTOR_VGA,
2312 CONNECTOR_OBJECT_ID_VGA,
2315 DRM_DEBUG_KMS("No connector info found\n");
2321 if (rdev->flags & RADEON_IS_MOBILITY || rdev->flags & RADEON_IS_IGP) {
2323 combios_get_table_offset(dev, COMBIOS_LCD_INFO_TABLE);
2325 uint16_t lcd_ddc_info =
2326 combios_get_table_offset(dev,
2327 COMBIOS_LCD_DDC_INFO_TABLE);
2329 radeon_add_legacy_encoder(dev,
2330 radeon_get_encoder_id(dev,
2331 ATOM_DEVICE_LCD1_SUPPORT,
2333 ATOM_DEVICE_LCD1_SUPPORT);
2336 ddc_type = RBIOS8(lcd_ddc_info + 2);
2340 combios_setup_i2c_bus
2341 (rdev, RADEON_GPIO_MONID);
2345 combios_setup_i2c_bus
2346 (rdev, RADEON_GPIO_DVI_DDC);
2350 combios_setup_i2c_bus
2351 (rdev, RADEON_GPIO_VGA_DDC);
2355 combios_setup_i2c_bus
2356 (rdev, RADEON_GPIO_CRT2_DDC);
2360 combios_setup_i2c_bus
2361 (rdev, RADEON_GPIOPAD_MASK);
2362 ddc_i2c.mask_clk_mask =
2363 RBIOS32(lcd_ddc_info + 3);
2364 ddc_i2c.mask_data_mask =
2365 RBIOS32(lcd_ddc_info + 7);
2366 ddc_i2c.a_clk_mask =
2367 RBIOS32(lcd_ddc_info + 3);
2368 ddc_i2c.a_data_mask =
2369 RBIOS32(lcd_ddc_info + 7);
2370 ddc_i2c.en_clk_mask =
2371 RBIOS32(lcd_ddc_info + 3);
2372 ddc_i2c.en_data_mask =
2373 RBIOS32(lcd_ddc_info + 7);
2374 ddc_i2c.y_clk_mask =
2375 RBIOS32(lcd_ddc_info + 3);
2376 ddc_i2c.y_data_mask =
2377 RBIOS32(lcd_ddc_info + 7);
2378 ddc_i2c.i2c_id = RADEON_I2C_LCD_ID;
2379 radeon_i2c_add(rdev, &ddc_i2c, "LCD");
2383 combios_setup_i2c_bus
2384 (rdev, RADEON_MDGPIO_MASK);
2385 ddc_i2c.mask_clk_mask =
2386 RBIOS32(lcd_ddc_info + 3);
2387 ddc_i2c.mask_data_mask =
2388 RBIOS32(lcd_ddc_info + 7);
2389 ddc_i2c.a_clk_mask =
2390 RBIOS32(lcd_ddc_info + 3);
2391 ddc_i2c.a_data_mask =
2392 RBIOS32(lcd_ddc_info + 7);
2393 ddc_i2c.en_clk_mask =
2394 RBIOS32(lcd_ddc_info + 3);
2395 ddc_i2c.en_data_mask =
2396 RBIOS32(lcd_ddc_info + 7);
2397 ddc_i2c.y_clk_mask =
2398 RBIOS32(lcd_ddc_info + 3);
2399 ddc_i2c.y_data_mask =
2400 RBIOS32(lcd_ddc_info + 7);
2401 ddc_i2c.i2c_id = RADEON_I2C_LCD_ID;
2402 radeon_i2c_add(rdev, &ddc_i2c, "LCD");
2405 ddc_i2c.valid = false;
2408 DRM_DEBUG_KMS("LCD DDC Info Table found!\n");
2410 ddc_i2c.valid = false;
2412 hpd.hpd = RADEON_HPD_NONE;
2413 radeon_add_legacy_connector(dev,
2415 ATOM_DEVICE_LCD1_SUPPORT,
2416 DRM_MODE_CONNECTOR_LVDS,
2418 CONNECTOR_OBJECT_ID_LVDS,
2423 /* check TV table */
2424 if (rdev->family != CHIP_R100 && rdev->family != CHIP_R200) {
2426 combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
2428 if (RBIOS8(tv_info + 6) == 'T') {
2429 if (radeon_apply_legacy_tv_quirks(dev)) {
2430 hpd.hpd = RADEON_HPD_NONE;
2431 ddc_i2c.valid = false;
2432 radeon_add_legacy_encoder(dev,
2433 radeon_get_encoder_id
2435 ATOM_DEVICE_TV1_SUPPORT,
2437 ATOM_DEVICE_TV1_SUPPORT);
2438 radeon_add_legacy_connector(dev, 6,
2439 ATOM_DEVICE_TV1_SUPPORT,
2440 DRM_MODE_CONNECTOR_SVIDEO,
2442 CONNECTOR_OBJECT_ID_SVIDEO,
2449 radeon_link_encoder_connector(dev);
2454 void radeon_combios_get_power_modes(struct radeon_device *rdev)
2456 struct drm_device *dev = rdev->ddev;
2457 u16 offset, misc, misc2 = 0;
2458 u8 rev, blocks, tmp;
2459 int state_index = 0;
2461 rdev->pm.default_power_state_index = -1;
2463 if (rdev->flags & RADEON_IS_MOBILITY) {
2464 offset = combios_get_table_offset(dev, COMBIOS_POWERPLAY_INFO_TABLE);
2466 rev = RBIOS8(offset);
2467 blocks = RBIOS8(offset + 0x2);
2468 /* power mode 0 tends to be the only valid one */
2469 rdev->pm.power_state[state_index].num_clock_modes = 1;
2470 rdev->pm.power_state[state_index].clock_info[0].mclk = RBIOS32(offset + 0x5 + 0x2);
2471 rdev->pm.power_state[state_index].clock_info[0].sclk = RBIOS32(offset + 0x5 + 0x6);
2472 if ((rdev->pm.power_state[state_index].clock_info[0].mclk == 0) ||
2473 (rdev->pm.power_state[state_index].clock_info[0].sclk == 0))
2475 rdev->pm.power_state[state_index].type =
2476 POWER_STATE_TYPE_BATTERY;
2477 misc = RBIOS16(offset + 0x5 + 0x0);
2479 misc2 = RBIOS16(offset + 0x5 + 0xe);
2480 rdev->pm.power_state[state_index].misc = misc;
2481 rdev->pm.power_state[state_index].misc2 = misc2;
2483 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_GPIO;
2485 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2488 rdev->pm.power_state[state_index].clock_info[0].voltage.active_high =
2490 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = true;
2492 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2493 RBIOS16(offset + 0x5 + 0xb) * 4;
2494 tmp = RBIOS8(offset + 0x5 + 0xd);
2495 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2497 u8 entries = RBIOS8(offset + 0x5 + 0xb);
2498 u16 voltage_table_offset = RBIOS16(offset + 0x5 + 0xc);
2499 if (entries && voltage_table_offset) {
2500 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.reg =
2501 RBIOS16(voltage_table_offset) * 4;
2502 tmp = RBIOS8(voltage_table_offset + 0x2);
2503 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.mask = (1 << tmp);
2505 rdev->pm.power_state[state_index].clock_info[0].voltage.gpio.valid = false;
2507 switch ((misc2 & 0x700) >> 8) {
2510 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 0;
2513 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 33;
2516 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 66;
2519 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 99;
2522 rdev->pm.power_state[state_index].clock_info[0].voltage.delay = 132;
2526 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2528 rdev->pm.power_state[state_index].pcie_lanes =
2529 RBIOS8(offset + 0x5 + 0x10);
2530 rdev->pm.power_state[state_index].flags = RADEON_PM_STATE_SINGLE_DISPLAY_ONLY;
2533 /* XXX figure out some good default low power mode for mobility cards w/out power tables */
2536 /* XXX figure out some good default low power mode for desktop cards */
2540 /* add the default mode */
2541 rdev->pm.power_state[state_index].type =
2542 POWER_STATE_TYPE_DEFAULT;
2543 rdev->pm.power_state[state_index].num_clock_modes = 1;
2544 rdev->pm.power_state[state_index].clock_info[0].mclk = rdev->clock.default_mclk;
2545 rdev->pm.power_state[state_index].clock_info[0].sclk = rdev->clock.default_sclk;
2546 rdev->pm.power_state[state_index].default_clock_mode = &rdev->pm.power_state[state_index].clock_info[0];
2547 if ((state_index > 0) &&
2548 (rdev->pm.power_state[0].clock_info[0].voltage.type == VOLTAGE_GPIO))
2549 rdev->pm.power_state[state_index].clock_info[0].voltage =
2550 rdev->pm.power_state[0].clock_info[0].voltage;
2552 rdev->pm.power_state[state_index].clock_info[0].voltage.type = VOLTAGE_NONE;
2553 rdev->pm.power_state[state_index].pcie_lanes = 16;
2554 rdev->pm.power_state[state_index].flags = 0;
2555 rdev->pm.default_power_state_index = state_index;
2556 rdev->pm.num_power_states = state_index + 1;
2558 rdev->pm.current_power_state_index = rdev->pm.default_power_state_index;
2559 rdev->pm.current_clock_mode_index = 0;
2562 void radeon_external_tmds_setup(struct drm_encoder *encoder)
2564 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2565 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2570 switch (tmds->dvo_chip) {
2573 radeon_i2c_put_byte(tmds->i2c_bus,
2576 radeon_i2c_put_byte(tmds->i2c_bus,
2579 radeon_i2c_put_byte(tmds->i2c_bus,
2582 radeon_i2c_put_byte(tmds->i2c_bus,
2585 radeon_i2c_put_byte(tmds->i2c_bus,
2590 /* sil 1178 - untested */
2609 bool radeon_combios_external_tmds_setup(struct drm_encoder *encoder)
2611 struct drm_device *dev = encoder->dev;
2612 struct radeon_device *rdev = dev->dev_private;
2613 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2615 uint8_t blocks, slave_addr, rev;
2617 uint32_t reg, val, and_mask, or_mask;
2618 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv;
2623 if (rdev->flags & RADEON_IS_IGP) {
2624 offset = combios_get_table_offset(dev, COMBIOS_TMDS_POWER_ON_TABLE);
2625 rev = RBIOS8(offset);
2627 rev = RBIOS8(offset);
2629 blocks = RBIOS8(offset + 3);
2631 while (blocks > 0) {
2632 id = RBIOS16(index);
2636 reg = (id & 0x1fff) * 4;
2637 val = RBIOS32(index);
2642 reg = (id & 0x1fff) * 4;
2643 and_mask = RBIOS32(index);
2645 or_mask = RBIOS32(index);
2648 val = (val & and_mask) | or_mask;
2652 val = RBIOS16(index);
2657 val = RBIOS16(index);
2662 slave_addr = id & 0xff;
2663 slave_addr >>= 1; /* 7 bit addressing */
2665 reg = RBIOS8(index);
2667 val = RBIOS8(index);
2669 radeon_i2c_put_byte(tmds->i2c_bus,
2674 DRM_ERROR("Unknown id %d\n", id >> 13);
2683 offset = combios_get_table_offset(dev, COMBIOS_EXT_TMDS_INFO_TABLE);
2685 index = offset + 10;
2686 id = RBIOS16(index);
2687 while (id != 0xffff) {
2691 reg = (id & 0x1fff) * 4;
2692 val = RBIOS32(index);
2696 reg = (id & 0x1fff) * 4;
2697 and_mask = RBIOS32(index);
2699 or_mask = RBIOS32(index);
2702 val = (val & and_mask) | or_mask;
2706 val = RBIOS16(index);
2712 and_mask = RBIOS32(index);
2714 or_mask = RBIOS32(index);
2716 val = RREG32_PLL(reg);
2717 val = (val & and_mask) | or_mask;
2718 WREG32_PLL(reg, val);
2722 val = RBIOS8(index);
2724 radeon_i2c_put_byte(tmds->i2c_bus,
2729 DRM_ERROR("Unknown id %d\n", id >> 13);
2732 id = RBIOS16(index);
2740 static void combios_parse_mmio_table(struct drm_device *dev, uint16_t offset)
2742 struct radeon_device *rdev = dev->dev_private;
2745 while (RBIOS16(offset)) {
2746 uint16_t cmd = ((RBIOS16(offset) & 0xe000) >> 13);
2747 uint32_t addr = (RBIOS16(offset) & 0x1fff);
2748 uint32_t val, and_mask, or_mask;
2754 val = RBIOS32(offset);
2759 val = RBIOS32(offset);
2764 and_mask = RBIOS32(offset);
2766 or_mask = RBIOS32(offset);
2774 and_mask = RBIOS32(offset);
2776 or_mask = RBIOS32(offset);
2784 val = RBIOS16(offset);
2789 val = RBIOS16(offset);
2796 (RADEON_CLK_PWRMGT_CNTL) &
2803 if ((RREG32(RADEON_MC_STATUS) &
2819 static void combios_parse_pll_table(struct drm_device *dev, uint16_t offset)
2821 struct radeon_device *rdev = dev->dev_private;
2824 while (RBIOS8(offset)) {
2825 uint8_t cmd = ((RBIOS8(offset) & 0xc0) >> 6);
2826 uint8_t addr = (RBIOS8(offset) & 0x3f);
2827 uint32_t val, shift, tmp;
2828 uint32_t and_mask, or_mask;
2833 val = RBIOS32(offset);
2835 WREG32_PLL(addr, val);
2838 shift = RBIOS8(offset) * 8;
2840 and_mask = RBIOS8(offset) << shift;
2841 and_mask |= ~(0xff << shift);
2843 or_mask = RBIOS8(offset) << shift;
2845 tmp = RREG32_PLL(addr);
2848 WREG32_PLL(addr, tmp);
2864 (RADEON_CLK_PWRMGT_CNTL) &
2872 (RADEON_CLK_PWRMGT_CNTL) &
2879 RREG32_PLL(RADEON_CLK_PWRMGT_CNTL);
2880 if (tmp & RADEON_CG_NO1_DEBUG_0) {
2882 uint32_t mclk_cntl =
2885 mclk_cntl &= 0xffff0000;
2886 /*mclk_cntl |= 0x00001111;*//* ??? */
2887 WREG32_PLL(RADEON_MCLK_CNTL,
2892 (RADEON_CLK_PWRMGT_CNTL,
2894 ~RADEON_CG_NO1_DEBUG_0);
2909 static void combios_parse_ram_reset_table(struct drm_device *dev,
2912 struct radeon_device *rdev = dev->dev_private;
2916 uint8_t val = RBIOS8(offset);
2917 while (val != 0xff) {
2921 uint32_t channel_complete_mask;
2923 if (ASIC_IS_R300(rdev))
2924 channel_complete_mask =
2925 R300_MEM_PWRUP_COMPLETE;
2927 channel_complete_mask =
2928 RADEON_MEM_PWRUP_COMPLETE;
2931 if ((RREG32(RADEON_MEM_STR_CNTL) &
2932 channel_complete_mask) ==
2933 channel_complete_mask)
2937 uint32_t or_mask = RBIOS16(offset);
2940 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2941 tmp &= RADEON_SDRAM_MODE_MASK;
2943 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2945 or_mask = val << 24;
2946 tmp = RREG32(RADEON_MEM_SDRAM_MODE_REG);
2947 tmp &= RADEON_B3MEM_RESET_MASK;
2949 WREG32(RADEON_MEM_SDRAM_MODE_REG, tmp);
2951 val = RBIOS8(offset);
2956 static uint32_t combios_detect_ram(struct drm_device *dev, int ram,
2957 int mem_addr_mapping)
2959 struct radeon_device *rdev = dev->dev_private;
2964 mem_cntl = RREG32(RADEON_MEM_CNTL);
2965 if (mem_cntl & RV100_HALF_MODE)
2968 mem_cntl &= ~(0xff << 8);
2969 mem_cntl |= (mem_addr_mapping & 0xff) << 8;
2970 WREG32(RADEON_MEM_CNTL, mem_cntl);
2971 RREG32(RADEON_MEM_CNTL);
2975 /* something like this???? */
2977 addr = ram * 1024 * 1024;
2978 /* write to each page */
2979 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2980 WREG32(RADEON_MM_DATA, 0xdeadbeef);
2981 /* read back and verify */
2982 WREG32(RADEON_MM_INDEX, (addr) | RADEON_MM_APER);
2983 if (RREG32(RADEON_MM_DATA) != 0xdeadbeef)
2990 static void combios_write_ram_size(struct drm_device *dev)
2992 struct radeon_device *rdev = dev->dev_private;
2995 uint32_t mem_size = 0;
2996 uint32_t mem_cntl = 0;
2998 /* should do something smarter here I guess... */
2999 if (rdev->flags & RADEON_IS_IGP)
3002 /* first check detected mem table */
3003 offset = combios_get_table_offset(dev, COMBIOS_DETECTED_MEM_TABLE);
3005 rev = RBIOS8(offset);
3007 mem_cntl = RBIOS32(offset + 1);
3008 mem_size = RBIOS16(offset + 5);
3009 if ((rdev->family < CHIP_R200) &&
3010 !ASIC_IS_RN50(rdev))
3011 WREG32(RADEON_MEM_CNTL, mem_cntl);
3017 combios_get_table_offset(dev, COMBIOS_MEM_CONFIG_TABLE);
3019 rev = RBIOS8(offset - 1);
3021 if ((rdev->family < CHIP_R200)
3022 && !ASIC_IS_RN50(rdev)) {
3024 int mem_addr_mapping = 0;
3026 while (RBIOS8(offset)) {
3027 ram = RBIOS8(offset);
3030 if (mem_addr_mapping != 0x25)
3033 combios_detect_ram(dev, ram,
3040 mem_size = RBIOS8(offset);
3042 mem_size = RBIOS8(offset);
3043 mem_size *= 2; /* convert to MB */
3048 mem_size *= (1024 * 1024); /* convert to bytes */
3049 WREG32(RADEON_CONFIG_MEMSIZE, mem_size);
3052 void radeon_combios_dyn_clk_setup(struct drm_device *dev, int enable)
3054 uint16_t dyn_clk_info =
3055 combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
3058 combios_parse_pll_table(dev, dyn_clk_info);
3061 void radeon_combios_asic_init(struct drm_device *dev)
3063 struct radeon_device *rdev = dev->dev_private;
3066 /* port hardcoded mac stuff from radeonfb */
3067 if (rdev->bios == NULL)
3071 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_1_TABLE);
3073 combios_parse_mmio_table(dev, table);
3076 table = combios_get_table_offset(dev, COMBIOS_PLL_INIT_TABLE);
3078 combios_parse_pll_table(dev, table);
3081 table = combios_get_table_offset(dev, COMBIOS_ASIC_INIT_2_TABLE);
3083 combios_parse_mmio_table(dev, table);
3085 if (!(rdev->flags & RADEON_IS_IGP)) {
3088 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_4_TABLE);
3090 combios_parse_mmio_table(dev, table);
3093 table = combios_get_table_offset(dev, COMBIOS_RAM_RESET_TABLE);
3095 combios_parse_ram_reset_table(dev, table);
3099 combios_get_table_offset(dev, COMBIOS_ASIC_INIT_3_TABLE);
3101 combios_parse_mmio_table(dev, table);
3103 /* write CONFIG_MEMSIZE */
3104 combios_write_ram_size(dev);
3107 /* quirk for rs4xx HP nx6125 laptop to make it resume
3108 * - it hangs on resume inside the dynclk 1 table.
3110 if (rdev->family == CHIP_RS480 &&
3111 rdev->pdev->subsystem_vendor == 0x103c &&
3112 rdev->pdev->subsystem_device == 0x308b)
3115 /* quirk for rs4xx HP dv5000 laptop to make it resume
3116 * - it hangs on resume inside the dynclk 1 table.
3118 if (rdev->family == CHIP_RS480 &&
3119 rdev->pdev->subsystem_vendor == 0x103c &&
3120 rdev->pdev->subsystem_device == 0x30a4)
3124 table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
3126 combios_parse_pll_table(dev, table);
3130 void radeon_combios_initialize_bios_scratch_regs(struct drm_device *dev)
3132 struct radeon_device *rdev = dev->dev_private;
3133 uint32_t bios_0_scratch, bios_6_scratch, bios_7_scratch;
3135 bios_0_scratch = RREG32(RADEON_BIOS_0_SCRATCH);
3136 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3137 bios_7_scratch = RREG32(RADEON_BIOS_7_SCRATCH);
3139 /* let the bios control the backlight */
3140 bios_0_scratch &= ~RADEON_DRIVER_BRIGHTNESS_EN;
3142 /* tell the bios not to handle mode switching */
3143 bios_6_scratch |= (RADEON_DISPLAY_SWITCHING_DIS |
3144 RADEON_ACC_MODE_CHANGE);
3146 /* tell the bios a driver is loaded */
3147 bios_7_scratch |= RADEON_DRV_LOADED;
3149 WREG32(RADEON_BIOS_0_SCRATCH, bios_0_scratch);
3150 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3151 WREG32(RADEON_BIOS_7_SCRATCH, bios_7_scratch);
3154 void radeon_combios_output_lock(struct drm_encoder *encoder, bool lock)
3156 struct drm_device *dev = encoder->dev;
3157 struct radeon_device *rdev = dev->dev_private;
3158 uint32_t bios_6_scratch;
3160 bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3163 bios_6_scratch |= RADEON_DRIVER_CRITICAL;
3165 bios_6_scratch &= ~RADEON_DRIVER_CRITICAL;
3167 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);
3171 radeon_combios_connected_scratch_regs(struct drm_connector *connector,
3172 struct drm_encoder *encoder,
3175 struct drm_device *dev = connector->dev;
3176 struct radeon_device *rdev = dev->dev_private;
3177 struct radeon_connector *radeon_connector =
3178 to_radeon_connector(connector);
3179 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3180 uint32_t bios_4_scratch = RREG32(RADEON_BIOS_4_SCRATCH);
3181 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3183 if ((radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) &&
3184 (radeon_connector->devices & ATOM_DEVICE_TV1_SUPPORT)) {
3186 DRM_DEBUG_KMS("TV1 connected\n");
3188 bios_4_scratch |= RADEON_TV1_ATTACHED_SVIDEO;
3189 /*save->bios_4_scratch |= RADEON_TV1_ATTACHED_COMP; */
3190 bios_5_scratch |= RADEON_TV1_ON;
3191 bios_5_scratch |= RADEON_ACC_REQ_TV1;
3193 DRM_DEBUG_KMS("TV1 disconnected\n");
3194 bios_4_scratch &= ~RADEON_TV1_ATTACHED_MASK;
3195 bios_5_scratch &= ~RADEON_TV1_ON;
3196 bios_5_scratch &= ~RADEON_ACC_REQ_TV1;
3199 if ((radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) &&
3200 (radeon_connector->devices & ATOM_DEVICE_LCD1_SUPPORT)) {
3202 DRM_DEBUG_KMS("LCD1 connected\n");
3203 bios_4_scratch |= RADEON_LCD1_ATTACHED;
3204 bios_5_scratch |= RADEON_LCD1_ON;
3205 bios_5_scratch |= RADEON_ACC_REQ_LCD1;
3207 DRM_DEBUG_KMS("LCD1 disconnected\n");
3208 bios_4_scratch &= ~RADEON_LCD1_ATTACHED;
3209 bios_5_scratch &= ~RADEON_LCD1_ON;
3210 bios_5_scratch &= ~RADEON_ACC_REQ_LCD1;
3213 if ((radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) &&
3214 (radeon_connector->devices & ATOM_DEVICE_CRT1_SUPPORT)) {
3216 DRM_DEBUG_KMS("CRT1 connected\n");
3217 bios_4_scratch |= RADEON_CRT1_ATTACHED_COLOR;
3218 bios_5_scratch |= RADEON_CRT1_ON;
3219 bios_5_scratch |= RADEON_ACC_REQ_CRT1;
3221 DRM_DEBUG_KMS("CRT1 disconnected\n");
3222 bios_4_scratch &= ~RADEON_CRT1_ATTACHED_MASK;
3223 bios_5_scratch &= ~RADEON_CRT1_ON;
3224 bios_5_scratch &= ~RADEON_ACC_REQ_CRT1;
3227 if ((radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) &&
3228 (radeon_connector->devices & ATOM_DEVICE_CRT2_SUPPORT)) {
3230 DRM_DEBUG_KMS("CRT2 connected\n");
3231 bios_4_scratch |= RADEON_CRT2_ATTACHED_COLOR;
3232 bios_5_scratch |= RADEON_CRT2_ON;
3233 bios_5_scratch |= RADEON_ACC_REQ_CRT2;
3235 DRM_DEBUG_KMS("CRT2 disconnected\n");
3236 bios_4_scratch &= ~RADEON_CRT2_ATTACHED_MASK;
3237 bios_5_scratch &= ~RADEON_CRT2_ON;
3238 bios_5_scratch &= ~RADEON_ACC_REQ_CRT2;
3241 if ((radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) &&
3242 (radeon_connector->devices & ATOM_DEVICE_DFP1_SUPPORT)) {
3244 DRM_DEBUG_KMS("DFP1 connected\n");
3245 bios_4_scratch |= RADEON_DFP1_ATTACHED;
3246 bios_5_scratch |= RADEON_DFP1_ON;
3247 bios_5_scratch |= RADEON_ACC_REQ_DFP1;
3249 DRM_DEBUG_KMS("DFP1 disconnected\n");
3250 bios_4_scratch &= ~RADEON_DFP1_ATTACHED;
3251 bios_5_scratch &= ~RADEON_DFP1_ON;
3252 bios_5_scratch &= ~RADEON_ACC_REQ_DFP1;
3255 if ((radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) &&
3256 (radeon_connector->devices & ATOM_DEVICE_DFP2_SUPPORT)) {
3258 DRM_DEBUG_KMS("DFP2 connected\n");
3259 bios_4_scratch |= RADEON_DFP2_ATTACHED;
3260 bios_5_scratch |= RADEON_DFP2_ON;
3261 bios_5_scratch |= RADEON_ACC_REQ_DFP2;
3263 DRM_DEBUG_KMS("DFP2 disconnected\n");
3264 bios_4_scratch &= ~RADEON_DFP2_ATTACHED;
3265 bios_5_scratch &= ~RADEON_DFP2_ON;
3266 bios_5_scratch &= ~RADEON_ACC_REQ_DFP2;
3269 WREG32(RADEON_BIOS_4_SCRATCH, bios_4_scratch);
3270 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3274 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc)
3276 struct drm_device *dev = encoder->dev;
3277 struct radeon_device *rdev = dev->dev_private;
3278 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3279 uint32_t bios_5_scratch = RREG32(RADEON_BIOS_5_SCRATCH);
3281 if (radeon_encoder->devices & ATOM_DEVICE_TV1_SUPPORT) {
3282 bios_5_scratch &= ~RADEON_TV1_CRTC_MASK;
3283 bios_5_scratch |= (crtc << RADEON_TV1_CRTC_SHIFT);
3285 if (radeon_encoder->devices & ATOM_DEVICE_CRT1_SUPPORT) {
3286 bios_5_scratch &= ~RADEON_CRT1_CRTC_MASK;
3287 bios_5_scratch |= (crtc << RADEON_CRT1_CRTC_SHIFT);
3289 if (radeon_encoder->devices & ATOM_DEVICE_CRT2_SUPPORT) {
3290 bios_5_scratch &= ~RADEON_CRT2_CRTC_MASK;
3291 bios_5_scratch |= (crtc << RADEON_CRT2_CRTC_SHIFT);
3293 if (radeon_encoder->devices & ATOM_DEVICE_LCD1_SUPPORT) {
3294 bios_5_scratch &= ~RADEON_LCD1_CRTC_MASK;
3295 bios_5_scratch |= (crtc << RADEON_LCD1_CRTC_SHIFT);
3297 if (radeon_encoder->devices & ATOM_DEVICE_DFP1_SUPPORT) {
3298 bios_5_scratch &= ~RADEON_DFP1_CRTC_MASK;
3299 bios_5_scratch |= (crtc << RADEON_DFP1_CRTC_SHIFT);
3301 if (radeon_encoder->devices & ATOM_DEVICE_DFP2_SUPPORT) {
3302 bios_5_scratch &= ~RADEON_DFP2_CRTC_MASK;
3303 bios_5_scratch |= (crtc << RADEON_DFP2_CRTC_SHIFT);
3305 WREG32(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
3309 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on)
3311 struct drm_device *dev = encoder->dev;
3312 struct radeon_device *rdev = dev->dev_private;
3313 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
3314 uint32_t bios_6_scratch = RREG32(RADEON_BIOS_6_SCRATCH);
3316 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT)) {
3318 bios_6_scratch |= RADEON_TV_DPMS_ON;
3320 bios_6_scratch &= ~RADEON_TV_DPMS_ON;
3322 if (radeon_encoder->devices & (ATOM_DEVICE_CRT_SUPPORT)) {
3324 bios_6_scratch |= RADEON_CRT_DPMS_ON;
3326 bios_6_scratch &= ~RADEON_CRT_DPMS_ON;
3328 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
3330 bios_6_scratch |= RADEON_LCD_DPMS_ON;
3332 bios_6_scratch &= ~RADEON_LCD_DPMS_ON;
3334 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
3336 bios_6_scratch |= RADEON_DFP_DPMS_ON;
3338 bios_6_scratch &= ~RADEON_DFP_DPMS_ON;
3340 WREG32(RADEON_BIOS_6_SCRATCH, bios_6_scratch);